示例#1
0
    private GameObject generateBaseGathered(GatherableType ofType)
    {
        GameObject generatedObject;

        switch (ofType)
        {
        case GatherableType.Dirt: {
            generatedObject = Instantiate(dirtPrefab, gatherPoint.transform.position, Quaternion.identity);
            break;
        }

        case GatherableType.Water: {
            generatedObject = Instantiate(waterPrefab, gatherPoint.transform.position, Quaternion.identity);
            break;
        }

        default: {
            generatedObject = Instantiate(waterPrefab, gatherPoint.transform.position, Quaternion.identity);
            break;
        }
        }

        Rigidbody targetRb = generatedObject.GetComponent <Rigidbody>();

        targetRb.isKinematic = true;

        generatedObject.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);

        return(generatedObject);
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        currentType = gatherer.getBucketType();


        if (Input.GetKey(KeyCode.RightShift))
        {
            //TODO: DEBUG THIS SO IT ONLY TAKES THE ONE TYPE
            gatherer.GatherTargets(currentType);
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            gatherer.blowFromBucket();
        }
    }
示例#3
0
    public void blowFromBucket()
    {
        if (getBucketCount() > 0)
        {
            GameObject     inHand        = gatherBucket[0];
            Gatherable     inHandGScript = inHand.GetComponent <Gatherable>();
            GatherableType inHandType    = inHandGScript.gatherType;

            if (targets.Count > 0)
            {
                foreach (GameObject target in targets)
                {
                    Gatherable     targetGScript = target.GetComponent <Gatherable>();
                    GatherableType targetType    = targetGScript.gatherType;

                    if (targetType == inHandType)
                    {
                        float inHandScaleX = inHand.transform.localScale.x;
                        float inHandScaleY = inHand.transform.localScale.y;
                        float inHandScaleZ = inHand.transform.localScale.z;

                        if (inHandScaleX > 0 && inHandScaleY > 0 && inHandScaleZ > 0)
                        {
                            inHand.transform.localScale =
                                new Vector3(inHand.transform.localScale.x - 0.01f,
                                            inHand.transform.localScale.y - 0.01f,
                                            inHand.transform.localScale.z - 0.01f);

                            target.transform.localScale =
                                new Vector3(target.transform.localScale.x + 0.01f,
                                            target.transform.localScale.y + 0.01f,
                                            target.transform.localScale.z + 0.01f);
                        }
                    }
                    else
                    {
                        generateBaseReturned(inHandType);
                    }
                }
            }
            else
            {
                generateBaseReturned(inHandType);
            }
        }
    }
示例#4
0
 // Start is called before the first frame update
 void Start()
 {
     gatherer    = gameObject.GetComponentInChildren <Gatherer>();
     currentType = GatherableType.All;
 }