diff --git a/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx b/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx index 9ba6191..6866ddc 100644 --- a/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx b/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx index 216f7f6..00d3ca4 100644 --- a/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx b/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx index 9bafc6d..76b7a0f 100644 --- a/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx b/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx index 9d78f08..6bdc2c7 100644 --- a/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/Sound.xlsx b/DungeonShooting_Godot/excel/excelFile/Sound.xlsx index 63764f1..fe89f6b 100644 --- a/DungeonShooting_Godot/excel/excelFile/Sound.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/Sound.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx b/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx index 6a85ce0..1c04d62 100644 --- a/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn new file mode 100644 index 0000000..65fd1c7 --- /dev/null +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn @@ -0,0 +1,60 @@ +[gd_scene load_steps=7 format=3 uid="uid://cjgnw37tqiqh7"] + +[ext_resource type="Script" path="res://src/game/activity/bullet/normal/Bullet.cs" id="1_vpnof"] +[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_v0al6"] +[ext_resource type="SpriteFrames" uid="uid://bcnhyin0aufl1" path="res://resource/spriteFrames/bullet/Bullet0003.tres" id="3_8mltb"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_v77gw"] +resource_local_to_scene = true +shader = ExtResource("2_v0al6") +shader_parameter/blend = Color(0, 0, 0, 0.470588) +shader_parameter/schedule = 1.0 +shader_parameter/modulate = Color(1, 1, 1, 1) +shader_parameter/show_outline = false +shader_parameter/outline_color = Color(0, 0, 0, 1) +shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_p0wfd"] +resource_local_to_scene = true +shader = ExtResource("2_v0al6") +shader_parameter/blend = Color(1, 1, 1, 1) +shader_parameter/schedule = 0.0 +shader_parameter/modulate = Color(1, 1, 1, 1) +shader_parameter/show_outline = false +shader_parameter/outline_color = Color(0, 0, 0, 1) +shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_c0onq"] +size = Vector2(6, 3.125) + +[node name="Bullet0005" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "ShadowSprite", "AnimatedSprite", "Collision")] +collision_layer = 2 +script = ExtResource("1_vpnof") +CollisionArea = NodePath("AnimatedSprite/CollisionArea") +ShadowSprite = NodePath("ShadowSprite") +AnimatedSprite = NodePath("AnimatedSprite") +Collision = NodePath("Collision") + +[node name="ShadowSprite" type="Sprite2D" parent="."] +z_index = -1 +material = SubResource("ShaderMaterial_v77gw") + +[node name="AnimatedSprite" type="AnimatedSprite2D" parent="."] +modulate = Color(1.6, 1.6, 1.6, 1) +material = SubResource("ShaderMaterial_p0wfd") +sprite_frames = ExtResource("3_8mltb") + +[node name="CollisionArea" type="Area2D" parent="AnimatedSprite"] +visible = false +collision_layer = 0 +collision_mask = 0 +monitorable = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="AnimatedSprite/CollisionArea"] +position = Vector2(1, 0) +shape = SubResource("RectangleShape2D_c0onq") + +[node name="Collision" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_c0onq") diff --git a/DungeonShooting_Godot/resource/config/ActivityBase.json b/DungeonShooting_Godot/resource/config/ActivityBase.json index c9bb74b..4f95e68 100644 --- a/DungeonShooting_Godot/resource/config/ActivityBase.json +++ b/DungeonShooting_Godot/resource/config/ActivityBase.json @@ -192,6 +192,18 @@ "ShowInMapEditor": false }, { + "Id": "bullet0005", + "Type": 6, + "Name": "\u654C\u65B9\u4E13\u7528\u5B50\u5F39", + "Intro": "", + "Details": "", + "IsStatic": false, + "__Material": "0004", + "Prefab": "res://prefab/bullet/normal/Bullet0005.tscn", + "Icon": "", + "ShowInMapEditor": false + }, + { "Id": "shell0001", "Type": 7, "Name": "", diff --git a/DungeonShooting_Godot/resource/config/ActivityMaterial.json b/DungeonShooting_Godot/resource/config/ActivityMaterial.json index 56f528a..0ada830 100644 --- a/DungeonShooting_Godot/resource/config/ActivityMaterial.json +++ b/DungeonShooting_Godot/resource/config/ActivityMaterial.json @@ -3,6 +3,7 @@ "Id": "0001", "Remark": "\u9ED8\u8BA4\u6750\u8D28\u5C5E\u6027", "Friction": 140, + "GravityScale": 1, "RotationFriction": 140, "Bounce": true, "BounceStrength": 0.5, @@ -14,6 +15,7 @@ "Id": "0002", "Remark": "\u7403\u4F53\u6750\u8D28\uFF0C\u6469\u64E6\u529B\u8F83\u4F4E", "Friction": 40, + "GravityScale": 1, "RotationFriction": 40, "Bounce": true, "BounceStrength": 0.7, @@ -23,8 +25,21 @@ }, { "Id": "0003", - "Remark": "\u5B50\u5F39,\u53CD\u5F39\u6D88\u8017\u4F4E", + "Remark": "\u666E\u901A\u5B50\u5F39,\u53CD\u5F39\u6D88\u8017\u4F4E,\u65E0\u91CD\u529B\u4E0B\u5760", "Friction": 140, + "GravityScale": 0, + "RotationFriction": 140, + "Bounce": true, + "BounceStrength": 1, + "FallBounceStrength": 0.5, + "FallBounceSpeed": 0.75, + "FallBounceRotation": 0.5 + }, + { + "Id": "0004", + "Remark": "\u6B63\u5E38\u91CD\u529B\u5B50\u5F39", + "Friction": 140, + "GravityScale": 1, "RotationFriction": 140, "Bounce": true, "BounceStrength": 1, diff --git a/DungeonShooting_Godot/resource/config/BulletBase.json b/DungeonShooting_Godot/resource/config/BulletBase.json index 6ce1a2e..104ffd0 100644 --- a/DungeonShooting_Godot/resource/config/BulletBase.json +++ b/DungeonShooting_Godot/resource/config/BulletBase.json @@ -24,7 +24,6 @@ 300, 400 ], - "UseGravity": false, "VerticalSpeed": [ 0 ], @@ -61,7 +60,6 @@ 200, 250 ], - "UseGravity": false, "VerticalSpeed": [ 0 ], @@ -97,7 +95,6 @@ 300, 400 ], - "UseGravity": false, "VerticalSpeed": [ 0 ], @@ -133,7 +130,6 @@ 600, 600 ], - "UseGravity": false, "VerticalSpeed": [ 0 ], @@ -169,7 +165,6 @@ 270, 360 ], - "UseGravity": true, "VerticalSpeed": [ 70 ], @@ -177,7 +172,42 @@ 999 ], "Penetration": [ - 1 + 0 + ] + }, + { + "Id": "0006", + "Name": "\u654C\u65B9\u4E13\u7528\u5B50\u5F39", + "Type": 1, + "Prefab": "bullet0005", + "HarmRange": [ + 5 + ], + "RepelRange": [ + 30 + ], + "DeviationAngleRange": [ + 0 + ], + "SpeedRange": [ + 100, + 100 + ], + "LifeTimeRange": [ + -1 + ], + "DistanceRange": [ + 270, + 360 + ], + "VerticalSpeed": [ + 70 + ], + "BounceCount": [ + 0 + ], + "Penetration": [ + 0 ] }, { @@ -205,7 +235,6 @@ 600, 600 ], - "UseGravity": false, "VerticalSpeed": null, "BounceCount": [ 0 @@ -235,7 +264,6 @@ "DistanceRange": [ 35 ], - "UseGravity": false, "VerticalSpeed": null, "BounceCount": null, "Penetration": null diff --git a/DungeonShooting_Godot/src/config/ExcelConfig_ActivityMaterial.cs b/DungeonShooting_Godot/src/config/ExcelConfig_ActivityMaterial.cs index d0d756b..3ce5304 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig_ActivityMaterial.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig_ActivityMaterial.cs @@ -26,6 +26,12 @@ public float Friction; /// + /// 重力缩放,如果为0则会关闭重力 + /// + [JsonInclude] + public float GravityScale; + + /// /// 旋转摩擦力 /// [JsonInclude] @@ -70,6 +76,7 @@ inst.Id = Id; inst.Remark = Remark; inst.Friction = Friction; + inst.GravityScale = GravityScale; inst.RotationFriction = RotationFriction; inst.Bounce = Bounce; inst.BounceStrength = BounceStrength; diff --git a/DungeonShooting_Godot/src/config/ExcelConfig_BulletBase.cs b/DungeonShooting_Godot/src/config/ExcelConfig_BulletBase.cs index dce87f4..549ed11 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig_BulletBase.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig_BulletBase.cs @@ -84,13 +84,6 @@ public float[] DistanceRange; /// - /// 是否开启重力下坠
- /// 只有Type为1时有效 - ///
- [JsonInclude] - public bool UseGravity; - - /// /// 初始纵轴速度区间
/// 只有Type为1时有效
/// 格式为[value]或者[min,max] @@ -130,7 +123,6 @@ inst.SpeedRange = SpeedRange; inst.LifeTimeRange = LifeTimeRange; inst.DistanceRange = DistanceRange; - inst.UseGravity = UseGravity; inst.VerticalSpeed = VerticalSpeed; inst.BounceCount = BounceCount; inst.Penetration = Penetration; diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index 44ba25a..1129a3e 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -356,6 +356,12 @@ { ActivityMaterial = config.Material; } + + //GravityScale 为 0 时关闭重力 + if (ActivityMaterial.GravityScale == 0) + { + EnableVerticalMotion = false; + } World = world; ItemConfig = config; @@ -1103,7 +1109,7 @@ var ysp = VerticalSpeed; _altitude += VerticalSpeed * delta; - _verticalSpeed -= GameConfig.G * delta; + _verticalSpeed -= GameConfig.G * ActivityMaterial.GravityScale * delta; //当高度大于16时, 显示在所有物体上 if (Altitude >= 16) diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs index a6c0b2a..df2a5bf 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs @@ -89,6 +89,11 @@ ///
public const string Id_bullet0004 = "bullet0004"; /// + /// 名称: 敌方专用子弹
+ /// 简介: + ///
+ public const string Id_bullet0005 = "bullet0005"; + /// /// 名称:
/// 简介: ///
diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs index fa1826f..447f5a7 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs @@ -58,6 +58,7 @@ { //播放撞击音效 SoundManager.PlaySoundByConfig("collision0001", Position, BulletData.TriggerRole); + //这里不调用父类的 OnFallToGround() 函数, 因为这种子弹落地不需要销毁 } /// diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs index 647d9fd..e825d05 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs @@ -55,6 +55,8 @@ _init = true; } + Debug.Log("g: " + ActivityMaterial.GravityScale + ", " + EnableVerticalMotion + ", " + VerticalSpeed); + CurrentBounce = 0; CurrentPenetration = 0; CurrFlyDistance = 0; @@ -79,7 +81,10 @@ { VerticalSpeed = data.VerticalSpeed; } - EnableVerticalMotion = data.BulletBase.UseGravity; + else + { + VerticalSpeed = 0; + } //BasisVelocity = new Vector2(data.FlySpeed, 0).Rotated(Rotation); MoveController.AddForce(new Vector2(data.FlySpeed, 0).Rotated(Rotation)); @@ -168,6 +173,13 @@ DoReclaim(); } + protected override void OnFallToGround() + { + //落地销毁 + PlayDisappearEffect(); + DoReclaim(); + } + /// /// 显示红色描边 /// diff --git a/DungeonShooting_Godot/src/game/activity/role/AdvancedRole.cs b/DungeonShooting_Godot/src/game/activity/role/AdvancedRole.cs index 7e7bade..c3dfc4b 100644 --- a/DungeonShooting_Godot/src/game/activity/role/AdvancedRole.cs +++ b/DungeonShooting_Godot/src/game/activity/role/AdvancedRole.cs @@ -49,11 +49,6 @@ /// public bool IsMeleeAttack { get; private set; } - /// - /// 当前角色所看向的对象, 也就是枪口指向的对象 - /// - public ActivityObject LookTarget { get; set; } - //近战计时器 private float _meleeAttackTimer = 0; @@ -105,24 +100,6 @@ _meleeAttackTimer -= delta; } - //看向目标 - if (LookTarget != null && MountLookTarget) - { - var pos = LookTarget.Position; - //脸的朝向 - var gPos = Position; - if (pos.X > gPos.X && Face == FaceDirection.Left) - { - Face = FaceDirection.Right; - } - else if (pos.X < gPos.X && Face == FaceDirection.Right) - { - Face = FaceDirection.Left; - } - //枪口跟随目标 - MountPoint.SetLookAt(pos); - } - base.Process(delta); } @@ -177,11 +154,11 @@ public override void LookTargetPosition(Vector2 pos) { - LookTarget = null; + LookPosition = pos; if (MountLookTarget) { //脸的朝向 - var gPos = GlobalPosition; + var gPos = Position; if (pos.X > gPos.X && Face == FaceDirection.Left) { Face = FaceDirection.Right; diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs index fde5416..1634e09 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -217,6 +217,11 @@ /// public List InteractiveItemList { get; } = new List(); + /// + /// 角色看向的坐标 + /// + public Vector2 LookPosition { get; protected set; } + //初始缩放 private Vector2 _startScale; //当前可互动的物体 @@ -510,8 +515,9 @@ /// public virtual void LookTargetPosition(Vector2 pos) { + LookPosition = pos; //脸的朝向 - var gPos = GlobalPosition; + var gPos = Position; if (pos.X > gPos.X && Face == FaceDirection.Left) { Face = FaceDirection.Right; diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/AdvancedEnemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/AdvancedEnemy.cs index 5104a60..da83f71 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/AdvancedEnemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/AdvancedEnemy.cs @@ -69,6 +69,11 @@ /// public AiAttackState AttackState { get; private set; } + /// + /// 当前敌人所看向的对象, 也就是枪口指向的对象 + /// + public ActivityObject LookTarget { get; set; } + //锁定目标时间 private float _lockTargetTime = 0; @@ -152,6 +157,26 @@ { return; } + + //看向目标 + if (LookTarget != null && MountLookTarget) + { + var pos = LookTarget.Position; + LookPosition = pos; + //脸的朝向 + var gPos = Position; + if (pos.X > gPos.X && Face == FaceDirection.Left) + { + Face = FaceDirection.Right; + } + else if (pos.X < gPos.X && Face == FaceDirection.Right) + { + Face = FaceDirection.Left; + } + //枪口跟随目标 + MountPoint.SetLookAt(pos); + } + //目标在视野内的时间 var currState = StateController.CurrState; if (currState == AiStateEnum.AiSurround || currState == AiStateEnum.AiFollowUp) @@ -522,4 +547,10 @@ { _lockTargetTime = time; } + + public override void LookTargetPosition(Vector2 pos) + { + LookTarget = null; + base.LookTargetPosition(pos); + } } diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs index baa6332..ca49323 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs @@ -1,4 +1,5 @@  +using System; using Config; using Godot; using NnormalState; @@ -69,10 +70,15 @@ public float AttackInterval { get; set; } = 3; /// - /// 锁定目标时间 + /// 锁定目标需要消耗的时间 /// public float LockingTime { get; set; } = 2; + /// + /// 当前敌人所看向的对象, 也就是枪口指向的对象 + /// + public ActivityObject LookTarget { get; set; } + //锁定目标时间 private float _lockTargetTime = 0; //攻击冷却计时器 @@ -136,7 +142,11 @@ public virtual void EnemyAttack() { Debug.Log("触发攻击"); - FireManager.ShootBullet(this, ConvertRotation(0), ExcelConfig.BulletBase_List[0]); + FireManager.ShootBullet(this, ConvertRotation(Position.AngleTo(LookPosition)), ExcelConfig.BulletBase_Map["0006"]); + // for (int i = 0; i < 100; i++) + // { + // FireManager.ShootBullet(this, ConvertRotation(Mathf.DegToRad(i * 3.6f)), ExcelConfig.BulletBase_List[0]); + // } } protected override void Process(float delta) @@ -146,6 +156,23 @@ { return; } + + //看向目标 + if (LookTarget != null) + { + var pos = LookTarget.Position; + LookPosition = pos; + //脸的朝向 + var gPos = Position; + if (pos.X > gPos.X && Face == FaceDirection.Left) + { + Face = FaceDirection.Right; + } + else if (pos.X < gPos.X && Face == FaceDirection.Right) + { + Face = FaceDirection.Left; + } + } if (_attackTimer > 0) { @@ -313,4 +340,10 @@ { return -AnimatedSprite.Position.Y - FirePoint.Position.Y; } + + public override void LookTargetPosition(Vector2 pos) + { + LookTarget = null; + base.LookTargetPosition(pos); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index a253d34..d92e804 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -72,7 +72,7 @@ StateController.Register(new PlayerRollState()); //默认状态 StateController.ChangeStateInstant(PlayerStateEnum.Idle); - + //InitSubLine(); } @@ -90,24 +90,21 @@ } //脸的朝向 - if (LookTarget == null) + var gPos = Position; + Vector2 mousePos = InputManager.CursorPosition; + if (mousePos.X > gPos.X && Face == FaceDirection.Left) { - var gPos = GlobalPosition; - Vector2 mousePos = InputManager.CursorPosition; - if (mousePos.X > gPos.X && Face == FaceDirection.Left) - { - Face = FaceDirection.Right; - } - else if (mousePos.X < gPos.X && Face == FaceDirection.Right) - { - Face = FaceDirection.Left; - } + Face = FaceDirection.Right; + } + else if (mousePos.X < gPos.X && Face == FaceDirection.Right) + { + Face = FaceDirection.Left; + } - if (MountLookTarget) - { - //枪口跟随鼠标 - MountPoint.SetLookAt(mousePos); - } + if (MountLookTarget) + { + //枪口跟随鼠标 + MountPoint.SetLookAt(mousePos); } if (InputManager.ExchangeWeapon) //切换武器