private void OnControllerColliderHit(ControllerColliderHit hit) { if (!IsAlive) { return; } Transform temp = hit.transform; if (temp.CompareTag(AppConst.TAG_OBSTACLE)) { ObstacleEntity entity = temp.GetComponent <ObstacleEntity>(); if (null != entity) { Vector3 dir = CacheModel.forward; switch (entity.Obs_type) { case ObstType.ObsType_TA: UpdateDir(Vector3.zero - CacheModel.position); break; case ObstType.ObsType_TB: case ObstType.ObsType_TC: UpdateDir(CacheModel.position - temp.position); break; } } EndCurrentStateToOtherState(StateID.Walk); } else if (temp.CompareTag(AppConst.TAG_NETENTITY)) { NetEntity entity = temp.GetComponent <NetEntity>(); if (null != entity) { if (!entity.IsAlive) { return; } Vector3 dir = CacheModel.position - temp.position; UpdateDir(dir); if (Util.CanKillBody(entity.Occupation, Occupation)) { entity.EndCurrentStateToOtherState(StateID.Walk); if (IsProtect()) { if (entity.IsUsingSkill()) { HitDir = CacheModel.TransformVector(entity.CacheModel.position - CacheModel.position); EndCurrentStateToOtherState(StateID.CrashPlayer); } else { EndCurrentStateToOtherState(StateID.Walk); } } else { BeKilled(); entity.KillBody(); EndCurrentStateToOtherState(StateID.Dead); } } else if (Util.CanKillBody(Occupation, entity.Occupation)) { EndCurrentStateToOtherState(StateID.Walk); if (entity.IsProtect()) { if (IsUsingSkill()) { entity.HitDir = entity.CacheModel.TransformVector(CacheModel.position - entity.CacheModel.position); entity.EndCurrentStateToOtherState(StateID.CrashPlayer); } else { entity.EndCurrentStateToOtherState(StateID.Walk); } } else { entity.BeKilled(); KillBody(); entity.EndCurrentStateToOtherState(StateID.Dead); } } else { if (entity.IsUsingSkill()) { HitDir = entity.CacheModel.TransformVector(entity.CacheModel.position - CacheModel.position); EndCurrentStateToOtherState(StateID.CrashPlayer); } else { EndCurrentStateToOtherState(StateID.Walk); } if (IsUsingSkill()) { entity.HitDir = entity.CacheModel.TransformVector(CacheModel.position - entity.CacheModel.position); entity.EndCurrentStateToOtherState(StateID.CrashPlayer); } else { entity.EndCurrentStateToOtherState(StateID.Walk); } } } } else if (temp.CompareTag(AppConst.TAG_PLAYER)) { //Vector3 dir = CacheModel.position - temp.position; //UpdateDir(dir); if (!GameMgr.Instance.MainEntity.IsAlive) { return; } if (Util.CanKillBody(GameMgr.Instance.MainEntity.Occupation, Occupation)) { GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.Idle); if (IsProtect()) { if (GameMgr.Instance.MainEntity.IsUsingSkill()) { HitDir = CacheModel.position - GameMgr.Instance.MainEntity.CacheModel.position; EndCurrentStateToOtherState(StateID.CrashPlayer); } else { EndCurrentStateToOtherState(StateID.Walk); } } else { BeKilled(); GameMgr.Instance.MainEntity.KillBody(); EndCurrentStateToOtherState(StateID.Dead); } } else if (Util.CanKillBody(Occupation, GameMgr.Instance.MainEntity.Occupation)) { EndCurrentStateToOtherState(StateID.Walk); if (GameMgr.Instance.MainEntity.IsProtect()) { if (IsUsingSkill()) { GameMgr.Instance.MainEntity.HitDir = GameMgr.Instance.MainEntity.CacheModel.position - CacheModel.position; GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.CrashPlayer); } else { if (GameMgr.Instance.MainEntity.IsForceDrag) { GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.Walk); } else { GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.Idle); } //GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.Idle); } } else { GameMgr.Instance.MainEntity.BeKilled(); KillBody(); GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.Dead); } } else { if (GameMgr.Instance.MainEntity.IsUsingSkill()) { HitDir = (CacheModel.position - GameMgr.Instance.MainEntity.CacheModel.position); EndCurrentStateToOtherState(StateID.CrashPlayer); } else { if (IsUsingSkill()) { GameMgr.Instance.MainEntity.HitDir = GameMgr.Instance.MainEntity.CacheModel.position - CacheModel.position; GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.CrashPlayer); } else { if (GameMgr.Instance.MainEntity.IsForceDrag) { GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.Walk); } else { GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.Idle); } //GameMgr.Instance.MainEntity.EndCurrentStateToOtherState(RoleStateID.Idle); } //EndCurrentStateToOtherState(StateID.Walk); } } } }
private void OnControllerColliderHit(ControllerColliderHit hit) { if (!IsAlive) { return; } Transform temp = hit.transform; if (temp.CompareTag(AppConst.TAG_OBSTACLE)) { if (IsUsingSkill()) { HitDir = CacheModel.forward * -1; EndCurrentStateToOtherState(RoleStateID.CrashPlayer); } } else if (temp.CompareTag(AppConst.TAG_NETENTITY)) { NetEntity entity = temp.GetComponent <NetEntity>(); if (null != entity) { if (!entity.IsAlive) { return; } if (Util.CanKillBody(entity.Occupation, Occupation)) { entity.EndCurrentStateToOtherState(StateID.Walk); if (IsProtect()) { if (entity.IsUsingSkill()) { HitDir = CacheModel.position - entity.CacheModel.position; EndCurrentStateToOtherState(RoleStateID.CrashPlayer); } else { //EndCurrentStateToOtherState(RoleStateID.Idle); if (IsForceDrag) { EndCurrentStateToOtherState(RoleStateID.Walk); } else { EndCurrentStateToOtherState(RoleStateID.Idle); } } } else { BeKilled(); entity.KillBody(); EndCurrentStateToOtherState(RoleStateID.Dead); } } else if (Util.CanKillBody(Occupation, entity.Occupation)) { EndSkillStateToIdle(); if (entity.IsProtect()) { if (IsUsingSkill()) { entity.HitDir = entity.CacheModel.position - CacheModel.position; entity.EndCurrentStateToOtherState(StateID.CrashPlayer); } else { entity.EndCurrentStateToOtherState(StateID.Walk); } } else { entity.BeKilled(); KillBody(); entity.EndCurrentStateToOtherState(StateID.Dead); } } else { if (entity.IsUsingSkill()) { HitDir = CacheModel.position - entity.CacheModel.position; EndCurrentStateToOtherState(RoleStateID.CrashPlayer); } else { if (IsUsingSkill()) { entity.HitDir = entity.CacheModel.position - CacheModel.position; entity.EndCurrentStateToOtherState(StateID.CrashPlayer); } else { entity.EndCurrentStateToOtherState(StateID.Walk); } if (IsForceDrag) { EndCurrentStateToOtherState(RoleStateID.Walk); } else { EndCurrentStateToOtherState(RoleStateID.Idle); } } } } } }