public void RecieveTimeTraveler() { if (phase == 0) { return; } List <LevelMoment> prevTimeline = LevelData.Instance.moments[phase - 1]; //Check if there can be a time traveler. if ((prevTimeline.Count - time) < 3) { return; } LevelMoment wormHole = prevTimeline[time + 2]; if (!wormHole.HasTimeTraveler()) { return; } WormHole(wormHole.timeTraveler); }
public void BuildDisplay() { if (built) { return; } if (moment == null) { built = true; return; } displayPool = new Dictionary <char, List <GameObject> >(); int x = moment.x; int y = moment.y; int z = moment.z; for (int k = 0; k < z; k++) { for (int j = 0; j < y; j++) { for (int i = 0; i < x; i++) { char key = moment.level[i, j, k]; if (key == GameBoardCubeDictionary.OPEN_SPACE) { continue; } if (key == GameBoardCubeDictionary.OPEN_CUBE) { continue; } GameObject newObject = GetObject(key); if (newObject == null) { continue; } newObject.SetActive(true); newObject.transform.localPosition = new Vector3(i, j, k); newObject.transform.localEulerAngles = Vector3.zero; } } } PlaceLemmings(GameBoardCubeDictionary.LEMMING, moment.lemmings); PlaceLemmings(GameBoardCubeDictionary.LEMMING_LIVE, moment.savedLemmings); PlaceLemmings(GameBoardCubeDictionary.LEMMING_DEAD, moment.deadLemmings); PlaceLemmings(GameBoardCubeDictionary.LEMMING_PHASED, moment.phasedLemmings); PlaceSpawners(GameBoardCubeDictionary.SPAWNER, moment.spawners); if (moment.HasTimeTraveler()) { PlaceLemming(GameBoardCubeDictionary.LEMMING, moment.timeTraveler); } built = true; }
private void CheckBuilding() { //if (!Input.GetKeyDown(KeyCode.N)) return; if (isWin) { return; } bool changed = false; //Find next map to update. (for not just go linearly) LevelMoment prevMoment = FindOldMoment(); if (prevMoment == null) { updating = false; return; } LevelMoment nextMoment = prevMoment.DeepCopyLevelMoment(); if (prevMoment.terminalBuffer == 0) { prevMoment.terminalBuffer++; } nextMoment.Age(); //Keep track of saved and dead lemming count Vector2Int lemCounts = new Vector2Int(nextMoment.savedLemmings.Count, nextMoment.deadLemmings.Count); //Go one past the last moment if ((lemCounts.x > 0) || (lemCounts.y > 0)) { changed = true; } nextMoment.goal -= lemCounts.x; nextMoment.fail -= lemCounts.y; List <Lemming> movingLemmings = new List <Lemming>(); movingLemmings.AddRange(nextMoment.lemmings); movingLemmings.AddRange(nextMoment.phasedLemmings); nextMoment.lemmings = new List <Lemming>(); nextMoment.savedLemmings = new List <Lemming>(); nextMoment.deadLemmings = new List <Lemming>(); nextMoment.phasedLemmings = new List <Lemming>(); foreach (Lemming lem in movingLemmings) { Vector3Int pos = lem.position; Vector3Int forwardIndex = lem.position + lem.direction; Vector3Int belowIndex = new Vector3Int(pos.x, pos.y - 1, pos.z); GameBlock current = null; GameBlock move = null; GameBlock below = null; current = GetBlock(prevMoment, pos); changed |= true; move = GetBlock(prevMoment, forwardIndex); below = GetBlock(prevMoment, belowIndex); Vector3Int prevPos = lem.position; if (below != null) { below.overMoveBehaviour.Move(nextMoment, prevMoment, lem, below); } if ((move != null) && (prevPos == lem.position)) { move.enterMoveBehaviour.Move(nextMoment, prevMoment, lem, move); } current.exitMoveBehaviour.Move(nextMoment, prevMoment, lem, below); Vector3Int lPos = lem.position;; char key = nextMoment.level[lPos.x, lPos.y, lPos.z]; if (key == GameBoardCubeDictionary.END_ZONE) { nextMoment.savedLemmings.Add(lem); } else if (CheckDead(lem)) { if (nextMoment.LemmingInPhase(lem)) { nextMoment.deadLemmings.Add(lem); } } else { if (nextMoment.LemmingInPhase(lem)) { nextMoment.lemmings.Add(lem); } else { nextMoment.phasedLemmings.Add(lem); } } } if (changed) { if (nextMoment.HasTimeTraveler()) { nextMoment.lemmings.Remove(nextMoment.timeTraveler); } } ProcessSpawners(nextMoment); nextMoment.RecieveTimeTraveler(); LevelData.Instance.CheckPast(nextMoment); //If a new moment was created, add it to the timeline, call event if ((MomentBuiltEvent != null)) { List <LevelMoment> timeline = levelData.moments[nextMoment.phase]; Vector2Int i = new Vector2Int(nextMoment.phase, nextMoment.time); timeline.Add(nextMoment); MomentBuiltEvent(i); } }