// Use this for initialization void Start() { controlMove = transform.GetComponent <CharacterController>(); animator = transform.GetComponentInChildren <Animator>(); animManager = new FSMManager((int)AnimalEnum.MaxValue); PlayerIdle tmpIdle = new PlayerIdle(animator, new AnimalStateBack(AnimalStateChange)); animManager.AddState(tmpIdle); PlayerRun tmpRun = new PlayerRun(animator, new AnimalStateBack(AnimalStateChange)); animManager.AddState(tmpRun); PlayerAttact tmpAttact = new PlayerAttact(animator, new AnimalStateBack(AnimalStateChange)); animManager.AddState(tmpAttact); PlayerBigAttact bigAttact = new PlayerBigAttact(animator, new AnimalStateBack(AnimalStateChange)); animManager.AddState(bigAttact); transform.localEulerAngles = new Vector3(0, 90, 0); }
void Start() { fsm = new FSMManager <Data>(); StateBase <Data> defreezeState = new DefreezeState(fsm); defreezeState.AddTransition(Transition.PressFreeze, StateID.FreezeState); defreezeState.AddTransition(Transition.PressReset, StateID.ResetState); StateBase <Data> freezeState = new FreezeState(fsm); freezeState.AddTransition(Transition.PressDefreeze, StateID.DefreezeState); freezeState.AddTransition(Transition.PressReset, StateID.ResetState); StateBase <Data> resetState = new ResetState(fsm); resetState.AddTransition(Transition.PressDefreeze, StateID.DefreezeState); resetState.AddTransition(Transition.PressFreeze, StateID.FreezeState); fsm.AddState(defreezeState); fsm.AddState(freezeState); fsm.AddState(resetState); fsm.InitState(freezeState); }
void Start() { RunFSM tmpRunFSM = new RunFSM(); AttackFSM tmpAttackFSM = new AttackFSM(); manager = new FSMManager(2); manager.AddState(tmpRunFSM); manager.AddState(tmpAttackFSM); }
// Use this for initialization void Start() { fm = new FSMManager((int)AnimationEnum.Max); Animator animator = GetComponent <Animator>(); CharacterController characterController = GetComponent <CharacterController>();; PlayerIdle tmpIdle = new PlayerIdle(animator); fm.AddState(tmpIdle); PlayerRun tmpRun = new PlayerRun(animator, characterController); fm.AddState(tmpRun); PlayerAttack tmpAttack = new PlayerAttack(animator, this); fm.AddState(tmpAttack); }
void Awake(){ m_Instance = this; //m_AIData初始化 m_AIData.fspeed = 20.0f; m_AIData.fMaxspeed = m_fMaxSpeed; m_AIData.frotate = 0.0f; m_AIData.fMaxrotate = 10.0f; m_AIData.fColProbe = 2.0f; m_AIData.thisPoint = this.gameObject; m_AIData.targetPoint = targetPoint; m_AIData.m_Obs = SceneManager.m_Instance.m_Obs; m_AIData.m_Wall = SceneManager.m_Instance.m_Wall; m_AIData.fRadius = 0.5f; m_AIData.iAstarIndex = -1; m_AIData.targetPosition = Vector3.zero; m_AIData.fDetectLength = 10.0f; m_AIData.fAttackLength = 5.0f; m_AIData.fAttack = 10.0f; m_AIData.fSkill = 30.0f; m_AIData.iLV = 1; m_AIData.iEXP = 0; m_AIData.fHP = fHP; m_AIData.fMP = fMP; m_AIData.fMaxHP = fMaxHP; m_AIData.fMaxMP = fMaxMP; //FSM的設定 m_FSMManager = new FSMManager (); FSMIdleState IdleState = new FSMIdleState (); m_FSMManager.AddState (IdleState); m_AIData.m_State = m_FSMManager; }
// Use this for initialization void Start() { fsmManager = new FSMManager((int)AnimationEnum.Max); Animator animator = GetComponent <Animator>(); PlayerWait tmpWait = new PlayerWait(animator); fsmManager.AddState(tmpWait); PlayerJump tmpJump = new PlayerJump(animator, this); fsmManager.AddState(tmpJump); PlayerWalk tmpWalk = new PlayerWalk(animator); fsmManager.AddState(tmpWalk); PlayerWait02 tmpWait02 = new PlayerWait02(animator); fsmManager.AddState(tmpWait02); }
private void Start() { base.Initial(); Animator animator; animator = GetComponent <Animator>(); #region 设置角色控制器的大小 control = GetComponent <CharacterController>(); control.center = new Vector3(0, 1, 0); control.height = 2; control.radius = 0.23f; #endregion #region 添加动画 PlayerIdel playerIdel = new PlayerIdel(animator); fsmManager.AddState(playerIdel); PlayerWalk playerWalk = new PlayerWalk(animator); fsmManager.AddState(playerWalk); PlayerRun playerRun = new PlayerRun(animator); fsmManager.AddState(playerRun); PlayerAttack playerAttack = new PlayerAttack(animator); fsmManager.AddState(playerAttack); PlayerAttacked playerAttacked = new PlayerAttacked(animator, this); fsmManager.AddState(playerAttacked); PlayerDie playerDie = new PlayerDie(animator); fsmManager.AddState(playerDie); #endregion }
/* //=============================角色動作============================= public Animator Anim; public AnimatorStateInfo BS; static int Idle = Animator.StringToHash("Base.Layer.BG_Chibi_Idle"); static int Run = Animator.StringToHash("Base.Layer.BG_Chibi_B_Run"); static int Attac = Animator.StringToHash("Base.Layer.0G_Chibi_Attack00"); static int Skill = Animator.StringToHash("Base.Layer.0G_Chibi_Attack00"); public enum eEgo { None = -1, Idle, Run, Attac, Skill } public eEgo iNowEgo = eEgo.None; //=============================完============================= */ void Awake(){ //iNowEgo = eEgo.Idle; m_Instance = this; //獲得AStar的Component //Camera mainCamera = Camera.main; //m_AStar = mainCamera.GetComponent<AStar>(); m_AStar = this.GetComponent<AStar> (); //m_AIData初始化 m_AIData.fspeed = 0.1f; m_AIData.fMaxspeed = m_fMaxSpeed; m_AIData.frotate = 0.0f; m_AIData.fMaxrotate = 10.0f; m_AIData.fColProbe = 1.0f; m_AIData.thisPoint = this.gameObject; m_AIData.targetPoint = targetPoint; m_AIData.m_Obs = SceneManager.m_Instance.m_Obs; m_AIData.fRadius = 0.5f; m_AIData.iAstarIndex = -1; m_AIData.targetPosition = Vector3.zero; m_AIData.fDetectLength = 10.0f; m_AIData.fAttackLength = 5.0f; m_AIData.fAttack = 10.0f; m_AIData.fSkill = 30.0f; m_AIData.fSkillMP = 20.0f; m_AIData.iEXPGET = 20; m_AIData.fHP = fHP; m_AIData.fMP = fMP; m_AIData.fMaxHP = fMaxHP; m_AIData.fMaxMP = fMaxMP; /* 生成隊長時呼叫自己的小兵,並傳入變數給小兵,指派他的隊長 */ //FSM的設定 m_FSMManager = new FSMManager (); FSMNpcIdleState IdleState = new FSMNpcIdleState (); FSMNpcTrackState TrackState = new FSMNpcTrackState (); FSMNpcAttackState AttackState = new FSMNpcAttackState (); FSMNpcSkillState SkillState = new FSMNpcSkillState (); IdleState.AddTransition (eTransitionID.Idle_To_Track, eStateID.Track); TrackState.AddTransition (eTransitionID.Track_To_Attack, eStateID.Attack); TrackState.AddTransition (eTransitionID.Track_To_Skill, eStateID.Skill); AttackState.AddTransition (eTransitionID.Attack_To_Idle, eStateID.Idle); AttackState.AddTransition (eTransitionID.Attack_To_Track, eStateID.Track); SkillState.AddTransition (eTransitionID.Skill_To_Idle, eStateID.Idle); SkillState.AddTransition (eTransitionID.Skill_To_Track, eStateID.Track); m_FSMManager.AddState (IdleState); m_FSMManager.AddState (TrackState); m_FSMManager.AddState (AttackState); m_FSMManager.AddState (SkillState); m_AIData.m_State = m_FSMManager; }
private void Start() { fsmManager = new FSMManager <GameObject>(); StateBase <GameObject> patrolState = new PatrolState(fsmManager); patrolState.AddTransition(Transition.SeeEnemy, StateID.ChaseState); StateBase <GameObject> chaseState = new ChaseState(fsmManager); chaseState.AddTransition(Transition.LostEnemy, StateID.PatrolState); chaseState.AddTransition(Transition.ChaseUpEnemy, StateID.AttackState); StateBase <GameObject> attackState = new AttackState(fsmManager); attackState.AddTransition(Transition.SeeEnemy, StateID.ChaseState); fsmManager.AddState(patrolState); fsmManager.AddState(chaseState); fsmManager.AddState(attackState); fsmManager.InitState(patrolState); }
private void Awake() { Initial(); fsmManager = new FSMManager((int)Data.AnimationCount.Max); animator = transform.GetComponent <Animator>(); control = transform.GetComponent <CharacterController>(); control.center = new Vector3(0, 1, 0); control.height = 2; control.radius = 0.23f; EnemyIdel enemyIdel = new EnemyIdel(animator); fsmManager.AddState(enemyIdel); EnemyWalk enemyWalk = new EnemyWalk(animator); fsmManager.AddState(enemyWalk); EnemyRun enemyRun = new EnemyRun(animator); fsmManager.AddState(enemyRun); EnemyAttack enemyAttack = new EnemyAttack(animator); fsmManager.AddState(enemyAttack); }
// Use this for initialization void Start() { m_AStar = this.GetComponent<AStar>(); ; //m_AIData初始化 m_AIData.fspeed = 20.0f; m_AIData.fMaxspeed = m_fMaxSpeed; m_AIData.frotate = 0.0f; m_AIData.fMaxrotate = 10.0f; m_AIData.fColProbe = 2.0f; m_AIData.thisPoint = this.gameObject; m_AIData.targetPoint = targetPoint; m_AIData.m_Obs = SceneManager.m_Instance.m_Obs; m_AIData.m_Wall = SceneManager.m_Instance.m_Wall; m_AIData.fRadius = 0.5f; m_AIData.iAstarIndex = -1; m_AIData.targetPosition = Vector3.zero; m_AIData.fDetectLength = 20.0f; m_AIData.fAttackLength = 10.0f; m_AIData.fHP = 100.0f; m_AIData.fMP = 30.0f; m_AIData.fAttack = 10.0f; m_AIData.fSkill = 30.0f; //FSM的設定 m_FSMManager = new FSMManager(); FSMIdleState IdleState = new FSMIdleState(); //FSMTrackState TrackState = new FSMTrackState (); //FSMChaseState ChaseState = new FSMChaseState (); //FSMAttackState AttackState = new FSMAttackState (); //FSMWanderState WanderState = new FSMWanderState (); //IdleState.AddTransition (eTransitionID.Idle_To_Track, eStateID.Track); //IdleState.AddTransition (eTransitionID.Idle_To_Chase, eStateID.Chase); //IdleState.AddTransition (eTransitionID.Idle_To_Attack, eStateID.Attack); //IdleState.AddTransition (eTransitionID.Idle_To_Wander, eStateID.Wander); //TrackState.AddTransition (eTransitionID.Track_To_Idle, eStateID.Idle); //TrackState.AddTransition (eTransitionID.Track_To_Chase, eStateID.Chase); //TrackState.AddTransition (eTransitionID.Track_To_Attack, eStateID.Attack); //TrackState.AddTransition (eTransitionID.Track_To_Wander, eStateID.Wander); //ChaseState.AddTransition (eTransitionID.Chase_To_Attack, eStateID.Attack); //ChaseState.AddTransition (eTransitionID.Chase_To_Idle, eStateID.Idle); //AttackState.AddTransition (eTransitionID.Attack_To_Idle, eStateID.Idle); //AttackState.AddTransition (eTransitionID.Attack_To_Chase, eStateID.Chase); //WanderState.AddTransition (eTransitionID.Wander_To_Idle, eStateID.Idle); m_FSMManager.AddState(IdleState); //m_FSMManager.AddState (TrackState); //m_FSMManager.AddState (ChaseState); //m_FSMManager.AddState (AttackState); //m_FSMManager.AddState (WanderState); m_AIData.m_State = m_FSMManager; }