public void SpawnArcher(UnitType type, UnitRace race, bool bIsPlayerUnit) { if (bIsPlayerUnit) { GameManger.instance.SpawnPlayerUnit(type, race); } else { GameManger.instance.SpawnEnemyUnit(type, race); } }
public static Unit Random() { var unit = new Unit { Gender = new Gender((Gender.Type)Randomizer.Do(0, 1)), Race = UnitRace.Random() }; unit.InteractableObjectsMap = CalculateCategoriesMap(unit); unit.Name = new UnitName(UnitNameGenerator.Gen(unit, true)); return(unit); }
public void SpawnEnemyUnit(UnitType type, UnitRace race) { List <Unit> temp = (from t in enemyUnitPrefabs where t.data.Type == type && t.data.Race == race select t).ToList <Unit>(); Unit unitPref = null; if (temp.Count > 0) { unitPref = temp[0]; } if (unitPref != null) { ObjectPoolManager.instance.GetObject(unitPref.gameObject, enemySpawn.tf.position, enemySpawn.tf.rotation); } }
public Unit() { // Populate unit fields with default values name = "Boi " + UnityEngine.Random.Range(1, 100).ToString(); gender = Gender.N; race = new Hume(); classes = new List <UnitClass>(); classes.Add(new Dweller()); statsUnique = new Dictionary <Stat, int>(); bodyResource = "UnitBody"; profileResource = ""; UpdateDerivedStats(); ResetCurrentStats(); }
public static UnitUpgrade Map(string repUpgrade) { UnitUpgrade myupgrade = null; string race = ""; int level = 0; string type = ""; string add = ""; Match match = rxUpgrade.Match(repUpgrade); if (match.Success) { race = match.Groups[1].Value.ToString(); type = match.Groups[2].Value.ToString(); level = int.Parse(match.Groups[3].Value); add = match.Groups[4].Value; UnitRace myrace = UnitRace.Terran; if (race == "Protoss") { myrace = UnitRace.Protoss; } else if (race == "Terran") { myrace = UnitRace.Terran; } else if (race == "Zerg") { myrace = UnitRace.Zerg; } UnitUpgrades upgradename = UnitUpgrades.GroundArmor; // Protoss if (type == "AirArmor") { upgradename = UnitUpgrades.AirArmor; } else if (type == "AirWeapons") { upgradename = UnitUpgrades.AirAttac; } else if (type == "GroundArmor") { upgradename = UnitUpgrades.GroundArmor; } else if (type == "GroundWeapons") { upgradename = UnitUpgrades.GroundAttac; } else if (type == "Shields") { upgradename = UnitUpgrades.ShieldArmor; } // Terran else if (type == "InfantryArmor") { upgradename = UnitUpgrades.GroundArmor; } else if (type == "InfantryWeapons") { upgradename = UnitUpgrades.GroundAttac; } else if (type == "VehicleandShipPlating" || type == "VehicleAndShipPlating") { upgradename = UnitUpgrades.VehicelArmor; } else if (type == "VehicleWeapons") { upgradename = UnitUpgrades.VehicelAttac; } // Zerg else if (type == "FlyerAttacks") { upgradename = UnitUpgrades.AirAttac; } else if (type == "FlyerCarapace") { upgradename = UnitUpgrades.AirArmor; } else if (type == "GroundCarapace") { upgradename = UnitUpgrades.GroundArmor; } else if (type == "MeleeAttacks") { upgradename = UnitUpgrades.GroundMeleeAttac; } else if (type == "MissileAttacks") { upgradename = UnitUpgrades.GroundAttac; } Upgrade u = UpgradePool.Upgrades.SingleOrDefault(x => x.Race == myrace && x.Name == upgradename); if (u != null) { myupgrade = new UnitUpgrade(); myupgrade.Upgrade = u.Name; myupgrade.Level = level; } } return(myupgrade); }
public static int GetPlayer(GameMapModel _map, dsreplay replay, Player pl, int gameloop = 0) { dsplayer dspl = replay.PLAYERS.SingleOrDefault(x => x.REALPOS == pl.Pos); if (dspl == null) { return(gameloop); } pl.SoftReset(); if (pl.Name == "") { pl.Name = dspl.NAME; pl.Pos = dspl.REALPOS; UnitRace race = UnitRace.Terran; if (dspl.RACE == "Protoss") { race = UnitRace.Protoss; } else if (dspl.RACE == "Zerg") { race = UnitRace.Zerg; } pl.Race = race; pl.Units = UnitPool.Units.Where(x => x.Race == race && x.Cost > 0).ToList(); } if (gameloop == 0) { gameloop = _map.plSpawns[pl.Pos].OrderBy(o => o).First(); } foreach (var unit in _map.Spawns[gameloop].Where(x => x.Owner == pl.Pos)) { Unit myunit = unit.DeepCopy(); if (pl.Pos <= 3) { //myunit.PlacePos = UnitService.mirrorImage(myunit.PlacePos); //myunit.PlacePos = new Vector2(Battlefield.Xmax - myunit.PlacePos.X, myunit.PlacePos.Y); myunit.PlacePos = new Vector2(myunit.PlacePos.X, 2 * 5 - myunit.PlacePos.Y - 1); } UnitService.NewUnit(pl, myunit); pl.Units.Add(myunit); pl.MineralsCurrent -= myunit.Cost; } foreach (var dic in _map.Upgrades[pl.Pos].OrderBy(x => x.Key)) { if (dic.Key > gameloop) { break; } foreach (var upgrade in dic.Value) { pl.MineralsCurrent -= UnitService.UpgradeUnit(upgrade.Upgrade, pl); } } foreach (var dic in _map.AbilityUpgrades[pl.Pos].OrderBy(x => x.Key)) { if (dic.Key > gameloop) { break; } foreach (var upgrade in dic.Value) { pl.MineralsCurrent -= UnitService.AbilityUpgradeUnit(upgrade, pl); } } pl.MineralsCurrent = 10000; return(gameloop); }