Exemplo n.º 1
0
    /// <summary>
    /// Initialize the character
    /// </summary>
    new public virtual void Start()
    {
        moveStick      = new ControlStick();
        jumpAlarm      = ScriptableObject.CreateInstance <Alarm>();
        hitLagAlarm    = ScriptableObject.CreateInstance <Alarm>();
        spriteRenderer = this.gameObject.GetComponentInChildren <SpriteRenderer>();

        timer     = 0;
        velocity  = new Vector3(0f, 0f, 0f);
        position  = new Vector2(0f, 0f);
        knockback = new Vector3(0f, 0f, 0f);
        jumpCount = 0;

        // Pool the states
        currentState = new StateIdle(this);
        stateAttack  = new StateAttack(this);
        stateCrouch  = new StateCrouch(this);
        stateIdle    = new StateIdle(this);
        stateDash    = new StateDash(this);
        stateJump    = new StateJump(this);
        stateRun     = new StateRun(this);
        stateHurt    = new StateHurt(this);
        stateFall    = new StateFall(this);
        playerContactFilter.layerMask = playerMask;

        timerSpeed = 1;

        canJump   = true;
        canAttack = true;
    }
Exemplo n.º 2
0
    public override StateBase <Hero> update(Hero hero)
    {
        StateBase <Hero> next = this;

        if (hero.want == Hero.wantAction.JUMP)
        {
            hero.jump();
            hero.animCtrl.SetBool("isJumping", true);
            hero.fire();
            next = new StateJump();
        }

        bool run = hero.move();

        if (run)
        {
            hero.animCtrl.SetBool("isRunning", true);
            next = new StateRun();
        }


        if (hero.want == Hero.wantAction.ATTACK)
        {
            hero.attack();
        }

        return(next);
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start () {
#if UNITY_EDITOR || UNITY_STANDALONE
        InputPlayer = IsInputPlayer; // Inspector -> Property
#else //SERVER SIDE
        InputPlayer = false;
#endif


        State state = new StateIdle();
        state.Event_OnEnter = StateEvent_OnEnter;
        _dicStates.Add((int)eState.E_IDLE, state);

        state = new StateRun();
        state.Event_OnEnter = StateEvent_OnEnter;
        _dicStates.Add((int)eState.E_RUN, state);

        state = new StateRun();
        state.Event_OnEnter = StateEvent_OnEnter;
        _dicStates.Add((int)eState.E_ATTACK, state);

        SetStateIdle();
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
#if UNITY_EDITOR || UNITY_STANDALONE
        InputPlayer = IsInputPlayer; // Inspector -> Property
#else //SERVER SIDE
        InputPlayer = false;
#endif


        State state = new StateIdle();
        state.Event_OnEnter = StateEvent_OnEnter;
        _dicStates.Add((int)eState.E_IDLE, state);

        state = new StateRun();
        state.Event_OnEnter = StateEvent_OnEnter;
        _dicStates.Add((int)eState.E_RUN, state);

        state = new StateRun();
        state.Event_OnEnter = StateEvent_OnEnter;
        _dicStates.Add((int)eState.E_ATTACK, state);

        SetStateIdle();
    }