diff --git a/scripts/Statemachine/FieldShow.gd b/scripts/Statemachine/FieldShow.gd index cb7e0f7..bb4c32a 100644 --- a/scripts/Statemachine/FieldShow.gd +++ b/scripts/Statemachine/FieldShow.gd @@ -5,11 +5,17 @@ class_name FieldShow @export var field: FieldStore.Entity = FieldStore.Entity.MAX_HEALTH @export var value: float = 0 @export var showSign: bool = true +@export var entity: EntityBase = null +@export var useViewCast: bool = false @onready var nameLabel: Label = $"%name" @onready var valueLabel: Label = $"%value" func _ready(): + if useViewCast: + var caster = FieldStore.entityViewCastMap.get(field) + if caster: + value = caster.call(entity, value) nameLabel.text = FieldStore.entityMap[field] var formattedValue: String var dataType = FieldStore.entityMapType[field] @@ -21,9 +27,11 @@ func _ready(): formattedValue = (MathTool.signBeforeStr(value * 100) if showSign else str(value * 100)) + "%" valueLabel.text = formattedValue -static func create(newField: FieldStore.Entity, newValue: float, newShowSign: bool) -> FieldShow: +static func create(newField: FieldStore.Entity, newValue: float, newShowSign: bool, newEntity: EntityBase, newUseViewCast: bool) -> FieldShow: var fieldShow = preload("res://components/UI/FieldShow.tscn").instantiate() fieldShow.field = newField fieldShow.value = newValue fieldShow.showSign = newShowSign + fieldShow.entity = newEntity + fieldShow.useViewCast = newUseViewCast return fieldShow diff --git a/scripts/Statemachine/ItemDropped.gd b/scripts/Statemachine/ItemDropped.gd index b5b7495..b89e3f6 100644 --- a/scripts/Statemachine/ItemDropped.gd +++ b/scripts/Statemachine/ItemDropped.gd @@ -21,7 +21,7 @@ func _physics_process(_delta): linear_velocity = Vector2.ZERO else: var direction = (targetPlayer.position - position).normalized() - var speed = 4000.0 / ((targetPlayer.position - position).length() ** (1 / 3.0)) + var speed = 5000.0 / ((targetPlayer.position - position).length() ** (1 / 3.0)) apply_central_force(direction * speed) if position.distance_to(targetPlayer.position) < 60: targetPlayer.collectItem(item, stackCount) diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index c4ca70d..08b2daa 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -39,7 +39,7 @@ func _physics_process(_delta): for i in fields.get_children(): fields.remove_child(i) for i in player.fields: - fields.add_child(FieldShow.create(i, player.fields[i], false)) + fields.add_child(FieldShow.create(i, player.fields[i], false, player, true)) fieldsAnimator.play("show") if Input.is_action_just_released("showFields"): fieldsAnimator.play("hide") diff --git a/scripts/Tools/FieldStore.gd b/scripts/Tools/FieldStore.gd index 195af25..7095141 100644 --- a/scripts/Tools/FieldStore.gd +++ b/scripts/Tools/FieldStore.gd @@ -25,7 +25,9 @@ enum Entity { FEED_COUNT_SHOW, FEED_COUNT_CAN_MADE, MAX_ENERGY, - LUCK_VALUE + LUCK_VALUE, + DROPPED_ITEM_GRAVITY_MULTIPILER, + DROPPED_ITEM_GRAVITY_INFLUENCE_BY_DISTANCE_MULTIPILER } static var entityMap = { Entity.MAX_HEALTH: "生命上限", @@ -46,7 +48,9 @@ static var entityMap = { Entity.FEED_COUNT_SHOW: "可选饲料数量", Entity.FEED_COUNT_CAN_MADE: "可制作饲料数量", Entity.MAX_ENERGY: "能量上限", - Entity.LUCK_VALUE: "幸运" + Entity.LUCK_VALUE: "幸运值", + Entity.DROPPED_ITEM_GRAVITY_MULTIPILER: "掉落物重力倍率", + Entity.DROPPED_ITEM_GRAVITY_INFLUENCE_BY_DISTANCE_MULTIPILER: "掉落物重力受距离影响" } static var entityMapType = { Entity.MAX_HEALTH: DataType.VALUE, @@ -67,7 +71,9 @@ static var entityMapType = { Entity.FEED_COUNT_SHOW: DataType.VALUE, Entity.FEED_COUNT_CAN_MADE: DataType.VALUE, Entity.MAX_ENERGY: DataType.VALUE, - Entity.LUCK_VALUE: DataType.VALUE + Entity.LUCK_VALUE: DataType.VALUE, + Entity.DROPPED_ITEM_GRAVITY_MULTIPILER: DataType.PERCENT, + Entity.DROPPED_ITEM_GRAVITY_INFLUENCE_BY_DISTANCE_MULTIPILER: DataType.VALUE } static var entityMaxValueMap = { Entity.CRIT_RATE: 1, @@ -91,6 +97,11 @@ static var entityApplier = { return true , } +static var entityViewCastMap = { + Entity.EXTRA_APPLE_MAX: func(entity, _value): + return entity.inventoryMax[ItemStore.ItemType.APPLE] + , +} enum Bullet { SPEED,