Beispiel #1
0
    public void Initialize()
    {
        m_me           = GetComponent <Charicter>();
        m_sprite       = GetComponent <SpriteRenderer>();
        m_inputHandler = GetComponent <BaseInputHandler>();
        m_inputHandler.Initialize();

        //m_attack1 = GetComponent<SaberAttack>();
        //m_attack1 = GetComponent<TonfaAttack>();
        //m_attack2 = GetComponent<ShieldAttack>();
        //m_attack2 = GetComponent<BusterAttack>();

        BuildWeapons();

        m_stateClass[(int)eStates.STANDING]      = GetComponent <StateStand>();
        m_stateClass[(int)eStates.WALKING]       = GetComponent <StateWalk>();
        m_stateClass[(int)eStates.JUMPING]       = GetComponent <StateJump>();
        m_stateClass[(int)eStates.PRE_POST_JUMP] = GetComponent <StatePrePostJump>();
        m_stateClass[(int)eStates.FALLING]       = GetComponent <StateFall>();
        m_stateClass[(int)eStates.SLIDING]       = GetComponent <StateSlide>();
        m_stateClass[(int)eStates.BLOCK]         = GetComponent <StateGuard>();

        m_stateClass[(int)eStates.ATTACK_1] = m_attack1.InitializeState();
        m_stateClass[(int)eStates.ATTACK_2] = m_attack2.InitializeState();
        m_stateClass[(int)eStates.THROW]    = GetComponent <StateThrow>();

        m_stateClass[(int)eStates.HIT_STUN]     = GetComponent <StateHitGround>();
        m_stateClass[(int)eStates.AIR_HIT_STUN] = GetComponent <StateHitAir>();
        m_stateClass[(int)eStates.SPAWNING]     = GetComponent <StateSpawn>();
        m_stateClass[(int)eStates.KO_D]         = GetComponent <StateKO>();

        m_newState     = eStates.SPAWNING;
        m_currentState = eStates.STANDING;

        m_stateClass[(int)m_newState].Enter(m_currentState);

        for (int z = 0; z < (int)eStates.SIZE_OF_E_STATES; z++)
        {
            m_stateClass[z].Initialize(m_me);
        }

        m_animations = GetComponent <AnimClass>();
        m_animations.F_initialize(m_sprite);

        m_animations.addAnim();         // STAND
        m_animations.addKeyFrame((int)eStates.STANDING, m_sprites[1], 0.01f);
        m_animations.animRepeat((int)eStates.STANDING);

        m_animations.addAnim();         // WALKING
        m_animations.addKeyFrame((int)eStates.WALKING, m_sprites[4], 0.15f);
        m_animations.addKeyFrame((int)eStates.WALKING, m_sprites[5], 0.15f);
        m_animations.addKeyFrame((int)eStates.WALKING, m_sprites[6], 0.15f);
        m_animations.addKeyFrame((int)eStates.WALKING, m_sprites[5], 0.15f);
        m_animations.animRepeat((int)eStates.WALKING);

        m_animations.addAnim();         // JUMPING
        m_animations.addKeyFrame((int)eStates.JUMPING, m_sprites[7], 0.01f);
        m_animations.animRepeat((int)eStates.JUMPING);

        m_animations.addAnim();         // PRE_POST_JUMP
        m_animations.addKeyFrame((int)eStates.PRE_POST_JUMP, m_sprites[1], 0.01f);
        m_animations.animRepeat((int)eStates.PRE_POST_JUMP);

        m_animations.addAnim();         // FALLING
        m_animations.addKeyFrame((int)eStates.FALLING, m_sprites[7], 0.01f);
        m_animations.animRepeat((int)eStates.FALLING);

        m_animations.addAnim();         // SLIDING
        m_animations.addKeyFrame((int)eStates.SLIDING, m_sprites[26], 0.01f);
        m_animations.animRepeat((int)eStates.SLIDING);

        m_animations.addAnim();         // BLOCK
        m_animations.addKeyFrame((int)eStates.BLOCK, m_sprites[51], 0.01f);
        m_animations.animRepeat((int)eStates.BLOCK);

        m_attack1.InitializeAnimation(m_animations, m_sprites, (int)eStates.ATTACK_1);
        m_attack2.InitializeAnimation(m_animations, m_sprites, (int)eStates.ATTACK_2);

        m_animations.addAnim();         // THROW
        m_animations.addKeyFrame((int)eStates.THROW, m_sprites[3], 5.0f / 60.0f);
        m_animations.addKeyFrame((int)eStates.THROW, m_sprites[27], 8.0f / 60.0f);
        m_animations.addKeyFrame((int)eStates.THROW, m_sprites[18], 12.0f / 60.0f);
        //m_animations.animRepeat((int)eStates.THROW);

        m_animations.addAnim();         // HIT_STUN
        m_animations.addKeyFrame((int)eStates.HIT_STUN, m_sprites[20], 0.01f);
        m_animations.animRepeat((int)eStates.HIT_STUN);

        m_animations.addAnim();         // AIR_HIT_STUN
        m_animations.addKeyFrame((int)eStates.AIR_HIT_STUN, m_sprites[21], 0.01f);
        m_animations.animRepeat((int)eStates.AIR_HIT_STUN);

        m_animations.addAnim();         // SPAWNING
        m_animations.addKeyFrame((int)eStates.SPAWNING, m_sprites[0], 0.2f);
        m_animations.addKeyFrame((int)eStates.SPAWNING, m_sprites[0], 0.2f);
        m_animations.addKeyFrame((int)eStates.SPAWNING, m_sprites[10], 0.2f);
        m_animations.addKeyFrame((int)eStates.SPAWNING, m_sprites[11], 0.2f);
        m_animations.addKeyFrame((int)eStates.SPAWNING, m_sprites[1], 0.2f);
        m_animations.addKeyFrame((int)eStates.SPAWNING, m_sprites[2], 0.25f);

        m_animations.addAnim();         // KO_D
        m_animations.addKeyFrame((int)eStates.KO_D, m_sprites[28], 0.01f);
        m_animations.animRepeat((int)eStates.KO_D);

        m_animations.F_play();

        ResetInputs();
        m_me.Initialize(m_sprite);
    }