コード例 #1
0
ファイル: FSMState.cs プロジェクト: hulor/VikingProject
 protected FSMState(List<TransitionInfo> transitions, Dictionary<eTransition, TransitionInfo.eTransitionType> transitionType, FSMSystem fsm, eStateId stat)
 {
     this.stateId = stat;
     this._transition = transitions;
     this._transType = transitionType;
     this._fsm = fsm;
 }
コード例 #2
0
ファイル: StateFollow.cs プロジェクト: zsutxz/U3dFramework
 public StateFollow(FSMSystem fms, Transform trans)
 {
     this.fms            = fms;
     this.name           = "follow";
     this.transSelf      = trans;
     transTarget         = GameObject.FindGameObjectWithTag("Player").transform;
     characterController = transSelf.GetComponent <CharacterController>();
 }
コード例 #3
0
ファイル: FSMManager.cs プロジェクト: hulor/VikingProject
	// Use this for initialization
	void Start ()
    {
        this.fsm = new FSM.FSMSystem(this.gameObject);
        List<FSM.FSMState> states = new List<FSM.FSMState>();
        List<FSM.TransitionInfo> trans = new List<FSM.TransitionInfo>();
        Dictionary<FSM.eTransition, FSM.TransitionInfo.eTransitionType> transType = new Dictionary<FSM.eTransition,FSM.TransitionInfo.eTransitionType>();

        trans.Add(new FSM.TransitionInfo(FSM.TransitionInfo.eTransitionType.NoneTransition, FSM.eStateId.Attack, FSM.eTransition.EnemyInTrigger, null));
        transType.Add(FSM.eTransition.EnemyInTrigger, FSM.TransitionInfo.eTransitionType.AddChild);
        states.Add(new FSM.Idle(trans, transType, this.fsm));
        trans.Clear();
        transType.Clear();
        states.Add(new FSM.Attack(trans, transType, this.fsm));
        this.fsm.AddState(states);
        this.fsm.SetState(FSM.eStateId.Idle);
	}
コード例 #4
0
        private void makeFMS()
        {
            fms = new FSMSystem();//状态机管理系统
            // StatePatrol statePatrol = new StatePatrol(fms, points,transform);//巡逻状态
            // statePatrol.addTransition(ETransition.PATROL_TO_FOLLOW, "follow");
            // statePatrol.addTransition(ETransition.PATROL_TO_ATTACK, "attack");

            StateFollow stateFollow = new StateFollow(fms, transform);//跟随状态

            stateFollow.addTransition(ETransition.FOLLOW_TO_ATTACK, "attack");
            stateFollow.addTransition(ETransition.FOLLOW_TO_PATROL, "patrol");

            StateAttack stateAttack = new StateAttack(fms, transform, firePoint, fireLight);//攻击状态

            stateAttack.addTransition(ETransition.ATTACK_TO_FOLLOW, "follow");
            stateAttack.addTransition(ETransition.ATTACK_PATROL, "patrol");

            // fms.addState(statePatrol);
            fms.addState(stateFollow);
            fms.addState(stateAttack);
        }
コード例 #5
0
ファイル: StateAttack.cs プロジェクト: zsutxz/U3dFramework
        public StateAttack(FSMSystem fms, Transform trans, Transform transFirePoint, Transform transFireLight)
        {
            this.fms            = fms;
            this.name           = "attack";//状态名字就叫攻击
            this.transSelf      = trans;
            transTarget         = GameObject.FindGameObjectWithTag("Player").transform;
            characterController = transSelf.GetComponent <CharacterController>();
            this.transFirePoint = transFirePoint;
            this.transFireLight = transFireLight;
            prefabBullet        = Resources.Load("NewPrefabs/bullet") as GameObject;
            GameObject goBullet = GameObject.Find("Bullets_Monster1");

            if (goBullet != null)
            {
                int num = goBullet.transform.childCount;
                transBullets = new Transform[num];
                int index = 0;
                foreach (Transform t in goBullet.transform)
                {
                    transBullets[index] = t;
                    index++;
                }
            }
        }
コード例 #6
0
ファイル: Idle.cs プロジェクト: hulor/VikingProject
 public Idle(List<TransitionInfo> transitions, Dictionary<eTransition, TransitionInfo.eTransitionType> transitionType, FSMSystem fsm)
     : base(transitions, transitionType, fsm, eStateId.Idle)
 {
 }
コード例 #7
0
ファイル: Transition.cs プロジェクト: hulor/VikingProject
 private void SwitchStateTransition(FSMSystem fsm, FSMState state)
 {
     fsm.StatTransitTo(state, this.idDest, this.data);
 }
コード例 #8
0
ファイル: Transition.cs プロジェクト: hulor/VikingProject
 private void AddTransition(FSMSystem fsm, FSMState state)
 {
     fsm.StatAddChild(state, this.idDest, this.data);
 }
コード例 #9
0
ファイル: Transition.cs プロジェクト: hulor/VikingProject
 public void PerformTransition(FSMSystem fsm, FSMState state)
 {
     if (this.transitionType == eTransitionType.NoneTransition)
         return;
     this._transitions[(int)this.transitionType](fsm, state);
 }