コード例 #1
0
    void Update()
    {
        // item drop
        if (Input.GetButtonDown("Action"))
        {
            if (carryItem && enteredEntrance && !enteredEntrance.IsGuarded())
            {
                // drop item on entrance
                enteredEntrance.ItemPlaced();
                enteredEntrance.ActivateGuard(carriedItemController);

                playerItemIndicator.ItemDropped();
                carriedItemController.ItemDrop(enteredEntrance.gameObject.transform.position);
                carryItem = false;

                gameManager.appManager.soundManager.Play(SoundManager.soundId.itemPlaced);
            }
            else if (!carryItem && enteredEntrance && enteredEntrance.IsGuarded())
            {
                // pickup item from guarded entrance
                enteredEntrance.ItemRemoved();
                carriedItemController = enteredEntrance.DeactivateGuard();

                carriedItemController.ItemPickedUp();

                carryItem = true;
                playerItemIndicator.ItemPickedUp();

                gameManager.PlayerItemPickup();
            }
            else if (carryItem && enteredAltar)
            {
                // drop item on altar
                enteredAltar.ItemPlaced();
                enteredAltar.BeginSacrifice(carriedItemController);

                playerItemIndicator.ItemDropped();
                carriedItemController.ItemDrop(enteredAltar.gameObject.transform.position);
                carryItem = false;

                gameManager.appManager.soundManager.Play(SoundManager.soundId.itemPlaced);
            }
            else
            {
                // action denied
                gameManager.appManager.soundManager.Play(SoundManager.soundId.actionDenied);
            }
        }
    }