//public List<TAttackInfo> PendingAttacks { get { return pendingAttacks; } } public OLD_TGame(PlayerSettings[] players, TrainingPlanetInfo[] planetsInfo) { GameMutex = new Mutex(); Debug.Log("EMPEZANDO PARTIDA - CREANDO PLANETAS"); #region PREPARING PLANETS planets = new OLD_TPlanet[planetsInfo.Length]; //instantiate planets for (int i = 0; i < planetsInfo.Length; i++) { planets[i] = new OLD_TPlanet(planetsInfo[i].Owner, planetsInfo[i].position, planetsInfo[i].MaxLevel, i); Debug.Log("Creando planeta " + i + " que pertenece al jugador " + planetsInfo[i].Owner + " situado en " + planetsInfo[i].position); } //store the distances in turns between planets int[] aux; for (int i = 0; i < planets.Length; i++) { aux = new int[planets.Length]; for (int j = 0; j < planets.Length; j++) { if (i == j) { aux[i] = -1; Debug.Log("El planeta " + i + " esta a una distancia de " + Vector3.Distance(planets[i].Position, planets[j].Position) + " al planeta " + j + " o, en turnos: " + aux[i]); continue; } aux[i] = Utilities.Utilities.GetDistanceInTurns(planets[i].Position, planets[j].Position); Debug.Log("El planeta " + i + " esta a una distancia de " + Vector3.Distance(planets[i].Position, planets[j].Position) + " al planeta " + j + " o, en turnos: " + aux[i]); } planets[i].UpdateDistances(aux); } #endregion Debug.Log("EMPEZANDO PARTIDA - CREANDO JUGADORES"); #region PREPARING_PLAYERS OLD_TPlayer[] mplayers = new OLD_TPlayer[players.Length]; List <OLD_TEventEntity> aux2; for (int i = 0; i < players.Length; i++) { aux2 = new List <OLD_TEventEntity>(); foreach (OLD_TEventEntity planet in planets) { if (planet.CurrentPlayerOwner == i) { aux2.Add(planet); } } mplayers[i] = new OLD_TPlayer(i, aux2, players[i].TypeAI, planets, true); Debug.Log("Jugador " + i + " creado con " + aux2.Count + " planetas e IA " + players[i].TypeAI); } this.players = mplayers; #endregion pendingAttacks = new List <TAttackInfo>(); TakeSnapshot(); }
/// <summary> /// Returns nearest planet to aany planet that belongs to the player /// </summary> /// <param name="returnNeutral"></param> /// <returns></returns> public static OLD_TEventEntity GetNearestPlanet(OLD_TPlayer myPlayer, OLD_TEventEntity[] map, bool returnNeutral = false) { OLD_TEventEntity aux = null; float currentDistance = float.PositiveInfinity; if (myPlayer.Planets.Count <= 0) { Debug.Log("NO TENGO PLANETAS"); } foreach (OLD_TEventEntity child in map) { for (int i = 0; i < myPlayer.Planets.Count; i++) { if (!myPlayer.Planets.Contains(child)) { if (Vector3.Distance(child.Position, myPlayer.Planets[i].Position) < currentDistance) { if (returnNeutral) { if (child.CurrentPlayerOwner == GlobalData.NO_PLAYER) { aux = child; currentDistance = Vector3.Distance(child.Position, myPlayer.Planets[i].Position); } } else { if (child.CurrentPlayerOwner != GlobalData.NO_PLAYER) { aux = child; currentDistance = Vector3.Distance(child.Position, myPlayer.Planets[i].Position); } } } } } } if (aux == null) { Debug.LogError("Error al localizar planeta cercano"); return(myPlayer.Planets[0]); } else { return(aux); } }
/// <summary> /// Returns necessary units to conquer or turn neutral /// </summary> /// <param name="ent">Entity we want to know abouta</param> /// <param name="turnNeutral">If true will return units to turn neutral</param> /// <returns></returns> public static int CountNecessaryUnitsToConquer(OLD_TEventEntity ent, OLD_TPlayer myPlayer, bool randomNumber = false, bool turnNeutral = false) { int objective = 0; if (ent.CurrentPlayerOwner == myPlayer.Id) { if (ent.CurrentLevel >= ent.MaxLevel) { return(0); } else { objective = ent.ExpForNextLevel - ent.CurrentExp; } } if ((ent.CurrentPlayerOwner == GlobalData.NO_PLAYER && ent.CurrentContestantId == myPlayer.Id) || (ent.CurrentPlayerOwner == GlobalData.NO_PLAYER && ent.CurrentContestantId == GlobalData.NO_PLAYER)) { objective = ent.ExpForNextLevel - ent.CurrentExp; } else if (ent.CurrentPlayerOwner == GlobalData.NO_PLAYER && ent.CurrentContestantId != myPlayer.Id) { objective = ent.ExpForNextLevel + ent.CurrentHealth; } else { if (turnNeutral) { objective = ent.CurrentUnits + ent.CurrentHealth; } else { objective = ent.CurrentHealth + ent.CurrentUnits + ent.GetExpForLEvel(0); } } if (randomNumber) { return(Mathf.RoundToInt(objective * (1.4f - Random.value))); } else { return(objective); } }
public OLD_TEffector(OLD_TPlayer play, OLD_TEventEntity[] map) { myPlayer = play; this.map = map; }
public OLD_TClasicAI(OLD_TPlayer play, OLD_TEventEntity[] map) { myPlayer = play; this.map = map; }