示例#1
0
    private void InitialzeStateManager()
    {
        _stateManager = new StateManager(_muffinAnimator);

        IdleState 		idle = new IdleState(_stateManager, transform);
        MoveState 		move = new MoveState(_stateManager, transform);
        TrapState 		trap = new TrapState(_stateManager, transform);
        DieState 		die	= new DieState(_stateManager, transform);
        SpinState		spin = new SpinState(_stateManager, transform);
        BlastState		blast = new BlastState(_stateManager, transform);
        ChocoRushState	chocoRush = new ChocoRushState(_stateManager, transform);

        PauseState		pause = new PauseState(_stateManager, transform);

        _stateManager.AddCharacterState(idle);
        _stateManager.AddCharacterState(move);
        _stateManager.AddCharacterState(trap);
        _stateManager.AddCharacterState(die);
        _stateManager.AddCharacterState(spin);
        _stateManager.AddCharacterState(blast);
        _stateManager.AddCharacterState(chocoRush);

        _stateManager.AddCharacterState(pause);

        _stateManager.SetDefaultState("Pause");
    }
示例#2
0
    private DieState()
    {
        if (instance != null)
        {
            return;
        }

        instance = this;
    }
        public DieState m_cDieState;           //死亡状态

        public StateWrap(GfxObject obj)
        {
            this.m_cIdleState     = new IdleState(obj);
            this.m_cAttackState   = new AttackState(obj);
            this.m_cMoveState     = new MoveState(obj);
            this.m_cMoveBackState = new MoveBackState(obj);
            this.m_cHurtState     = new HurtState(obj);
            this.m_cSkillState    = new SkillState(obj);
            this.m_cDieState      = new DieState(obj);
        }
示例#4
0
 private void Awake()
 {
     enemy            = GetComponent <Enemy>();
     anim             = GetComponent <Animator>();
     idleState        = new IdleState(this);
     wanderState      = new WanderState(this);
     rangeAttackState = new RangeAttackState(this);
     dieState         = new DieState(this);
     isWaiting        = false;
 }
示例#5
0
    public bool ChangeState(int state_code)
    {
        if (this.CurState != null)
        {
            Config     cStateChange     = ConfigPool.Load("StateChange");
            ConfigItem cStateChangeItem = cStateChange[this.CurState.GetStateType()];
            if (cStateChangeItem == null)
            {
                Log.Error(string.Format("StateChange Config Id:{0} Not Exist", this.CurState.GetStateType()));
                return(false);
            }

            if (cStateChangeItem["CanChange"].Contains(state_code))
            {
                return(false);
            }
        }

        StateBase state = null;

        switch (state_code)
        {
        case StateType.IDLE:
        {
            state = new IdleState();
        }; break;

        case StateType.RUN:
        {
            state = new RunState();
        }; break;

        case StateType.ATTACK:
        {
            state = new AttackState();
        }; break;

        case StateType.DIE:
        {
            state = new DieState();
        }; break;

        default:
        {
            Log.Error("");
        }; break;
        }

        if (state == null || !state.CanChange(this.role))
        {
            return(false);
        }

        return(true);
    }
 public PlayerState(GameObject gameObject)
 {
     this.gameObject = gameObject;
     moveState       = new MoveState();
     attackState     = new AttackState();
     dieState        = new DieState();
     injuredState    = new InjuredState();
     autoMove        = new AutoMoveState();
     SetState(States.move);
     curState = moveState;
 }
 public EnemyState(GameObject gameObject)
 {
     this.gameObject = gameObject;
     moveState       = new MoveState();
     attackState     = new AttackState();
     dieState        = new DieState();
     injuredState    = new InjuredState();
     autoMove        = new AutoMoveState();
     SetState(States.move);
     curState = moveState;
     ani      = gameObject.GetComponent <Animator>();
 }
 private Brush GetColorForDieButtonBorder(DieState dieState)
 {
     switch (dieState)
     {
         case DieState.Unclicked:
             return Brushes.Gray;
         case DieState.TemporarilySetAside:
             return Brushes.Blue;
         case DieState.PermanentlySetAside:
             return Brushes.Red;
         default:
             throw new InvalidOperationException("Invalid die state encountered.");
     }
 }
示例#9
0
        private void Awake()
        {
            rigidbody = GetComponent <Rigidbody2D>();
            collider  = GetComponent <Collider2D>();
            animator  = GetComponent <Animator>();


            stateMachine = ScriptableObject.CreateInstance <StateMachine>();
            groundState  = new GroundState(this);
            ladderState  = new LadderState(this);
            jumpState    = new JumpState(this);
            dieState     = new DieState(this);

            stateMachine.ChangeState(groundState);
        }
示例#10
0
    public override void Place()
    {
        base.Place();

        LevelController = FindObjectOfType <LevelController>();

        _stateMachine = new StateMachine();

        _walkState = new WalkState(this);
        var fallState  = new FallState(this);
        var climbState = new ClimbState(this);
        var dieState   = new DieState(this);

        _stateMachine.AddTransition(_walkState, fallState, () => !OnGround);
        _stateMachine.AddTransition(fallState, _walkState, () => OnGround);
        _stateMachine.AddTransition(_walkState, climbState, () => Climbing);
        _stateMachine.AddTransition(climbState, _walkState, () => !Climbing);

        _stateMachine.AddAnyTransition(dieState, () => _dead);
    }
示例#11
0
 // Update is called once per frame
 /// <summary>
 /// The FixedUpdate
 /// </summary>
 private void FixedUpdate()
 {
     rigid.maxAngularVelocity = maxRollSpeed;
     if (state == DieState.Rolling)
     {
         if (randomlyChangeDirectionEvery != 0f && lastChange + randomlyChangeDirectionEvery <= Time.time)
         {
             RandomizeRollDirection();
         }
         rigid.angularVelocity = rollDirection * rollSpeed;
     }
     else if (state == DieState.Thrown)
     {
         rigid.useGravity = true;
         if (rigid.IsSleeping())
         {
             state = DieState.Stopped;
         }
     }
 }
示例#12
0
    void MakeFSM()
    {
        m_fsm                     = new FiniteStateMachine <VFCharacter, RoleState>(this);
        m_attack1State            = new Attack1State(); m_fsm.RegisterState(m_attack1State);
        m_attack2State            = new Attack2State(); m_fsm.RegisterState(m_attack2State);
        m_attack3State            = new Attack3State(); m_fsm.RegisterState(m_attack3State);
        m_battleWalkBackwardState = new BattleWalkBackwardState(); m_fsm.RegisterState(m_battleWalkBackwardState);
        m_battleWalkForwardState  = new BattleWalkForwardState(); m_fsm.RegisterState(m_battleWalkForwardState);
        m_battleWalkLeftState     = new BattleWalkLeftState(); m_fsm.RegisterState(m_battleWalkLeftState);
        m_battleWalkRightState    = new BattleWalkRightState(); m_fsm.RegisterState(m_battleWalkRightState);
        m_defineState             = new DefendState(); m_fsm.RegisterState(m_defineState);
        m_dieState                = new DieState(); m_fsm.RegisterState(m_dieState);
        m_hitState                = new HitState(); m_fsm.RegisterState(m_hitState);
        m_idleState               = new IdleState(); m_fsm.RegisterState(m_idleState);
        m_jumpState               = new JumpState(); m_fsm.RegisterState(m_jumpState);
        m_runState                = new RunState(); m_fsm.RegisterState(m_runState);
        m_walkState               = new WalkState(); m_fsm.RegisterState(m_walkState);
        m_tauntState              = new TauntState(); m_fsm.RegisterState(m_tauntState);

        m_fsm.ChangeState(RoleState.idle02);
    }
示例#13
0
    protected virtual void Awake()
    {
        base.Awake();
        levelSystem        = new LevelSystem();
        statsSystem        = new StatsSystem(playerStatsDatum, levelSystem.GetLevel());
        healthPointsSystem = new HealthPointsSystem(statsSystem.GetTotalMaxHealthPoints());

        command = new NullCommand(this);

        #region State
        state    = basicState = new BasicState(this);
        dieState = new DieState(this, 5f);
        state.Begin();
        #endregion

        RuntimeAnimatorController runtimeAnimatorController = transform.Find("model").GetComponent <Animator>().runtimeAnimatorController;
        AnimationClip[]           animationClips            = runtimeAnimatorController.animationClips;

        for (int i = 0; i < animationClips.Length; i++)
        {
            clipLengths.Add(animationClips[i].name, animationClips[i].length);
            print(animationClips[i].name + ": " + animationClips[i].length);
        }
    }
示例#14
0
文件: Die.cs 项目: KRDMTech/Yahtzee
 private Die(DieState state)
 {
     State = state;
     _random = new Random();
 }
示例#15
0
 public void Roll()
 {
     State = DieState.Rolling;
 }
示例#16
0
 public void Stop()
 {
     State = DieState.Normal;
 }
示例#17
0
 public abstract void Visit(DieState dieState);
示例#18
0
 private Die(DieState state)
 {
     State   = state;
     _random = new Random();
 }
示例#19
0
 public override void Visit(DieState dieState)
 {
 }
示例#20
0
 public override void Visit(DieState dieState)
 {
     return;
 }