예제 #1
0
 private void InitialCellBehaviour()
 {
     allCells = tgs.cells;
     foreach (Cell cell in allCells)
     {
         int cellIndex = tgs.CellGetIndex(cell);
         //green = wood;
         if (tgs.CellGetTexture(cellIndex) == tgs.textures[1])
         {
             tgs.CellSetCrossCost(cellIndex, 2);
             tgs.CellToggleRegionSurface(cellIndex, false, tgs.textures[1]);
             tgs.CellSetGroup(cellIndex, group1);
         }
         //apple = swamp
         else if (tgs.CellGetTexture(cellIndex) == tgs.textures[2])
         {
             tgs.CellSetCrossCost(cellIndex, 4);
             tgs.CellToggleRegionSurface(cellIndex, false, tgs.textures[2]);
             tgs.CellSetGroup(cellIndex, group2);
         }
         //map = mountain
         else if (tgs.CellGetTexture(cellIndex) == tgs.textures[3])
         {
             tgs.CellSetCanCross(cellIndex, false);
             tgs.CellToggleRegionSurface(cellIndex, false, tgs.textures[3]);
         }
     }
 }
예제 #2
0
    void Start()
    {
        // playAud = GetComponent<playSequence>();
        //grabs Audio
        treeSounds = gameObject.AddComponent <AudioSource>();
        //TerrainGridSystem ref
        tgs            = TerrainGridSystem.instance;
        randomRotation = 60 * Random.Range(0, 6);
        // Clone Sapling prefabs and Instantiate
        groundTile = tgs.CellGetAtPosition(transform.position, true);
        //transform.SetParent ();
        cellIndex = tgs.CellGetIndex(groundTile);
        neighbors = tgs.CellGetNeighbours(groundTile);
        tgs.CellSetCanCross(cellIndex, false);
        //fills up neighborIndexes with the proper cell indexes
        for (int i = 0; i < neighbors.Count; i++)
        {
            int index = tgs.CellGetIndex(neighbors[i]);
            neighborIndexes.Add(index);
            neighbourPos[i] = tgs.CellGetPosition(index);
            //this gives you neighbor cell position
            //can be used to see which cell you’re being given
            //raycast to this position to get the plant collider and get the sequencer
            if (tgs.CellGetTag(index) == 1)
            {
                //this cell has a tree planted, but don’t run this in start
                //send to an array of “plants nearby”

                //for any rule make a bool in plantlife for “isFollowingRule” to see if neighbours are occupied or following a rule already
                //are two adjacent cells in the index occupied that’s a triad
                //if all cells are occupied that’s an arp, arp beats triad
            }
        }


        if (plantedInEditor)
        {
            ageCounter        -= 1;
            transform.position = tgs.CellGetPosition(cellIndex);
            tgs.CellSetTag(cellIndex, 1);
            tgs.CellToggleRegionSurface(cellIndex, true, growingTexture);
        }
        else
        {
            //Set age and fruit
            ageCounter = 0;
            //fruitAmount = 0;
            growthPeriod = 1;
        }
        StartCoroutine(Growth());
    }
예제 #3
0
    //	note = seq.GetAllNoteOnsInRange (0, 96);

    //	newNote = note [0];
    void Update()
    {
        if (hasGrown)
        {
            switch (ageCounter)
            {
            case 1:     //Sapling
                hasGrown = false;
                playAud.changedSequence = false;
                tgs.CellToggleRegionSurface(cellIndex, true, growingTexture);
                saplingClone = Instantiate(sapling, transform.position, Quaternion.Euler(0, randomRotation, 0), transform);
                currentTree  = saplingClone.transform;
                growthDay    = Random.Range(2, 4);
                StartCoroutine(Growth());
                break;

            /*  case 1: //Young
             *    hasGrown = false;
             *    playAud.clipsSwitched = false;
             *    youngClone = Instantiate(young, transform.position, Quaternion.Euler(0, randomRotation, 0));
             *    Destroy(saplingClone);
             *    currentTree = youngClone.transform;
             *    fruitAmount = Random.Range(0, 2);
             *    growthDay = Random.Range(3, 5);
             *    StartCoroutine(Growth());
             *    break; */

            case 2:                     //Adult
                hasGrown = false;
                playAud.changedSequence = false;
                Destroy(saplingClone);
                adultClone  = Instantiate(adult, transform.position, Quaternion.Euler(0, randomRotation, 0), transform);
                currentTree = adultClone.transform;
                fruitAmount = Random.Range(0, 2);
                growthDay   = Random.Range(3, 6);
                StartCoroutine(Growth());
                break;

            case 3:     // Old
                hasGrown = false;
                playAud.changedSequence = false;
                Destroy(adultClone);
                oldClone    = Instantiate(old, transform.position, Quaternion.Euler(0, randomRotation, 0), transform);
                currentTree = oldClone.transform;
                fruitAmount = Random.Range(0, 2);
                growthDay   = Random.Range(3, 10);
                StartCoroutine(Growth());
                break;

            case 4:     // Dead
                hasGrown = false;
                playAud.changedSequence = false;
                Destroy(oldClone);
                currentTree = null;
                //Takes current cell and sets it back to normal Ground for tree death

                tgs.CellSetTag(groundTile, 0);
                tgs.CellToggleRegionSurface(cellIndex, true, groundTexture);
                tgs.CellSetCanCross(cellIndex, true);
                //Death
                Destroy(gameObject);
                //stumpClone = Instantiate(stump, transform.position, Quaternion.Euler(0, randomRotation, 0));
                // silence after death or leftover ringing in Stump
                //THIS IS WHERE I SHOULD INCORPORATE POSSIBILITY OF ANCIENT
                break;
            }
        }
        //		seq.OnNoteOn (newNote);
        //	currentTree.localScale = Vector3.Lerp (new Vector3(1.2f, 1.2f, 1.2f), new Vector3(1.4f, 1.4f, 1.4f), Mathf.PingPong(Time.time, 1));
        //} else {
        //	currentTree.localScale = Vector3.Lerp (currentTree.localScale, new Vector3 (1f, 1f, 1f), Time.deltaTime);

        //}
        //}
    }