Exemple #1
0
    /// sets up CharacterStateController data
    public override void InitWeapon(CharacterStateController ctrl)
    {
        ctrl.GetAnimator().SetTrigger("WeaponChange");
        ctrl.GetAnimator().SetInteger("WeaponId", 2);

        var state_idle      = ctrl.AddState(true);     // 0
        var state_pain      = ctrl.AddState();         // 1
        var state_dash      = ctrl.AddState();         // 2
        var state_dashBack  = ctrl.AddState();         // 3
        var state_bowHit    = ctrl.AddState();         // 4
        var state_arrowHit  = ctrl.AddState();         // 5
        var state_loadArrow = ctrl.AddState();         // 6

        var state_drawArrow         = ctrl.AddState(); // 7
        var state_holdArrow         = ctrl.AddState(); // 8
        var state_releaseArrow      = ctrl.AddState(); // 9
        var state_shootArrow        = ctrl.AddState(); // 10
        var state_releaseArrow_fake = ctrl.AddState(); // 11
        var state_jump = ctrl.AddState();              // 12


        int cd_dash      = ctrl.AddCd(0.3f);
        int cd_dash_long = ctrl.AddCd(0.5f);
        int cd_bowHit    = ctrl.AddCd(0.3f);
        int cd_shoot     = ctrl.AddCd(0.3f);
        int cd_loadArrow = ctrl.AddCd(0.35f);


        const float atackRotationSpeed     = 0.45f;
        const float arrowHoldRotationSpeed = 0.15f;
        const float freeRotFar             = 0.25f;
        const float freeRotClose           = 0.25f;

        ctrl.AddTransitionAll(state_pain, new Period(0f, 1f));



        state_idle
        .AddComponent(new CStateAnimationAtMove("AtMove"))

        .AddTransition(state_dash)
        .AddTransition(state_bowHit)
        .AddTransition(state_drawArrow)
        .AddTransition(state_loadArrow)
        ;

        state_drawArrow
        .AddComponent(new CStateCanUseArrows())
        .AddComponent(new CStateInput(0))
        .AddComponent(new CStateAnimation("drawArrow"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed * 0.75f, freeRotClose, new Period(0, 0.25f)))
        .AddComponent(new CStateInitDirectionUpdate(arrowHoldRotationSpeed, freeRotClose, 8.75f, new Period(0.25f, float.PositiveInfinity)))
        .AddComponent(new CStateCd(cd_shoot))

        .AddComponent(new CStateAutoTransition(state_holdArrow))

        .AddTransition(state_bowHit, new Period(0.5f))
        .AddTransition(state_dash, new Period(0.5f))
        .AddTransition(state_releaseArrow_fake, new Period(0.35f))
        ;
        state_holdArrow
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateInitDirectionUpdate(arrowHoldRotationSpeed, freeRotClose, 7.75f, new Period(0, float.PositiveInfinity)))

        .AddTransition(state_bowHit)
        .AddTransition(state_dash)
        .AddTransition(state_releaseArrow)
        .AddTransition(state_shootArrow)
        ;
        state_releaseArrow
        .AddComponent(new CStateInput(2))
        .AddComponent(new CStateAnimation("releaseArrow"))
        .AddComponent(new CStateMaxStateInstances())

        .AddComponent(new CStateAutoTransition(state_idle))

        .AddTransition(state_bowHit, new Period(0.85f))
        .AddTransition(state_dash, new Period(0.85f))
        ;

        state_releaseArrow_fake
        .AddComponent(new CStateInput(0, true))
        .AddComponent(new CStateAnimation("releaseArrow"))
        .AddComponent(new CStateMaxStateInstances())

        .AddComponent(new CStateAutoTransition(state_idle))

        .AddTransition(state_bowHit, new Period(0.85f))
        .AddTransition(state_dash, new Period(0.85f))
        ;
        state_shootArrow
        .AddComponent(new CStateUseArrows(0.45f))
        .AddComponent(new CStateInput(0, true))
        .AddComponent(new CStateAnimation("shootArrow"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_shoot, CStateCd.EMode.ERestartOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        ;

        state_loadArrow
        .AddComponent(new CStateInput(2))
        .AddComponent(new CStateAnimation("loadArrow"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateLoadArrow(0.55f))
        .AddComponent(new CStateCd(cd_loadArrow))
        //.AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotClose, new Period(0, 0.65f)))
        //.AddComponent(new CStateEnergy(0, 20f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        .AddTransition(state_dash, new Period(0.3f))

        ;

        state_dash
        .AddComponent(new CStateInput(3))
        .AddComponent(new CStateAnimation("dash"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_dash))
        .AddComponent(new CStateCd(cd_dash_long, CStateCd.EMode.EConditionOnly))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotFar, new Period(0, 0.65f)))
        //.AddComponent(new CStateEnergy(0, 10f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        .AddTransition(state_arrowHit, new Period(0.1f, 0.7f))
        .AddTransition(state_jump, new Period(0.125f, 0.95f), false)
        //.AddTransition(state_dashBack, new Period(0.325f, 0.9f), false)
        ;

        state_bowHit
        .AddComponent(new CStateInput(1))
        .AddComponent(new CStateAnimation("bowHit"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_bowHit))
        .AddComponent(new CStateCd(cd_dash_long, CStateCd.EMode.EConditionOnly))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotClose, new Period(0, 0.65f)))
        //.AddComponent(new CStateEnergy(0, 20f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        .AddTransition(state_dashBack, new Period(0.375f, 0.8f), false)

        ;
        state_arrowHit
        .AddComponent(new CStateInput(1))
        .AddComponent(new CStateAnimation("arrowHit"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_bowHit))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotClose, new Period(0, 0.65f)))
        //.AddComponent(new CStateEnergy(0, 20f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        .AddTransition(state_dashBack, new Period(0.375f, 0.75f), false)
        ;

        state_dashBack
        .AddComponent(new CStateInput(3))
        .AddComponent(new CStateAnimation("dashBack"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_dash_long, CStateCd.EMode.ERestartOnly))
        .AddComponent(new CStateCd(cd_bowHit, CStateCd.EMode.ERestartOnly))

        .AddComponent(new CStateReflectedDirection(0.65f, 0.75f, atackRotationSpeed, freeRotFar, new Period(0, 0.65f)).SetRaySeparation(0.35f))
        .AddComponent(new CStateEnergy(0, 5f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        ;

        state_jump
        .AddComponent(new CStateInput(3))
        .AddComponent(new CStateAnimation("jump"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_dash_long, CStateCd.EMode.ERestartOnly))
        .AddComponent(new CStateCd(cd_bowHit, CStateCd.EMode.ERestartOnly))
        .AddComponent(new CStateDashThroughWall(0.51f, 0.95f, 0.35f, 0.375f, 0.1825f))

        .AddComponent(new CStateEnergy(0, 5f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        .AddTransition(state_drawArrow, new Period(0.7f))
        .AddTransition(state_arrowHit, new Period(0.7f))
        ;


        state_pain
        .AddComponent(new CStateRandomAnimation(new string[] { "pain1", "pain2" }))
        .AddComponent(new CStateDamageShake())
        .AddComponent(new CStateDamage(10.0f, 0.0f))

        /*.AddComponent(new CStateCdReduce(
         *  new CStateCdReduce.CdRestartStruct[] {
         *      new CStateCdReduce.CdRestartStruct(cd_swing, 0.1f),
         *      new CStateCdReduce.CdRestartStruct(cd_push, 0.1f),
         *      new CStateCdReduce.CdRestartStruct(cd_pull, 0.1f),
         *      new CStateCdReduce.CdRestartStruct(cd_dash, -1.35f),
         *  }))*/
        .AddComponent(new CStateAutoTransition(state_idle))

        ;
    }
    /// sets up CharacterStateController data
    public override void InitWeapon(CharacterStateController ctrl)
    {
        ctrl.GetAnimator().SetTrigger("WeaponChange");
        ctrl.GetAnimator().SetInteger("WeaponId", 0);

        var state_idle     = ctrl.AddState(true);    // 0
        var state_swing    = ctrl.AddState();        // 1
        var state_push     = ctrl.AddState();        // 2
        var state_pull     = ctrl.AddState();        // 3
        var state_dash     = ctrl.AddState();        // 4
        var state_throw    = ctrl.AddState();        // 5
        var state_pain     = ctrl.AddState();        // 6
        var state_dashBack = ctrl.AddState();        // 7
        var state_jump     = ctrl.AddState();        // 8

        int cd_swing = ctrl.AddCd(0.25f);            // 1
        int cd_push  = ctrl.AddCd(0.35f);            // 2
        int cd_pull  = ctrl.AddCd(0.35f);            // 3
        int cd_throw = ctrl.AddCd(0.4f);             // 4
        int cd_dash  = ctrl.AddCd(0.25f);            // 5
        int cd_pain  = ctrl.AddCd(0.55f);            // 6

        float atackRotationSpeed = 0.45f;
        float freeRotFar         = 0.25f;
        float freeRotClose       = 0.25f;

        ctrl.AddTransitionAll(state_pain, new Period(0f, 1f));


        state_jump
        .AddComponent(new CStateInput(3))
        .AddComponent(new CStateAnimation("jump"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_dash, CStateCd.EMode.ERestartOnly))
        .AddComponent(new CStateDashThroughWall(0.51f, 0.95f, 0.35f, 0.185f, 0.25f))

        .AddComponent(new CStateAutoTransition(state_idle))
        //.AddTransition(state_drawArrow, new Period(0.7f))
        //.AddTransition(state_arrowHit, new Period(0.7f))
        ;
        state_swing
        .AddComponent(new CStateInput(0))
        .AddComponent(new CStateAnimation("swing"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_swing))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotClose, new Period(0, 0.65f)))
        .AddComponent(new CStateEnergy(0, 15f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))

        //.AddTransition(state_dashBack, new Period(0.45f, 0.95f))
        .AddTransition(state_push, new Period(0.55f, 1f))
        .AddTransition(state_throw, new Period(0.45f, 0.5f))
        ;
        state_push
        .AddComponent(new CStateInput(1))
        .AddComponent(new CStateAnimation("push"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_push))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotClose, new Period(0, 0.65f)))
        .AddComponent(new CStateEnergy(0, 20f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))

        //.AddTransition(state_dashBack, new Period(0.45f, 0.95f))
        .AddTransition(state_pull, new Period(0.375f, 0.55f))
        .AddTransition(state_swing, new Period(0.25f, 1f))
        ;
        state_pull
        .AddComponent(new CStateInput(2))
        .AddComponent(new CStateAnimation("pull"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_pull))
        .AddComponent(new CStateCd(cd_throw, CStateCd.EMode.ERestartOnly))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotClose, new Period(0, 0.65f)))
        .AddComponent(new CStateEnergy(0, 25f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))

        .AddTransition(state_push, new Period(0.25f, 0.5f))
        .AddTransition(state_swing, new Period(0.3f, 1f))
        ;
        state_dash
        .AddComponent(new CStateInput(3))
        .AddComponent(new CStateAnimation("dash"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_dash))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotFar, new Period(0, 0.65f)))
        .AddComponent(new CStateEnergy(0, 10f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))

        //.AddTransition(state_dashBack, new Period(0.1f, 0.75f))
        .AddTransition(state_swing, new Period(0.2f, 0.7f))
        .AddTransition(state_push, new Period(0.25f, 1f))
        .AddTransition(state_pull, new Period(0.2f, 1f))
        .AddTransition(state_jump, new Period(0.2f, 0.8f), false)
        ;
        state_dashBack
        .AddComponent(new CStateInput(3))
        .AddComponent(new CStateInput(2))
        .AddComponent(new CStateAnimation("dash-back"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_dash, CStateCd.EMode.ERestartOnly))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotFar, new Period(0, 0.65f)))
        .AddComponent(new CStateCollisionInFront(1.0f, new Vector2(-0.5f, 1.25f)))
        .AddComponent(new CStateCollisionInFront(1.0f, new Vector2(0.5f, 1.25f)))
        .AddComponent(new CStateEnergy(0, 5f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        ;


        state_idle
        .AddTransition(state_swing)
        .AddTransition(state_push)
        .AddTransition(state_pull)
        .AddTransition(state_dash)
        ;
        state_throw
        .AddComponent(new CStateInput(2))
        .AddComponent(new CStateAnimation("throw"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_pull, CStateCd.EMode.ERestartOnly))
        .AddComponent(new CStateCd(cd_throw))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed * 3, 1.5f, new Period(0.35f, 0.65f)))
        .AddComponent(new CStateSpawn(0, new Period(0.45f, 1f)))
        .AddComponent(new CStateEnergy(0, 15f, CStateEnergy.Mode.EConsumeOnly))

        .AddComponent(new CStateAutoTransition(state_idle))
        ;


        state_pain
        //.AddComponent(new CStateResetAnimation(new string[] { "painWall3", "painWall2", "painWall1" }))
        .AddComponent(new CStateRandomAnimation(new string[] { "pain", "pain2" }))
        .AddComponent(new CStateDamageShake())
        .AddComponent(new CStateDamage(10.0f, 0.0f))
        .AddComponent(new CStateCdReduce(
                          new CStateCdReduce.CdRestartStruct[] {
            new CStateCdReduce.CdRestartStruct(cd_swing, 0.1f),
            new CStateCdReduce.CdRestartStruct(cd_push, 0.1f),
            new CStateCdReduce.CdRestartStruct(cd_pull, 0.1f),
            new CStateCdReduce.CdRestartStruct(cd_dash, -1.35f),
        }))
        .AddComponent(new CStateAutoTransition(state_idle))

        //.AddTransition(state_painWall, new Period(0f, 1f));
        ;
    }
    /// sets up CharacterStateController data
    public override void InitWeapon(CharacterStateController ctrl)
    {
        ctrl.GetAnimator().SetTrigger("WeaponChange");
        ctrl.GetAnimator().SetInteger("WeaponId", 3);

        var state_idle       = ctrl.AddState(true);  // 0
        var state_dash       = ctrl.AddState();      // 1
        var state_blockInit  = ctrl.AddState();      // 2
        var state_blockStay  = ctrl.AddState();      // 3
        var state_blockBack  = ctrl.AddState();      // 4
        var state_shieldBash = ctrl.AddState();      // 5
        var state_slashLoad  = ctrl.AddState();      // 6
        var state_slashStay  = ctrl.AddState();      // 7
        var state_slashBack  = ctrl.AddState();      // 8
        var state_push       = ctrl.AddState();      // 9
        var state_pain       = ctrl.AddState();      // 10

        int cd_dash  = ctrl.AddCd(0.3f);
        int cd_block = ctrl.AddCd(0.1f);
        int cd_slash = ctrl.AddCd(0.25f);

        const float atackRotationSpeed = 0.45f;
        const float freeRotFar         = 0.25f;
        const float freeRotClose       = 0.25f;
        const float blockRotationSpeed = 0.1f;

        state_pain
        .AddComponent(new CStateRandomAnimation(new string[] { "Pain1", "Pain2" }))
        .AddComponent(new CStateDamageShake())
        .AddComponent(new CStateDamage(10.0f, 0.0f))
        .AddComponent(new CStateAutoTransition(state_idle))
        ;

        state_idle
        .AddComponent(new CStateAnimationAtMove("AtMove"))

        .AddTransition(state_dash)
        .AddTransition(state_blockInit)
        .AddTransition(state_slashLoad)
        .AddTransition(state_push)
        ;


        ctrl.AddTransitionAll(state_pain, new Period(0f, 1f));

        state_dash
        .AddComponent(new CStateInput(3))
        .AddComponent(new CStateAnimation("Dash"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateCd(cd_dash))
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotFar, new Period(0, 0.65f)))

        .AddComponent(new CStateAutoTransition(state_idle))

        //.AddTransition(state_slashBack)
        .AddTransition(state_shieldBash, new Period(0.45f, 0.6f), false);
        ;

        state_push
        .AddComponent(new CStateInput(1))
        .AddComponent(new CStateAnimation("Push"))
        .AddComponent(new CStateMaxStateInstances())

        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotFar, new Period(0, 0.65f)))

        .AddComponent(new CStateAutoTransition(state_idle))
        ;

        state_shieldBash
        .AddComponent(new CStateInput(1))
        .AddComponent(new CStateAnimation("ShieldBash"))
        .AddComponent(new CStateMaxStateInstances())

        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed, freeRotFar, new Period(0, 0.65f)))

        .AddComponent(new CStateAutoTransition(state_idle))
        //.AddTransition(state_blockInit, new Period(0.8f))
        ;

        state_blockInit
        .AddComponent(new CStateInput(2))
        .AddComponent(new CStateAnimation("Block"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed * 0.75f, freeRotClose, new Period(0, 0.25f)))
        .AddComponent(new CStateInitDirectionUpdate(blockRotationSpeed, freeRotClose, 8.75f, new Period(0.25f, float.PositiveInfinity)))
        .AddComponent(new CStateCd(cd_block))

        .AddComponent(new CStateAutoTransition(state_blockStay))
        ;
        state_blockStay
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateInitDirectionUpdate(blockRotationSpeed, freeRotClose, 10.75f, new Period(0, float.PositiveInfinity)))

        .AddTransition(state_blockBack)
        .AddTransition(state_dash)
        //.AddTransition(state_shieldBash)
        .AddTransition(state_push)
        ;

        state_blockBack
        .AddComponent(new CStateInput(2, true))
        .AddComponent(new CStateAnimation("BlockBack"))
        .AddComponent(new CStateMaxStateInstances())

        .AddComponent(new CStateAutoTransition(state_idle))
        .AddTransition(state_shieldBash)
        .AddTransition(state_dash)
        ;

        state_slashLoad
        .AddComponent(new CStateInput(0))
        .AddComponent(new CStateAnimation("Slash"))
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateInitDirectionSmooth(atackRotationSpeed * 0.75f, freeRotClose, new Period(0, 0.25f)))
        .AddComponent(new CStateInitDirectionUpdate(blockRotationSpeed, freeRotClose, 8.75f, new Period(0.25f, float.PositiveInfinity)))
        .AddComponent(new CStateCd(cd_slash))

        .AddComponent(new CStateAutoTransition(state_slashStay))

        //.AddTransition(state_dash)
        //.AddTransition(state_shieldBash)
        ;

        state_slashStay
        .AddComponent(new CStateMaxStateInstances())
        .AddComponent(new CStateInitDirectionUpdate(blockRotationSpeed, freeRotClose, 3.75f, new Period(0, float.PositiveInfinity)))

        .AddTransition(state_dash)
        .AddTransition(state_shieldBash)
        .AddTransition(state_slashBack)
        ;
        state_slashBack
        .AddComponent(new CStateInput(0, true))
        .AddComponent(new CStateAnimation("SlashBack"))
        .AddComponent(new CStateMaxStateInstances())

        .AddComponent(new CStateAutoTransition(state_idle))
        .AddTransition(state_blockInit, new Period(0.5f))
        //.AddTransition(state_dash, new Period(0.9f))
        //.AddTransition(state_shieldBash, new Period(0.9f))
        ;
    }