コード例 #1
0
    void SetStates()
    {
        var idle          = new EState <PlayerInputs>("Idle");
        var move          = new EState <PlayerInputs>("Move");
        var beginBlock    = new EState <PlayerInputs>("Begin_Block");
        var block         = new EState <PlayerInputs>("Block");
        var endBlock      = new EState <PlayerInputs>("End_Block");
        var parry         = new EState <PlayerInputs>("Parry");
        var roll          = new EState <PlayerInputs>("Roll");
        var attackCharge  = new EState <PlayerInputs>("Charge_Attack");
        var attackRelease = new EState <PlayerInputs>("Release_Attack");
        var takeDamage    = new EState <PlayerInputs>("Take_Damage");
        var dead          = new EState <PlayerInputs>("Dead");
        var spin          = new EState <PlayerInputs>("Spin");
        var stun          = new EState <PlayerInputs>("Stun");

        ConfigureState.Create(idle)
        .SetTransition(PlayerInputs.MOVE, move)
        .SetTransition(PlayerInputs.BEGIN_BLOCK, beginBlock)
        //.SetTransition(PlayerInputs.PARRY, parry)
        .SetTransition(PlayerInputs.ROLL, roll)
        .SetTransition(PlayerInputs.CHARGE_ATTACK, attackCharge)
        .SetTransition(PlayerInputs.TAKE_DAMAGE, takeDamage)
        .SetTransition(PlayerInputs.DEAD, dead)
        .SetTransition(PlayerInputs.SPIN, spin)
        .SetTransition(PlayerInputs.STUN, stun)
        .Done();

        ConfigureState.Create(move)
        .SetTransition(PlayerInputs.IDLE, idle)
        .SetTransition(PlayerInputs.BEGIN_BLOCK, beginBlock)
        //.SetTransition(PlayerInputs.PARRY, parry)
        .SetTransition(PlayerInputs.ROLL, roll)
        .SetTransition(PlayerInputs.CHARGE_ATTACK, attackCharge)
        .SetTransition(PlayerInputs.TAKE_DAMAGE, takeDamage)
        .SetTransition(PlayerInputs.DEAD, dead)
        .SetTransition(PlayerInputs.SPIN, spin)
        .SetTransition(PlayerInputs.STUN, stun)
        .Done();

        ConfigureState.Create(beginBlock)
        .SetTransition(PlayerInputs.BLOCK, block)
        .SetTransition(PlayerInputs.END_BLOCK, endBlock)
        .SetTransition(PlayerInputs.CHARGE_ATTACK, attackCharge)
        .SetTransition(PlayerInputs.TAKE_DAMAGE, takeDamage)
        .SetTransition(PlayerInputs.DEAD, dead)
        .Done();

        ConfigureState.Create(block)
        .SetTransition(PlayerInputs.END_BLOCK, endBlock)
        // .SetTransition(PlayerInputs.ROLL, roll)
        //.SetTransition(PlayerInputs.CHARGE_ATTACK, attackCharge)
        .SetTransition(PlayerInputs.TAKE_DAMAGE, takeDamage)
        .SetTransition(PlayerInputs.PARRY, parry)
        .SetTransition(PlayerInputs.DEAD, dead)
        .Done();

        ConfigureState.Create(endBlock)
        .SetTransition(PlayerInputs.IDLE, idle)
        .SetTransition(PlayerInputs.MOVE, move)
        .SetTransition(PlayerInputs.TAKE_DAMAGE, takeDamage)
        .SetTransition(PlayerInputs.DEAD, dead)
        .Done();

        ConfigureState.Create(parry)
        .SetTransition(PlayerInputs.IDLE, idle)
        .SetTransition(PlayerInputs.DEAD, dead)
        .Done();

        ConfigureState.Create(roll)
        .SetTransition(PlayerInputs.IDLE, idle)
        .SetTransition(PlayerInputs.MOVE, move)
        .SetTransition(PlayerInputs.DEAD, dead)
        .Done();

        ConfigureState.Create(attackCharge)
        .SetTransition(PlayerInputs.RELEASE_ATTACK, attackRelease)
        .SetTransition(PlayerInputs.DEAD, dead)
        .Done();

        ConfigureState.Create(attackRelease)
        .SetTransition(PlayerInputs.IDLE, idle)
        .SetTransition(PlayerInputs.CHARGE_ATTACK, idle)
        .SetTransition(PlayerInputs.DEAD, dead)
        .Done();

        ConfigureState.Create(takeDamage)
        .SetTransition(PlayerInputs.IDLE, idle)
        .SetTransition(PlayerInputs.DEAD, dead)
        .Done();

        ConfigureState.Create(spin)
        .SetTransition(PlayerInputs.STUN, stun)
        .Done();

        ConfigureState.Create(stun)
        .SetTransition(PlayerInputs.IDLE, idle)
        .SetTransition(PlayerInputs.MOVE, move)
        .Done();

        ConfigureState.Create(dead)
        .Done();

        stateMachine = new EventStateMachine <PlayerInputs>(idle, DebugState);

        new CharIdle(idle, stateMachine)
        .SetLeftAxis(GetLeftHorizontal, GetLeftVertical)
        .SetRightAxis(GetRightHorizontal, GetRightVertical)
        .SetMovement(this.move);

        new CharMove(move, stateMachine)
        .SetLeftAxis(GetLeftHorizontal, GetLeftVertical)
        .SetRightAxis(GetRightHorizontal, GetRightVertical)
        .SetMovement(this.move);

        new CharBeginBlock(beginBlock, stateMachine)
        .SetLeftAxis(GetLeftHorizontal, GetLeftVertical)
        .SetRightAxis(GetRightHorizontal, GetRightVertical)
        .SetMovement(this.move).SetBlock(charBlock);

        new CharBlock(block, stateMachine)
        .SetLeftAxis(GetLeftHorizontal, GetLeftVertical)
        .SetRightAxis(GetRightHorizontal, GetRightVertical)
        .SetMovement(this.move)
        .SetBlock(charBlock);

        new CharEndBlock(endBlock, stateMachine)
        .SetLeftAxis(GetLeftHorizontal, GetLeftVertical)
        .SetBlock(charBlock);

        new CharParry(parry, stateMachine, parryRecall)
        .SetMovement(this.move).SetBlock(charBlock);

        new CharRoll(roll, stateMachine, evadeParticle)
        .SetMovement(this.move);

        new CharChargeAttack(attackCharge, stateMachine)
        .SetLeftAxis(GetLeftHorizontal, GetLeftVertical)
        .SetRightAxis(GetRightHorizontal, GetRightVertical)
        .SetMovement(this.move)
        .SetAttack(charAttack);

        new CharReleaseAttack(attackRelease, stateMachine, attackRecall, HeavyAttackRealease, ChangeHeavy)
        .SetMovement(this.move)
        .SetAttack(charAttack)
        .SetLeftAxis(GetLeftHorizontal, GetLeftVertical);

        new CharTakeDmg(takeDamage, stateMachine, takeDamageRecall);

        new CharSpin(spin, stateMachine)
        .Configurate(GetSpinDuration, GetSpinSpeed, go_SpinFeedback, sensorSpin)
        .SetLeftAxis(GetLeftHorizontal, GetLeftVertical)
        //.SetRightAxis(GetRightHorizontal, GetRightVertical)
        .SetMovement(this.move)
        .SetAnimator(charanim);

        new CharStun(stun, stateMachine)
        .Configurate(GetStunDuration, go_StunFeedback)
        .SetAnimator(charanim);

        new CharDead(dead, stateMachine);
    }
コード例 #2
0
    void SetStates()
    {
        var idle        = new EState <DummyEnemyInputs>("Idle");
        var goToPos     = new EState <DummyEnemyInputs>("Follow");
        var beginAttack = new EState <DummyEnemyInputs>("Begin_Attack");
        var attack      = new EState <DummyEnemyInputs>("Attack");
        var parried     = new EState <DummyEnemyInputs>("Parried");
        var takeDamage  = new EState <DummyEnemyInputs>("Take_Damage");
        var die         = new EState <DummyEnemyInputs>("Die");
        var disable     = new EState <DummyEnemyInputs>("Disable");
        var petrified   = new EState <DummyEnemyInputs>("Petrified");
        var freeze      = new EState <DummyEnemyInputs>("Freeze");

        ConfigureState.Create(idle)
        .SetTransition(DummyEnemyInputs.GO_TO_POS, goToPos)
        .SetTransition(DummyEnemyInputs.TAKE_DAMAGE, takeDamage)
        .SetTransition(DummyEnemyInputs.BEGIN_ATTACK, beginAttack)
        .SetTransition(DummyEnemyInputs.DIE, die)
        .SetTransition(DummyEnemyInputs.PETRIFIED, petrified)
        .SetTransition(DummyEnemyInputs.FREEZE, freeze)
        .SetTransition(DummyEnemyInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(goToPos)
        .SetTransition(DummyEnemyInputs.IDLE, idle)
        .SetTransition(DummyEnemyInputs.TAKE_DAMAGE, takeDamage)
        .SetTransition(DummyEnemyInputs.DIE, die)
        .SetTransition(DummyEnemyInputs.PETRIFIED, petrified)
        .SetTransition(DummyEnemyInputs.FREEZE, freeze)
        .SetTransition(DummyEnemyInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(beginAttack)
        .SetTransition(DummyEnemyInputs.ATTACK, attack)
        .SetTransition(DummyEnemyInputs.DIE, die)
        .SetTransition(DummyEnemyInputs.PETRIFIED, petrified)
        .SetTransition(DummyEnemyInputs.FREEZE, freeze)
        .SetTransition(DummyEnemyInputs.PARRIED, parried)
        .Done();

        ConfigureState.Create(attack)
        .SetTransition(DummyEnemyInputs.IDLE, idle)
        .SetTransition(DummyEnemyInputs.DIE, die)
        .SetTransition(DummyEnemyInputs.PETRIFIED, petrified)
        .SetTransition(DummyEnemyInputs.FREEZE, freeze)
        .SetTransition(DummyEnemyInputs.PARRIED, parried)
        .Done();

        ConfigureState.Create(parried)
        .SetTransition(DummyEnemyInputs.IDLE, idle)
        .SetTransition(DummyEnemyInputs.PETRIFIED, petrified)
        .SetTransition(DummyEnemyInputs.FREEZE, freeze)
        .SetTransition(DummyEnemyInputs.DIE, die)
        .Done();

        ConfigureState.Create(petrified)
        .SetTransition(DummyEnemyInputs.IDLE, idle)
        .SetTransition(DummyEnemyInputs.ATTACK, attack)
        .SetTransition(DummyEnemyInputs.BEGIN_ATTACK, beginAttack)
        .SetTransition(DummyEnemyInputs.DIE, die)
        .SetTransition(DummyEnemyInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(freeze)
        .SetTransition(DummyEnemyInputs.IDLE, idle)
        .SetTransition(DummyEnemyInputs.TAKE_DAMAGE, takeDamage)
        .SetTransition(DummyEnemyInputs.DIE, die)
        .SetTransition(DummyEnemyInputs.PETRIFIED, petrified)
        .SetTransition(DummyEnemyInputs.FREEZE, freeze)
        .SetTransition(DummyEnemyInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(takeDamage)
        .SetTransition(DummyEnemyInputs.IDLE, idle)
        .SetTransition(DummyEnemyInputs.DISABLE, disable)
        .SetTransition(DummyEnemyInputs.PETRIFIED, petrified)
        .SetTransition(DummyEnemyInputs.FREEZE, freeze)
        .SetTransition(DummyEnemyInputs.DIE, die)
        .Done();

        ConfigureState.Create(die)
        .Done();

        ConfigureState.Create(disable)
        .SetTransition(DummyEnemyInputs.IDLE, idle)
        .Done();

        sm = new EventStateMachine <DummyEnemyInputs>(idle, DebugState);

        var head = Main.instance.GetChar();

        //Asignando las funciones de cada estado
        new DummyIdleState(idle, sm, IsAttack, CurrentTargetPos, distanceToAttack, normalDistance, rotSpeed, this).SetAnimator(animator).SetRoot(rootTransform)
        .SetDirector(director);

        new DummyFollowState(goToPos, sm, avoidRadious, avoidWeight, rotSpeed, GetCurrentSpeed, CurrentTargetPos, normalDistance, this).SetAnimator(animator).SetRigidbody(rb)
        .SetRoot(rootTransform);

        new DummyAttAnt(beginAttack, sm, rotSpeed, this).SetAnimator(animator).SetDirector(director).SetRoot(rootTransform);

        new DummyAttackState(attack, sm, cdToAttack, this).SetAnimator(animator).SetDirector(director);

        new DummyParried(parried, sm, parriedTime, this).SetAnimator(animator).SetDirector(director);

        new DummyTDState(takeDamage, sm, recallTime).SetAnimator(animator);

        new DummyStunState(petrified, sm, petrifiedTime, attack).SetAnimator(animator);

        new DummySlowedState(freezeTime, freezeSpeedSlowed, freeze_shader, freeze, sm, avoidRadious, avoidWeight, rotSpeed, GetCurrentSpeed, CurrentTargetPos, normalDistance, this).SetAnimator(animator).SetRigidbody(rb)
        .SetRoot(rootTransform);

        new DummyDieState(die, sm).SetAnimator(animator).SetDirector(director).SetRigidbody(rb);

        new DummyDisableState(disable, sm, EnableObject, DisableObject);
    }
コード例 #3
0
    void SetStates()
    {
        var idle       = new EState <JabaliInputs>("Idle");
        var persuit    = new EState <JabaliInputs>("Persuit");
        var chargePush = new EState <JabaliInputs>("Charge_Push");
        var push       = new EState <JabaliInputs>("Push");
        var headAnt    = new EState <JabaliInputs>("Head_Anticipation");
        var headAttack = new EState <JabaliInputs>("Head_Attack");
        var takeDamage = new EState <JabaliInputs>("Take_DMG");
        var parried    = new EState <JabaliInputs>("Parried");
        var petrified  = new EState <JabaliInputs>("Petrified");
        var dead       = new EState <JabaliInputs>("Dead");
        var disable    = new EState <JabaliInputs>("Disable");

        ConfigureState.Create(idle)
        .SetTransition(JabaliInputs.PERSUIT, persuit)
        .SetTransition(JabaliInputs.CHARGE_PUSH, chargePush)
        .SetTransition(JabaliInputs.HEAD_ANTICIP, headAnt)
        .SetTransition(JabaliInputs.TAKE_DMG, takeDamage)
        .SetTransition(JabaliInputs.PETRIFIED, petrified)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(persuit)
        .SetTransition(JabaliInputs.IDLE, idle)
        .SetTransition(JabaliInputs.TAKE_DMG, takeDamage)
        .SetTransition(JabaliInputs.PETRIFIED, petrified)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(chargePush)
        .SetTransition(JabaliInputs.PUSH, push)
        .SetTransition(JabaliInputs.PETRIFIED, petrified)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(push)
        .SetTransition(JabaliInputs.IDLE, idle)
        .SetTransition(JabaliInputs.PETRIFIED, petrified)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(headAnt)
        .SetTransition(JabaliInputs.HEAD_ATTACK, headAttack)
        .SetTransition(JabaliInputs.PETRIFIED, petrified)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(headAttack)
        .SetTransition(JabaliInputs.IDLE, idle)
        .SetTransition(JabaliInputs.PARRIED, parried)
        .SetTransition(JabaliInputs.PETRIFIED, petrified)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(takeDamage)
        .SetTransition(JabaliInputs.IDLE, idle)
        .SetTransition(JabaliInputs.PETRIFIED, petrified)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(parried)
        .SetTransition(JabaliInputs.IDLE, idle)
        .SetTransition(JabaliInputs.PETRIFIED, petrified)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(petrified)
        .SetTransition(JabaliInputs.IDLE, idle)
        .SetTransition(JabaliInputs.CHARGE_PUSH, chargePush)
        .SetTransition(JabaliInputs.PUSH, push)
        .SetTransition(JabaliInputs.HEAD_ANTICIP, headAnt)
        .SetTransition(JabaliInputs.HEAD_ATTACK, headAttack)
        .SetTransition(JabaliInputs.DEAD, dead)
        .SetTransition(JabaliInputs.DISABLE, disable)
        .Done();

        ConfigureState.Create(dead)
        .Done();

        ConfigureState.Create(disable)
        .SetTransition(JabaliInputs.IDLE, idle)
        .Done();

        sm = new EventStateMachine <JabaliInputs>(idle, DebugState);

        new JabaliIdle(idle, sm, distanceToCharge, normalDistance, distanceToAttack, IsAttack, IsChargeOk).SetThis(this).SetRotation(rootTransform, rotSpeed);

        new JabaliPersuit(persuit, sm, lineOfSight.OnSight, IsChargeOk, distanceToAttack, distanceToCharge - 1)
        .SetMovement(rb, this, avoidRadious, avoidWeight, GetCurrentSpeed, avoidMask).SetRotation(rootTransform, rotSpeed).SetAnimator(animator);

        new JabaliCharge(chargePush, sm, chargeTime).SetAnimator(animator).SetDirector(director).SetThis(this);

        new JabaliPushAttack(push, sm, chargeSpeed, PushAttack).SetAnimator(animator).SetRigidbody(rb);

        new JabaliAttackAnticipation(headAnt, sm, normalAttAnticipation).SetAnimator(animator).SetRotation(rootTransform, rotSpeed).SetDirector(director).SetThis(this);

        new JabaliHeadAttack(headAttack, sm, cdToHeadAttack).SetAnimator(animator).SetDirector(director).SetThis(this);

        new JabaliTD(takeDamage, sm, tdRecall).SetAnimator(animator);

        new JabaliParried(parried, sm, timeParried).SetAnimator(animator);

        new JabaliStun(petrified, sm, StartStun, TickStun, EndStun);

        new JabaliDeath(dead, sm).SetAnimator(animator);

        disable.OnEnter += (input) => DisableObject();

        disable.OnExit += (input) => EnableObject();
    }
コード例 #4
0
ファイル: ConfigureGamepad.cs プロジェクト: rje/rubbertron
 void SetState(ConfigureState newState)
 {
     m_state = newState;
     UpdateLabels();
     switch(m_state) {
     case ConfigureState.MoveHorizAxis:
     case ConfigureState.MoveVertAxis:
     case ConfigureState.FireHorizAxis:
     case ConfigureState.FireVertAxis:
         ResetAxisInput();
         break;
     }
 }