Exemple #1
0
    private void OnTriggerExit(Collider other)
    {
        GameObject otherObject = other.gameObject;

        if (otherObject.tag == "Planted" || otherObject.tag == "SpawnPoint")
        {
            Collider  collider  = GetComponent <Collider>();
            Rigidbody rigidbody = GetComponent <Rigidbody>();

            isTimerRun           = false;
            rigidbody.useGravity = true;
            collider.isTrigger   = false;
            transform.parent     = null;

            if (otherObject.tag == "Planted" && !isPicked)
            {
                GroundBehavior ground = otherObject.GetComponent <GroundBehavior>();
                ground.isReset = true;
            }
            else if (otherObject.tag == "SpawnPoint" && !isPicked)
            {
                PolyCarpicRespawn spawnPoint = otherObject.GetComponent <PolyCarpicRespawn>();
                spawnPoint.isFertile = false;
            }
            isPicked = true;
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        PolyCarpicRespawn fruitVariable1 = fruitRespawn1.GetComponent <PolyCarpicRespawn>();
        PolyCarpicRespawn fruitVariable2 = fruitRespawn2.GetComponent <PolyCarpicRespawn>();
        PolyCarpicRespawn fruitVariable3 = fruitRespawn3.GetComponent <PolyCarpicRespawn>();

        if (isReady)
        {
            if (!stopGrow)
            {
                if (transform.position.y > 0.65f)
                {
                    stopGrow = true;
                }
                else
                {
                    transform.position = new Vector3(transform.position.x, transform.position.y + 0.01f, transform.position.z);
                }
            }

            //first time
            currentTime += Time.deltaTime;
            if (currentTime > spawnTime)
            {
                fruitVariable1.isReady = true;
                fruitVariable2.isReady = true;
                fruitVariable3.isReady = true;
            }
        }
        else
        {
            fruitVariable1.isReady = false;
            fruitVariable2.isReady = false;
            fruitVariable3.isReady = false;
        }

        if (isFertilized)
        {
            fruitVariable1.isFertilized = true;
            fruitVariable2.isFertilized = true;
            fruitVariable3.isFertilized = true;
        }
        else
        {
            fruitVariable1.isFertilized = false;
            fruitVariable2.isFertilized = false;
            fruitVariable3.isFertilized = false;
        }
    }
Exemple #3
0
    private void OnTriggerStay(Collider other)
    {
        GameObject otherObject = other.gameObject;

        if (otherObject.tag == "Planted")
        {
            GroundBehavior ground = otherObject.GetComponent <GroundBehavior>();
            if (ground.isWatered)
            {
                isReady = true;
            }

            if (ground.isFertile && !isFertilized)
            {
                valuePlant  += valuePlant * 10 / 100;
                isFertilized = true;
            }

            //Check weed
            if (ground.isWeed)
            {
                isWeed = true;
            }
            else
            {
                isWeed = false;
            }
        }
        else if (otherObject.tag == "SpawnPoint")
        {
            PolyCarpicRespawn spawnPoint = otherObject.GetComponent <PolyCarpicRespawn>();
            if (spawnPoint.isFertile && !isFertilized)
            {
                valuePlant  += valuePlant * 10 / 100;
                isFertilized = true;
            }
        }

        else if (otherObject.tag == "Mole")
        {
            Transform molePos = otherObject.GetComponent <Transform>();
            transform.position = new Vector3(transform.position.x, molePos.transform.position.y + 0.28f, transform.position.z);
        }
    }