Esempio n. 1
0
    protected void ConstructFSM()
    {
        Debug.Log("!!");
        PlayerWalkState Walk = new PlayerWalkState();

        AddFSMState(Walk);
    }
Esempio n. 2
0
 // Start is called before the first frame update
 void Start()
 {
     lockOnList         = new List <GameObject>();
     walkState          = new PlayerWalkState(this.gameObject, this, keyconfig, arm, gun);
     standState         = new PlayerStandState(this.gameObject, this, keyconfig, arm, gun);
     rollState          = new PlayerRollState(this.gameObject, this, keyconfig);
     rollState.particle = dustParticle;
     hitboxes           = GetComponentsInChildren <Collider2D>();
     Initialize(startState: standState);
 }
Esempio n. 3
0
 private void Awake()
 {
     rigidbody = GetComponent <Rigidbody>();
     rigidbody.freezeRotation = true;
     rigidbody.useGravity     = false;
     score        = mainCamera.GetComponent <Gui> ().score_count;
     idleState    = new PlayerIdleState(this);
     walkState    = new PlayerWalkState(this);
     bounceState  = new PlayerBounceState(this);
     sneakState   = new PlayerSneakState(this);
     hookState    = new PlayerHookState(this);
     targetState  = new PlayerTargetState(this);
     distToGround = GetComponent <Collider> ().bounds.extents.y;
 }
Esempio n. 4
0
    public void InitializePlayerStateMachine()
    {
        idleState        = new PlayerIdleState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData);
        walkState        = new PlayerWalkState(stateMachine, this, AlfAnimationHash.RUN_0, playerData);
        jumpState        = new PlayerJumpState(stateMachine, this, AlfAnimationHash.JUMP_0, playerData);
        inAirState       = new PlayerInAirState(stateMachine, this, AlfAnimationHash.INAIR_0, playerData);
        meleeAttackState = new PlayerMeleeAttackState(stateMachine, this, AlfAnimationHash.ATTACK_0, playerData);
        parryState       = new PlayerParryState(stateMachine, this, AlfAnimationHash.PARRY_1, playerData);
        rollState        = new PlayerRollState(stateMachine, this, AlfAnimationHash.ROLL_0, playerData);
        stunState        = new PlayerStunState(stateMachine, this, AlfAnimationHash.STUN_0, playerData);
        deadState        = new PlayerDeadState(stateMachine, this, AlfAnimationHash.DEAD_0, playerData);
        takeDamageState  = new PlayerTakeDamageState(stateMachine, this, AlfAnimationHash.TAKEDAMAGE_0, playerData);
        wallState        = new PlayerWallState(stateMachine, this, AlfAnimationHash.WALL_0, playerData);
        dashState        = new PlayerDashState(stateMachine, this, AlfAnimationHash.DASH_0, playerData);
        converseState    = new PlayerConverseState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData);
        cinemaState      = new PlayerCinemaState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData);
        ladderState      = new PlayerLadderState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData);

        InitializePlayerCooldownTimer();
    }
Esempio n. 5
0
    private PlayerState GetState(PlayerStateEnum _pse, params object[] _args)
    {
        PlayerState _ret = null;

        switch (_pse)
        {
        case PlayerStateEnum.Stand:
            _ret = new PlayerStandState(gameObject);
            _ret.Reset();
            break;

        case PlayerStateEnum.Walk:
            Vector2         _walkDir = (Vector2)_args[0];
            PlayerWalkState _pws     = new PlayerWalkState(gameObject);
            _pws.Dir = _walkDir;
            _ret     = _pws;
            break;

        case PlayerStateEnum.Run:
            Vector2        _runDir = (Vector2)_args[0];
            PlayerRunState _prs    = new PlayerRunState(gameObject);
            _prs.Dir = _runDir;
            _ret     = _prs;
            break;

        default:
            break;
        }
        if (_ret == null)
        {
            MyLogger.Error("RoleControl", "{0} state don't have a creator!", _pse);
            return(_ret);
        }
        else
        {
            return(_ret);
        }
    }
Esempio n. 6
0
        /// <summary>
        /// Raises the message event.
        /// </summary>
        /// <param name="message">Message.</param>
        public void OnMessage(EventMessageBase message)
        {
            if (message.eventMessageModel == EventMessageModel.eEventMessageModel_PLAY_MOVE_STATE)
            {
                m_stateMachine.ChangeState(PlayerWalkState.GetInstance());
                m_stateMachine.OnMessage(message);
            }
            else if (message.eventMessageModel == EventMessageModel.eEventMessageModel_PLAY_STATE)
            {
                if (message.eventMessageAction == (int)EnitityCommon.EnitityAction.ENITITY_ACTION_FIGHT_FINISH)
                {
                    m_stateMachine.ChangeState(PlayerIdelState.GetInstance());
                    m_stateMachine.OnMessage(message);
                }
                else
                {
                    blood -= message.eventMessageAction;

                    if (blood <= 0)
                    {
                        m_stateMachine.ChangeState(PlayerDeathState.GetInstance());
                        m_stateMachine.OnMessage(message);
                    }
                    else
                    {
                        m_stateMachine.ChangeState(PlayerInjuerState.GetInstance());
                        m_stateMachine.OnMessage(message);
                    }

                    //Debug.Log("ai a ~~~~~~~~~ blood == " + blood.ToString());
                }
            }
            else if (message.eventMessageModel == EventMessageModel.eEventMessageModel_PLAY_ATTACK_STATE)
            {
                m_stateMachine.ChangeState(PlayerAttackState.GetInstance());
            }
        }
Esempio n. 7
0
    public void InitializePlayerStateMachine()
    {
        idleState        = new PlayerIdleState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData);
        walkState        = new PlayerWalkState(stateMachine, this, AlfAnimationHash.RUN_0, playerData);
        jumpState        = new PlayerJumpState(stateMachine, this, AlfAnimationHash.JUMP_0, playerData);
        inAirState       = new PlayerInAirState(stateMachine, this, AlfAnimationHash.INAIR_0, playerData);
        meleeAttackState = new PlayerMeleeAttackState(stateMachine, this, AlfAnimationHash.ATTACK_IRONSWORD, playerData);
        bowAttackState   = new PlayerBowAttackState(stateMachine, this, AlfAnimationHash.IDLE_WOODBOW, playerData);
        magicAttackState = new PlayerMagicAttackState(stateMachine, this, AlfAnimationHash.IDLE_APPRENTICE_STICK, playerData);
        parryState       = new PlayerParryState(stateMachine, this, AlfAnimationHash.PARRY_1, playerData);
        rollState        = new PlayerRollState(stateMachine, this, AlfAnimationHash.ROLL_0, playerData);
        stunState        = new PlayerStunState(stateMachine, this, AlfAnimationHash.STUN_0, playerData);
        deadState        = new PlayerDeadState(stateMachine, this, AlfAnimationHash.DEAD_0, playerData);
        takeDamageState  = new PlayerTakeDamageState(stateMachine, this, AlfAnimationHash.TAKEDAMAGE_0, playerData);
        wallState        = new PlayerWallState(stateMachine, this, AlfAnimationHash.WALL_0, playerData);
        dashState        = new PlayerDashState(stateMachine, this, AlfAnimationHash.DASH_0, playerData);
        converseState    = new PlayerConverseState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData);
        cinemaState      = new PlayerCinemaState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData);
        ladderState      = new PlayerLadderState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData);
        wakeupState      = new PlayerWakeupState(stateMachine, this, AlfAnimationHash.WAKEUP_SITUP_0, playerData);
        littleSunState   = new PlayerLittleSunState(stateMachine, this, AlfAnimationHash.LITTLESUN_SIT_0, playerData);

        InitializePlayerCooldownTimer();
    }
Esempio n. 8
0
 public static bool HasSameSign(this PlayerWalkState state, float value) => FromFloat(value) == state;
Esempio n. 9
0
    //NPC有两个状态分别是在路径中巡逻和追逐玩家
    //如果他在第一个状态并且SawPlayer 过度状态被出发了,它就转变到ChasePlayer状态
    //如果他在ChasePlayer状态并且LostPlayer状态被触发了,它就转变到FollowPath状态

    private void MakeFSM()//建造状态机
    {
        PlayerIdleState idle = new PlayerIdleState();

        idle.AddTransition(Transition.FreeWalk, StateID.Walk);
        idle.AddTransition(Transition.Dead, StateID.Dead);
        idle.AddTransition(Transition.Acct, StateID.Acct);
        idle.AddTransition(Transition.Skill, StateID.Skill);
        idle.AddTransition(Transition.CrashPlayer, StateID.CrashPlayer);

        PlayerWalkState walk = new PlayerWalkState();

        walk.AddTransition(Transition.FreeWalk, StateID.Walk);
        walk.AddTransition(Transition.Acct, StateID.Acct);
        walk.AddTransition(Transition.Skill, StateID.Skill);
        walk.AddTransition(Transition.Dead, StateID.Dead);
        walk.AddTransition(Transition.Idle, StateID.Idle);
        walk.AddTransition(Transition.CrashPlayer, StateID.CrashPlayer);

        PlayerDeadState dead = new PlayerDeadState();

        dead.AddTransition(Transition.Dead, StateID.Dead);
        dead.AddTransition(Transition.Idle, StateID.Idle);
        dead.AddTransition(Transition.FreeWalk, StateID.Walk);

        PlayerAcceState acce = new PlayerAcceState();

        acce.AddTransition(Transition.Acct, StateID.Acct);
        acce.AddTransition(Transition.Skill, StateID.Skill);
        acce.AddTransition(Transition.FreeWalk, StateID.Walk);
        acce.AddTransition(Transition.Dead, StateID.Dead);
        acce.AddTransition(Transition.Idle, StateID.Idle);
        acce.AddTransition(Transition.CrashPlayer, StateID.CrashPlayer);

        PlayerSkillState skill = new PlayerSkillState();

        skill.AddTransition(Transition.Skill, StateID.Skill);
        skill.AddTransition(Transition.Acct, StateID.Acct);
        skill.AddTransition(Transition.FreeWalk, StateID.Walk);
        skill.AddTransition(Transition.Dead, StateID.Dead);
        skill.AddTransition(Transition.Idle, StateID.Idle);
        skill.AddTransition(Transition.CrashPlayer, StateID.CrashPlayer);

        //PlayerSwitchState sw = new PlayerSwitchState();
        //sw.AddTransition(Transition.Skill, StateID.Skill);
        //sw.AddTransition(Transition.Acct, StateID.Acct);
        //sw.AddTransition(Transition.FreeWalk, StateID.Walk);
        //sw.AddTransition(Transition.Dead, StateID.Dead);
        //sw.AddTransition(Transition.Idle, StateID.Idle);
        //sw.AddTransition(Transition.CrashPlayer, StateID.CrashPlayer);

        PlayerCrashState crash = new PlayerCrashState();

        crash.AddTransition(Transition.Skill, StateID.Skill);
        crash.AddTransition(Transition.Acct, StateID.Acct);
        crash.AddTransition(Transition.FreeWalk, StateID.Walk);
        crash.AddTransition(Transition.Dead, StateID.Dead);
        crash.AddTransition(Transition.Idle, StateID.Idle);

        Fsm = new FSMSystem();
        Fsm.AddState(idle);
        Fsm.AddState(walk);
        Fsm.AddState(acce);
        Fsm.AddState(skill);
        Fsm.AddState(dead);
        //Fsm.AddState(sw);
        Fsm.AddState(crash);
    }