public static void Generate(Point2D[] points, TileType type, PlantType tSpring, PlantType tSummer, PlantType tAutomn, PlantType tWinter, int range) { for (int i = 0; i < points.Length; ++i) { Point2D p = points[i]; //Console.WriteLine(p.ToString()); int count; if (range == 80) { count = 10; } else if (range == 60) { count = 7; } else if (range == 40) { count = 3; } else { count = 1; } PlantSpawner ps = new PlantSpawner(p, type, tSpring, tSummer, tAutomn, tWinter, range, count, BaseMinDelay, BaseMaxDelay); } }
//Calculates final health, calls plantDestroyed from PlantSpawner, then destroy object void plantRemovalAndCalc() { PlantSpawner plantSpawner = GameObject.Find("PlantSpawner").GetComponent <PlantSpawner>(); Movement bugMovement = GameObject.FindGameObjectWithTag("Bug").GetComponent <Movement>(); MultiObjGameManager multiObjGameManager = GameObject.Find("MultiObjGameManager").GetComponent <MultiObjGameManager>(); Debug.Log("bugMovement's name: " + bugMovement.tag); var healed = gameObject.GetComponent <Animator> ().GetBool("healed"); var hurt = gameObject.GetComponent <Animator> ().GetBool("hurt"); // if (this.health >= 80) { // plantSpawner.plantDestroyed ("success"); // } // else { // plantSpawner.plantDestroyed ("failure"); // } //Tells PlantSpawner.cs plantDestroyer function if it was a success or a failure if (healed) { plantSpawner.plantDestroyed("success"); } else if (hurt) { plantSpawner.plantDestroyed("failure"); } Destroy(gameObject); plantSpawner.plantRestart = true; bugMovement.plantIsAlive = false; // multiObjGameManager.restartBugs = true; }
public static void OnSeasonChange(Season season) { ArrayList items = new ArrayList(World.Items.Values); for (int i = 0; i < items.Count; ++i) { if (items[i] is Item) { Item item = (Item)items[i]; if (item is PlantSpawner) { PlantSpawner ps = (PlantSpawner)item; ps.Respawn(); } } } }
// Use this for initialization void Start() { //Change the plant to have a color same as one of the bugs on screen var MultiObjGameManager = GameObject.Find("MultiObjGameManager"); var bugList = MultiObjGameManager.GetComponent <MultiObjGameManager> ().colors; Debug.Log("multiobjGameManager: " + MultiObjGameManager); if (MultiObjGameManager) { int randomBug = Random.Range(0, bugList.Count); Debug.Log("type of bug color: " + bugList [randomBug].GetComponent <CloakControl> ().type); correctBugType = bugList [randomBug].GetComponent <CloakControl> ().type; if (correctBugType == BugType.Blue) { bugColor = Color.blue; } else if (correctBugType == BugType.Green) { bugColor = Color.green; } else if (correctBugType == BugType.Red) { bugColor = Color.red; } else if (correctBugType == BugType.White) { bugColor = Color.white; } else if (correctBugType == BugType.Yellow) { bugColor = Color.yellow; } } //start plant health int health = 100; //Lets the plant only be hit once notHitYet = true; //Set animator script parameter value gameObject.GetComponent <Animator> ().SetFloat("animHealth", health); PlantSpawner plantSpawner = GameObject.Find("PlantSpawner").GetComponent <PlantSpawner>(); FieldInfo info = Util.getFieldInfo(field); var bottomLeftCorner = new Vector3(info.lowerX, info.lowerY, 0); var upperRightCorner = new Vector3(info.upperX, info.upperY, 0); var blank = wayPointReference; topBound = Instantiate(blank, upperRightCorner, transform.rotation) as WayPoint; bottomBound = Instantiate(blank, bottomLeftCorner, transform.rotation) as WayPoint; leftBound = Instantiate(blank, bottomLeftCorner, transform.rotation) as WayPoint; rightBound = Instantiate(blank, upperRightCorner, transform.rotation) as WayPoint; //TODO: change this to one of the actual colors // this.GetComponent<Renderer>().material.color = Util.randomColor (); this.GetComponent <Renderer>().material.color = bugColor; // Debug.Log (health); InvokeRepeating("Depleting", depleteSeconds, depleteSeconds); var player = GameObject.Find("Player"); playerCircleCollider = player.GetComponent <CircleCollider2D> (); }
public void Start() { plantspawner = GetComponent <PlantSpawner>(); SpawnPlatforms(); }