Exemple #1
0
    void Activate()
    {
        AcquireThings();
        if (!activated)
        {
            //Debug.Log("ZECPOENT");

            atorLamp.SetTrigger("activate");
            atorRunes.SetTrigger("activate");
            pGen.Trigger();

            SetCurrentCheckpoint();
            activated = true;
        }
    }
Exemple #2
0
    void Update()
    {
        if (allowInput)
        {
            padInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        }
        else
        {
            padInput = Vector2.zero;
        }

        float colliderWidth  = gameObject.GetComponent <BoxCollider2D>().size.x;       //startiin?
        float colliderHeight = gameObject.GetComponent <BoxCollider2D>().size.y;

        //animation
        Animation();

        //sounds
        if (onGround)
        {
            if (rigid.velocity.x != 0)
            {
                if (!soundDelay)
                {
                    soundHandler.PlaySound(SoundType.Movement);
                    soundDelay = true;
                    Invoke("ResetSoundDelay", 0.4f);
                }
            }
        }

        //glide
        if (Input.GetButton("Glide") && allowInput)
        {
            if (!onGround && !dashing && rigid.velocity.y < 0.0f && glideHitWallTimer == 0.0f)
            {
                if (stamina.Remaining())
                {
                    gliding = true;
                }
            }
        }
        else
        {
            gliding          = false;
            glideAllowDeFace = true;
        }

        //oneway
        OneWayPlatformCollision(colliderWidth, colliderHeight);

        //stop gliding if we slow down or hit a wall
        GlideWallInteract(colliderWidth, colliderHeight);

        //movement
        if (dashing && !gliding)         //dash movement
        {
            MovementDash();
        }
        else if (gliding && !dashing)         //glide movement
        {
            MovementGlide();
        }
        else         //normal movement
        {
            MovementNormal();
        }

        //jump and boost
        if (Input.GetButtonDown("Jump") && allowInput)
        {
            if (onGround)             //normal jump
            {
                ator.SetTrigger("jump");
                Jump();
            }
            else if (allowBoost && /*!gliding &&*/ !dashing && !onGround)
            {
                if (stamina.Use())
                {
                    ator.SetTrigger("doubleJump");
                    doubleJumpParticleGen.Trigger();
                    if (rigid.velocity.y > 0.0f)                     //boost jump
                    {
                        JumpBoost();
                    }
                    else                     //weaker boost
                    {
                        JumpBoostWeak();
                    }
                }
            }
        }

        if (gliding && !onGround)
        {
            if (stamina.GetRegen())
            {
                stamina.Use();
                stamina.SetRegen(false);
            }
        }
        else
        {
            if (!stamina.GetRegen())
            {
                stamina.SetRegen(true);
            }
        }

        //dash
        if (Input.GetButton("Dash") && allowInput)
        {
            if (onGround && !dashing && stamina.Use())
            {
                dashParticleGen.Trigger();
                dashing   = true;
                dashTimer = dashLength;
            }
        }

        //limit speed
        float maxX = 10.0f;
        float maxY = 10.0f;

        rigid.velocity = new Vector3(Mathf.Clamp(rigid.velocity.x, -maxX, maxX), Mathf.Clamp(rigid.velocity.y, -maxY, maxY), 0.0f);

        //for debugging only
        //free movement

        /*if (Input.GetKey(KeyCode.Keypad8))
         * {
         *      rigid.velocity = new Vector2(0.0f, 15.0f);
         * }
         * if (Input.GetKey(KeyCode.Keypad5) || Input.GetKey(KeyCode.Keypad2))
         * {
         *      rigid.velocity = new Vector2(0.0f, -15.0f);
         * }
         * if (Input.GetKey(KeyCode.Keypad4))
         * {
         *      rigid.velocity = new Vector2(-15.0f, 0.0f);
         * }
         * if (Input.GetKey(KeyCode.Keypad6))
         * {
         *      rigid.velocity = new Vector2(15.0f, 0.0f);
         * }*/

        TerrainCollision(colliderWidth, colliderHeight);
        CheckIllegalPosition();

        if (!allowInput)
        {
            rigid.velocity     = Vector3.zero;
            rigid.gravityScale = 0.0f;
        }
        else if (rigid.gravityScale == 0.0f)
        {
            rigid.gravityScale = 1.0f;
        }

        //camera following and limiting
        if (allowCameraFollowing)
        {
            camFollow.UpdateCameraPosition();
        }

        //GameObject.Find("UI/Debug Text/Label").GetComponent<UILabel>().text = "velocity: " + rigid.velocity + "\ndeface: " + glideAllowDeFace + "\ndefaceDir: " + glideDefaceDirection + "\nfaceDirection: " + faceDirection;
    }