You've already forked taptap2024_GJ_chidouren
updat core
This commit is contained in:
@@ -37,10 +37,12 @@ namespace Game.Component
|
||||
var lastState = this.cameraState;
|
||||
this.closeUpTarget.position = target.position;
|
||||
SetCameraState (CameraState.CloseUp);
|
||||
MapContent.Instance.IsPause = true;
|
||||
this._closeUpTimeHandler = GameUpdateMgr.Instance.CreateTimer (duration , () =>
|
||||
{
|
||||
SetCameraState (lastState);
|
||||
this._closeUpTimeHandler = null;
|
||||
this._closeUpTimeHandler = null;
|
||||
MapContent.Instance.IsPause = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -162,20 +162,34 @@ namespace Game.Component
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public bool HasRunaway => MapContent.Instance?.IsRunaway ?? false;
|
||||
|
||||
public float CurMoveSpeed => this._curMoveSpeedOffset * (this.MaxMoveSpeed *
|
||||
(1 +
|
||||
( this._expTimeHandler?.IsPlaying ?? false
|
||||
? (1 - this._expTimeHandler.CurProgress) * this._expSpeedOffset
|
||||
: 0f)
|
||||
)
|
||||
);
|
||||
public float CurMoveSpeed => (MapContent.Instance?.MoveGlobalOffset ?? 0) * this._curMoveSpeedOffset * (this.MaxMoveSpeed *
|
||||
(1 +
|
||||
( this._expTimeHandler?.IsPlaying ?? false
|
||||
? (1 - this._expTimeHandler.CurProgress) * this._expSpeedOffset
|
||||
: 0f)
|
||||
)
|
||||
);
|
||||
#else
|
||||
public bool HasRunaway => MapContent.Instance.IsRunaway ?? false;
|
||||
|
||||
public float CurMoveSpeed => (MapContent.Instance.MoveGlobalOffset) * this._curMoveSpeedOffset * (this.MaxMoveSpeed *
|
||||
(1 +
|
||||
( this._expTimeHandler?.IsPlaying ?? false
|
||||
? (1 - this._expTimeHandler.CurProgress) * this._expSpeedOffset
|
||||
: 0f)
|
||||
)
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
public void ResetState ()
|
||||
{
|
||||
this.transform.position = this.CreatePos;
|
||||
this.AnimState.SetState (EnemyAnimStateType.Idle);
|
||||
EndAttack ();
|
||||
this.UpdateSpeedState (false , false);
|
||||
_curAttackingTime = 0;
|
||||
_curAttackCDTime = 0;
|
||||
@@ -267,10 +281,11 @@ namespace Game.Component
|
||||
|
||||
public void CheckUpdateFsmData (bool isUpdate = false)
|
||||
{
|
||||
isUpdate |= _fsmData.HasAttack != this.HasAttack;
|
||||
isUpdate |= _fsmData.HasSafeArea != this.HasSafeArea;
|
||||
isUpdate |= _fsmData.HasRunaway != this.HasRunaway;
|
||||
isUpdate |= _fsmData.HasActive != MapContent.Instance.IsActiveGame;
|
||||
this._aiLerp.speed = this.CurMoveSpeed;
|
||||
isUpdate |= _fsmData.HasAttack != this.HasAttack;
|
||||
isUpdate |= _fsmData.HasSafeArea != this.HasSafeArea;
|
||||
isUpdate |= _fsmData.HasRunaway != this.HasRunaway;
|
||||
isUpdate |= _fsmData.HasActive != MapContent.Instance.IsActiveGame;
|
||||
|
||||
this._fsmData.HasAttack = HasAttack;
|
||||
this._fsmData.HasSafeArea = HasSafeArea;
|
||||
@@ -294,9 +309,8 @@ namespace Game.Component
|
||||
this._expSpeedOffset = offset;
|
||||
this._expTimeHandler?.Kill ();
|
||||
this._expTimeHandler = GameUpdateMgr.Instance.CreateTimer (duration , null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void EndAttack ()
|
||||
{
|
||||
this._hasAtkState = false;
|
||||
|
||||
@@ -13,11 +13,11 @@ namespace Game.Component.EnemyFSM_AI
|
||||
public override void OnUpdate ()
|
||||
{
|
||||
var playerEntityTransform = MapContent.Instance.PlayerEntity.transform;
|
||||
// if (Vector2.Distance (playerEntityTransform.position , this.Entity.transform.position) <= this.Entity.TriggerDistance)
|
||||
// {
|
||||
// this.SetAiTarget (playerEntityTransform.position);
|
||||
// }
|
||||
// else
|
||||
if (Vector2.Distance (playerEntityTransform.position , this.Entity.transform.position) <= this.Entity.TriggerDistance * 0.5f)
|
||||
{
|
||||
this.SetAiTarget (playerEntityTransform.position);
|
||||
}
|
||||
else
|
||||
{
|
||||
var forward = playerEntityTransform.up;
|
||||
this.SetAiTarget (playerEntityTransform.position + forward * this.Entity.TriggerDistance);
|
||||
|
||||
@@ -15,9 +15,18 @@ namespace Game.Component
|
||||
|
||||
public bool IsActiveGame;
|
||||
|
||||
private float _moveGlobalOffset = 1;
|
||||
|
||||
//玩家位置
|
||||
public Vector2 PlayerPosition { private set; get; }
|
||||
public bool IsRunaway { get ; private set ; }
|
||||
public float MoveGlobalOffset => this._moveGlobalOffset;
|
||||
|
||||
public bool IsPause
|
||||
{
|
||||
get => this._moveGlobalOffset <= 0;
|
||||
set => this._moveGlobalOffset = value ? 0 : 1;
|
||||
}
|
||||
|
||||
private TimeHandler _RunawayTimeHandler;
|
||||
|
||||
@@ -71,19 +80,21 @@ namespace Game.Component
|
||||
|
||||
public void ResetGame ()
|
||||
{
|
||||
this.IsPause = false;
|
||||
this._RunawayTimeHandler?.Kill ();
|
||||
this.IsRunaway = false;
|
||||
this.ScenePart.RefreshInit ();
|
||||
this.PlayerEntity.speed = this.ScenePart.playerBaseSpeed;
|
||||
this.PlayerEntity.transform.position = this.ScenePart.createPos.position;
|
||||
this.PlayerEntity.gameObject.SetActive (true);
|
||||
this.PlayerEntity.RefreshInit ();
|
||||
//播放特效
|
||||
}
|
||||
|
||||
public void OverlyCoin (int messageOverlyCoin)
|
||||
public bool OverlyCoin (int messageOverlyCoin)
|
||||
{
|
||||
// ReSharper disable once Unity.NoNullPropagation
|
||||
this.ScenePart?.AddConditionNumber (messageOverlyCoin);
|
||||
return this.ScenePart?.AddConditionNumber (messageOverlyCoin) ?? false;
|
||||
}
|
||||
|
||||
private void OnRunaway (IEventMessage message)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Game.Component
|
||||
private float speedBuffOffset;
|
||||
private TimeHandler speedBuffTimer;
|
||||
|
||||
public float CurSpeed => this.speed *
|
||||
public float CurSpeed => MapContent.Instance.MoveGlobalOffset * this.speed *
|
||||
(1 + (this.speedBuffTimer?.IsPlaying ?? false ? this.speedBuffOffset * (1 - this.speedBuffTimer.CurProgress) : 0));
|
||||
|
||||
public void AddSpeedBuff (float duration = 3 , float offset = 0.5f)
|
||||
@@ -27,7 +27,6 @@ namespace Game.Component
|
||||
public void OnMove (Vector2 vector)
|
||||
{
|
||||
|
||||
|
||||
var t = this.transform;
|
||||
// 获取前方方向的世界坐标
|
||||
Vector3 forward = (Vector3)vector;
|
||||
|
||||
@@ -1,27 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using Game.Component.SceneProp;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Game.Component
|
||||
{
|
||||
public class ScenePart : MonoBehaviour
|
||||
{
|
||||
public TextAsset mapCacheData;
|
||||
public PolygonCollider2D cameraCollider;
|
||||
public Transform createPos;
|
||||
|
||||
public int completeConditionNumber = 10;
|
||||
public float playerBaseSpeed = 4f;
|
||||
|
||||
[FormerlySerializedAs ("completeProp")] public SuccessProp successProp;
|
||||
|
||||
[LabelText ("当前完成数:")] private int _currentConditionNumber = 0;
|
||||
|
||||
public int CurrentConditionNumber => this._currentConditionNumber;
|
||||
|
||||
private List<EnemyEntity> _enemyEntities;
|
||||
private List<BaseProp> _baseProps;
|
||||
|
||||
public float CurProgress => this._currentConditionNumber * 1f / completeConditionNumber;
|
||||
|
||||
public bool IsComplete => _currentConditionNumber >= completeConditionNumber;
|
||||
public bool IsCondition => _currentConditionNumber >= completeConditionNumber;
|
||||
|
||||
public bool AddConditionNumber (int number = 1)
|
||||
{
|
||||
@@ -36,12 +40,18 @@ namespace Game.Component
|
||||
{
|
||||
enemyEntity.ResetState ();
|
||||
}
|
||||
foreach (var baseProp in this._baseProps)
|
||||
{
|
||||
baseProp.ResetProp ();
|
||||
}
|
||||
this.successProp.gameObject.SetActive (false);
|
||||
}
|
||||
|
||||
public void InitPart ()
|
||||
{
|
||||
this._enemyEntities = new List<EnemyEntity> ();
|
||||
this._enemyEntities = new List<EnemyEntity> (transform.GetComponentsInChildren<EnemyEntity> (true));
|
||||
this._baseProps = new List<BaseProp> (transform.GetComponentsInChildren<BaseProp> (true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,12 @@ namespace Game.Component.SceneProp
|
||||
private TimeHandler _timeHandler;
|
||||
protected bool isReady => this._timeHandler == null || this._timeHandler.IsDone;
|
||||
|
||||
|
||||
public void ResetProp ()
|
||||
{
|
||||
this.gameObject.SetActive (true);
|
||||
RefreshInvalidTime ();
|
||||
}
|
||||
|
||||
protected virtual void OnTriggerEnter2D (Collider2D other)
|
||||
{
|
||||
if (other.gameObject.CompareTag ("Player"))
|
||||
|
||||
@@ -117,6 +117,23 @@ namespace Game.Component.SceneProp.Editor
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/场景道具/创建通关触发器" , false, 10)]
|
||||
public static void CreateCompleteProp (MenuCommand menuCommand)
|
||||
{
|
||||
var prefab = LoadPrefab ("Assets/GameRes/AutoSource/scene_prop/completeProp.prefab");
|
||||
var pos = CreatePos ();
|
||||
var prop = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
prop.transform.position = pos;
|
||||
var target = Selection.activeTransform;
|
||||
if (target != null)
|
||||
{
|
||||
prop.transform.SetParent (target);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(prop, "Create " + prop.name);
|
||||
Selection.activeObject = prop;
|
||||
Selection.activeTransform = prop.transform;
|
||||
}
|
||||
|
||||
//创建敌人a
|
||||
[MenuItem("GameObject/场景敌人/创建敌人a" , false, 10)]
|
||||
public static void CreateEnemyA (MenuCommand menuCommand)
|
||||
|
||||
32
Assets/Scripts/Game/Component/SceneProp/SuccessProp.cs
Normal file
32
Assets/Scripts/Game/Component/SceneProp/SuccessProp.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Game.EventDefine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Component.SceneProp
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏成功触发器
|
||||
/// </summary>
|
||||
public class SuccessProp : BaseProp
|
||||
{
|
||||
protected override void OnReady ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnTrigger (PlayerEntity entity)
|
||||
{
|
||||
// GameEventDefine.GameComplete.SendMessage ();
|
||||
GameEventDefine.ChangeGameFsm.SendMessage (GameState.SuccessGame);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmos ()
|
||||
{
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawSphere (transform.position , 0.5f);
|
||||
UnityEditor.Handles.Label (transform.position, "通关点");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08b0720d3833493da90838afadab7e8a
|
||||
timeCreated: 1729604454
|
||||
@@ -8,7 +8,6 @@ namespace Game.Component.SceneProp
|
||||
[SerializeField] private float _duration = 1.5f;
|
||||
protected override void OnTrigger (PlayerEntity entity)
|
||||
{
|
||||
Debug.Log ("wtf?");
|
||||
GameEventDefine.GlobalRunaway.SendMessage (this._duration);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user