Exemplo n.º 1
0
    public override void PlayerDroppedItem(HoldableItem droppedItem, PlayerController playerThatDroppedTheItem)
    {
        Disposable disposableItem = droppedItem.GetComponent <Disposable>();

        if (disposableItem != null)
        {
            GameManager.GameManagerSingleton.ModifyPlayerScore(playerThatDroppedTheItem.Player, -disposableItem.PointsDeductedForDisposing());
            disposableItem.Dispose(playerThatDroppedTheItem);
        }
    }
Exemplo n.º 2
0
    public override void PlayerDroppedItem(HoldableItem droppedItem, PlayerController player)
    {
        HoldableItem itemOnBoard = transform.GetComponentInChildren <HoldableItem>();

        if (itemOnBoard == null)
        {
            droppedItem.transform.parent   = transform;
            droppedItem.transform.position = transform.position;
            droppedItem.ToggleRigidBodyKinematic(true);
            choppableItemOnBoard = droppedItem.GetComponent <Choppable>();
            if (choppableItemOnBoard != null)
            {
                droppedItem.OnHoldStateChange.AddListener(OnChoppableItemOnBoardPickedUp);
                OnChoppableItemBoarded.Invoke(choppableItemOnBoard);
            }
        }
    }
    public override void PlayerDroppedItem(HoldableItem droppedItem, PlayerController playerThatDroppedTheItem)
    {
        // If the max ingredients are held in this bowl, then do nothing
        if (MaxIngredientsHeld())
        {
            return;
        }

        // Try and get the dropped item's food game object component
        FoodGameObject droppedFood = droppedItem.GetComponent <FoodGameObject>();

        if (droppedFood != null)
        {
            // If the dropped food is bowlable, then add the salad ingredient
            if (droppedFood.FoodIngredient.IsBowlable)
            {
                AddSaladIngredientToList(droppedFood);
            }
        }
    }
    /// <summary>
    /// Method called when the customer is served
    /// </summary>
    /// <param name="itemServed"></param>
    /// <param name="servingPlayer"></param>
    private void CustomerAreaServed(HoldableItem itemServed, PlayerController servingPlayer)
    {
        // Try to get the salad locator on the item served
        SaladLocator saladLocator = itemServed.GetComponent <SaladLocator>();

        // If the salad item is not null, then see if the salad ingredients match the order ingredients
        if (saladLocator != null)
        {
            // Check if the ingredient lists are the same
            if (AreIngredientListsTheSame(CustomerOrder, saladLocator.SaladBowlAttached.SaladIngredients))
            {
                // If yes, then the customer has been served
                customerServed = true;
                // Remove the listener from the on area served event
                servingArea.OnAreaServed.RemoveListener(CustomerAreaServed);
                // Consume the ingredients in the bowl
                saladLocator.SaladBowlAttached.ConsumeBowl();
                // Reward the corresponding player using the respective player logic handler
                if (customerLogicHandler != null)
                {
                    customerLogicHandler.RewardPlayer(servingPlayer.Player, this);
                }
                OnCustomerCorrectlyServed.Invoke(this);
            }
            // Otherwise, the player served the wrong order, call the player served wrong order
            else
            {
                PlayerServedWrongOder(servingPlayer);
            }
        }
        // If the item served is not a salad, make the customer angry lol
        else
        {
            PlayerServedWrongOder(servingPlayer);
        }
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        Vector2 input      = GetMovementInput();
        Vector2 mouseInput = GetMouseInput();
        float   rollInput  = GetRotationInput();
        float   vInput     = GetVerticalInput();

        Quaternion lookX    = Quaternion.AngleAxis(mouseInput.x, Vector3.up);
        Quaternion lookY    = Quaternion.AngleAxis(mouseInput.y, -Vector3.right);
        Quaternion lookRoll = Quaternion.AngleAxis(rollInput, -Vector3.forward);

        transform.localRotation = transform.localRotation * lookX * lookY * lookRoll;

        Vector3 move = (transform.forward * input.y) + (transform.right * input.x) + (transform.up * vInput);

        rb.velocity = move * Speed;

        GameObject objectInCrosshairs = GetObjectInCrosshairs();

        if (objectInCrosshairs != target)
        {
            if (target != null)
            {
                target.GetComponent <Outline>().enabled = false;
                target = null;
            }

            if (objectInCrosshairs != null)
            {
                objectInCrosshairs.GetComponent <Outline>().enabled = true;
                target = objectInCrosshairs;
            }
        }


        if (Input.GetMouseButtonDown(0))
        {
            if (heldItem == null)
            {
                if (objectInCrosshairs != null)
                {
                    HoldableItem holdable = objectInCrosshairs.GetComponent <HoldableItem>();
                    if (holdable)
                    {
                        holdable.PickUp(Hand);
                        heldItem           = holdable;
                        heldItem.OnThrown += OnDrop;
                        usableItem         = heldItem.GetComponent <UsableItem>();
                    }
                    else
                    {
                        UsableItem usable = objectInCrosshairs.GetComponent <UsableItem>();
                        if (usable)
                        {
                            usable.Use(gameObject, objectInCrosshairs);
                        }
                    }
                }
            }
            else
            {
                if (usableItem)
                {
                    usableItem.Use(gameObject, objectInCrosshairs);
                }
            }
        }

        if (heldItem != null && Input.GetMouseButtonDown(1))
        {
            heldItem.Drop(Hand);
            heldItem = null;
        }
    }