Example #1
0
    private void MakeFSM()
    {
        NormalState normalState = new NormalState(this);

        normalState.AddTransition(Transition.InSpecialMoveZone, StateID.SpecialMove);
        normalState.AddTransition(Transition.InPickUpZone, StateID.PickingUp);
        normalState.AddTransition(Transition.InDropOffZone, StateID.DroppingOff);

        SpecialMoveState specialMoveState = new SpecialMoveState(this);

        specialMoveState.AddTransition(Transition.ReturnToNormal, StateID.Normal);

        PickingUpState pickingUpState = new PickingUpState(this, playerSettings.PickUpTime, playerSettings.PickupParkingPos);

        pickingUpState.AddTransition(Transition.ReturnToNormal, StateID.Normal);

        DroppingOffState droppingOffState = new DroppingOffState(this, playerSettings.DropOffTime, playerSettings.DropoffParkingPos);

        droppingOffState.AddTransition(Transition.ReturnToNormal, StateID.Normal);

        fsm = new FSMSystem();
        fsm.AddState(normalState);
        fsm.AddState(specialMoveState);
        fsm.AddState(pickingUpState);
        fsm.AddState(droppingOffState);
    }
Example #2
0
    public LandPatrolState(FSMSystem fsm, GameObject role) : base(fsm, role)//初始化
    {
        //设定状态
        stateID = StateID.LandPatrolState;

        //参数
        offset       = new Vector3(0f, 1.8f, 0f) * role.transform.localScale.x;
        viewDistance = 8 * role.transform.localScale.x;
        roleSize     = role.transform.localScale.x;

        //组件
        if (!role.GetComponent <Rigidbody>())
        {
            role.AddComponent <Rigidbody>();
        }
        role.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
        if (!role.GetComponent <SphereCollider>())
        {
            role.AddComponent <SphereCollider>();
        }
        role.GetComponent <SphereCollider>().center = new Vector3(0f, 1.8f, 0f);             //模型锚点缺陷
        role.GetComponent <SphereCollider>().radius = 0.7f;
        //参数
        turn       = false;
        speed      = 0.02f;
        isEating   = false;
        isRotating = false;
        isTurning  = false;
        time_limit = 2.0f;
    }
Example #3
0
    private void MakeFSM(Soldier soldier)
    {
        LookupState lookupState = new LookupState(soldier.gameObject);

        lookupState.AddTransition(Transition.FoundEnemy, StateID.ForwardEnemy);
        lookupState.AddTransition(Transition.HpEmpty, StateID.Dead);

        ForwardState forwardState = new ForwardState(soldier.gameObject);

        forwardState.AddTransition(Transition.LostEnemy, StateID.LookupEnemy);
        forwardState.AddTransition(Transition.CanAttackEnemy, StateID.AttackEnemy);
        forwardState.AddTransition(Transition.HpEmpty, StateID.Dead);

        AttackState attackState = new AttackState(soldier.gameObject);

        attackState.AddTransition(Transition.LostEnemy, StateID.LookupEnemy);
        attackState.AddTransition(Transition.HpEmpty, StateID.Dead);

        DeadState deadState = new DeadState(soldier.gameObject);

        deadState.AddTransition(Transition.HpRemain, StateID.LookupEnemy);

        fsm = new FSMSystem();
        fsm.AddState(lookupState);
        fsm.AddState(forwardState);
        fsm.AddState(attackState);
        fsm.AddState(deadState);
    }
Example #4
0
    private void MakeFSM()
    {
        PatrolState patrol = new PatrolState(player, transform, path);

        patrol.AddTransition(Transition.GuardPlayer, StateID.GuardID);

        GuardState guard = new GuardState(player, transform);

        guard.AddTransition(Transition.AutoPatrol, StateID.PatrolID);
        guard.AddTransition(Transition.ChasingPlayer, StateID.ChasingID);

        ChaseState chase = new ChaseState(player, transform);

        chase.AddTransition(Transition.GuardPlayer, StateID.GuardID);
        chase.AddTransition(Transition.AttackPlayer, StateID.AttackID);

        AttackState attack = new AttackState(player, transform);

        attack.AddTransition(Transition.GuardPlayer, StateID.GuardID);
        attack.AddTransition(Transition.ChasingPlayer, StateID.ChasingID);

        fsm = new FSMSystem();

        fsm.AddState(patrol);
        fsm.AddState(guard);
        fsm.AddState(chase);
        fsm.AddState(attack);
    }
Example #5
0
    public override void Start()
    {
        CurrentRotation = TROTATION.Front;
        initialState    = new State(STATE.Attack, this,
                                    () =>
        {
            GetTurretDamage();
            //SetAffectedCells(); //todo -> descomentar para nada más spawnear, causar daño
        },
                                    () =>
        {
        });

        FSMSystem.AddState(this, initialState);
        currentState       = states.Find((x) => x.stateName == STATE.Attack);
        currentTransitions = transitions.FindAll((x) => x.currentState == currentState);
        currentState.OnEnter();

        SetStates();
        SetTransitions();

        base.Start();

        executed = true; //todo -> esto sirve par saber si ha ejecutado la accion del turno, si esta a false, puede spawnear y realizar una acción
    }
Example #6
0
    void InitFSM()
    {
        fsm = new FSMSystem();

        FSMState landPatrolState  = new LandPatrolState(fsm, gameObject);
        FSMState landChaseState   = new LandChaseState(fsm, gameObject);
        FSMState landEatState     = new LandEatState(fsm, gameObject);
        FSMState waterPatrolState = new WaterPatrolState(fsm, gameObject);
        FSMState waterChaseState  = new WaterChaseState(fsm, gameObject);
        FSMState waterEatState    = new WaterEatState(fsm, gameObject);

        fsm.AddState(landPatrolState);
        fsm.AddState(landChaseState);
        fsm.AddState(landEatState);
        fsm.AddState(waterPatrolState);
        fsm.AddState(waterChaseState);
        fsm.AddState(waterEatState);

        //转换
        landPatrolState.AddTransition(Transition.LookFood, StateID.LandChaseState);        //landPatrolState
        landPatrolState.AddTransition(Transition.FallIntoWater, StateID.WaterPatrolState); //陆地->水里
        landChaseState.AddTransition(Transition.LostFood, StateID.LandPatrolState);        //landChaseState
        landChaseState.AddTransition(Transition.FallIntoWater, StateID.WaterChaseState);   //陆地->水里
        landChaseState.AddTransition(Transition.GetFood, StateID.LandEatState);
        landEatState.AddTransition(Transition.LostFood, StateID.LandPatrolState);          //landEatState
        landEatState.AddTransition(Transition.LookFood, StateID.LandChaseState);
        waterPatrolState.AddTransition(Transition.LookFood, StateID.WaterChaseState);      //waterPatrolState
        waterPatrolState.AddTransition(Transition.GoToLand, StateID.LandPatrolState);      //水里->陆地
        waterChaseState.AddTransition(Transition.LostFood, StateID.WaterPatrolState);      //waterChaseState
        waterChaseState.AddTransition(Transition.GoToLand, StateID.LandChaseState);        //水里->陆地
        waterChaseState.AddTransition(Transition.GetFood, StateID.WaterEatState);
        waterEatState.AddTransition(Transition.LostFood, StateID.WaterPatrolState);        //waterEatState
        waterEatState.AddTransition(Transition.LookFood, StateID.WaterChaseState);
    }
Example #7
0
    void Start()
    {
        LV1Att = atControl.construct(atBuild);

        fsmSystem = new FSMSystem(this.gameObject);

        FSMBaseState bornState = new LV1BornState(fsmSystem);

        bornState.AddTransition(FSMTransition.LeavePlayer, FSMStateID.stayState);

        //巡逻状态,在构造参数传一个系统参数,确定该状态是在哪个状态系统中管理的,状态转换的时候调用
        FSMBaseState stayState = new LV1StayState(fsmSystem);

        stayState.AddTransition(FSMTransition.SeePlayer, FSMStateID.attackState);
        stayState.AddTransition(FSMTransition.zeroHp, FSMStateID.death);

        //追逐状态
        FSMBaseState attackState = new LV1AttackState(fsmSystem);

        attackState.AddTransition(FSMTransition.LeavePlayer, FSMStateID.stayState);
        attackState.AddTransition(FSMTransition.zeroHp, FSMStateID.death);

        FSMBaseState dieState = new LV1DieState(fsmSystem);

        fsmSystem.AddFSMState(bornState);
        fsmSystem.AddFSMState(stayState);
        fsmSystem.AddFSMState(attackState);
        fsmSystem.AddFSMState(dieState);
    }
Example #8
0
    public override void SetTransitions()
    {
        base.SetTransitions();
        List <NextStateInfo> nextStatesInfo2 = new List <NextStateInfo>()
        {
            new NextStateInfo(this, STATE.Attack, STATE.Remain, GetComponent <AttackOrder>()),
            new NextStateInfo(this, STATE.Move, STATE.Remain, GetComponent <MoveOrder>())
        };

        FSMSystem.AddTransition(this, STATE.Idle, nextStatesInfo2);

        List <NextStateInfo> nextStateInfo3 = new List <NextStateInfo>()
        {
            new NextStateInfo(this, STATE.Idle, STATE.Remain, GetComponent <IdleOrder>())
        };

        FSMSystem.AddTransition(this, STATE.Move, nextStateInfo3);

        List <NextStateInfo> nextStateInfo4 = new List <NextStateInfo>()
        {
            new NextStateInfo(this, STATE.Idle, STATE.Remain, GetComponent <IdleOrder>())
        };

        FSMSystem.AddTransition(this, STATE.Attack, nextStateInfo4);
    }
Example #9
0
    /// <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);
    }
Example #10
0
 public NPCPatrol(Transform[] path, Transform player, FSMSystem fSM)
 {
     mPoints  = path;
     mPlayer  = player;
     this.fsm = fSM;
     mStateID = StateID.Patrol;
 }
Example #11
0
    public void MakeFSM()
    {
        IdleState idle = new IdleState();

        idle.AddTransition(Transition.SawPlayer, StateID.AttackingState);
        idle.AddTransition(Transition.LostPlayer, StateID.MovingState);

        MoveState move = new MoveState();

        move.AddTransition(Transition.SawPlayer, StateID.AttackingState);

        AttackState attack = new AttackState();

        attack.AddTransition(Transition.LostPlayer, StateID.MovingState);
        attack.AddTransition(Transition.IdleTransition, StateID.IdleStateID);

        DefendState defend = new DefendState();

        EvadeState evade = new EvadeState();

        WinState win = new WinState();

        DeathState death = new DeathState();



        fsm = new FSMSystem();
        fsm.AddState(move);
        fsm.AddState(attack);
        fsm.AddState(idle);
        fsm.AddState(defend);
        fsm.AddState(evade);
        fsm.AddState(win);
        fsm.AddState(death);
    }
    public void Initialize(FSMSystem fsmSystem)
    {
        this.FsmSystem = fsmSystem;
        bool letControllerControlGui = (MultiPanelDeclarations.Count == 0); //Only when there are no panel declaration scripts, should the controller be in control of the GUI enabling/disabling.

        if (StateController != null)
        {
            AbstractPanelDeclarations primaryPanelDeclaration = null;
            if (MultiPanelDeclarations.Count > 0)
            {
                primaryPanelDeclaration = MultiPanelDeclarations[0];
            }
            StateController.ControllerInitialize(fsmSystem, this, primaryPanelDeclaration, letControllerControlGui);
        }
        if (MultiPanelDeclarations.Count > 0)
        {
            foreach (AbstractPanelDeclarations panelDeclarations in MultiPanelDeclarations)
            {
                panelDeclarations.OnButtonClicked += this.GUIButtonEventHandler;
                panelDeclarations.PanelInitialize(fsmSystem, !letControllerControlGui, this);
            }
        }
        NeedsGUILayout = true;
        TimeInState    = 0;
        OnInitialize();
    }
Example #13
0
 public PlayState(FSMSystem fsm) : base(fsm)
 {
     stateID          = StateID.Play;
     initalPosition   = GameObject.Find("DogInitiatePosition").transform;
     idle             = new IdleState(fsm);
     idle.isCanPatrol = false;
 }
Example #14
0
    /// <summary>
    /// 初始化状态机时,构造一个状态机
    /// </summary>
    void ConstructFSM()
    {
        FSM = new FSMSystem();

        AttackState attackState = new AttackState(gameObject);

        attackState.AddTransition(Transition.LostEnemy, StateID.Wander);

        MoveToState moveToState = new MoveToState(gameObject, MoveTarget);

        moveToState.AddTransition(Transition.ReadyToAttack, StateID.Attack);
        moveToState.AddTransition(Transition.LostEnemy, StateID.Wander);

        WanderState wanderState = new WanderState(gameObject, wanderPoints);

        wanderState.AddTransition(Transition.SawEnemy, StateID.MoveTo);
        wanderState.AddTransition(Transition.SawItem, StateID.MoveTo);



        FSM.AddState(attackState);
        FSM.AddState(wanderState);
        FSM.AddState(moveToState);



        FSM.start(StateID.Wander);
    }
Example #15
0
    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);
    }
Example #16
0
    /// <summary>
    /// Initializes the Finite state machine.
    /// </summary>
    protected virtual void MakeFSM()
    {
        // Follow behaviour
        FollowPlayer follow = new FollowPlayer(attackRange, playerAttackLayer, this);

        follow.AddTransition(Transition.InPlayerAttackRange, StateID.AttackPlayer);
        follow.AddTransition(Transition.ReachedDestination, StateID.Idle);


        // Attack behaviour
        AttackPlayer attack = new AttackPlayer(attackRange, playerAttackLayer, attackInterval, pushAwayForce, this);

        attack.AddTransition(Transition.LostPlayerAttackRange, StateID.FollowPlayer);
        attack.AddTransition(Transition.ReachedDestination, StateID.Idle);

        // Idle behaviour
        IdleEnemy idle = new IdleEnemy();

        idle.AddTransition(Transition.SawPlayer, StateID.FollowPlayer);


        fsm = new FSMSystem();
        fsm.AddState(follow);
        fsm.AddState(attack);
        fsm.AddState(idle);
    }
Example #17
0
    private void MakeFSM()
    {
        MovementState movement = new MovementState(path);

        movement.AddTransition(Transition.NearNPC, StateID.TrackNPC);
        movement.AddTransition(Transition.AngryNPC, StateID.AggroNPC);


        PlayerNearState track = new PlayerNearState();

        track.AddTransition(Transition.RoamNPC, StateID.MovementNPC);
        track.AddTransition(Transition.InteractNPC, StateID.InteractionNPC);
        track.AddDialogue(NPCDialogue);

        InteractionState interact = new InteractionState();

        interact.AddTransition(Transition.NearNPC, StateID.TrackNPC);

        AggroState aggro = new AggroState();

        aggro.AddTransition(Transition.RoamNPC, StateID.MovementNPC);
        aggro.AddTransition(Transition.AttackNPC, StateID.DamageNPC);

        AttackState attack = new AttackState();

        attack.AddTransition(Transition.AngryNPC, StateID.AggroNPC);


        sm = new FSMSystem();
        sm.AddState(movement);
        sm.AddState(track);
        sm.AddState(interact);
        sm.AddState(aggro);
        sm.AddState(attack);
    }
Example #18
0
    // The NPC has two states: FollowPath and ChasePlayer
    // If it's on the first state and SawPlayer transition is fired, it changes to ChasePlayer
    // If it's on ChasePlayerState and LostPlayer transition is fired, it returns to FollowPath
    private void MakeFSM()
    {
        FollowPathState follow = new FollowPathState(/*path*/);

        follow.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);

        ChasePlayerState chase = new ChasePlayerState();

        chase.AddTransition(Transition.LostPlayer, StateID.FollowingPath);

        PatrolState patrolState = new PatrolState(PatrolWayPoints);

        patrolState.AddTransition(Transition.Alert, StateID.AlertNpc);

        AlertState alertState = new AlertState();

        alertState.AddTransition(Transition.Attack, StateID.AttackingPlayer);
        alertState.AddTransition(Transition.Patrol, StateID.Patroling);

        AttackState attackState = new AttackState();

        attackState.AddTransition(Transition.Alert, StateID.AlertNpc);


        fsm = new FSMSystem();
        fsm.AddState(patrolState);
        fsm.AddState(alertState);
        fsm.AddState(attackState);
        //fsm.AddState(chase);
        //fsm.AddState(follow);

        Debug.Log("First State: " + fsm.CurrentState.ToString());
    }
Example #19
0
    //!	@brief	FSMシステム初期化失敗テスト
    //!	@return	なし
    [Test] public void FSMSysmteInitializeFailedTest()
    {
        var log            = string.Empty;
        var logMsgRecieved = new Application.LogCallback((condition, stackTrace, type) => {
            log = condition;
        });

        Application.logMessageReceived += logMsgRecieved;

        var fsm = new FSMSystem();

        fsm.initialize(new IFSMState[] {
            new FSMTestState(State.Test0, null),
            new FSMTestState(State.Test0, null),
        });

        Application.logMessageReceived -= logMsgRecieved;

        var testLog =
            "State \"" + State.Test0 + "\" is duplicate !!!!!"
            + "\nFailed initialize FSMSystem ..."
        ;

        Assert.AreEqual(testLog, log);
    }
    public void SetMoveState()
    {
        FSMSystem.AddState(this, new State(STATE.Move, this,
                                           () =>//on enter move state
        {
            currentStateDebug.text = STATE.Move.ToString();
            DisableShaderAttackCells();
            _pathfindingGrid.UpdateGrid(this);
            GetCellsPossibleMovements();
        },
                                           () =>
        {
            DisableShaderMoveCells();
            Debug.Log("hacemos el onexit");
            possibleMovements.Clear();
            _pathfindingGrid.UpdateGrid(this);
        })
                           );

        List <Action> behavioursMoveState = new List <Action>()
        {
            GetComponent <Move>()
        };

        FSMSystem.AddBehaviours(this, behavioursMoveState, states.Find((x) => x.stateName == STATE.Move));
    }
Example #21
0
    private void MakeFSM()
    {
        IdleState idle = new IdleState();

        idle.AddTransition(Transition.Walk, StateID.Walk);
        idle.AddTransition(Transition.Jump, StateID.Jump);
        idle.AddTransition(Transition.Die, StateID.Die);

        WalkState walk = new WalkState(path);

        walk.AddTransition(Transition.Idle, StateID.Idle);
        walk.AddTransition(Transition.Jump, StateID.Jump);
        walk.AddTransition(Transition.Die, StateID.Die);

        JumpState jump = new JumpState();

        jump.AddTransition(Transition.Idle, StateID.Idle);
        jump.AddTransition(Transition.Die, StateID.Die);
        DeadState die = new DeadState();

        fsm = new FSMSystem();
        fsm.AddState(idle);
        fsm.AddState(walk);
        fsm.AddState(jump);
        fsm.AddState(die);
    }
Example #22
0
    protected override void InitStateMachine()
    {
        m_FSM      = new FSMSystem();
        m_FSM.attr = attr;

        idleState  = new EnemyIdleState();
        moveState  = new EnemyMoveState();
        fightState = new EnemyFightState();
        deathState = new EnemyDeathState();



        m_FSM.AddState(idleState, this);
        idleState.AddTransition(Transition.IsMove, StateID.Move);
        idleState.AddTransition(Transition.IsFight, StateID.Fight);


        m_FSM.AddState(moveState, this);
        moveState.AddTransition(Transition.IsIdle, StateID.Idle);
        moveState.AddTransition(Transition.IsFight, StateID.Fight);


        m_FSM.AddState(fightState, this);
        fightState.AddTransition(Transition.IsIdle, StateID.Idle);

        m_FSM.AddState(deathState, this);

        //初始状态为Idle
        m_FSM.SetCurrentState(idleState);
    }
Example #23
0
    // Use this for initialization
    void Start()
    {
        sm = new FSMSystem();
        Debug.Log("Add IdleState");
        BossIdleState bis = new BossIdleState();

        bis.AddTransition(Transition.NearPlayer, StateID.BossAttack);

        Boss2AttackState bas = new Boss2AttackState();

        bas.AttackProjPrefab(proj);
        bas.AddTransition(Transition.LostPlayer, StateID.BossIdle);
        bas.shootInterval = shootInterval;

        sm.AddState(bis);
        sm.AddState(bas);

        //player = Global.Instance.player;

        Rigidbody2D rigidBody2D = GetComponent <Rigidbody2D>();

        rigidBody2D.velocity = new Vector3(Random.value, Random.value, 0).normalized *moveSpd;

        Global.Instance.boss = this.gameObject;

        hp = GetComponent <Health>();
        hp.SetHp(_hp);

        EnemyHealthBar ehbscript = GetComponent <EnemyHealthBar>();

        ehbscript.cam = Global.Instance.cam;
    }
Example #24
0
    // The tile has 3 states: idle, wrapping and moving
    // If it's on idle and userSwipe transition is fired, it changes to moving
    // If it's on moving and reachedGoal transition is fired, it returns to idle
    // If it's on moving and offGrid is fired, it changes to wrapping
    // If it's on wrapping and finished wrap is fired, it changes to idle
    private void MakeFSM()
    {

        IdleState idle = new IdleState(this);
        idle.AddTransition(Transition.UserSwiped, StateID.Follow);

        FollowState follow = new FollowState(this);
        follow.AddTransition(Transition.FinishedFollow, StateID.Snapping);

        SnappingState snap = new SnappingState(this);
        snap.AddTransition(Transition.FinishedSnapping, StateID.Idle);
        snap.AddTransition(Transition.OffGrid, StateID.Wrapping);

        WrapState wrap = new WrapState(this);
        wrap.AddTransition(Transition.FinishedWrap, StateID.Idle);

        SetupState setup = new SetupState(this);
        setup.AddTransition(Transition.FinishedSetup, StateID.Idle);

        fsm = new FSMSystem();
        fsm.AddState(setup);
        fsm.AddState(idle);
        fsm.AddState(follow);
        fsm.AddState(snap);
        fsm.AddState(wrap);
    }
Example #25
0
    private void MakeFSM()
    {
        mFSMSystem = new FSMSystem();

        FSMState standbyState = new StateStandby(mFSMSystem);

        ///standbyState StateID.StandbyState,转换条件分别为
        ///Transition.SeeEnemy
        standbyState.AddTransition(Transition.SeeEnemy, StateID.ChaseState);

        FSMState chaseState = new StateChase(mFSMSystem);

        ///由ChaseState状态可以转换到 StateID.StandbyState StateID.AttackState,转换条件分别为
        ///Transition.DonotSeeEnemy  Transition.EnemyInTheAttackRange
        chaseState.AddTransition(Transition.DonotSeeEnemy, StateID.StandbyState);
        chaseState.AddTransition(Transition.EnemyInTheAttackRange, StateID.AttackState);

        FSMState attackState = new StateAttack(mFSMSystem);

        ///由attackState状态可以转换到 StateID.StandbyState StateID.ChaseState,转换条件分别为
        ///Transition.DonotSeeEnemy  Transition.EnemyOutOfTheAttackRange
        attackState.AddTransition(Transition.DonotSeeEnemy, StateID.StandbyState);
        attackState.AddTransition(Transition.EnemyOutOfTheAttackRange, StateID.ChaseState);

        mFSMSystem.AddState(standbyState);
        mFSMSystem.AddState(chaseState);
        mFSMSystem.AddState(attackState);
    }
Example #26
0
    private void SetupStateMachine()
    {
        AIAttackTargetState attackState = new AIAttackTargetState(this);
        AIChaseTargetState chaseState = new AIChaseTargetState(this);
        AIEvasiveManeuverState evasiveManeuverState = new AIEvasiveManeuverState(this);
        AIFleeState fleeState = new AIFleeState(this);
        AIPatrolState patrolState = new AIPatrolState(this);

        patrolState.AddTransition(Transition.EnemyAITargetInSight, StateID.EnemyAIChase);

        chaseState.AddTransition(Transition.EnemyAITargetLockAcquired, StateID.EnemyAIAttack);
        chaseState.AddTransition(Transition.EnemyAITargetSightLost, StateID.EnemyAIPatrol);
        chaseState.AddTransition(Transition.EnemyAITargetKilled, StateID.EnemyAIPatrol);
        //        chaseState.AddTransition(Transition.EnemyAIDamageReceived, StateID.EnemyAIEvasiveManeuver);

        attackState.AddTransition(Transition.EnemyAITargetLockLost, StateID.EnemyAIChase);
        attackState.AddTransition(Transition.EnemyAITargetSightLost, StateID.EnemyAIPatrol);
        //        attackState.AddTransition(Transition.EnemyAIDamageReceived, StateID.EnemyAIEvasiveManeuver);

        FSM = new FSMSystem();
        FSM.AddState(patrolState); // Will be the current state (pdcgomes 30.12.2013)
        FSM.AddState(attackState);
        FSM.AddState(chaseState);
        FSM.AddState(evasiveManeuverState);
        FSM.AddState(fleeState);
    }
Example #27
0
    /// <summary>
    /// Initializes the FSM.
    /// </summary>
    protected override void MakeFSM()
    {
        // Set up FSM.
        BossIdle idle = new BossIdle(this);

        idle.AddTransition(Transition.DecisionMelee, StateID.BossAttackMelee);
        idle.AddTransition(Transition.DecisionRanged, StateID.BossAttackRanged);
        idle.AddTransition(Transition.DecisionSpecial, StateID.BossAttackSpecial);
        idle.AddTransition(Transition.DecisionMobSpawn, StateID.BossMobSpawn);
        idle.AddTransition(Transition.DecisionSprint, StateID.BossSprint);

        BossAttackMelee attackMelee = new BossAttackMelee(MeleePhase.phaseTime, StateID.BossAttackMelee);

        attackMelee.AddTransition(Transition.AttackFinished, StateID.BossIdle);
        attackMelee.AddTransition(Transition.LostPlayerAttackRange, StateID.BossWalk);

        BossWalk attackPhaseWalk = new BossWalk(AttackRange, StateID.BossWalk);

        attackPhaseWalk.AddTransition(Transition.ReachedDestination, StateID.BossAttackMelee);


        BossAttackRanged attackRanged = new BossAttackRanged(RangedPhase.phaseTime, StateID.BossAttackRanged);

        attackRanged.AddTransition(Transition.AttackFinished, StateID.BossIdle);
        attackRanged.AddTransition(Transition.LostPlayerAttackRange, StateID.BossWalkRanged);

        BossWalk attackRangedWalk = new BossWalk(RangedAttackRange, StateID.BossWalkRanged);

        attackRangedWalk.AddTransition(Transition.ReachedDestination, StateID.BossAttackRanged);


        BossAttackSpecial attackSpecial = new BossAttackSpecial(SpecialPhase.phaseTime, StateID.BossAttackSpecial);

        attackSpecial.AddTransition(Transition.AttackFinished, StateID.BossIdle);
        attackSpecial.AddTransition(Transition.LostPlayerAttackRange, StateID.BossWalkSpecial);

        BossWalk walkSpecial = new BossWalk(RangedAttackRange, StateID.BossWalkSpecial);

        walkSpecial.AddTransition(Transition.ReachedDestination, StateID.BossAttackSpecial);

        BossMobSpawn mobSpawn = new BossMobSpawn(MobSpawnPhase.phaseTime, StateID.BossMobSpawn);

        mobSpawn.AddTransition(Transition.AttackFinished, StateID.BossIdle);

        BossSprint bossSprint = new BossSprint(StateID.BossSprint, this);

        bossSprint.AddTransition(Transition.ReachedDestination, StateID.BossIdle);

        fsm = new FSMSystem();
        fsm.AddState(idle);
        fsm.AddState(attackMelee);
        fsm.AddState(attackPhaseWalk);
        fsm.AddState(attackRanged);
        fsm.AddState(attackRangedWalk);
        fsm.AddState(attackSpecial);
        fsm.AddState(walkSpecial);
        fsm.AddState(mobSpawn);
        fsm.AddState(bossSprint);
    }
 // Use this for initialization
 void Start()
 {
     statesController    = GameObject.Find("StatesController").GetComponent <FSMSystem>();
     statesList          = statesController.GetStatesList();
     user                = GameObject.Find("Camera (eye)").gameObject;
     robotic_wall_states = null;
     elevator            = null;
 }
Example #29
0
    void Start()
    {
        fsm = new FSMSystem();

        //FSMState state = new AanayState(fsm,StateID.NullStateID);
        //state.AddTransition(Transition.NullTransition, StateID.NullStateID);
        //fsm.AddState(state);
    }
Example #30
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_fsm">Fsm.</param>
 /// <param name="_enemyTransform">Enemy transform.</param>
 /// <param name="_playerTransform">Player transform.</param>
 /// <param name="_agent">Agent.</param>
 /// <param name="_anim">Animation.</param>
 public FSMStateBase(FSMSystem _fsm, Transform _enemyTransform, Transform _playerTransform, NavMeshAgent _agent, Animator _anim)
 {
     fsm             = _fsm;
     enemyTransform  = _enemyTransform;
     playerTransform = _playerTransform;
     agent           = _agent;
     anim            = _anim;
 }
Example #31
0
 /// <summary>
 /// 建立FSMSystem
 /// </summary>
 private void MakeFSM(string filename)
 {
     fSMSystem = new FSMSystem(this);
     //配置
     fSMSystem.ConfigFSM(filename);
     //初始化
     fSMSystem.InitDefaultState(defaultStateID);
 }
    // The NPC has two states: FollowPath and ChasePlayer
    // If it's on the first state and SawPlayer transition is fired, it changes to ChasePlayer
    // If it's on ChasePlayerState and LostPlayer transition is fired, it returns to FollowPath
    private void MakeFSM()
    {
        FollowPathState follow = new FollowPathState(path);
        follow.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);

        ChasePlayerState chase = new ChasePlayerState();
        chase.AddTransition(Transition.LostPlayer, StateID.FollowingPath);

        fsm = new FSMSystem();
        fsm.AddState(follow);
        fsm.AddState(chase);
    }
    void MakeFSM()
    {
        FollowPathState state1 = new FollowPathState (path);
        state1.AddTransition (Transition.SawPlayer, StateID.ChasingPlayer);

        ChasePlayerState state2 = new ChasePlayerState ();
        state2.AddTransition (Transition.LostPlayer, StateID.FollowingPath);

        fsm = new FSMSystem ();
        fsm.AddState (state1);
        fsm.AddState (state2);
    }
    // The NPC has 3 states: Idle and ChasingPlayer
    // If it's on the first state and SawPlayer transition is fired, it changes to ChasePlayer
    // If it's on ChasePlayerState and LostPlayer transition is fired, it returns to FollowPath
    protected void MakeFSM()
    {
        fsm = new FSMSystem ();

        IdleState idleState = new IdleState (detectionRange, initialPosition);
        idleState.AddTransition (Transition.PlayerDetected, StateID.ChasingPlayer);

        ChasingPlayerState chasingState = new ChasingPlayerState (this.detectionRange, this.attackRange);
        chasingState.AddTransition (Transition.PlayerConcealed, StateID.Idle);

        fsm.AddState (idleState);
        fsm.AddState (chasingState);
    }
Example #35
0
    private void MakeFSM()
    {
        PatrollingState patrolling = new PatrollingState (this);
        patrolling.AddTransition(Transition.poiInSight, StateID.Chasing);
        patrolling.AddTransition(Transition.isDestroyed, StateID.Destroyed);

        ChasingState chasing = new ChasingState(this);
        chasing.AddTransition(Transition.poiLost, StateID.Patroling);
        chasing.AddTransition(Transition.poiInFireingRange, StateID.Attacking);
        chasing.AddTransition(Transition.isDestroyed, StateID.Destroyed);

        AttackingState attacking = new AttackingState(this);
        attacking.AddTransition(Transition.poiLost, StateID.Patroling);
        attacking.AddTransition(Transition.isDestroyed, StateID.Destroyed);

        DestroyedState destroyed = new DestroyedState(this);

        fsm = new FSMSystem();
        fsm.AddState(patrolling);
        fsm.AddState(chasing);
        fsm.AddState(attacking);
        fsm.AddState(destroyed);
    }
Example #36
0
	/// <summary>
	/// Aux method that creates a machine state (FSM) to manage turret AI
	/// </summary>
	private void CreateMachineState ()
	{
		machineState = new FSMSystem(this.gameObject);
		
		TurretIdleState idleState = new TurretIdleState(this.gameObject);
		idleState.AddTransition(Transition.TargetInRange,StateID.Deploying);
		idleState.AddTransition(Transition.NoLife,StateID.Dead);
		
		TurretDeployingState deployingState = new TurretDeployingState(this.gameObject,this.animationController);
		deployingState.AddTransition(Transition.DeployingEnd,StateID.Attacking);
		deployingState.AddTransition(Transition.NoLife,StateID.Dead);
				
		TurretAttackingState attackingState = new TurretAttackingState(this.gameObject);
		attackingState.AddTransition(Transition.LostTarget,StateID.UnDeploying);
		attackingState.AddTransition(Transition.NoLife,StateID.Dead);
		
		TurretUndeployingState undeployingState= new TurretUndeployingState(this.gameObject,this.cannonControllers,this.bodyController,this.animationController);
		undeployingState.AddTransition(Transition.DeployingEnd,StateID.Idle);
		undeployingState.AddTransition(Transition.TargetInRange,StateID.Attacking);
		undeployingState.AddTransition(Transition.NoLife,StateID.Dead);
		
		TurretDeadState deadState = new TurretDeadState(this.gameObject);
		
		machineState.AddState(idleState);
		machineState.AddState(deployingState);
		machineState.AddState(attackingState);
		machineState.AddState(undeployingState);
		machineState.AddState(deadState);
	}
Example #37
0
    private Node nodeView; //Not used yet. Exists to enable controll of the GameObject

    #endregion Fields

    #region Constructors

    public NodeController(NodeModel model, Node view, FSMSystem FSM)
    {
        nodeModel = model;
        nodeView = view;
        nodeFSM = FSM;
    }
Example #38
0
	private void MakeFSM()
	{
		StayStillState stay = new StayStillState();
		stay.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);
		
		ChasePlayerState chase = new ChasePlayerState();
		chase.AddTransition(Transition.LostPlayer, StateID.FindPlayer);
		chase.AddTransition(Transition.ReachPlayer, StateID.AttackPlayer);
		
		AttackPlayerState attack = new AttackPlayerState();
		attack.AddTransition(Transition.LostPlayer, StateID.ChasingPlayer);
		
		//StayStillState stay = new StayStillState();
		
		fsm = new FSMSystem();
		fsm.AddState(stay);
		fsm.AddState(chase);
		fsm.AddState(attack);
		//fsm.AddState(stay);
		fsm.SetCurrentState(stay);
	}
Example #39
0
 private FSMSystem configureFSM()
 {
     FSMSystem FSM = new FSMSystem();
     return FSM;
 }
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType<PlatformerCharacter2D>().gameObject;
        boneParent = GameObject.FindWithTag("Container");
        animator = GetComponent<Animator>();

        fsmSystem = new FSMSystem();

        SkeletonAttack sa = new SkeletonAttack(animator, player, attackDistance);
        sa.AddTransition(Transition.LostPlayer, StateID.Idle);
        sa.AddTransition(Transition.Dying, StateID.Dead);

        SkeletonJump sj = new SkeletonJump(animator);
        sj.AddTransition(Transition.StopJump, StateID.Idle);
        sj.AddTransition(Transition.Dying, StateID.Dead);
        sj.AddTransition(Transition.Jumping, StateID.Jumping);

        SkeletonMove sm = new SkeletonMove(animator, player, attackDistance);
        sm.AddTransition(Transition.Jumping, StateID.Jumping);
        sm.AddTransition(Transition.Dying, StateID.Dead);
        sm.AddTransition(Transition.DetectedPlayer, StateID.Attacking);

        fsmSystem.AddState(sm);
        fsmSystem.AddState(sj);
        fsmSystem.AddState(sa);

        visible = false;
    }
    // The NPC has two states: FollowPath and ChasePlayer
    // If it's on the first state and SawPlayer transition is fired, it changes to ChasePlayer
    // If it's on ChasePlayerState and LostPlayer transition is fired, it returns to FollowPath
    private void MakeFSM()
    {
        ChasePlayerState chase = new ChasePlayerState();
        chase.AddTransition(Transition.LostPlayer, StateID.FollowingPath);

        Vector3[] path = new Vector3[waypoint[0].childCount];
        for (int i = 0; i < waypoint[0].childCount; i++)
        {
            path[i] = waypoint[0].GetChild(i).position;
        }
        FollowPathState follow = new FollowPathState(path);
        follow.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);

        fsm = new FSMSystem();
        fsm.AddState(follow);
        fsm.AddState(chase);
    }
Example #42
0
    private void InitializeFSM()
    {
        EmotionState neutral = new EmotionState(StateID.Neutral);
        neutral.High = 10f;
        neutral.Low = -10f;
        neutral.AddTransition(Transition.Interested, StateID.Interested);
        neutral.AddTransition(Transition.Annoyed, StateID.Annoyed);

        EmotionState interested = new EmotionState(StateID.Interested);
        interested.High = 10f;
        interested.Low = -10f;
        interested.AddTransition(Transition.Happy, StateID.Happy);
        interested.AddTransition(Transition.Annoyed, StateID.Annoyed);

        EmotionState annoyed = new EmotionState(StateID.Annoyed);
        annoyed.High = 10f;
        annoyed.Low = -10f;
        annoyed.AddTransition(Transition.Interested, StateID.Interested);
        annoyed.AddTransition(Transition.Angry, StateID.Angry);

        EmotionState angry = new EmotionState(StateID.Angry);
        angry.High = 12f;
        angry.Low = -8f;
        angry.AddTransition(Transition.Annoyed, StateID.Annoyed);
        angry.AddTransition(Transition.Lose, StateID.Lose);

        EmotionState happy = new EmotionState(StateID.Happy);
        happy.High = 10f;
        happy.AddTransition(Transition.Win, StateID.Win);

        EmotionState win = new EmotionState(StateID.Win);
        EmotionState lose = new EmotionState(StateID.Lose);

        fsm = new FSMSystem();

        fsm.AddState(neutral);
        fsm.AddState(annoyed);
        fsm.AddState(angry);
        fsm.AddState(happy);
        fsm.AddState(interested);
        fsm.AddState(lose);
        fsm.AddState(win);

        Debug.Log("Imouto FSM successfully Initialized");
    }