Пример #1
0
    //Ждет пока игрок прикоснется к экрану и начнет игру
    private void WaitTouchToLunch()
    {
        Vector2 currentMousePos = GetCurrentGMousePos();

        if (currentMousePos.y < boundManager.GetTopMiddleGameZone().y&& currentMousePos.y > boundManager.GetBotMiddleGameZone().y)
        {
            Vector2 startVector;
            if (Input.GetMouseButton(0) && !mouseDownIsDetected)
            {
                mouseDownIsDetected = true;
            }
            if (mouseDownIsDetected)
            {
                angle       = GetFixetAngle(Vector2.left, currentMousePos - startPosition);
                startVector = RotateVector(Vector2.left, angle) + startPosition;
                trajectorySimulator.SimulatePath(ballObjectsList[0], GetVectorByPoints(startPosition, startVector), segmentCount);
                if (!Input.GetMouseButton(0))
                {
                    lineRenderer.positionCount = 0;
                    //Запускает шарик
                    firstBallIsStoped   = false;
                    mouseDownIsDetected = false;
                    gameStatus          = GameStatus.LAUNCHED;
                    startBallsCoroutine = StartCoroutine(StartBall(ballObjectsList, GetVectorByPoints(startPosition, startVector)));
                }
            }
        }
        else if (mouseDownIsDetected && !Input.GetMouseButton(0))
        {
            lineRenderer.positionCount = 0;
            mouseDownIsDetected        = false;
        }
    }
Пример #2
0
    private void ProcessInput()
    {
        //jump
        if (cc.isGrounded)
        {
            moveVector.y = 0;
            if (jumpInput)
            {
                moveVector.y = jumpStrength;
            }
        }

        //dodge
        if (currentDodgeCooldown > 0.0f)
        {
            currentDodgeCooldown -= Time.deltaTime;
        }
        if (elapsedDodgeTime < dodgeDuration)
        {
            elapsedDodgeTime += Time.deltaTime;
            dodgeing          = true;
            moveVector        = dodgeVector;

            //if no direction, dodge backwards
            if (dodgeVector.x == 0 && dodgeVector.z == 0)
            {
                dodgeVector.z = -1;
            }
        }
        else
        {
            dodgeing = false;
        }

        //move
        moveVector.y -= gravity * Time.deltaTime;
        moveVector.x *= (dodgeing ? dodgeSpeed : moveSpeed) * Time.deltaTime;
        moveVector.z *= (dodgeing ? dodgeSpeed : moveSpeed) * Time.deltaTime;

        cc.Move(moveVector);


        if (transform.position.z * teamAxis > 0)
        {
            transform.position.Set(transform.position.x, transform.position.y, 0);
        }

        //rotate
        circleObject.transform.rotation = Quaternion.Euler(lookVector);
        ts.Enabled = false;

        //keep ball
        if (heldGameObject)
        {
            #region Update HeldObject
            heldGameObject.transform.position = new Vector3(this.transform.position.x, this.transform.position.y + 2, this.transform.position.z);
            heldGameObject.transform.rotation = Quaternion.Euler(new Vector3(-currentThrowAngle, lookVector.y, 0));
            Rigidbody rb = heldGameObject.GetComponent <Rigidbody>();
            rb.velocity = heldGameObject.transform.forward;
            #endregion

            if (dropInput)
            {
                heldGameObject = null;
                chargingBall   = false;
                throwInput     = false;
            }

            if (throwInput || chargingBall)
            {
                //charge
                chargingBall = true;

                currentThrowStrength = Mathf.Clamp(currentThrowStrength + (Time.deltaTime * chargeStrengthSpeed), 500, 1000);
                currentThrowAngle    = Mathf.Clamp(currentThrowAngle + (Time.deltaTime * chargeAngleSpeed), 0, 45);

                ts.SimulatePath(heldGameObject, (rb.velocity * throwStrength * simulationMultiplier) + new Vector3(0, 0, moveVector.z), rb.mass, rb.drag);
                ts.Enabled = true;
            }


            if (releaseInput && chargingBall)
            {
                chargingBall = false;
                ////throw
                rb.AddForce((heldGameObject.transform.forward * throwStrength) + new Vector3(0, 0, moveVector.z));

                heldGameObject = null;

                currentThrowStrength = throwStrength;
                currentThrowAngle    = throwAngle;
            }

            //let go of exploded bomb
            if (heldGameObject && heldGameObject.GetComponent <BombConroller>())
            {
                if (heldGameObject.GetComponent <BombConroller>().dissolve)
                {
                    heldGameObject = null;
                }
            }
        }

        if (throwInput)
        {
            //pickup
            if (outlinedGameObject && !outlinedGameObject.GetComponent <BombConroller>().dissolve)
            {
                heldGameObject     = outlinedGameObject;
                outlinedGameObject = null;
                heldGameObject.GetComponent <Animator>().enabled = true;
            }
        }
    }