示例#1
0
    void Start()
    {
        rigidBody      = GetComponent <Rigidbody2D>();
        boxCollider    = GetComponent <BoxCollider2D>();
        animator       = GetComponent <Animator>();
        spriteRenderer = GetComponent <SpriteRenderer>();
        fireParticles  = transform.GetChild(0).GetComponent <ParticleSystem>();
        bloodParticles = transform.GetChild(1).GetComponent <ParticleSystem>();

        joystick                 = ReInput.players.GetPlayer(playerNumber);
        movementBools            = new Dictionary <string, bool>();
        movementBools["pushed"]  = false;
        movementBools["succed"]  = false;
        movementBools["bounced"] = false;
        movementBools["frozen"]  = false;
        movementBools["ashed"]   = false;
        movementBools["spiked"]  = false;
        movementBools["slipped"] = false;
        movementBools["doubled"] = false;
        movementBools["active"]  = false;
        NStateInfo info = new NStateInfo(this, rigidBody, boxCollider, joystick, animator, spriteRenderer, balanceData);

        movementStates     = new NState[13];
        movementStates[0]  = new NStateNormal(info, EState.normal);
        movementStates[1]  = new NStateJump1(info, EState.jump1);
        movementStates[2]  = new NStateJump2(info, EState.jump2);
        movementStates[3]  = new NStateAshes(info, EState.ashes);
        movementStates[4]  = new NStateAirborne(info, EState.airborne);
        movementStates[5]  = new NStateSucc(info, EState.succ, transform.position);
        movementStates[6]  = new NStatePushed(info, EState.pushed, Vector2.zero);
        movementStates[7]  = new NStateBounced(info, EState.bounced, info.bd.bouncedInitialVelocity, info.bd.bouncedTransitionLockoutFrames);
        movementStates[8]  = new NStateSpiked(info, EState.spiked, Vector2.zero);
        movementStates[9]  = new NStateSlipped(info, EState.slipped);
        movementStates[10] = new NStateSlam(info, EState.slam);
        movementStates[11] = new NStateBounced(info, EState.boinked, info.bd.boinkedInitialVelocity, info.bd.boinkedTransitionLockoutFrames);
        movementStates[12] = new NStateInactive(info, EState.inactive);

        movementState = movementStates[12];

        weapons = new SortedList <EElement, Queue <NWeapon> >(6);
        weapons[EElement.air]    = new Queue <NWeapon>(weaponCounts[0]);
        weapons[EElement.fire]   = new Queue <NWeapon>(weaponCounts[1]);
        weapons[EElement.water]  = new Queue <NWeapon>(weaponCounts[2]);
        weapons[EElement.earth]  = new Queue <NWeapon>(weaponCounts[3]);
        weapons[EElement.plasma] = new Queue <NWeapon>(weaponCounts[4]);
        weapons[EElement.none]   = new Queue <NWeapon>(1);
        weaponEquipped           = EElement.air;
        weapon    = null;
        totem     = null;
        totemDist = Mathf.Infinity;
        living    = true;
        avatar    = false;
    }
示例#2
0
    public void HitByEarth(Vector2 direction)
    {
        living = false;
        rigidBody.constraints = RigidbodyConstraints2D.None;
        NStateSpiked spiked = (NStateSpiked)movementStates[8];

        spiked.SetSpikedDirection(direction);
        movementState.SetBool("spiked", true);
        bloodParticles.Play();
        ReleaseAllWeapons();
        levelManager.RemovePlayer(gameObject);
    }
示例#3
0
    public void DeathBySpikes(bool h)
    {
        living = false;
        rigidBody.constraints = RigidbodyConstraints2D.None;
        NStateSpiked spiked    = (NStateSpiked)movementStates[8];
        Vector2      direction = h ? new Vector2(rigidBody.velocity.x, -rigidBody.velocity.y * 0.5f) : new Vector2(-rigidBody.velocity.x, rigidBody.velocity.y);

        spiked.SetSpikedDirection(direction);
        movementState.SetBool("spiked", true);
        bloodParticles.Play();
        ReleaseAllWeapons();
        levelManager.RemovePlayer(gameObject);
    }