diff --git a/components/Weapons/MushroomPickaxe.tscn b/components/Weapons/MushroomPickaxe.tscn index ded1f6e..33a9fe6 100644 --- a/components/Weapons/MushroomPickaxe.tscn +++ b/components/Weapons/MushroomPickaxe.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://dwsyn746hr25d"] [ext_resource type="PackedScene" uid="uid://ckq2cq6m23hq3" path="res://components/Abstracts/WeaponCardBase.tscn" id="1_aoaad"] -[ext_resource type="Script" path="res://scripts/Contents/Weapons/MushroomPickaxe.gd" id="2_5dp3e"] +[ext_resource type="Script" uid="uid://bmmf864uc3atu" path="res://scripts/Contents/Weapons/MushroomPickaxe.gd" id="2_5dp3e"] [ext_resource type="Texture2D" uid="uid://cqg0aluvegqfe" path="res://resources/bullets/MushroomPickaxe/frames/Shroomite_Digging_Claw.webp" id="2_u2d30"] [node name="MushroomPickaxe" instance=ExtResource("1_aoaad")] @@ -11,8 +11,8 @@ displayName = "蘑菇矿挖爪" costBeachball = 750 store = { "atk": 1, -"count": 5.0, -"rate": 0.15 +"count": 3.0, +"rate": 0.1 } storeType = { "atk": 1, @@ -26,10 +26,14 @@ debugRebuild = true [node name="avatar" parent="container/info" index="0"] texture = ExtResource("2_u2d30") +[node name="energy" parent="container/info/infos/energyInfo" index="1"] +text = "2.0" +[node name="beachball" parent="container/info/infos" index="1"] +count = 750 [node name="name" parent="container/info" index="2"] displayName = "蘑菇矿挖爪" [node name="description" parent="container" index="2"] -text = "[center]命中时造成[color=cyan]1[/color]→[color=yellow]2[/color]点伤害,有[color=cyan]15%[/color]→[color=yellow]19%[/color]概率挖出1~[color=cyan]5[/color]→[color=yellow]6[/color]个随机物品。[/center]" +text = "[center]命中时造成[color=cyan]1[/color]点伤害,有[color=cyan]10%[/color]概率挖出1~[color=cyan]3[/color]个随机物品。[/center]" diff --git a/scripts/Contents/AIPresets/Entity.gd b/scripts/Contents/AIPresets/Entity.gd index a19b116..c9e4f50 100644 --- a/scripts/Contents/AIPresets/Entity.gd +++ b/scripts/Contents/AIPresets/Entity.gd @@ -17,5 +17,5 @@ static func distanceAction(entity: EntityBase, target: EntityBase, minDistance: if minDistance <= distance and distance <= maxDistance: action.call() static func weightAttack(entity: EntityBase, indexes: Array[int], weight: Array[int], chargeUp: Callable): - var method = MathTool.randChoiceWeightsFrom(indexes, weight) + var method = MathTool.randomChoiceFromWeights(indexes, weight) entity.tryAttack(method, chargeUp.call(method)) diff --git a/scripts/Contents/Bullets/MushroomPickaxe.gd b/scripts/Contents/Bullets/MushroomPickaxe.gd index 6f51963..2193002 100644 --- a/scripts/Contents/Bullets/MushroomPickaxe.gd +++ b/scripts/Contents/Bullets/MushroomPickaxe.gd @@ -6,9 +6,8 @@ var rate: float = 0.1 func succeedToHit(_dmg, entity): if MathTool.rate(rate): - for i in randi_range(1, count): - ItemDropped.generate( - MathTool.randomChoiceFrom([ItemStore.ItemType.BASEBALL, ItemStore.ItemType.BASKETBALL, ItemStore.ItemType.BEACHBALL]), - randi_range(1, count), - entity.position + MathTool.randomVector2In(GameRule.itemDroppedSpawnOffset) - ) + ItemDropped.generate( + MathTool.randomChoiceFrom([ItemStore.ItemType.BASEBALL, ItemStore.ItemType.BASKETBALL, ItemStore.ItemType.BEACHBALL]), + randi_range(1, count), + entity.position + MathTool.sampleInCircle(GameRule.itemDroppedSpawnOffset) + ) diff --git a/scripts/Contents/Characters/Bear.gd b/scripts/Contents/Characters/Bear.gd index 888e839..624e365 100644 --- a/scripts/Contents/Characters/Bear.gd +++ b/scripts/Contents/Characters/Bear.gd @@ -52,7 +52,7 @@ func attack(type): if !is_instance_valid(currentFocusedBoss): return false for bullet in BulletBase.generate(ComponentManager.getBullet("ArrowSeven"), self, findWeaponAnchor("normal"), deg_to_rad(randf_range(0, 360))): bullet.tracer = currentFocusedBoss - bullet.position += MathTool.randomVector2In(50) + bullet.position += MathTool.sampleInCircle(50) await TickTool.millseconds(50) return false elif type == 1: @@ -76,7 +76,7 @@ func attack(type): await trySprint() sprintParticle.emitting = false canRunAi = true - await sprintTo(currentFocusedBoss.position + MathTool.randomVector2In(400), 0.25) + await sprintTo(currentFocusedBoss.position + MathTool.sampleInCircle(400), 0.25) currentInvinsible = false return false elif type == 4: @@ -102,8 +102,8 @@ func attack(type): for i in 16: if !is_instance_valid(currentFocusedBoss): return false for bullet in BulletBase.generate(ComponentManager.getBullet("LightGun"), self, currentFocusedBoss.position, 0): - bullet.position += MathTool.randomVector2In(600) - bullet.look_at(currentFocusedBoss.position + MathTool.randomVector2In(50)) + bullet.position += MathTool.sampleInCircle(600) + bullet.look_at(currentFocusedBoss.position + MathTool.sampleInCircle(50)) await TickTool.millseconds(100) return false elif type == 7: diff --git a/scripts/Contents/Characters/Chick.gd b/scripts/Contents/Characters/Chick.gd index 8f9f99a..5ad76a6 100644 --- a/scripts/Contents/Characters/Chick.gd +++ b/scripts/Contents/Characters/Chick.gd @@ -34,7 +34,7 @@ func attack(type): if type == 0: var weaponPos = findWeaponAnchor("normal") for i in randi_range(7, 16): - BulletBase.generate(ComponentManager.getBullet("Diamond"), self, weaponPos + MathTool.randomVector2In(20), rotation + deg_to_rad(randf_range(-90, 90))) + BulletBase.generate(ComponentManager.getBullet("Diamond"), self, weaponPos + MathTool.sampleInCircle(20), rotation + deg_to_rad(randf_range(-90, 90))) elif type == 1: var laserCount = randi_range(2, 4) for i in laserCount: diff --git a/scripts/Contents/Characters/KukeMC.gd b/scripts/Contents/Characters/KukeMC.gd index ed5c9d6..0abd1b3 100644 --- a/scripts/Contents/Characters/KukeMC.gd +++ b/scripts/Contents/Characters/KukeMC.gd @@ -34,7 +34,7 @@ func attack(type): await TickTool.millseconds(randi_range(10, 50)) elif type == 1 and health < fields[FieldStore.Entity.MAX_HEALTH] * 0.5 and canSummon: for i in randi_range(1, 2): - var child = EntityBase.generate(ComponentManager.getCharacter("KukeChild"), position + MathTool.randomVector2In(500)) + var child = EntityBase.generate(ComponentManager.getCharacter("KukeChild"), position + MathTool.sampleInCircle(500)) child.currentFocusedBoss = currentFocusedBoss child.masterMine = self elif type == 2: diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index dc36bdb..75265b9 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -88,7 +88,7 @@ static func spawn(center: Vector2) -> Array: var wave: Wave = data[i] for j in range(entityCountOf(wave)): var currentWave = wave.duplicate() - currentWave.entityPosition = MathTool.randomRingPoint(200, 1000) + center + currentWave.entityPosition = MathTool.sampleInRing(200, 1000) + center result.append(currentWave) return result static func next(waves: Array): diff --git a/scripts/Contents/Weapons/MushroomPickaxe.gd b/scripts/Contents/Weapons/MushroomPickaxe.gd index 49d9d44..367e6b3 100644 --- a/scripts/Contents/Weapons/MushroomPickaxe.gd +++ b/scripts/Contents/Weapons/MushroomPickaxe.gd @@ -2,8 +2,8 @@ extends Weapon func update(to: int, origin: Dictionary, _entity: EntityBase): - origin["atk"] += 1 * to * soulLevel - origin["rate"] += 0.04 * to * soulLevel + origin["atk"] += 0.5 * to * soulLevel + origin["rate"] = 0.1 * soulLevel origin["count"] += 1 * to * soulLevel return origin func attack(entity: EntityBase): diff --git a/scripts/Contents/Weapons/WhiteSoul.gd b/scripts/Contents/Weapons/WhiteSoul.gd index f453b34..655c320 100644 --- a/scripts/Contents/Weapons/WhiteSoul.gd +++ b/scripts/Contents/Weapons/WhiteSoul.gd @@ -11,7 +11,7 @@ func attack(entity: EntityBase): var myPos = get_global_mouse_position() + QuickUI.getWindowSize() * Vector2(randf_range(-1, 1) * 0.25, -1) for j in BulletBase.generate(ComponentManager.getBullet("WhiteSoul"), entity, myPos, - myPos.angle_to_point(get_global_mouse_position() + MathTool.randomVector2In(readStore("radius"))) + myPos.angle_to_point(get_global_mouse_position() + MathTool.sampleInCircle(readStore("radius"))) ): if j is BulletBase: j.baseDamage = readStore("atk") diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index b609b37..17fe043 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -234,7 +234,7 @@ func takeDamage(baseDamage: float, crit: bool = false, perfectMiss: bool = false var resultDamage = baseDamage + baseDamage * int(crit) * fields.get(FieldStore.Entity.CRIT_DAMAGE) health -= resultDamage healthChanged.emit(health) - DamageLabel.create(resultDamage, crit || perfectMiss, damageAnchor.global_position + MathTool.randomVector2In(GameRule.damageLabelSpawnOffset)) + DamageLabel.create(resultDamage, crit || perfectMiss, damageAnchor.global_position + MathTool.sampleInCircle(GameRule.damageLabelSpawnOffset)) if health <= 0: tryDie(null) return resultDamage @@ -261,7 +261,7 @@ func bulletHit(bullet: BulletBase, crit: bool): hit.emit(damage, bullet, crit) health -= damage healthChanged.emit(health) - DamageLabel.create(damage, crit || perfectMiss, damageAnchor.global_position + MathTool.randomVector2In(GameRule.damageLabelSpawnOffset)) + DamageLabel.create(damage, crit || perfectMiss, damageAnchor.global_position + MathTool.sampleInCircle(GameRule.damageLabelSpawnOffset)) if isBoss and bullet.launcher.isPlayer(): bullet.launcher.setBoss(self) if health <= 0: @@ -338,24 +338,24 @@ func tryDie(by: BulletBase = null): var item = drops[drop] var count = ceil(randf_range(dropCounts[drop].x, dropCounts[drop].y)) for i in range(count): - ItemDropped.generate(item, randi_range(1, round(2.5 * sqrt(GameRule.difficulty - GameRule.difficultyRange.x + 1))), position + MathTool.randomVector2In(GameRule.itemDroppedSpawnOffset)) + ItemDropped.generate(item, randi_range(1, round(2.5 * sqrt(GameRule.difficulty - GameRule.difficultyRange.x + 1))), position + MathTool.sampleInCircle(GameRule.itemDroppedSpawnOffset)) if MathTool.rate( GameRule.appleDropRate + by.launcher.fields.get(FieldStore.Entity.DROP_APPLE_RATE) + GameRule.appleDropRateInfluenceByLuckValue * by.launcher.fields[FieldStore.Entity.LUCK_VALUE] ) or isBoss: for i in randi_range(appleCount.x, appleCount.y): - ItemDropped.generate(ItemStore.ItemType.APPLE, 1, position + MathTool.randomVector2In(GameRule.itemDroppedSpawnOffset)) + ItemDropped.generate(ItemStore.ItemType.APPLE, 1, position + MathTool.sampleInCircle(GameRule.itemDroppedSpawnOffset)) ItemDropped.generate( ItemStore.ItemType.BEACHBALL, fields[FieldStore.Entity.MAX_HEALTH] * randf_range(1 - GameRule.beachballOffset, 1 + GameRule.beachballOffset), - position + MathTool.randomVector2In(GameRule.itemDroppedSpawnOffset) + position + MathTool.sampleInCircle(GameRule.itemDroppedSpawnOffset) ) if isBoss: ItemDropped.generate( ItemStore.ItemType.SOUL, randi_range(1, 2), - position + MathTool.randomVector2In(GameRule.itemDroppedSpawnOffset) + position + MathTool.sampleInCircle(GameRule.itemDroppedSpawnOffset) ) if isPlayer(): if UIState.player == self: @@ -452,7 +452,7 @@ func sprint(): pass func heal(count: float): health += count - DamageLabel.create(-count, false, damageAnchor.global_position + MathTool.randomVector2In(GameRule.damageLabelSpawnOffset)) + DamageLabel.create(-count, false, damageAnchor.global_position + MathTool.sampleInCircle(GameRule.damageLabelSpawnOffset)) return count func register(): pass diff --git a/scripts/Statemachine/FieldShow.gd b/scripts/Statemachine/FieldShow.gd index 6e057f4..8bdc4f9 100644 --- a/scripts/Statemachine/FieldShow.gd +++ b/scripts/Statemachine/FieldShow.gd @@ -24,13 +24,13 @@ func _ready(): var formattedValue: String var dataType = FieldStore.entityMapType[field] if dataType == FieldStore.DataType.VALUE: - formattedValue = "%s" % (MathTool.signBeforeStr(value) if showSign else str(value)) + formattedValue = "%s" % (MathTool.toSigned(value) if showSign else str(value)) elif dataType == FieldStore.DataType.INTEGER: - formattedValue = "%s" % (MathTool.signBeforeStr(int(value)) if showSign else str(int(value))) + formattedValue = "%s" % (MathTool.toSigned(int(value)) if showSign else str(int(value))) elif dataType == FieldStore.DataType.ANGLE: - formattedValue = "%s°" % (MathTool.signBeforeStr(value) if showSign else str(value)) + formattedValue = "%s°" % (MathTool.toSigned(value) if showSign else str(value)) elif dataType == FieldStore.DataType.PERCENT: - formattedValue = (MathTool.signBeforeStr(value * 100) if showSign else str(value * 100)) + "%" + formattedValue = (MathTool.toSigned(value * 100) if showSign else str(value * 100)) + "%" valueLabel.label_settings = valueLabel.label_settings.duplicate() valueLabel.text = formattedValue if maxed: diff --git a/scripts/Tools/Managers/CameraManager.gd b/scripts/Tools/Managers/CameraManager.gd index 0a5dab9..8adc416 100644 --- a/scripts/Tools/Managers/CameraManager.gd +++ b/scripts/Tools/Managers/CameraManager.gd @@ -15,7 +15,7 @@ func _ready(): func _physics_process(_delta): if is_instance_valid(UIState.player): position = UIState.player.position + constantOffset - position += MathTool.randomVector2In(shakeIntensity) + position += MathTool.sampleInCircle(shakeIntensity) offset += ((get_global_mouse_position() - UIState.player.position).clampf(-100, 100) - offset) * 0.15 static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue): diff --git a/scripts/Tools/MathTool.gd b/scripts/Tools/MathTool.gd index 1e3947d..2de9916 100644 --- a/scripts/Tools/MathTool.gd +++ b/scripts/Tools/MathTool.gd @@ -2,16 +2,13 @@ class_name MathTool static func rate(value: float) -> bool: return randf() < value -static func randomVector2In(offset: float): - return Vector2( - randf_range(-offset, offset), - randf_range(-offset, offset) - ) -static func randomRingPoint(innerRadius: float, outerRadius: float): +static func sampleInCircle(radius: float): + return sampleInRing(0, radius) +static func sampleInRing(innerRadius: float, outerRadius: float): return Vector2.from_angle(randf_range(0, 2 * PI)) * randf_range(innerRadius, outerRadius) static func randomChoiceFrom(array: Array): return array[randi() % array.size()] -static func randChoiceWeightsFrom(indexes: Array, weights: Array[int]): +static func randomChoiceFromWeights(indexes: Array, weights: Array[int]): var totals: Array = [] var index = 0 for i in indexes: @@ -19,7 +16,7 @@ static func randChoiceWeightsFrom(indexes: Array, weights: Array[int]): totals.append(i) index += 1 return randomChoiceFrom(totals) -static func signBeforeStr(value: float): +static func toSigned(value: float): return ("+" if value > 0 else "-" if value < 0 else "") + str(abs(value)) static func percent(value: float): return value / 100