コード例 #1
0
    void handleBroom()
    {
        if (AtlasInputManager.getKeyPressed("Broom") ||
            AtlasInputManager.getKeyPressed("Down") ||
            (!AtlasInputManager.getKey("Broom") &&
             AtlasInputManager.Instance.holdBroom))
        {
            endBroom();
            return;
        }
        if (AtlasInputManager.getKeyPressed("Jump") && canDoubleJump && resourceManager.Instance.getPlayerMana() >= 1)
        {
            endBroom();
            if (hasDoubleJump)
            {
                doubleJump();
            }
            return;
        }
        if ((facing == -1) ? controller.collisions.left : controller.collisions.right)
        {
            startBonk();
            return;
        }
        float vdir = 0 * AtlasInputManager.getAxisState("Dpad").y;

        velocity.y = moveSpeed / 2.0f * vdir;
        velocity.x = moveSpeed * 2 * facing;
    }
コード例 #2
0
    void Update()
    {
        Vector2 input = AtlasInputManager.getAxisState("Dpad");

        if (input.x == 0 && input.y == 0)
        {
            selectIcon.transform.localPosition = Vector2.zero;
            selectIcon.SetActive(false);
            return;
        }
        selectIcon.SetActive(true);
        float theta = Mathf.Atan2(input.y, input.x);

        theta *= Mathf.Rad2Deg;
        theta += 360.0f;
        int index = (int)Mathf.Round(theta / 45.0f);

        index   %= 8;
        selected = index;
        selectIcon.transform.localPosition = Vector2.SmoothDamp(
            selectIcon.transform.localPosition,
            input.normalized,
            ref selectIconVel,
            0.05f);
    }
コード例 #3
0
 void handleUncrouch()
 {
     checkCrouchHitbox();
     if (dropThroughPlatforms && AtlasInputManager.getAxisState("Dpad").y >= 0 || isGrounded())
     {
         dropThroughPlatforms = false;
     }
 }
コード例 #4
0
    public void takeStep(float stepSize)
    {
        stepSize = 0.175f;
        if (Mathf.Ceil(AtlasInputManager.getAxisState("Dpad").x) != pc.facing)
        {
            return;
        }
        Vector3 velocity = stepSize * pc.facing * Vector3.right + .01f * Vector3.down;

        pc.controller.Move(velocity);
    }
コード例 #5
0
 void allowCrouch()
 {
     if (AtlasInputManager.getAxisState("Dpad").y < 0 && isGrounded())
     {
         anim.SetBool("isCrouching", true);
     }
     else if (controller.checkVertDist(0.3f))
     {
         anim.SetBool("isCrouching", false);
     }
 }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if (!AtlasInputManager.getKey("Scout"))
        {
            Destroy(gameObject);
        }
        if (selectedPc && AtlasInputManager.getKeyPressed("Jump"))
        {
            textPanel.SetActive(true);
            textPanel.GetComponentInChildren <TextMeshProUGUI>().text = selectedPc.scoutMessage.Replace("\\n", "\n");
        }
        Vector2 velocity = AtlasInputManager.getAxisState("Dpad");

        transform.Translate(velocity * speed * Time.deltaTime);
    }
コード例 #7
0
    //State BroomStart waits for Atlas to get on Broom. Animator calls startBroom
    void handleBroomStart()
    {
        anim.SetTrigger("broomStart");
        SoundManager.Instance.playClip("onBroom");
        deformer.RemoveDeform("fastfall");
        deformer.RemoveDeform("jump");
        if (state == State.Attack)
        {
            setFacing(AtlasInputManager.getAxisState("Dpad").x);
        }
        //if (AtlasInputManager.Instance.aimAtMouse())
        //{
        //    setFacing(AtlasInputManager.Instance.getPlayerAim(true).x);
        //}

        state     = fastBroom ? State.Broom : State.Wait;
        fastBroom = false;
        velocity  = Vector3.zero;
    }
コード例 #8
0
    void isWallSliding()
    {
        if (isGrounded() || state == State.Attack)
        {
            wallRiding = false;
            return;
        }
        float hdir = AtlasInputManager.getAxisState("Dpad").x;

        if (!wallRiding)
        {
            if (controller.collisions.wallRideLeft && hdir == -1 || controller.collisions.wallRideRight && hdir == 1)
            {
                wallRiding = true;
                return;
            }
        }
        else
        {
            wallRiding = controller.collisions.wallRideLeft || controller.collisions.wallRideRight;
            return;
        }
        wallRiding = false;
    }
コード例 #9
0
 //Popping a WooshBerry calls this.
 public void triggerBroomStart(bool fast = false, float dir = 0)
 {
     if (resetPosition || !controller.collisions.tangible)
     {
         return;
     }
     if (intangibleStates.Contains(state))
     {
         return;
     }
     //Cancel is ceiling above while crouching
     if (isCrouching() && !controller.checkVertDist(0.3f))
     {
         return;
     }
     if (dir == 0 && !wallRiding)
     {
         dir = AtlasInputManager.getAxisState("Dpad").x;
     }
     setFacing(dir);
     state     = State.BroomStart;
     fastBroom = fast;
     canBroom  = false;
 }
コード例 #10
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        playerController pc = animator.gameObject.GetComponentInParent <playerController>();

        foreach (AnimatorControllerParameter key in animator.parameters)
        {
            if (key.type == AnimatorControllerParameterType.Trigger)
            {
                animator.ResetTrigger(key.name);
            }
        }
        animator.SetBool("Attacking", true);

        bool up   = false;
        bool down = false;

        if (AtlasInputManager.Instance.aimAtMouse())
        {
            Vector2 aim = AtlasInputManager.Instance.getPlayerAim(true);
            up   = aim.y > 0;
            down = pc.isGrounded() ? pc.isCrouching() : aim.y < 0;
            if (aim.x != 0)
            {
                pc.setFacing(aim.x);
            }
        }
        else
        {
            up   = AtlasInputManager.getAxisState("Dpad").y > 0.1f;
            down = AtlasInputManager.getAxisState("Dpad").y < -0.1f || pc.isCrouching();
        }

        bool falling = (pc.velocity.y < -0.1);

        if (up)
        {
            animator.SetTrigger("UpAttack");
            SoundManager.Instance.playClip("BroomAttacks/LightAttack", Random.Range(-1, 1));
        }
        else if (down)
        {
            animator.SetTrigger("DownAttack");
            SoundManager.Instance.playClip("BroomAttacks/LightAttack", Random.Range(-1, 1));
        }
        else
        {
            if (!pc.isGrounded())
            {
                if (falling)
                {
                    animator.SetTrigger("FallingAttack");
                }
                else
                {
                    animator.SetTrigger("RisingAttack");
                }
            }
            else
            {
                animator.SetTrigger("Attack");
            }
            SoundManager.Instance.playClip("BroomAttacks/LightAttack", Random.Range(-1, 1));
        }
    }
コード例 #11
0
    void handleMovement(float msMod = 1.0f, bool canJump = true, bool canTurnAround = true)
    {
        if (heldObject != null)
        {
            msMod  *= 0.5f;
            canJump = false;
        }

        Vector2 input = new Vector2(0, 0);

        if (!(state == State.WaitMoveable && isGrounded()))
        {
            input = new Vector2(AtlasInputManager.getAxisState("Dpad").x, AtlasInputManager.getAxisState("Dpad").y);
        }

        if (isGrounded() || coyoteTime > 0)
        {
            if (AtlasInputManager.getKeyPressed("Jump") && canJump)
            {
                firstJump();
            }
            if (AtlasInputManager.getKeyPressed("Broom"))
            {
                triggerBroomStart();
            }
            if (isGrounded())
            {
                if (!canBroom && state == State.Movement)
                {
                    canBroom = true;
                }
                canDoubleJump = true;
                resourceManager.Instance.restoreMana();
            }
        }
        else
        {
            if (canBroom && AtlasInputManager.getKeyPressed("Broom"))
            {
                if (wallRiding)
                {
                    flipHorizontal();
                    triggerBroomStart(fastBroom, facing);
                }
                else
                {
                    triggerBroomStart(fastBroom);
                }
                return;
            }

            if (hasWallJump && wallRiding && AtlasInputManager.getKeyPressed("Jump") && resourceManager.Instance.getPlayerMana() >= 2)
            {
                state = State.WallJumpInit;
                return;
            }

            if (hasDoubleJump && AtlasInputManager.getKeyPressed("Jump") && canJump && canDoubleJump && resourceManager.Instance.getPlayerMana() >= 1)
            {
                doubleJump();
            }
        }

        float currentMoveSpeed = moveSpeed;

        if (isCrouching())
        {
            currentMoveSpeed = 1.5f;
        }
        float targetVelocityX = input.x * currentMoveSpeed * msMod;

        anim.SetBool("isRunning", isGrounded() && (targetVelocityX != 0));
        anim.SetBool("isJumping", !isGrounded() && (velocity.y > 0) && canDoubleJump);
        anim.SetBool("isFalling", !isGrounded() && (velocity.y < -0.5f) && !controller.collisions.descendingSlope && !heldObject);
        anim.SetBool("wallSlide", wallRiding);
        if (wallRiding)
        {
            deformer.RemoveDeform("jump");
            deformer.RemoveDeform("fastfall");
        }

        if (canTurnAround)
        {
            setFacing(velocity.x);
        }

        velocity.x  = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisions.below) ? groundAccelerationTime : airAccelerationTime);
        velocity.y += gravity * Time.deltaTime * ((wallRiding && velocity.y <= 0) ? 0.5f : 1.0f);

        if (wallRiding && velocity.y < maxWallSlideVel)
        {
            velocity.y = maxWallSlideVel;
        }

        float termVel;

        if (fastFalling)
        {
            if (AtlasInputManager.getAxisState("Dpad").y >= 0 || isGrounded() || velocity.y > 0)
            {
                fastFalling = false;
            }
            termVel     = fastFallVel;
            velocity.y += gravity * Time.deltaTime;
        }
        else
        {
            termVel = maxFallVel;
            deformer.RemoveDeform("fastfall");
            if (AtlasInputManager.getKeyPressed("Down") && !isGrounded() && (velocity.y <= 0.5f || !AtlasInputManager.getKey("Jump")))
            {
                fastFalling = true;
                deformer.startDeform(new Vector3(0.85f, 1.4f, 1.0f), 0.2f, -1.0f, -1.0f, "fastfall", true);
            }
        }
        if (velocity.y < termVel)
        {
            velocity.y = termVel;
        }

        if (velocity.y <= 0 && controller.isSafePosition())
        {
            lastSafePosition = transform.position;
        }
    }