Esempio n. 1
0
    void DoThrow(Vector3 pos, float speed, float angle, bool applyBodyVelocity)
    {
        mBody.ResetCollision();

        attachSpriteAnim.Play(attachSpriteClipEmpty);

        bomb.transform.position        = pos;
        bomb.transform.rotation        = throwPoint.rotation;
        bomb.rigidbody.angularVelocity = Vector3.zero;
        bomb.rigidbody.velocity        = Vector3.zero;

        Vector3 newVel;

        if (applyBodyVelocity)
        {
            Vector3 bodyLVel = mBody.localVelocity;

            float velX = mBodySpriteCtrl.isLeft ? bodyLVel.x <0.0f ? bodyLVel.x : 0.0f : bodyLVel.x> 0.0 ? bodyLVel.x : 0.0f;
            float velY = mBody.localVelocity.y < 0 ? 0.0f : mBody.localVelocity.y;

            newVel = bomb.transform.localToWorldMatrix.MultiplyVector(new Vector3(velX, velY));
        }
        else
        {
            newVel = Vector3.zero;
        }

        bomb.SetActive(true);
        mBombCtrl.Activate();

        if (speed != 0.0f)
        {
            Vector3 dir = mBodySpriteCtrl.isLeft ? -mBody.dirHolder.right : mBody.dirHolder.right;

            Quaternion rot = Quaternion.AngleAxis(angle, mBodySpriteCtrl.isLeft ? -Vector3.forward : Vector3.forward);

            dir = rot * dir;

            newVel += dir * speed;
        }

        bomb.rigidbody.AddForce(newVel, ForceMode.VelocityChange);

        StartCoroutine(DoBombCorrection(mBody.gravityController.up));

        tk2dBaseSprite bombSpr = bomb.GetComponentInChildren <tk2dBaseSprite>();

        if (bombSpr)
        {
            bombSpr.FlipX = mBodySpriteCtrl.isLeft;
        }

        mPlayer.HUD.targetOffScreen.gameObject.SetActive(false);

        if (bombGrabber)
        {
            bombGrabber.gameObject.SetActive(true);
        }
    }
Esempio n. 2
0
    protected override void StateChanged()
    {
        base.StateChanged();

        switch ((State)state)
        {
        case State.Active:
            mCtrl.ResetCollision();
            mCtrl.gravityController.enabled = true;

            Invoke("DoBlink", decayDelay * 0.85f);
            break;

        case State.Invalid:
            mCtrl.ResetCollision();
            mCtrl.gravityController.enabled = false;
            break;
        }
    }
    protected override void StateChanged()
    {
        switch ((State)prevState)
        {
        case State.Active:
            mCtrl.Jump(false);
            mCtrl.moveSide = 0.0f;
            break;
        }

        base.StateChanged();

        switch ((State)state)
        {
        case State.Active:
            //mCtrl.gravityController.enabled = true;
            //mCtrl.enabled = true;
            mCtrl.moveSideLock = true;
            mCtrl.moveEnabled  = true;
            mCtrl.ResetCollision();
            dieDelay = mDefaultDieDelay;
            mLastFollowPlayerTime = 0;
            mLastJumpTime         = Time.fixedTime;
            break;

        case State.Dying:
            shaker.enabled = true;
            mCtrl.moveSide = 0.0f;
            mCtrl.ResetCollision();
            Vector3 lv = mCtrl.localVelocity;
            lv.x = 0.0f;
            mCtrl.localVelocity = lv;
            break;

        case State.Invalid:
            //mCtrl.gravityController.enabled = false;
            //mCtrl.enabled = false;
            shaker.enabled = false;
            break;
        }
    }
Esempio n. 4
0
    void LockControls()
    {
        SetSlide(false);

        //disable all input
        inputEnabled = false;

        InputManager input = Main.instance != null ? Main.instance.input : null;

        if (input)
        {
            input.RemoveButtonCall(0, InputAction.MenuEscape, OnInputPause);
        }
        //

        mStats.isInvul = true;

        mCtrl.moveSideLock = true;
        mCtrl.moveSide     = 0.0f;
        mCtrl.ResetCollision();
    }