private bool ProcessSpawners(LevelMoment mom) { bool result = false; List <Spawner> spawners = new List <Spawner>(); spawners.AddRange(mom.spawners); foreach (Spawner spawn in spawners) { spawn.age--; if (spawn.age == 0) { mom.spawners.Remove(spawn); } if (spawn.age % 2 != 0) { continue; } Lemming lem = spawn.MakeLemming(); if (mom.IsFree(lem.position)) { mom.lemmings.Add(lem); } } return(result); }
private void CheckDisplayUpdate() { //See if the mouse is over any point ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { Vector2Int i = momDisplay.displayCenter; Transform centerDisplay = momDisplay.displays[i.x][i.y].transform; Transform t = hit.collider.transform; //Only place the new object in the centre display if (!t.IsChildOf(centerDisplay)) { return; } //Check that the square in the game space is free LevelMoment moment = momDisplay.GetFocusedMoment(); Vector3Int j = new Vector3Int(Mathf.RoundToInt(t.localPosition.x), Mathf.RoundToInt(t.localPosition.y + 1), Mathf.RoundToInt(t.localPosition.z)); if (!moment.IsFree(j)) { return; } displayTrans.position = t.position + Vector3.up; displayTrans.eulerAngles = t.eulerAngles; DisplayData data = centerDisplay.GetComponentInChildren <DisplayData>(); displayTrans.parent = data.centeringTransform; tempObj.SetActive(true); } else { tempObj.SetActive(false); } }