public void GenerateGiantAcorn(int num)
    {
        for (int i = 0; i < num; i++)
        {
            GameObject newAcorn = Instantiate(acornPrefeb, transform);
            float      pos_x    = Random.Range(0.5f, 0.7f);
            float      pos_z    = Random.Range(0.5f, 0.6f);
            int        pos      = Random.Range(0, 4);
            switch (pos)
            {
            case 0:
                newAcorn.transform.position = new Vector3(pos_x, newAcorn.transform.position.y, pos_z);
                break;

            case 1:
                newAcorn.transform.position = new Vector3(-pos_x, newAcorn.transform.position.y, pos_z);
                break;

            case 2:
                newAcorn.transform.position = new Vector3(-pos_x, newAcorn.transform.position.y, -pos_z);
                break;

            case 3:
                newAcorn.transform.position = new Vector3(pos_x, newAcorn.transform.position.y, -pos_z);
                break;
            }
            float scaleSize = Random.Range(16.0f, 18.0f);
            newAcorn.transform.localScale = new Vector3(scaleSize, scaleSize, scaleSize);
            newAcorn.transform.Rotate(Random.Range(0.0f, 180.0f), Random.Range(0.0f, 180.0f), Random.Range(0.0f, 180.0f));
            GiantAcornScript giantScript = newAcorn.GetComponent <GiantAcornScript>();
            giantScript.setGiant(true);
        }
    }
    IEnumerator GenerateGiantAcorn()
    {
        if (numberOfGiantAcorn > 0)
        {
            numberOfGiantAcorn--;
            yield return(new WaitForSeconds(1.5f));

            GameObject newAcorn = Instantiate(acornPrefeb, transform);
            newAcorn.transform.position = new Vector3(Random.Range(-0.3f, 0.3f), newAcorn.transform.position.y, Random.Range(-0.3f, 0.3f));
            float scaleSize = Random.Range(14.0f, 18.0f);
            newAcorn.transform.localScale = new Vector3(scaleSize, scaleSize, scaleSize);
            newAcorn.transform.Rotate(Random.Range(0.0f, 180.0f), Random.Range(0.0f, 180.0f), Random.Range(0.0f, 180.0f));
            GiantAcornScript giantScript = newAcorn.GetComponent <GiantAcornScript>();
            giantScript.setGiant(true);
            StartCoroutine(GenerateGiantAcorn());
        }
    }
Example #3
0
    private void Update()
    {
        if (Controller.GetHairTriggerDown())
        {
            clawAnimator.SetBool("isClawGrab", true);
            if (collidingObject)
            {
                GiantAcornScript giantScript = collidingObject.GetComponent <GiantAcornScript>();
                if (giantScript)
                {
                    if (giantScript.getGiant())
                    {
                        if (giantScript.getIsHeldByLeft() && giantScript.getIsHeldByRight())
                        {
                            GrabObject();
                        }
                    }
                    else
                    {
                        GrabObject();
                    }
                }
            }
        }

        if (Controller.GetHairTriggerUp())
        {
            clawAnimator.SetBool("isClawGrab", false);
            if (objectInHand)
            {
                ReleaseObject();
            }
        }

        if (objectInHand && collidingObject)
        {
            GiantAcornScript giantScript = collidingObject.GetComponent <GiantAcornScript>();
            if (giantScript && giantScript.getGiant())
            {
                if ((!giantScript.getIsHeldByLeft()) || (!giantScript.getIsHeldByRight()))
                {
                    ReleaseObject();
                }
            }
        }
    }
Example #4
0
    public void OnTriggerExit(Collider other)
    {
        if (!collidingObject)
        {
            return;
        }
        GiantAcornScript giantScript = collidingObject.GetComponent <GiantAcornScript>();

        if (giantScript)
        {
            if (isLeft)
            {
                giantScript.SetLeftHand(false);
            }
            else
            {
                giantScript.SetRightHand(false);
            }
        }
        collidingObject = null;
    }
Example #5
0
    private void SetCollidingObject(Collider col)
    {
        if (collidingObject || !col.GetComponent <Rigidbody>())
        {
            return;
        }

        collidingObject = col.gameObject;
        GiantAcornScript giantScript = collidingObject.GetComponent <GiantAcornScript>();

        if (giantScript)
        {
            if (isLeft)
            {
                giantScript.SetLeftHand(true);
            }
            else
            {
                giantScript.SetRightHand(true);
            }
        }
    }