Beispiel #1
0
    void Start()
    {
        camara = GameObject.FindGameObjectWithTag("MainCamera").transform;

        anim          = GetComponentsInChildren <AnimationHandler>();
        hitBoxControl = GetComponent <PlayerHitBoxControl>();
        control       = GameObject.FindGameObjectWithTag("Control").GetComponent <Control>();

        lastPos = transform.position;
        state   = PlayerState.Air;
        anim[0].setAnimation(state, DEF_ANIM_SPEED);
        anim[1].setAnimation(state, DEF_ANIM_SPEED);
        normal = -Physics.gravity.normalized;
    }
Beispiel #2
0
    public void usePowerUp()
    {
        if (stack != -1)
        {
            if (isActive)
            {
                terminatePowerUp();
            }
            activePowerUp = stack;
            stack         = -1;
            timeLeft      = 10;
            isActive      = true;
            Movement            m   = GetComponent <Movement>();
            PlayerHitBoxControl phb = GetComponent <PlayerHitBoxControl>();
            switch (activePowerUp)
            {
            case 0:
                phb.setShield(true);
                //Debug.Log ("Shield");
                break;

            case 1:
                m.jumpForce *= 3;
                m.maxSpeed  *= 2;
//				m.acceleration *=2;
//				m.maxAirSpeed *=2;
                m.airAcceleration *= 2;
                //Debug.Log ("Estic super saltant");
                break;

            case 2:
                m.maxSpeed     *= 2;
                m.acceleration *= 2;
                m.maxAirSpeed  *= 1.5f;
                //	m.airAcceleration *=2;
                //Debug.Log ("Estic super corrents");
                break;

            case 3:
                rigidbody.useGravity = false;
                //Debug.Log ("No tinc gravetat");
                break;

            default:
                break;
            }
        }
    }
Beispiel #3
0
    void terminatePowerUp()
    {
        isActive = false;
        timeLeft = 0;
        Movement            m   = GetComponent <Movement>();
        PlayerHitBoxControl pHB = GetComponent <PlayerHitBoxControl>();

        switch (activePowerUp)
        {
        case 0:
            pHB.setShield(false);
            break;

        case 1:
            m.jumpForce /= 3;
            m.maxSpeed  /= 2;
//				m.acceleration /=2;
//				m.maxAirSpeed /=2;
            m.airAcceleration /= 2;
            break;

        case 2:
            m.maxSpeed     /= 2;
            m.acceleration /= 2;
            m.maxAirSpeed  /= 1.5f;
//				m.airAcceleration /=2;
            break;

        case 3:
            rigidbody.useGravity = true;
            break;

        default:
            break;
        }
        activePowerUp = -1;
    }
Beispiel #4
0
    void Start()
    {
        camara = GameObject.FindGameObjectWithTag("MainCamera").transform;

        anim = GetComponentsInChildren<AnimationHandler>();
        hitBoxControl = GetComponent<PlayerHitBoxControl>();
        control = GameObject.FindGameObjectWithTag("Control").GetComponent<Control>();

        lastPos = transform.position;
        state = PlayerState.Air;
        anim[0].setAnimation(state, DEF_ANIM_SPEED);
        anim[1].setAnimation(state, DEF_ANIM_SPEED);
        normal = -Physics.gravity.normalized;
    }