/// <summary> /// ³õʼ»¯×´Ì¬»ú,Ìí¼ÓÖÖ״̬ /// </summary> private void InitFSM() { m_FSMSystem = new FSMSystem(this); PlayerIdleState idleState = new PlayerIdleState(); idleState.AddTransition(Transition.PlayerToIdle, StateID.PlayerIdle); m_FSMSystem.AddState(idleState); PlayerRunState runState = new PlayerRunState(); runState.AddTransition(Transition.PlayerToTarget, StateID.PlayerRun); m_FSMSystem.AddState(runState); PlayerBeAttackedState beAttackedState = new PlayerBeAttackedState(); beAttackedState.AddTransition(Transition.PlayerBeAttacked, StateID.PlayerBeAttacked); m_FSMSystem.AddState(beAttackedState); PlayerNormalSkillFireState normalSkillFireState = new PlayerNormalSkillFireState(); normalSkillFireState.AddTransition(Transition.PlayerFireNormalSkill, StateID.PlayerNormalSkill); m_FSMSystem.AddState(normalSkillFireState); PlayerInitiativeSkillFireState initiativeSkillFireState = new PlayerInitiativeSkillFireState(); initiativeSkillFireState.AddTransition(Transition.PlayerFireInitiativeSkill, StateID.PlayerInitiativeSkill); m_FSMSystem.AddState(initiativeSkillFireState); }
public void InitFSM() { CachEntityAnimation(); m_FSMSystem = new FSMSystem(this, AllowStateChange); m_FSMSystem.OnPerformTransition += this.OnPlayerStateChangedHandle; PlayerIdleState idleState = new PlayerIdleState(); m_FSMSystem.AddState(idleState); PlayerRunState runState = new PlayerRunState(); m_FSMSystem.AddState(runState); PlayerBeAttackedState beAttackedState = new PlayerBeAttackedState(); m_FSMSystem.AddState(beAttackedState); PlayerNormalSkillFireState normalSkillFireState = new PlayerNormalSkillFireState(); m_FSMSystem.AddState(normalSkillFireState); PlayerInitiativeSkillFireState initiativeSkillFireState = new PlayerInitiativeSkillFireState(); m_FSMSystem.AddState(initiativeSkillFireState); InitiativeSkillSelectedState initiativeSkillSelectState = new InitiativeSkillSelectedState(); m_FSMSystem.AddState(initiativeSkillSelectState); m_initiativeSkillSelectedState = initiativeSkillSelectState; PlayerFindPathState findPathState = new PlayerFindPathState(); m_FSMSystem.AddState(findPathState); PlayerDieState playerDieState = new PlayerDieState(); m_FSMSystem.AddState(playerDieState); m_FSMSystem.AddState(new PlayerBeAdsorbState()); m_FSMSystem.AddState(new PlayerScrollSkillFireState()); m_FSMSystem.AddState(new PlayerBeHitFlyState()); m_FSMSystem.AddState(new PlayerStandState()); m_FSMSystem.AddState(new PlayerCastAbilityState()); m_FSMSystem.PerformTransition(Transition.PlayerToIdle); }
/*void TestFun() * { * if (npcTest == null) { * npcTest = GameObject.Find("JH_Mod_NPC104(Clone)").transform; * } * Vector3 pos1 = new Vector3 (3,0,0); * Vector3 pos2 = new Vector3 (0,4,0); * pos1 = pos1 - Vector3.Project (pos1,Vector3.up); * pos2 = pos2 - Vector3.Project (pos2,Vector3.up); * float angle1 = Vector3.Angle (pos1,pos2); * float angle2 = Vector3.Angle (pos2,pos1); * * Vector3 pp1 = npcTest.position - Vector3.Project (npcTest.position,Vector3.up); * Vector3 pp2 = transform.position - Vector3.Project (transform.position,Vector3.up); * * * Debug.Log ("angle1="+angle1+"angle2="+angle2+"----------"+Vector3.Angle(pp1,pp2)+"--=="+(Vector3.Angle(transform.forward,(npcTest.position-transform.position)))); * * * * Vector3 selfPos = npcTest.position; * Vector3 poss = transform.InverseTransformPoint(selfPos); * bool inAngle = false; * float newAng = Vector3.Angle (Vector3.forward, poss); * Debug.Log ("newAng="+newAng); * }*/ /// <summary> /// ÊÕµœµã»÷ÖžÁ»ò·ÅŒŒÄÜ£¬»òÐÐ×ß /// </summary> /// <param name="touchInvoke"></param> //private Transform npcTest ; public void GetTouchDown(TouchInvoke touchInvoke) { if (this.IsDie || BattleManager.Instance.BlockPlayerToIdle) { return; } /*if (IsInvoking ("TestFun")) * CancelInvoke ("TestFun"); * InvokeRepeating ("TestFun",2,2);*/ if (GameManager.Instance.CurrentState == GameManager.GameState.GAME_STATE_PLAYERROOM) { return; } if (touchInvoke.TouchGO.tag.ToLower() == "terrain") { if (GameManager.Instance.CurrentState == GameManager.GameState.GAME_STATE_TOWN) { if (TaskModel.Instance.isNpcTalking) { return; } } this.m_LastWalkToPosition = touchInvoke.TouchPoint; //°Ñ×îºóÒ»žöµã»÷µãŒÇÂŒÏÂÀŽ UIEventManager.Instance.TriggerUIEvent(UIEventType.AddAPMNumber, null); StateID sId = m_FSMSystem.CurrentState.StateID; if (sId == StateID.PlayerInitialtiveSkillSelect || sId == StateID.PlayerInitiativeSkill) { if (sId == StateID.PlayerInitialtiveSkillSelect) { InitiativeSkillSelectedState state = (InitiativeSkillSelectedState)(m_FSMSystem.CurrentState); state.OnTouch(touchInvoke.TouchPoint); } else { PlayerInitiativeSkillFireState state = (PlayerInitiativeSkillFireState)(m_FSMSystem.CurrentState); state.OnTouch(touchInvoke.TouchPoint); } } else if (touchInvoke.TouchCount == 1) { WalkToPosition = touchInvoke.TouchPoint; TargetType = ResourceType.Terrain; if (GameManager.Instance.CurrentState == GameManager.GameState.GAME_STATE_BATTLE && m_FSMSystem.CurrentStateID == StateID.PlayerRun) { m_LastWalkToPosition = null; ((PlayerRunState)m_FSMSystem.CurrentState).StartToRun(2.0f, 2.0f); } if (m_FSMSystem.CurrentStateID == StateID.PlayerFindPathing) { transform.GetComponent <NavMeshAgent>().enabled = false; m_FSMSystem.PerformTransition(Transition.PlayerToIdle); } /* * if (GameManager.Instance.CurrentState == GameManager.GameState.GAME_STATE_BATTLE * && m_FSMSystem.CurrentStateID == StateID.PlayerBeAdsorb) * { * ((PlayerBeAdsorbState)m_FSMSystem.CurrentState).Run(WalkToPosition.Value); * } */ } else if (touchInvoke.TouchCount == 2 && GameManager.Instance.CurrentState == GameManager.GameState.GAME_STATE_BATTLE) { /* * var skillId = PlayerDataManager.Instance.GetBattleItemData(this.PlayerKind).ScrollSkillID; * var skillConfig = SkillDataManager.Instance.GetSkillConfigData(skillId); * if (!BreakSkillCheck(skillConfig)) * { * return; * } * //Add by limanru * if (PlayerGasSlotManager.Instance.IsCanRoll()) * { * PlayerGasSlotManager.Instance.ConsumeOneRollAirSlot(1); * } * else * { * return; * } * ChangeForward(touchInvoke.TouchPoint); * m_FSMSystem.PerformTransition(Transition.PlayerFireScrollSkill); */ } } }