Пример #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);
    }
Пример #2
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);
    }
Пример #3
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);
    }
Пример #4
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);
    }
Пример #5
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);
    }
Пример #6
0
    void InitFSM()
    {
        IdleState  idleState  = new IdleState(gameObject);
        RunState   runState   = new RunState(gameObject);
        ThrowState throwState = new ThrowState(gameObject);
        DeadState  deadState  = new DeadState(gameObject);

        // 注册切换条件 对应的 状态
        idleState.AddTransition(FSMTransition.IdleToRun, FSMStateId.Run);
        runState.AddTransition(FSMTransition.RunToIdle, FSMStateId.Idle);

        idleState.AddTransition(FSMTransition.IdleToThrow, FSMStateId.Throw);
        runState.AddTransition(FSMTransition.RunToThrow, FSMStateId.Throw);

        throwState.AddTransition(FSMTransition.ThrowToIdle, FSMStateId.Idle);

        idleState.AddTransition(FSMTransition.IdleToDead, FSMStateId.Dead);
        runState.AddTransition(FSMTransition.RunToDead, FSMStateId.Dead);
        throwState.AddTransition(FSMTransition.ThrowToDead, FSMStateId.Dead);

        system.AddState(idleState);
        system.AddState(runState);
        system.AddState(throwState);
        system.AddState(deadState);

        system.Start(FSMStateId.Idle);
    }
Пример #7
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);
    }
Пример #8
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());
    }
Пример #9
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);
    }
Пример #10
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);
    }
Пример #11
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;
    }
Пример #12
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);
    }
Пример #13
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);
    }
Пример #14
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);
    }
Пример #15
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);
    }
Пример #16
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);
    }
Пример #17
0
    void ImitFSM()
    {
        fsm = new FSMSystem();
        FSMState patrolState = new PatrolState(fsm);

        patrolState.AddTranstion(Transition.SeePlayer, StateID.Chase);
        FSMState chaseState = new ChaseState(fsm);

        fsm.AddState(patrolState);
        fsm.AddState(chaseState);
    }
Пример #18
0
    void SetupFSM()
    {
        FSM = new PlayerFSM(gameObject);

        PlayerFSM.MoveState move = new PlayerFSM.MoveState();

        PlayerFSM.AttackState attack = new PlayerFSM.AttackState();

        FSM.AddState(move);
        FSM.AddState(attack);
    }
Пример #19
0
    // Use this for initialization
    void Start()
    {
        fsm = new FSMSystem(this);
        FSMState idle     = fsm.AddState(State.Idle.ToString(), new IdleState());
        FSMState rotating = fsm.AddState(State.Rotating.ToString(), new RotatingState());

        idle.MarkNextState(rotating.ID);
        rotating.MarkNextState(idle.ID);

        fsm.ChangeState(State.Idle.ToString());
    }
Пример #20
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);

        fsm = new FSMSystem();
        fsm.AddState(follow);
        fsm.AddState(chase);
    }
Пример #21
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);
    }
Пример #22
0
    private void Start()
    {
        fsm = new FSMSystem();
        FSMState patrolState = new PatrolState(fsm);
        FSMState chaseState  = new ChaseState(fsm);

        fsm.AddState(patrolState);
        fsm.AddState(chaseState);
        patrolState.AddTransition(Transition.FindPlayer, StateID.ChaseState);
        chaseState.AddTransition(Transition.LosePlayer, StateID.PatrolState);
    }
Пример #23
0
    void InitFsm()
    {
        fsm = new FSMSystem();
        PatrolState patrolState = new PatrolState(fsm);

        patrolState.ADDTransition(Transition.SeePlayer, StateID.Chase);
        ChaseState chaseState = new ChaseState(fsm);

        chaseState.ADDTransition(Transition.LostPlayer, StateID.PatroState);
        fsm.AddState(patrolState);
        fsm.AddState(chaseState);
    }
Пример #24
0
    protected override void MakeFSM()
    {
        FrogMoveState frogMove = new FrogMoveState(gameObject, timeBetweenJumps);

        frogMove.AddTransition(Transition.NoHealth, StateID.Dead);

        DeadState dead = new DeadState();

        fsm = new FSMSystem();
        fsm.AddState(frogMove);
        fsm.AddState(dead);
    }
Пример #25
0
    void InitFsmSystem()
    {
        fSMSystem = new FSMSystem();
        FSMState patrolState = new PatrolState(fSMSystem);

        patrolState.AddTransition(Transition.SeePlayer, StateID.Chease);
        fSMSystem.AddState(patrolState);
        FSMState chaseState = new ChaseState(fSMSystem);

        chaseState.AddTransition(Transition.LosePlayer, StateID.Patrol);
        fSMSystem.AddState(chaseState);
    }
Пример #26
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);

        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);
    }
Пример #28
0
        private void MakeFSM()
        {
            BattleState battle = new BattleState();

            battle.AddTransition(Transition.TransitionToNormalState, StateID.NormalStateID);
            NormalState normal = new NormalState();

            normal.AddTransition(Transition.TransitionToBattleState, StateID.BattleStateID);

            fsm = new FSMSystem();
            fsm.AddState(normal);
            fsm.AddState(battle);
        }
Пример #29
0
    // 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);
    }
Пример #30
0
    //NPC有两个状态分别是在路径中巡逻和追逐玩家
    //如果他在第一个状态并且SawPlayer 过度状态被出发了,它就转变到ChasePlayer状态
    //如果他在ChasePlayer状态并且LostPlayer状态被触发了,它就转变到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);
    }
Пример #31
0
    private void MakeFSM()
    {
        FollowPathState follow = new FollowPathState(playerCharacterParameters.retreatRadius);

        follow.AddTransition(Transition.SawEnemy, StateID.ChasingEnemy);

        ChasePlayerState chase = new ChasePlayerState(playerCharacterParameters.retreatRadius);

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

        fsm = new FSMSystem();
        fsm.AddState(follow);
        fsm.AddState(chase);
    }
Пример #32
0
    protected override void MakeFSM()
    {
        fsm = new FSMSystem();

        IdleState idle = new IdleState(gameObject);

        idle.AddTransition(Transition.PlayerVisible, StateID.Chase);
        fsm.AddState(idle);

        ChaseState chase = new ChaseState(gameObject);

        chase.AddTransition(Transition.PlayerNotVisible, StateID.Idle);
        fsm.AddState(chase);
    }
Пример #33
0
    void Awake()
    {
        fsm = new FSMSystem();
        fsm.AddState(new MoveState());
        fsm.AddState(new JumpState());
        fsm.AddState(new DashState());
        fsm.AddState(new SlideState());

        physics = new PhysicsUpdate(this);
        sprite  = new SpriteUpdate(this);

        PosChangeEvent += Camera.main.GetComponent <SceneManager>().CameraFollow;
        PosChangeEvent += Camera.main.GetComponent <SceneManager>().ArchivePosChange;
    }
Пример #34
0
    private void MakeFSM()
    {
        PlayerCombatState playerCombat = new PlayerCombatState(gameObject);

        playerCombat.AddTransition(Transition.PlayerHit, StateID.Invulnerable);

        InvulnerableState invulnerable = new InvulnerableState(1.0f, gameObject);

        invulnerable.AddTransition(Transition.DoneInvulnerable, StateID.PlayerCombat);

        fsm = new FSMSystem();
        fsm.AddState(playerCombat);
        fsm.AddState(invulnerable);
    }
Пример #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);
    }
    // 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);
    }
Пример #37
0
    // 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;
    }
Пример #38
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");
    }
Пример #39
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);
	}
Пример #40
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);
	}