public void OnDayChange()
    {
//		Debug.Log ("yesterday was " + lastDayNum + ", today is " + dayNum);

        mangroveList.Clear();
        reedList.Clear();
        mangroveList.AddRange(GameObject.FindGameObjectsWithTag("Mangrove"));
        reedList.AddRange(GameObject.FindGameObjectsWithTag("Invasive"));

        reedPosition = new Vector3(Mathf.Round(this.transform.position.x), 0, Mathf.Round(this.transform.position.z));
        reedRight    = reedPosition + new Vector3(10, 0, 0);
        reedLeft     = reedPosition + new Vector3(-10, 0, 0);
        reedUp       = reedPosition + new Vector3(0, 0, 10);
        reedDown     = reedPosition + new Vector3(0, 0, -10);

        destroySpots.Clear();
//		destroySpots.Add (reedPosition);
        destroySpots.Add(reedUp);
        destroySpots.Add(reedDown);
        destroySpots.Add(reedRight);
        destroySpots.Add(reedLeft);

        foreach (GameObject tile in tileList)
        {
            tileReference = tile.GetComponent <TileSelect> ();
            tileReference.TileReference();
            foreach (Vector3 position in destroySpots)
            {
                if (Mathf.Approximately(tileReference.tilePosition.x, position.x) && Mathf.Approximately(tileReference.tilePosition.z, position.z))
                {
//					Debug.Log ("found tile");
                    if (tileReference.reedPresent != true && tileReference.mangrovePresent != true)
                    {
//						Debug.Log ("time to spread");
                        Instantiate(newReed, position, Quaternion.identity);
                    }
                }
//				Debug.Log (marshPosition + " marsh spot position");
//				if (Mathf.Approximately(position.x, marshPosition.x) && Mathf.Approximately(position.z, marshPosition.y)) {
//					Debug.Log ("reed growth POTENTIAL");
//					foreach (GameObject reed in reedList) {
//						otherReed = reed.transform.position;
//						if (position.x != otherReed.x && position.z != otherReed.z) {
//							Debug.Log ("reed growth???");
//
//
//						}
//					}
//				}
            }

//			foreach (GameObject mangrove in mangroveList) {
//				mangrovePosition = mangrove.transform.position;
//				if (position.x != mangrovePosition.x && position.z != mangrovePosition.z) {
//					Debug.Log ("reed growth");
//					Instantiate (reed, position, Quaternion.identity);
//				}
//			}
        }
    }
	public void OnDayChange () {
//		Debug.Log ("yesterday was " + lastDayNum + ", today is " + dayNum);

		mangroveList.Clear ();
		reedList.Clear ();
		mangroveList.AddRange (GameObject.FindGameObjectsWithTag ("Mangrove"));
		reedList.AddRange(GameObject.FindGameObjectsWithTag ("Invasive"));

		reedPosition = new Vector3 (Mathf.Round (this.transform.position.x), 0, Mathf.Round (this.transform.position.z));
		reedRight = reedPosition + new Vector3 (10, 0, 0);
		reedLeft = reedPosition + new Vector3 (-10, 0, 0);
		reedUp = reedPosition + new Vector3 (0, 0, 10);
		reedDown = reedPosition + new Vector3 (0, 0, -10);

		destroySpots.Clear();
//		destroySpots.Add (reedPosition);
		destroySpots.Add (reedUp);
		destroySpots.Add (reedDown);
		destroySpots.Add (reedRight);
		destroySpots.Add (reedLeft);

		foreach (GameObject tile in tileList) {
			tileReference = tile.GetComponent<TileSelect> ();
			tileReference.TileReference();
			foreach (Vector3 position in destroySpots) {
				if (Mathf.Approximately(tileReference.tilePosition.x, position.x) && Mathf.Approximately(tileReference.tilePosition.z, position.z)) {
//					Debug.Log ("found tile");
					if (tileReference.reedPresent != true && tileReference.mangrovePresent != true){
//						Debug.Log ("time to spread");
						Instantiate (newReed, position, Quaternion.identity);

					}

				}
//				Debug.Log (marshPosition + " marsh spot position");
//				if (Mathf.Approximately(position.x, marshPosition.x) && Mathf.Approximately(position.z, marshPosition.y)) {
//					Debug.Log ("reed growth POTENTIAL");
//					foreach (GameObject reed in reedList) {
//						otherReed = reed.transform.position;
//						if (position.x != otherReed.x && position.z != otherReed.z) {
//							Debug.Log ("reed growth???");
//
//
//						}
//					}
//				} 
			}

//			foreach (GameObject mangrove in mangroveList) {
//				mangrovePosition = mangrove.transform.position;
//				if (position.x != mangrovePosition.x && position.z != mangrovePosition.z) {
//					Debug.Log ("reed growth");
//					Instantiate (reed, position, Quaternion.identity);
//				} 
//			}
		}
	}
Exemplo n.º 3
0
    public void OnDayChange()
    {
        trashPosition = new Vector3(Mathf.Round(this.transform.position.x), 0, Mathf.Round(this.transform.position.z));
        trashRight    = trashPosition + new Vector3(10, 0, 0);
        //		Debug.Log (personRight + " person, " + playerPosition + " player");
        trashLeft = trashPosition + new Vector3(-10, 0, 0);
        //		Debug.Log (personLeft + " person, " + playerPosition + " player");
        trashUp = trashPosition + new Vector3(0, 0, 10);
        //		Debug.Log (personUp + " person, " + playerPosition + " player");
        trashDown = trashPosition + new Vector3(0, 0, -10);
        //		Debug.Log (personDown + " person, " + playerPosition + " player");

//		Debug.Log ("the day changed.");
//		Debug.Log ("trash at position " + trash.transform.position.x + "x, " + trash.transform.position.z + "y");
        destroySpots.Clear();
//		destroySpots.Add (trashPosition);
        destroySpots.Add(trashUp);
        destroySpots.Add(trashDown);
        destroySpots.Add(trashRight);
        destroySpots.Add(trashLeft);

        openSpots.Clear();

        foreach (GameObject tile in tileList)
        {
            tileReference = tile.GetComponent <TileSelect> ();
            tileReference.TileReference();
            foreach (Vector3 position in destroySpots)
            {
                if (Mathf.Approximately(tileReference.tilePosition.x, position.x) && Mathf.Approximately(tileReference.tilePosition.z, position.z))
                {
                    //					Debug.Log ("found tile");
                    if (tileReference.trashPresent != true || tileReference.mangrovePresent != true)
                    {
//						Debug.Log (position + "is open");
                        openSpots.Add(position);
                    }
//					if (tileReference.mangrovePresent != true) {
//						Debug.Log (position + "removed");
//						destroySpots.Remove (position);
//					}
                }
            }
        }

        int spotIndex = Mathf.FloorToInt(Random.value * (float)openSpots.Count);

//		Debug.Log (spotIndex + " out of " + openSpots.Count);
        moveSpot = openSpots [spotIndex];
        this.transform.position = moveSpot;
//		Debug.Log ("trash moved to " + moveSpot);
    }
Exemplo n.º 4
0
	public void OnDayChange () {
		
		trashPosition = new Vector3 (Mathf.Round (this.transform.position.x), 0, Mathf.Round (this.transform.position.z));
		trashRight = trashPosition + new Vector3 (10, 0, 0);
		//		Debug.Log (personRight + " person, " + playerPosition + " player");
		trashLeft = trashPosition + new Vector3 (-10, 0, 0);
		//		Debug.Log (personLeft + " person, " + playerPosition + " player");
		trashUp = trashPosition + new Vector3 (0, 0, 10);
		//		Debug.Log (personUp + " person, " + playerPosition + " player");
		trashDown = trashPosition + new Vector3 (0, 0, -10);
		//		Debug.Log (personDown + " person, " + playerPosition + " player");

//		Debug.Log ("the day changed.");
//		Debug.Log ("trash at position " + trash.transform.position.x + "x, " + trash.transform.position.z + "y");
		destroySpots.Clear();
//		destroySpots.Add (trashPosition);
		destroySpots.Add (trashUp);
		destroySpots.Add (trashDown);
		destroySpots.Add (trashRight);
		destroySpots.Add (trashLeft);

		openSpots.Clear ();

		foreach (GameObject tile in tileList) {
			tileReference = tile.GetComponent<TileSelect> ();
			tileReference.TileReference ();
			foreach (Vector3 position in destroySpots) {
				if (Mathf.Approximately(tileReference.tilePosition.x, position.x) && Mathf.Approximately(tileReference.tilePosition.z, position.z)) {
					//					Debug.Log ("found tile");
					if (tileReference.trashPresent != true || tileReference.mangrovePresent != true) {
//						Debug.Log (position + "is open");
						openSpots.Add (position);
					}
//					if (tileReference.mangrovePresent != true) {
//						Debug.Log (position + "removed");
//						destroySpots.Remove (position);
//					}

				}
			}
		}

		int spotIndex = Mathf.FloorToInt (Random.value * (float)openSpots.Count);
//		Debug.Log (spotIndex + " out of " + openSpots.Count);
		moveSpot = openSpots [spotIndex];
		this.transform.position = moveSpot;
//		Debug.Log ("trash moved to " + moveSpot);

	}