Esempio n. 1
0
    public void Interact()
    {
        Collider[] colliders = Physics.OverlapSphere(Hands.position, GrabRange, WhatCanBeTaken);
        if (colliders.Length > 0 && canTakeItems && !colliders[0].gameObject.GetComponent <Idol>().onPlayer)
        {
            itemInHands  = colliders[0].gameObject.GetComponent <Idol>();
            canTakeItems = false;

            if (itemInHands.status == IdolRepairedStatus.broken)
            {
                Image.ChangeImageSprite(playerImages.Workbench_1);
            }

            if (itemInHands.myPlayerIndex == playerIndex)
            {
                if (itemInHands.status == IdolRepairedStatus.repaired)
                {
                    Image.ChangeImageSprite(playerImages.Altar);
                }
                else if (itemInHands.level == 2)
                {
                    if (itemInHands.status == IdolRepairedStatus.broken)
                    {
                        Image.ChangeImageSprite(playerImages.Workbench_1);
                    }
                    else if (itemInHands.status == IdolRepairedStatus.semiBroken)
                    {
                        Image.ChangeImageSprite(playerImages.Workbench_2);
                    }
                    else if (itemInHands.status == IdolRepairedStatus.repaired)
                    {
                        Image.ChangeImageSprite(playerImages.Altar);
                    }
                }
            }
            else
            {
                if (itemInHands.status != IdolRepairedStatus.broken)
                {
                    Image.ChangeImageSprite(playerImages.Workbench_3);
                }
            }

            Pedestal pedestal = itemInHands.transform.parent.GetComponent <Pedestal>();
            if (pedestal != null)
            {
                pedestal.isOccupied = false;
            }

            Altar altar = itemInHands.transform.parent.GetComponent <Altar>();
            if (altar != null)
            {
                altar.ResetAltar();
            }

            Image.ChangeImageState();
            itemInHands.transform.parent   = transform;
            itemInHands.transform.position = new Vector3(transform.position.x, transform.position.y + selfCollider.height, transform.position.z);
            itemInHands.onPlayer           = true;
            audioSource.clip = audioFx.iteraction;
            audioSource.Play();
        }
    }