Beispiel #1
0
        private void FixedUpdate()
        {
            //Prevent player from moving outside
            if (Camera.main != null)
            {
                float   leftBound  = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x;
                float   rightBound = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, 0)).x;
                Vector3 position   = transform.position;
                position.x         = Mathf.Clamp(position.x, leftBound, rightBound);
                transform.position = position;
            }

            //Ground Check
            _onGround = Physics2D.OverlapArea(topLeft.position, bottomRight.position, groundLayer);
            if (buildMenu.IsShowing)
            {
                Rb.velocity = new Vector2(0, Rb.velocity.y);
                return;
            }

            //Movement
            Rb.velocity = new Vector2(_movementInput.x * baseMovementSpeed, Rb.velocity.y);
            //Aiming
            float angle = Vector2.SignedAngle(Vector2.right, _aimDirection);

            weapon.transform.eulerAngles = new Vector3(0, 0, angle);
            FlipEntity(angle > 90 || angle <= -90);

            // Show upgrade menu if necessary
            Building nearestBuilding = GetNearestBuildingInRange();

            if (nearestBuilding == null)
            {
                upgradeMenu.Hide();
            }
            else
            {
                upgradeMenu.ShowForBuilding(nearestBuilding);
            }
        }
Beispiel #2
0
 public void HideUpgradeMenu()
 {
     _upgradeMenu.Hide();
 }