diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index 6f1bc50..6c11d4a 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -125,7 +125,7 @@ { throw new Exception("创建 ActivityObject 没有找到指定挂载的预制体: " + scenePath); } - + ItemId = itemId; Name = GetType().Name + (_instanceIndex++); @@ -137,6 +137,7 @@ var body = _templateInstance.GetChild(0); _templateInstance.RemoveChild(body); AddChild(body); + body.Owner = this; switch (body.Name) { case "AnimatedSprite": @@ -165,6 +166,8 @@ //临时处理, 4.0 有bug, 不能销毁模板实例, 不然关闭游戏会报错!!! //_templateInstance.CallDeferred(Node.MethodName.QueueFree); + + OnInit(); } /// <summary> @@ -243,6 +246,13 @@ } /// <summary> + /// 物体初始化时调用 + /// </summary> + public virtual void OnInit() + { + } + + /// <summary> /// 返回是否能与其他ActivityObject互动 /// </summary> /// <param name="master">触发者</param> @@ -866,7 +876,7 @@ } //临时处理, 4.0 有bug, 不能销毁模板实例, 不然关闭游戏会报错!!! - //_templateInstance.QueueFree(); + _templateInstance.QueueFree(); } /// <summary> diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTile.cs b/DungeonShooting_Godot/src/framework/map/DungeonTile.cs index aafafa9..3f1ba07 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTile.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTile.cs @@ -597,7 +597,6 @@ closePolygonData.Points.Add(cp3); closePolygonData.Points.Add(cp4); - //这里 NavigationPolygonData 需要计算, 后续补上 _connectNavigationItemList.Add(new DoorNavigationInfo(doorInfo, openPolygonData, closePolygonData)); } diff --git a/DungeonShooting_Godot/src/game/role/Player.cs b/DungeonShooting_Godot/src/game/role/Player.cs index 9863765..ac1d6dc 100644 --- a/DungeonShooting_Godot/src/game/role/Player.cs +++ b/DungeonShooting_Godot/src/game/role/Player.cs @@ -22,9 +22,9 @@ /// </summary> public float Friction { get; set; } = 800f; - public override void _Ready() + public override void OnInit() { - base._Ready(); + base.OnInit(); AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Props | PhysicsLayer.Enemy; Camp = CampEnum.Camp1; diff --git a/DungeonShooting_Godot/src/game/role/Role.cs b/DungeonShooting_Godot/src/game/role/Role.cs index aead7a9..88d627b 100644 --- a/DungeonShooting_Godot/src/game/role/Role.cs +++ b/DungeonShooting_Godot/src/game/role/Role.cs @@ -210,7 +210,7 @@ { } - public override void _Ready() + public override void OnInit() { Holster = new Holster(this); _startScale = Scale; diff --git a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs index 00e79f9..e26025b 100644 --- a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs @@ -80,9 +80,9 @@ //目标在视野内的时间 private float _targetInViewTime = 0; - public override void _Ready() + public override void OnInit() { - base._Ready(); + base.OnInit(); IsAi = true; StateController = AddComponent<StateController<Enemy, AiStateEnum>>();