/// <summary> /// Same as take snapshot, but stores the current state in a new TGame and returns it /// DOES NOT OVERWRITE SNAPSHOT /// </summary> public TGame TakeAndGetSnapshot() { TEventEntity[] s_planets = new TEventEntity[planets.Length]; TGame game = new TGame(); for (int i = 0; i < planets.Length; i++) { s_planets[i] = planets[i].GetSnapshot(game); } TPlayer[] s_players = new TPlayer[players.Length]; List <TEventEntity> aux; for (int i = 0; i < players.Length; i++) { aux = new List <TEventEntity>(); s_players[i] = players[i].GetSnapshot(s_planets); foreach (TEventEntity ent in s_planets) { if (ent.CurrentPlayerOwner == s_players[i].Id) { aux.Add(ent); } } s_players[i].SetPlanets(aux); } List <TAttackInfo> s_attacks = new List <TAttackInfo>(pendingAttacks); game.Initialize(s_players, s_planets, s_attacks, weHaveAWinner, winner); return(game); }
public TGame GetSnapshot() { TEventEntity[] s_planets = new TEventEntity[planets.Length]; TGame game = new TGame(); for (int i = 0; i < planets.Length; i++) { s_planets[i] = planets[i].TakeSnapshot(game); } TPlayer[] s_players = new TPlayer[players.Length]; List <TEventEntity> aux; for (int i = 0; i < players.Length; i++) { aux = new List <TEventEntity>(); s_players[i] = players[i].GetSnapshotInstance(s_planets); foreach (TEventEntity ent in s_planets) { if (ent.CurrentPlayerOwner == s_players[i].Id) { aux.Add(ent); } } s_players[i].SetPlanets(aux); } List <TAttackInfo> s_attacks = new List <TAttackInfo>(); foreach (Transform att in attackPool.transform) { if (att.gameObject.activeSelf) { s_attacks.Add(att.GetComponent <Attack>().GetTrainingSnapshot()); } } game.Initialize(s_players, s_planets, s_attacks); return(game); }