Compare commits
8 Commits
dd8583f5bf
...
865eb964de
Author | SHA1 | Date | |
---|---|---|---|
865eb964de | |||
a20b9162a3 | |||
|
cfc99321bb | ||
|
bd3fc47816 | ||
|
38e5718426 | ||
|
8af339b0b7 | ||
|
1f70eeef7a | ||
4ff5c71900 |
|
@ -1,19 +1,13 @@
|
|||
[gd_scene load_steps=3 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dmjlddmt2h1pa"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cgptnp74ive4r" path="res://resource/sprite/common/Circle.png" id="1"]
|
||||
[ext_resource type="Script" path="res://src/game/effects/Blood.cs" id="2"]
|
||||
|
||||
|
||||
|
||||
[node name="Blood" type="CPUParticles2D"]
|
||||
z_index = -5
|
||||
lifetime = 0.2
|
||||
explosiveness = 0.9
|
||||
texture = ExtResource( 1 )
|
||||
gravity = Vector2( 0, 0 )
|
||||
initial_velocity = 150.0
|
||||
initial_velocity_random = 1.0
|
||||
scale_amount = 0.15
|
||||
scale_amount_random = 0.4
|
||||
color = Color( 0.627451, 0.0705882, 0.0705882, 0.705882 )
|
||||
script = ExtResource( 2 )
|
||||
texture = ExtResource("1")
|
||||
gravity = Vector2(0, 0)
|
||||
color = Color(0.627451, 0.0705882, 0.0705882, 0.705882)
|
||||
script = ExtResource("2")
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
[ext_resource type="Shader" path="res://resource/shader/Blend.gdshader" id="2_1c01w"]
|
||||
[ext_resource type="Texture2D" uid="uid://b74yx6c2jifyd" path="res://resource/sprite/item/hall_b/item-31.png" id="3_mua0g"]
|
||||
|
||||
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wh4b7"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_1c01w")
|
||||
|
@ -42,7 +40,7 @@ animations = [{
|
|||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kmpvc"]
|
||||
size = Vector2(58, 16)
|
||||
size = Vector2(42, 16)
|
||||
|
||||
[node name="Item0001" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")]
|
||||
collision_layer = 512
|
||||
|
@ -62,5 +60,9 @@ position = Vector2(0, -10.5)
|
|||
sprite_frames = SubResource("SpriteFrames_uqva1")
|
||||
|
||||
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 4)
|
||||
position = Vector2(-3, -15)
|
||||
shape = SubResource("RectangleShape2D_kmpvc")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
position = Vector2(32, -10)
|
||||
polygon = PackedVector2Array(-14, 31, -14, -13, 4, -13, 4, 31)
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
[ext_resource type="Shader" path="res://resource/shader/Blend.gdshader" id="2_u3oiv"]
|
||||
[ext_resource type="Texture2D" uid="uid://dl15qkga1kc82" path="res://resource/sprite/item/hall_b/item-12.png" id="3_6b42f"]
|
||||
|
||||
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wh4b7"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_u3oiv")
|
||||
|
@ -55,7 +53,7 @@ material = SubResource("ShaderMaterial_wh4b7")
|
|||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite2D" parent="."]
|
||||
material = SubResource("ShaderMaterial_f7tsa")
|
||||
position = Vector2(15.5, -10)
|
||||
position = Vector2(0, -10)
|
||||
sprite_frames = SubResource("SpriteFrames_uqva1")
|
||||
|
||||
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
[ext_resource type="Shader" path="res://resource/shader/Blend.gdshader" id="2_fbidd"]
|
||||
[ext_resource type="Texture2D" uid="uid://dr2d6toqxxifv" path="res://resource/sprite/item/hall_b/item-32.png" id="3_4miy3"]
|
||||
|
||||
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wh4b7"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_fbidd")
|
||||
|
@ -42,7 +40,7 @@ animations = [{
|
|||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_p3c6b"]
|
||||
size = Vector2(54, 17)
|
||||
size = Vector2(28, 29)
|
||||
|
||||
[node name="Item0003" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")]
|
||||
collision_layer = 512
|
||||
|
@ -58,9 +56,7 @@ material = SubResource("ShaderMaterial_wh4b7")
|
|||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite2D" parent="."]
|
||||
material = SubResource("ShaderMaterial_f7tsa")
|
||||
position = Vector2(0, -4)
|
||||
sprite_frames = SubResource("SpriteFrames_uqva1")
|
||||
|
||||
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 2.5)
|
||||
shape = SubResource("RectangleShape2D_p3c6b")
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
[ext_resource type="Shader" path="res://resource/shader/Blend.gdshader" id="2_lp5ce"]
|
||||
[ext_resource type="Texture2D" uid="uid://belr22s50exy8" path="res://resource/sprite/item/hall_b/item-18.png" id="3_px2by"]
|
||||
|
||||
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wh4b7"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_lp5ce")
|
||||
|
@ -42,7 +40,7 @@ animations = [{
|
|||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_p3c6b"]
|
||||
size = Vector2(24, 12)
|
||||
size = Vector2(62, 73)
|
||||
|
||||
[node name="Item0004" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")]
|
||||
collision_layer = 512
|
||||
|
@ -58,9 +56,17 @@ material = SubResource("ShaderMaterial_wh4b7")
|
|||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite2D" parent="."]
|
||||
material = SubResource("ShaderMaterial_f7tsa")
|
||||
position = Vector2(0, -4)
|
||||
position = Vector2(0, 27)
|
||||
sprite_frames = SubResource("SpriteFrames_uqva1")
|
||||
|
||||
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 2)
|
||||
position = Vector2(0, 35)
|
||||
scale = Vector2(1e-05, 1e-05)
|
||||
shape = SubResource("RectangleShape2D_p3c6b")
|
||||
one_way_collision_margin = 0.0
|
||||
debug_color = Color(0, 0.6, 0.701961, 0.419608)
|
||||
metadata/collsionShape2D1 = false
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
position = Vector2(-29, 14)
|
||||
polygon = PackedVector2Array(-12, -14, 48, -14, 48, 51, 69, 51, 69, 55, -12, 55)
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
[ext_resource type="Shader" path="res://resource/shader/Blend.gdshader" id="2_fshwj"]
|
||||
[ext_resource type="Texture2D" uid="uid://bijiqseh8y667" path="res://resource/sprite/item/hall_b/item-01.png" id="3_3isqs"]
|
||||
|
||||
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wh4b7"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_fshwj")
|
||||
|
@ -58,9 +56,9 @@ material = SubResource("ShaderMaterial_wh4b7")
|
|||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite2D" parent="."]
|
||||
material = SubResource("ShaderMaterial_f7tsa")
|
||||
position = Vector2(0, -4)
|
||||
position = Vector2(0.5, -0.5)
|
||||
sprite_frames = SubResource("SpriteFrames_uqva1")
|
||||
|
||||
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, -1)
|
||||
position = Vector2(0, 5)
|
||||
shape = SubResource("RectangleShape2D_p3c6b")
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[ext_resource type="Shader" path="res://resource/shader/Blend.gdshader" id="2_5sjig"]
|
||||
[ext_resource type="Texture2D" uid="uid://u3ri36urv8xn" path="res://resource/sprite/item/hall_c/item _56.png" id="3_bkxin"]
|
||||
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wh4b7"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_5sjig")
|
||||
|
@ -41,7 +40,7 @@ animations = [{
|
|||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kmpvc"]
|
||||
size = Vector2(46, 12)
|
||||
size = Vector2(26, 12)
|
||||
|
||||
[node name="Item0056" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")]
|
||||
collision_layer = 512
|
||||
|
@ -61,5 +60,5 @@ position = Vector2(0, 2)
|
|||
sprite_frames = SubResource("SpriteFrames_uqva1")
|
||||
|
||||
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 5)
|
||||
position = Vector2(0, 17)
|
||||
shape = SubResource("RectangleShape2D_kmpvc")
|
||||
|
|
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 616 B After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 971 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 305 B |
Before Width: | Height: | Size: 317 B After Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -134,6 +134,12 @@ texture = ExtResource("1_vwr2k")
|
|||
3:5/0 = 0
|
||||
3:5/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||
3:5/0/physics_layer_0/angular_velocity = 0.0
|
||||
4:5/0 = 0
|
||||
4:5/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||
4:5/0/physics_layer_0/angular_velocity = 0.0
|
||||
5:5/0 = 0
|
||||
5:5/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||
5:5/0/physics_layer_0/angular_velocity = 0.0
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_wecvb"]
|
||||
texture = ExtResource("2_01oxu")
|
||||
|
@ -144,5 +150,5 @@ texture = ExtResource("2_01oxu")
|
|||
[resource]
|
||||
physics_layer_0/collision_layer = 1
|
||||
physics_layer_0/collision_mask = 0
|
||||
sources/0 = SubResource("TileSetAtlasSource_7e1ow")
|
||||
sources/1 = SubResource("TileSetAtlasSource_wecvb")
|
||||
sources/0 = SubResource("TileSetAtlasSource_7e1ow")
|
||||
|
|
|
@ -88,7 +88,7 @@ public partial class AffiliationArea : Area2D, IDestroy
|
|||
if (_includeItems.Add(activityObject))
|
||||
{
|
||||
//如果是玩家
|
||||
if (activityObject == Player.Current)
|
||||
if (activityObject == RoomInfo.World.Player)
|
||||
{
|
||||
CallDeferred(nameof(OnPlayerInsertRoom));
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ public partial class AffiliationArea : Area2D, IDestroy
|
|||
{
|
||||
if (IsFirstEnterFlag)
|
||||
{
|
||||
Player.Current.OnFirstEnterRoom(RoomInfo);
|
||||
RoomInfo.World.Player.OnFirstEnterRoom(RoomInfo);
|
||||
EventManager.EmitEvent(EventEnum.OnPlayerFirstEnterRoom, RoomInfo);
|
||||
}
|
||||
EventManager.EmitEvent(EventEnum.OnPlayerEnterRoom, RoomInfo);
|
||||
|
|
|
@ -63,7 +63,7 @@ public partial class AisleFogArea : Area2D, IDestroy
|
|||
|
||||
private void OnBodyEntered(Node2D body)
|
||||
{
|
||||
if (body == Player.Current)
|
||||
if (body == RoomDoorInfo.RoomInfo.World.Player)
|
||||
{
|
||||
//注意需要延时调用
|
||||
CallDeferred(nameof(InsertPlayer));
|
||||
|
|
|
@ -21,6 +21,11 @@ public class RoomInfo : IDestroy
|
|||
RoomSplit = roomSplit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所在世界对象
|
||||
/// </summary>
|
||||
public World World;
|
||||
|
||||
/// <summary>
|
||||
/// 房间 id
|
||||
/// </summary>
|
||||
|
|
|
@ -12,7 +12,12 @@ public partial class World : CanvasModulate, ICoroutine
|
|||
/// <summary>
|
||||
/// 当前的游戏世界对象
|
||||
/// </summary>
|
||||
public static World Current => GameApplication.Instance?.DungeonManager?.CurrWorld;
|
||||
public static World Current => GameApplication.Instance.DungeonManager.CurrWorld;
|
||||
|
||||
/// <summary>
|
||||
/// 当前操作的玩家
|
||||
/// </summary>
|
||||
public Player Player { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// //对象根节点
|
||||
|
@ -119,6 +124,17 @@ public partial class World : CanvasModulate, ICoroutine
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前操作的玩家对象
|
||||
/// </summary>
|
||||
public void SetCurrentPlayer(Player player)
|
||||
{
|
||||
Player = player;
|
||||
//设置相机和鼠标跟随玩家
|
||||
GameCamera.Main.SetFollowTarget(player);
|
||||
GameApplication.Instance.Cursor.SetMountRole(player);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知其他敌人发现目标了
|
||||
/// </summary>
|
||||
|
|
|
@ -103,7 +103,7 @@ public partial class Laser : Area2D, IBullet
|
|||
LineSprite.Scale = new Vector2(0, width * _pixelScale);
|
||||
|
||||
//如果子弹会对玩家造成伤害, 则显示成红色
|
||||
if (Player.Current.CollisionWithMask(attackLayer))
|
||||
if (BulletData.World.Player.CollisionWithMask(attackLayer))
|
||||
{
|
||||
LineSprite.Modulate = new Color(2.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ public partial class Bullet : ActivityObject, IBullet
|
|||
MoveController.AddForce(new Vector2(data.FlySpeed, 0).Rotated(Rotation));
|
||||
|
||||
//如果子弹会对玩家造成伤害, 则显示红色描边
|
||||
if (Player.Current != null && Player.Current.CollisionWithMask(attackLayer))
|
||||
if (World.Player != null && World.Player.CollisionWithMask(attackLayer))
|
||||
{
|
||||
if (!IsEnemyBullet)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
/// <summary>
|
||||
|
@ -27,7 +28,7 @@ public partial class Gold : ActivityObject, IPoolItem
|
|||
|
||||
protected override void OnThrowOver()
|
||||
{
|
||||
var current = Player.Current;
|
||||
var current = World.Player;
|
||||
if (current != null)
|
||||
{
|
||||
this.CallDelay(0.3f, () =>
|
||||
|
@ -70,4 +71,29 @@ public partial class Gold : ActivityObject, IPoolItem
|
|||
MoveController.ClearForce();
|
||||
MoveController.SetAllVelocity(Vector2.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建散落的金币
|
||||
/// </summary>
|
||||
/// <param name="position">位置</param>
|
||||
/// <param name="count">金币数量</param>
|
||||
/// <param name="force">投抛力度</param>
|
||||
public static List<Gold> CreateGold(Vector2 position, int count, int force = 10)
|
||||
{
|
||||
var list = new List<Gold>();
|
||||
var goldList = Utils.GetGoldList(count);
|
||||
foreach (var id in goldList)
|
||||
{
|
||||
var o = ObjectManager.GetActivityObject<Gold>(id);
|
||||
o.Position = position;
|
||||
o.Throw(0,
|
||||
Utils.Random.RandomRangeInt(5 * force, 11 * force),
|
||||
new Vector2(Utils.Random.RandomRangeInt(-2 * force, 2 * force), Utils.Random.RandomRangeInt(-2 * force, 2 * force)),
|
||||
0
|
||||
);
|
||||
list.Add(o);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1013,7 +1013,7 @@ public abstract partial class Role : ActivityObject
|
|||
/// </summary>
|
||||
public bool IsPlayer()
|
||||
{
|
||||
return this == Player.Current;
|
||||
return this == World.Player;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1021,11 +1021,11 @@ public abstract partial class Role : ActivityObject
|
|||
/// </summary>
|
||||
public bool IsEnemyWithPlayer()
|
||||
{
|
||||
if (Player.Current == null)
|
||||
if (World.Player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return CollisionWithMask(Player.Current.EnemyLayer);
|
||||
return CollisionWithMask(World.Player.EnemyLayer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -100,6 +100,14 @@ public abstract partial class AiRole : Role
|
|||
//NavigationAgent2D.VelocityComputed += OnVelocityComputed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取攻击的目标对象, 该函数不能返回 null
|
||||
/// </summary>
|
||||
public virtual Role GetAttackTarget()
|
||||
{
|
||||
return World.Player;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回地上的武器是否有可以拾取的, 也包含没有被其他敌人标记的武器
|
||||
/// </summary>
|
||||
|
@ -370,6 +378,16 @@ public abstract partial class AiRole : Role
|
|||
}
|
||||
}
|
||||
|
||||
protected override void OnDie()
|
||||
{
|
||||
//扔掉所有武器
|
||||
ThrowAllWeapon();
|
||||
//创建金币
|
||||
Gold.CreateGold(Position, RoleState.Gold);
|
||||
//销毁
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// private void OnVelocityComputed(Vector2 velocity)
|
||||
// {
|
||||
// if (Mathf.Abs(velocity.X) >= 0.01f && Mathf.Abs(velocity.Y) >= 0.01f)
|
||||
|
|
|
@ -75,14 +75,14 @@ public class AiFindAmmoState : StateBase<AiRole, AIStateEnum>
|
|||
if (Master.LookTarget == null) //没有目标
|
||||
{
|
||||
//临时处理
|
||||
var player = Player.Current;
|
||||
var playerPos = player.GetCenterPosition();
|
||||
if (Master.IsInViewRange(playerPos) && !Master.TestViewRayCast(playerPos)) //发现玩家
|
||||
var attackTarget = Master.GetAttackTarget();
|
||||
var targetPos = attackTarget.GetCenterPosition();
|
||||
if (Master.IsInViewRange(targetPos) && !Master.TestViewRayCast(targetPos)) //发现玩家
|
||||
{
|
||||
//关闭射线检测
|
||||
Master.TestViewRayCastOver();
|
||||
//发现玩家
|
||||
Master.LookTarget = player;
|
||||
Master.LookTarget = attackTarget;
|
||||
//进入惊讶状态, 然后再进入通知状态
|
||||
ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiFindAmmo, TargetWeapon);
|
||||
return;
|
||||
|
|
|
@ -102,16 +102,17 @@ public class AiLeaveForState : StateBase<AiRole, AIStateEnum>
|
|||
Master.DoIdle();
|
||||
}
|
||||
|
||||
var playerPos = Player.Current.GetCenterPosition();
|
||||
var attackTarget = Master.GetAttackTarget();
|
||||
var targetPos = attackTarget.GetCenterPosition();
|
||||
//检测玩家是否在视野内, 如果在, 则切换到 AiTargetInView 状态
|
||||
if (Master.IsInTailAfterViewRange(playerPos))
|
||||
if (Master.IsInTailAfterViewRange(targetPos))
|
||||
{
|
||||
if (!Master.TestViewRayCast(playerPos)) //看到玩家
|
||||
if (!Master.TestViewRayCast(targetPos)) //看到玩家
|
||||
{
|
||||
//关闭射线检测
|
||||
Master.TestViewRayCastOver();
|
||||
//切换成发现目标状态
|
||||
Master.LookTarget = Player.Current;
|
||||
Master.LookTarget = attackTarget;
|
||||
ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiFollowUp);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -46,17 +46,17 @@ public class AiNormalState : StateBase<AiRole, AIStateEnum>
|
|||
|
||||
public override void Process(float delta)
|
||||
{
|
||||
//检测玩家
|
||||
var player = Player.Current;
|
||||
//获取攻击目标
|
||||
var attackTarget = Master.GetAttackTarget();
|
||||
//玩家中心点坐标
|
||||
var playerPos = player.GetCenterPosition();
|
||||
var targetPos = attackTarget.GetCenterPosition();
|
||||
|
||||
if (Master.IsInViewRange(playerPos) && !Master.TestViewRayCast(playerPos)) //发现玩家
|
||||
if (Master.IsInViewRange(targetPos) && !Master.TestViewRayCast(targetPos)) //发现目标
|
||||
{
|
||||
//关闭射线检测
|
||||
Master.TestViewRayCastOver();
|
||||
//发现玩家
|
||||
Master.LookTarget = player;
|
||||
Master.LookTarget = attackTarget;
|
||||
//判断是否进入通知状态
|
||||
if (Master.World.Enemy_InstanceList.FindIndex(enemy =>
|
||||
enemy != Master && !enemy.IsDie && enemy.AffiliationArea == Master.AffiliationArea &&
|
||||
|
|
|
@ -110,9 +110,6 @@ public partial class Enemy : AiRole
|
|||
|
||||
protected override void OnDie()
|
||||
{
|
||||
//扔掉所有武器
|
||||
ThrowAllWeapon();
|
||||
|
||||
var effPos = Position + new Vector2(0, -Altitude);
|
||||
//血液特效
|
||||
var blood = ObjectManager.GetPoolItem<AutoDestroyParticles>(ResourcePath.prefab_effect_enemy_EnemyBlood0001_tscn);
|
||||
|
@ -130,12 +127,10 @@ public partial class Enemy : AiRole
|
|||
debris.MoveController.AddForce(Velocity + realVelocity);
|
||||
}
|
||||
|
||||
//创建金币
|
||||
CreateGold();
|
||||
|
||||
//派发敌人死亡信号
|
||||
EventManager.EmitEvent(EventEnum.OnEnemyDie, this);
|
||||
Destroy();
|
||||
|
||||
base.OnDie();
|
||||
}
|
||||
|
||||
protected override void Process(float delta)
|
||||
|
@ -172,24 +167,6 @@ public partial class Enemy : AiRole
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建散落的金币
|
||||
/// </summary>
|
||||
protected void CreateGold()
|
||||
{
|
||||
var goldList = Utils.GetGoldList(RoleState.Gold);
|
||||
foreach (var id in goldList)
|
||||
{
|
||||
var o = ObjectManager.GetActivityObject<Gold>(id);
|
||||
o.Position = Position;
|
||||
o.Throw(0,
|
||||
Utils.Random.RandomRangeInt(50, 110),
|
||||
new Vector2(Utils.Random.RandomRangeInt(-20, 20), Utils.Random.RandomRangeInt(-20, 20)),
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsAllWeaponTotalAmmoEmpty()
|
||||
{
|
||||
if (!_enemyAttribute.CanPickUpWeapon)
|
||||
|
|
|
@ -71,7 +71,7 @@ public partial class NoWeaponEnemy : Enemy
|
|||
debris.BrushPrevPosition = BrushPrevPosition;
|
||||
|
||||
//创建金币
|
||||
CreateGold();
|
||||
Gold.CreateGold(Position, RoleState.Gold);
|
||||
|
||||
//派发敌人死亡信号
|
||||
EventManager.EmitEvent(EventEnum.OnEnemyDie, this);
|
||||
|
|
|
@ -14,11 +14,6 @@ public partial class Player : Role
|
|||
/// </summary>
|
||||
public event Action<RoomInfo> OnFirstEnterRoomEvent;
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前操作的角色
|
||||
/// </summary>
|
||||
public static Player Current { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 玩家身上的状态机控制器
|
||||
/// </summary>
|
||||
|
@ -36,17 +31,6 @@ public partial class Player : Role
|
|||
|
||||
private BrushImageData _brushData2;
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前操作的玩家对象
|
||||
/// </summary>
|
||||
public static void SetCurrentPlayer(Player player)
|
||||
{
|
||||
Current = player;
|
||||
//设置相机和鼠标跟随玩家
|
||||
GameCamera.Main.SetFollowTarget(player);
|
||||
GameApplication.Instance.Cursor.SetMountRole(player);
|
||||
}
|
||||
|
||||
public override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
|
|
|
@ -8,7 +8,7 @@ public partial class Gun : Weapon
|
|||
{
|
||||
protected override void OnFire()
|
||||
{
|
||||
if (Master == Player.Current)
|
||||
if (Master == World.Player)
|
||||
{
|
||||
//创建抖动
|
||||
GameCamera.Main.DirectionalShake(Vector2.Right.Rotated(GlobalRotation) * Attribute.CameraShake);
|
||||
|
|
|
@ -94,7 +94,7 @@ public partial class Knife : Weapon
|
|||
}
|
||||
|
||||
|
||||
if (Master == Player.Current)
|
||||
if (Master == World.Player)
|
||||
{
|
||||
var r = Master.MountPoint.RotationDegrees;
|
||||
//创建屏幕抖动
|
||||
|
|
|
@ -18,16 +18,6 @@ public class Eff_GetGold : EffectFragment
|
|||
|
||||
public override void OnUse()
|
||||
{
|
||||
var goldList = Utils.GetGoldList(Mathf.FloorToInt(_value));
|
||||
foreach (var id in goldList)
|
||||
{
|
||||
var o = ObjectManager.GetActivityObject<Gold>(id);
|
||||
o.Position = Role.Position;
|
||||
o.Throw(0,
|
||||
Utils.Random.RandomRangeInt(50, 110),
|
||||
new Vector2(Utils.Random.RandomRangeInt(-20, 20), Utils.Random.RandomRangeInt(-20, 20)),
|
||||
0
|
||||
);
|
||||
}
|
||||
Gold.CreateGold(Role.Position, _value);
|
||||
}
|
||||
}
|
|
@ -25,17 +25,7 @@ public class Eff_PiggyBank : EffectFragment
|
|||
|
||||
public override void OnUse()
|
||||
{
|
||||
var goldList = Utils.GetGoldList(Mathf.FloorToInt(_currValue * _value));
|
||||
foreach (var id in goldList)
|
||||
{
|
||||
var o = ObjectManager.GetActivityObject<Gold>(id);
|
||||
o.Position = Role.Position;
|
||||
o.Throw(0,
|
||||
Utils.Random.RandomRangeInt(50, 110),
|
||||
new Vector2(Utils.Random.RandomRangeInt(-20, 20), Utils.Random.RandomRangeInt(-20, 20)),
|
||||
0
|
||||
);
|
||||
}
|
||||
Gold.CreateGold(Role.Position, Mathf.FloorToInt(_currValue * _value));
|
||||
|
||||
_currValue = 0;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,11 @@ using Godot;
|
|||
/// </summary>
|
||||
public class BulletData : IClone<BulletData>
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据所在世界对象
|
||||
/// </summary>
|
||||
public World World;
|
||||
|
||||
/// <summary>
|
||||
/// 发射该子弹的武器, 可能为null
|
||||
/// </summary>
|
||||
|
@ -77,9 +82,14 @@ public class BulletData : IClone<BulletData>
|
|||
/// </summary>
|
||||
public float Rotation;
|
||||
|
||||
public BulletData(World world)
|
||||
{
|
||||
World = world;
|
||||
}
|
||||
|
||||
public BulletData Clone()
|
||||
{
|
||||
return new BulletData
|
||||
return new BulletData(World)
|
||||
{
|
||||
Weapon = Weapon,
|
||||
BulletBase = BulletBase,
|
||||
|
|
|
@ -172,7 +172,7 @@ public static class FireManager
|
|||
|
||||
private static BulletData CreateSolidBulletData(Weapon weapon, float fireRotation, ExcelConfig.BulletBase bullet)
|
||||
{
|
||||
var data = new BulletData()
|
||||
var data = new BulletData(weapon.World)
|
||||
{
|
||||
Weapon = weapon,
|
||||
BulletBase = bullet,
|
||||
|
@ -216,7 +216,7 @@ public static class FireManager
|
|||
|
||||
private static BulletData CreateSolidBulletData(Role role, float fireRotation, ExcelConfig.BulletBase bullet)
|
||||
{
|
||||
var data = new BulletData()
|
||||
var data = new BulletData(role.World)
|
||||
{
|
||||
Weapon = null,
|
||||
BulletBase = bullet,
|
||||
|
@ -261,7 +261,7 @@ public static class FireManager
|
|||
|
||||
private static BulletData CreateLaserData(Weapon weapon, float fireRotation, ExcelConfig.BulletBase bullet)
|
||||
{
|
||||
var data = new BulletData()
|
||||
var data = new BulletData(weapon.World)
|
||||
{
|
||||
Weapon = weapon,
|
||||
BulletBase = bullet,
|
||||
|
|
|
@ -16,12 +16,12 @@ public partial class DungeonManager : Node2D
|
|||
/// <summary>
|
||||
/// 当前玩家所在的房间
|
||||
/// </summary>
|
||||
public RoomInfo ActiveRoomInfo => Player.Current?.AffiliationArea?.RoomInfo;
|
||||
public RoomInfo ActiveRoomInfo => CurrWorld.Player?.AffiliationArea?.RoomInfo;
|
||||
|
||||
/// <summary>
|
||||
/// 当前玩家所在的区域
|
||||
/// </summary>
|
||||
public AffiliationArea ActiveAffiliationArea => Player.Current?.AffiliationArea;
|
||||
public AffiliationArea ActiveAffiliationArea => CurrWorld.Player?.AffiliationArea;
|
||||
|
||||
/// <summary>
|
||||
/// 是否在地牢里
|
||||
|
@ -277,6 +277,7 @@ public partial class DungeonManager : Node2D
|
|||
|
||||
//创建房间数据
|
||||
var roomInfo = new RoomInfo(0, DungeonRoomType.None, null);
|
||||
roomInfo.World = CurrWorld;
|
||||
roomInfo.Size = hall.BgSprite.Texture.GetSize().AsVector2I() / GameConfig.TileCellSize + new Vector2I(10, 10);
|
||||
roomInfo.Position = hall.BgSprite.Position.AsVector2I() - new Vector2I(5, 5) * GameConfig.TileCellSize;
|
||||
hall.RoomInfo = roomInfo;
|
||||
|
@ -316,7 +317,7 @@ public partial class DungeonManager : Node2D
|
|||
yield return 0;
|
||||
|
||||
//创建玩家
|
||||
var player = Player.Current;
|
||||
var player = CurrWorld.Player;
|
||||
if (player == null)
|
||||
{
|
||||
player = ActivityObject.Create<Player>(ActivityObject.Ids.Id_role0001);
|
||||
|
@ -325,7 +326,7 @@ public partial class DungeonManager : Node2D
|
|||
player.World = CurrWorld;
|
||||
player.Position = hall.BirthMark.Position;
|
||||
player.PutDown(RoomLayerEnum.YSortLayer);
|
||||
Player.SetCurrentPlayer(player);
|
||||
CurrWorld.SetCurrentPlayer(player);
|
||||
affiliation.InsertItem(player);
|
||||
player.WeaponPack.PickupItem(ActivityObject.Create<Weapon>(ActivityObject.Ids.Id_weapon0001));
|
||||
yield return 0;
|
||||
|
@ -359,11 +360,11 @@ public partial class DungeonManager : Node2D
|
|||
yield return 0;
|
||||
if (!keepPlayer)
|
||||
{
|
||||
Player.SetCurrentPlayer(null);
|
||||
CurrWorld.SetCurrentPlayer(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var player = Player.Current;
|
||||
var player = CurrWorld.Player;
|
||||
player.AffiliationArea?.RemoveItem(player);
|
||||
player.GetParent().RemoveChild(player);
|
||||
player.World = null;
|
||||
|
@ -452,6 +453,11 @@ public partial class DungeonManager : Node2D
|
|||
//创建世界场景
|
||||
var dungeon = (Dungeon)CreateNewWorld(_dungeonGenerator.Random, ResourcePath.scene_Dungeon_tscn);
|
||||
dungeon.InitLayer();
|
||||
//初始化房间 World 字段
|
||||
foreach (var roomInfo in _dungeonGenerator.RoomInfos)
|
||||
{
|
||||
roomInfo.World = dungeon;
|
||||
}
|
||||
yield return 0;
|
||||
var group = GameApplication.Instance.RoomConfig[CurrConfig.GroupName];
|
||||
var tileSetSplit = GameApplication.Instance.TileSetConfig[group.TileSet];
|
||||
|
@ -483,7 +489,7 @@ public partial class DungeonManager : Node2D
|
|||
var playerBirthMark = StartRoomInfo.RoomPreinstall.GetSpecialMark(SpecialMarkType.BirthPoint);
|
||||
|
||||
//创建玩家
|
||||
var player = Player.Current;
|
||||
var player = CurrWorld.Player;
|
||||
if (player == null)
|
||||
{
|
||||
player = ActivityObject.Create<Player>(ActivityObject.Ids.Id_role0001);
|
||||
|
@ -496,7 +502,7 @@ public partial class DungeonManager : Node2D
|
|||
|
||||
player.World = CurrWorld;
|
||||
player.PutDown(RoomLayerEnum.YSortLayer);
|
||||
Player.SetCurrentPlayer(player);
|
||||
CurrWorld.SetCurrentPlayer(player);
|
||||
StartRoomInfo.AffiliationArea.InsertItem(player);
|
||||
yield return 0;
|
||||
player.Collision.Disabled = false;
|
||||
|
@ -530,11 +536,11 @@ public partial class DungeonManager : Node2D
|
|||
yield return 0;
|
||||
if (!keepPlayer)
|
||||
{
|
||||
Player.SetCurrentPlayer(null);
|
||||
CurrWorld.SetCurrentPlayer(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var player = Player.Current;
|
||||
var player = CurrWorld.Player;
|
||||
player.AffiliationArea?.RemoveItem(player);
|
||||
player.GetParent().RemoveChild(player);
|
||||
player.World = null;
|
||||
|
@ -851,7 +857,7 @@ public partial class DungeonManager : Node2D
|
|||
//如果关门了, 那么房间外的敌人就会丢失目标
|
||||
if (room.IsSeclusion)
|
||||
{
|
||||
var playerAffiliationArea = Player.Current.AffiliationArea;
|
||||
var playerAffiliationArea = CurrWorld.Player.AffiliationArea;
|
||||
foreach (var enemy in CurrWorld.Enemy_InstanceList)
|
||||
{
|
||||
//不与玩家处于同一个房间
|
||||
|
|
|
@ -141,10 +141,11 @@ public partial class RoomMapPanel : RoomMap
|
|||
_needRefresh.Clear();
|
||||
}
|
||||
|
||||
if (Player.Current != null)
|
||||
var player = World.Current.Player;
|
||||
if (player != null)
|
||||
{
|
||||
//更新地图中心点位置
|
||||
var playPosition = Player.Current.GetCenterPosition();
|
||||
var playPosition = player.GetCenterPosition();
|
||||
if (!_isMagnifyMap)
|
||||
{
|
||||
S_Root.Instance.Position = CalcRootPosition(playPosition);
|
||||
|
@ -155,7 +156,7 @@ public partial class RoomMapPanel : RoomMap
|
|||
S_Mark.Instance.Position = S_DrawContainer.Instance.Size / 2 + _mapOffset;
|
||||
}
|
||||
|
||||
var area = Player.Current.AffiliationArea;
|
||||
var area = player.AffiliationArea;
|
||||
//传送
|
||||
if (_pressMapFlag && _mouseHoverRoom != null &&
|
||||
area != null && !area.RoomInfo.IsSeclusion &&
|
||||
|
@ -269,7 +270,7 @@ public partial class RoomMapPanel : RoomMap
|
|||
var shaderMaterial = (ShaderMaterial)roomInfo.PreviewSprite.Material;
|
||||
_originOutlineColor = shaderMaterial.GetShaderParameter("outline_color").AsColor();
|
||||
//玩家所在的房间门是否打开
|
||||
var area = Player.Current.AffiliationArea;
|
||||
var area = World.Current.Player.AffiliationArea;
|
||||
if (area != null)
|
||||
{
|
||||
var isOpen = !area.RoomInfo.IsSeclusion;
|
||||
|
@ -411,7 +412,7 @@ public partial class RoomMapPanel : RoomMap
|
|||
_transmissionTween.TweenProperty(roomUI.S_Mask.Instance, "color", new Color(0, 0, 0), 0.3f);
|
||||
_transmissionTween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
Player.Current.Position = position;
|
||||
World.Current.Player.Position = position;
|
||||
}));
|
||||
_transmissionTween.TweenInterval(0.2f);
|
||||
_transmissionTween.TweenProperty(roomUI.S_Mask.Instance, "color", new Color(0, 0, 0, 0), 0.3f);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ActivePropBarHandler
|
|||
|
||||
public void Process(float delta)
|
||||
{
|
||||
var prop = Player.Current?.ActivePropsPack.ActiveItem;
|
||||
var prop = World.Current.Player?.ActivePropsPack.ActiveItem;
|
||||
if (prop != null)
|
||||
{
|
||||
SetActivePropCount(prop.Count);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class InteractiveTipBarHandler
|
|||
else
|
||||
{
|
||||
var result = (CheckInteractiveResult)o;
|
||||
var interactiveItem = Player.Current.InteractiveItem;
|
||||
var interactiveItem = World.Current.Player.InteractiveItem;
|
||||
//if (interactiveItem is Weapon)
|
||||
var icon = result.GetIcon();
|
||||
if (icon != null)
|
||||
|
|
|
@ -67,7 +67,7 @@ public class LifeBarHandler
|
|||
|
||||
private void HandlerRefreshLife()
|
||||
{
|
||||
var player = Player.Current;
|
||||
var player = World.Current.Player;
|
||||
if (player.MaxHp % 2 != 0)
|
||||
{
|
||||
Debug.LogError("玩家血量不是偶数!");
|
||||
|
@ -108,7 +108,7 @@ public class LifeBarHandler
|
|||
|
||||
private void HandlerRefreshGold()
|
||||
{
|
||||
_bar.L_Gold.L_GoldText.Instance.Text = Player.Current.RoleState.Gold.ToString();
|
||||
_bar.L_Gold.L_GoldText.Instance.Text = World.Current.Player.RoleState.Gold.ToString();
|
||||
}
|
||||
|
||||
}
|
|
@ -55,8 +55,8 @@ public class ReloadBarHandler
|
|||
/// </summary>
|
||||
public void OnCameraPositionUpdate(float delta)
|
||||
{
|
||||
var player = Player.Current;
|
||||
var activeItem = player.WeaponPack.ActiveItem;
|
||||
var player = World.Current.Player;
|
||||
var activeItem = player?.WeaponPack.ActiveItem;
|
||||
if (activeItem != null && activeItem.Reloading && activeItem.Attribute.ShowReloadBar)
|
||||
{
|
||||
ShowBar(player.GlobalPosition, activeItem.ReloadProgress);
|
||||
|
|
|
@ -25,7 +25,7 @@ public class WeaponBarHandler
|
|||
|
||||
public void Process(float delta)
|
||||
{
|
||||
var weapon = Player.Current?.WeaponPack.ActiveItem;
|
||||
var weapon = World.Current.Player?.WeaponPack.ActiveItem;
|
||||
if (weapon != null)
|
||||
{
|
||||
SetWeaponTexture(weapon.GetCurrentTexture());
|
||||
|
|
|
@ -159,7 +159,7 @@ public partial class WeaponRoulettePanel : WeaponRoulette
|
|||
//如果选中了物体
|
||||
if (ActiveWeapon != null)
|
||||
{
|
||||
Player.Current.ExchangeWeaponByIndex(ActiveWeapon.PackageIndex);
|
||||
World.Current.Player.ExchangeWeaponByIndex(ActiveWeapon.PackageIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ public partial class WeaponRoulettePanel : WeaponRoulette
|
|||
//刷新页码
|
||||
private void RefreshSlotPage()
|
||||
{
|
||||
var current = Player.Current;
|
||||
var current = World.Current.Player;
|
||||
if (current == null)
|
||||
{
|
||||
return;
|
||||
|
@ -211,7 +211,7 @@ public partial class WeaponRoulettePanel : WeaponRoulette
|
|||
//更新显示的武器
|
||||
private void RefreshWeapon()
|
||||
{
|
||||
var current = Player.Current;
|
||||
var current = World.Current.Player;
|
||||
if (current == null) //没有玩家对象,这是异常情况
|
||||
{
|
||||
foreach (var slotNode in _slotNodes)
|
||||
|
|