Exemple #1
0
    private void FixedUpdate()
    {
        if (!GameManager.IsGamePaused())
        {
            // Find nearest bunny
            float      nearestDistance = _grabRadius;
            GameObject nearestBunny    = null;
            foreach (var bunny in GameObject.FindGameObjectsWithTag("Bunny"))
            {
                float bunnyDistance = Vector2.Distance(bunny.transform.position, transform.position);
                if (bunnyDistance < nearestDistance)
                {
                    nearestDistance = bunnyDistance;
                    nearestBunny    = bunny.gameObject;
                }
            }

            if (Input.GetMouseButtonDown(0))
            {
                // If we can drop a bunny
                if (CanDropBunny())
                {
                    if (interactionController.GetIsInBunnyDropZone())
                    {
                        DropObject();
                    }
                    else if (interactionController.GetIsInMotorZone() || interactionController.GetIsInDeliveryZone())
                    {
                        UseBunny();
                    }
                }
                else if (nearestBunny != null)
                {
                    if (interactionController.GetIsInBunnyDropZone())
                    {
                        // Grab nearest bunny if there is one
                        HoldObject(nearestBunny);
                    }
                    else
                    {
                        UseZone();
                    }
                }
                else if (_holdedObject == null)
                {
                    UseZone();
                }
            }

            if (interactionController.GetIsInWallZone())
            {
                tooltipManager.ToggleRepairIcon(true);
            }
            else
            {
                tooltipManager.ToggleRepairIcon(false);
            }
        }
    }