private void Update() { if (Input.GetKeyDown(KeyCode.A)) { fsm.PerformTransition(PlayerST.InputA); } if (Input.GetKeyDown(KeyCode.B)) { fsm.PerformTransition(PlayerST.InputB); } }
public void SetTransition(Transition t) { isTransited = true; fsm.PerformTransition(t); currentState = fsm.CurrentState.ID; GameController.Instance.StateChange(fsm.CurrentState.ID); }
public void Restart() { GameContext.GameOver = false; view.HideGameOverUI(); Transform[,] modelMap = model.map; for (int i = 0; i < 10; i++) { for (int j = 0; j < 18; j++) { Transform shape = modelMap[i, j]; if (shape) { Destroy(shape.gameObject); modelMap[i, j] = null; } } } if (gameManager.currentShape) { Destroy(gameManager.currentShape.gameObject); gameManager.currentShape = null; } fsm.PerformTransition(Transition.StartButtonClicked); }
public override void Reason(GameObject npc) { if (Vector3.Distance(npc.transform.position, mPlayer.transform.position) < 2) { fsm.PerformTransition(Transition.SeePlayer); } }
private void OnEnable() { m_SoundManager = this.GetComponent <SoundManager>(); SoundDataSetting Soundsetting = ResourceManager.m_Instance.LoadData(typeof(SoundDataSetting), "Sounds/Mobs/Fish", "SoundDataSetting") as SoundDataSetting; m_SoundManager.SetAudioClips(Soundsetting.SoundDatas); MobManager.m_Instance.OnDestroyAll += Death; if (m_FSM == null) { return; } m_AIData.m_Go = this.gameObject; m_bDead = false; m_CurrentHp = m_MaxHp; m_BodyCollider.enabled = true; m_DamageCollider.enabled = true; m_GODeadBlood = null; m_GOHurtBlood = null; m_DeadBloodSpurt = null; m_HurtBloodSpurt = null; m_FSM.PerformTransition(eFSMTransition.Go_Respawn); if (OnSpawn != null) { OnSpawn(); } }
public void InitFSM() { CachEntityAnimation(); m_FSMSystem = new FSMSystem(this); MonsterMoveState moveState = new MonsterMoveState(); m_FSMSystem.AddState(moveState); MonsterIdleState idleState = new MonsterIdleState(); m_FSMSystem.AddState(idleState); m_MonsterAttackState = new MonsterAttackState(); m_FSMSystem.AddState(m_MonsterAttackState); m_MonsterBeAttackState = new MonsterBeAttackState(); m_FSMSystem.AddState(m_MonsterBeAttackState); MonsterDieState dieState = new MonsterDieState(); m_FSMSystem.AddState(dieState); MonsterStandState standState = new MonsterStandState(); m_FSMSystem.AddState(standState); m_MonsterBeHitFlyState = new MonsterBeHitFlyState(); m_FSMSystem.AddState(m_MonsterBeHitFlyState); MonsterBeAdsorbState monsterBeAdsorbState = new MonsterBeAdsorbState(); m_FSMSystem.AddState(monsterBeAdsorbState); m_FSMSystem.AddState(new MonsterBeHordeState()); m_FSMSystem.PerformTransition(Transition.MonsterToIdle); }
void Update() { fsm.CurrentState.Reason(transform, player); fsm.CurrentState.Act(transform, player); if (currentHp <= 0) { fsm.PerformTransition(dead); } }
//物体落下后的处理 public void FallDownHandle() { currentBlock = null; if (IsGameOver()) { fsm.PerformTransition(Transition.GameOver); PlayerPrefs.SetInt("highScore", facade.Model.HighScore); isPause = true; } }
/// <summary> /// 20141011 动态阻挡传送结算 /// </summary> /// <param name="sMsgFightTeleport_CSC"></param> public void BeTeleport(SMsgFightTeleport_CSC sMsgFightTeleport_CSC) { // 传送前先打断目标所有动作,将其置为站立状态,无视霸体和无敌 m_FSMSystem.PerformTransition(Transition.PlayerToIdle); ThisTransform.position = new Vector3(0.1f * sMsgFightTeleport_CSC.ptPosX, ThisTransform.position.y, -0.1f * sMsgFightTeleport_CSC.ptPosY); var euler = new Vector3(0.1f * sMsgFightTeleport_CSC.ptDirectX, 0, -0.1f * sMsgFightTeleport_CSC.ptDirectY); ThisTransform.rotation = Quaternion.Euler(euler); }
// set the transition so the things in the app gonna call this to transition from one state //To another public void SetTransition(TRANSITION transition) { if (_FSM != null) { _FSM.PerformTransition(transition); } else { WKStaticFunction.WKMessageError("there is no fsm system in the app"); MakeFSM(); } }
// set the transition so the things in the app gonna call this to transition from one state //To another public void SetTransition(Transition transition) { if (_FSM != null) { _FSM.PerformTransition(transition); } else { Debug.LogError("there is no fsm system in the app"); MakeFSM(); } }
public void Play() { switch (fsmSystem.CurrentStateID) { case StateID.NullStateID: Debug.LogError($"No valid transition to the {StateID.PlayStateID} state from the {fsmSystem.CurrentStateID} state"); break; case StateID.MenuStateID: fsmSystem.PerformTransition(Transition.MenuPlayTransition); break; case StateID.PlayStateID: Debug.LogError($"No valid transition to the {StateID.PlayStateID} state from the {fsmSystem.CurrentStateID} state"); break; case StateID.GameOverStateID: fsmSystem.PerformTransition(Transition.GameOverPlayTransition); break; default: throw new ArgumentOutOfRangeException(); } }
public void FsmTestBasicCycle() { Assert.IsTrue(_fsm.CurrentState.ID == PlayerFSMStates.PlayerTurn); _fsm.PerformTransition(PlayerFSMTransitions.PlayCard); Assert.IsTrue(_fsm.CurrentState.ID == PlayerFSMStates.PlayCard); _fsm.PerformTransition(PlayerFSMTransitions.PlayerTurn); Assert.IsTrue(_fsm.CurrentState.ID == PlayerFSMStates.PlayerTurn); _fsm.PerformTransition(PlayerFSMTransitions.EndTurn); Assert.IsTrue(_fsm.CurrentState.ID == PlayerFSMStates.EndTurn); _fsm.PerformTransition(PlayerFSMTransitions.PassControllToOtherPlayer); Assert.IsTrue(_fsm.CurrentState.ID == PlayerFSMStates.OtherPlayerTurn); _fsm.PerformTransition(PlayerFSMTransitions.PlayerTurn); Assert.IsTrue(_fsm.CurrentState.ID == PlayerFSMStates.PlayerTurn); _fsm.PerformTransition(PlayerFSMTransitions.Stand); Assert.IsTrue(_fsm.CurrentState.ID == PlayerFSMStates.Stand); _fsm.PerformTransition(PlayerFSMTransitions.PassControllToOtherPlayer); Assert.IsTrue(_fsm.CurrentState.ID == PlayerFSMStates.OtherPlayerTurn); }
public void SetTransition(Transition t) { StateID NextActionStateID = fsm.CurrentState.GetOutputState(t); //only attack action need to check attack AI strategy if (StateIDToActionID.ContainsKey(NextActionStateID)) { Action NextAction = StateIDToActionID[NextActionStateID]; float ActionValue = DragonKnowledge.GetStateActionValue(fsm.CurrentState.MDPQstate.EndState, NextAction); if (ActionValue < -0.006 || DragonKnowledge.GetStateLearningInfo(fsm.CurrentState.MDPQstate.EndState)) { //performing UCB and find the next action StateID NextStateID = DragonKnowledge.UCBPolicy(fsm.CurrentState.MDPQstate.EndState); fsm.PerformAITransition(NextStateID); return; } } fsm.PerformTransition(t); }
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); }
public virtual void SetTransition(Transition t) { Fsm.PerformTransition(t); }
public void SetTransition(Transition t) { fsm.PerformTransition(t); }
public void SetTransition(FSMSystem.Transition trans) { // perform transition Fsm.PerformTransition(trans); }
public void wanderAttackTransistion(GameObject target) { attackState.Target = target; fsm.PerformTransition(Transition.Follow_Attack); }
/// <summary> /// 执行转换,fSMSystem.PerformTransition /// </summary> /// <param name="transitionID"></param> public void PerformTransition(FSMTransitionID transitionID) { fSMSystem.PerformTransition(transitionID); }
public void SetTransition(Transition t) { Debug.Log(t + " firesd"); fsm.PerformTransition(t); }
public void SetTransition(Transition transition) { _fsm.PerformTransition(transition); }
public void SetTransition(Transition t) { m_FSM.PerformTransition(t); }
public void SetTransition(Transition t, Animator animator) { fsm.PerformTransition(t, animator); }
//public void SetArrowBehaviour(ArrowBehaviour arrowBehaviour) //{ // this.m_ArrowBehaviour = arrowBehaviour; //} public void EntityMove(SMsgActionMove_SCS sMsgActionMove) { monsterMoveNodes.Add(new Vector3(sMsgActionMove.floatX / 10.0f, 0.1f, sMsgActionMove.floatY / -10.0f)); if (m_FSMSystem.CurrentStateID == StateID.MonsterBeHitFly || m_FSMSystem.CurrentStateID == StateID.MonsterStand || m_FSMSystem.CurrentStateID == StateID.MonsterBeAttacked || m_FSMSystem.CurrentStateID == StateID.MonsterAttack) { TraceUtil.Log(SystemModel.Common, TraceLevel.Error, "wrong node"); return; } if (this.RoleDataModel.SMsg_Header.uidEntity == sMsgActionMove.uidEntity && MonsterBehaviour.UsePathSmooth) { m_currentNode = sMsgActionMove; Vector2 lastPos = new Vector2(m_lastNode.floatX, m_lastNode.floatY); Vector2 currentPos = new Vector2(ThisTransform.position.x * 10.0f, ThisTransform.position.z * (-10.0f)); if (m_currentNode.fSpeed > 0.1f) //Vector2.Distance( currentPos , lastPos) > 0.1f && lastPos != Vector2.zero) { if (m_FSMSystem.CurrentStateID == StateID.MonsterIdle) { m_smooth.Init(ThisTransform.position, ThisTransform.TransformDirection(Vector3.forward) * WalkSpeed, new Vector3(sMsgActionMove.floatX / 10.0f, 0, -sMsgActionMove.floatY / 10.0f), new Vector3(sMsgActionMove.fDirectX, 0, -sMsgActionMove.fDirectY) * sMsgActionMove.fSpeed / 10.0f, ConfigDefineManager.TIME_MOVE_SYNC_FOWARD); nodes.Clear(); for (int i = 0; i <= 10; i++) { Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i); nodes.Add(new Vector3(nodepos.x, 1, nodepos.z)); } m_FSMSystem.PerformTransition(Transition.MonsterToMove); MonsterMoveState state = (MonsterMoveState)m_FSMSystem.CurrentState; state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD); } else if (m_FSMSystem.CurrentStateID == StateID.MonsterMove) { MonsterMoveState state = (MonsterMoveState)m_FSMSystem.CurrentState; state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD); m_smooth.Init(ThisTransform.position, ThisTransform.TransformDirection(Vector3.forward) * WalkSpeed, new Vector3(sMsgActionMove.floatX / 10.0f, 0, -sMsgActionMove.floatY / 10.0f), new Vector3(sMsgActionMove.fDirectX, 0, -sMsgActionMove.fDirectY) * sMsgActionMove.fSpeed / 10.0f, ConfigDefineManager.TIME_MOVE_SYNC_FOWARD); nodes.Clear(); for (int i = 0; i <= 10; i++) { Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i); nodes.Add(new Vector3(nodepos.x, 1, nodepos.z)); } } m_clientEndPos = null; ClientMove = true; } else { m_clientEndPos = new Vector3(CurrentNode.floatX / 10.0f, 0, CurrentNode.floatY / -10.0f); ClientMove = false; } m_lastNode = m_currentNode; } WalkToPosition = ThisTransform.position; WalkToPosition = WalkToPosition.Value.GetFromServer(sMsgActionMove.floatX, 0.1f, sMsgActionMove.floatY, -0.1f); }
/// <summary> /// Tries to set the desired transition. /// </summary> /// <param name="transition">Transition</param> public virtual void SetTransition(Transition transition) { fsm.PerformTransition(transition); }