public Unit CreateUnit(UnitType unit) { Unit newUnit = (Unit)Entities.Instance.Create(unit, Parent); newUnit.Position = Position + new Vec3(0, 0, unit.SpawnHeight); newUnit.Rotation = Rotation; spawned = newUnit; newUnit.PostCreate(); selectedUnit = null; if (UnitSpawned != null) { UnitSpawned(newUnit); } return(newUnit); }
Unit ServerOrSingle_CreatePlayerUnit(PlayerManager.ServerOrSingle_Player player, MapObject spawnPoint) { string unitTypeName; if (!player.Bot) { if (GameMap.Instance.PlayerUnitType != null) { unitTypeName = GameMap.Instance.PlayerUnitType.Name; } else { unitTypeName = "Girl"; } } else { unitTypeName = player.Name; } Unit unit = (Unit)Entities.Instance.Create(unitTypeName, Map.Instance); Vec3 posOffset = new Vec3(0, 0, 1.5f); unit.Position = spawnPoint.Position + posOffset; unit.Rotation = spawnPoint.Rotation; unit.PostCreate(); if (player.Intellect != null) { player.Intellect.ControlledObject = unit; unit.SetIntellect(player.Intellect, false); } Teleporter teleporter = spawnPoint as Teleporter; if (teleporter != null) { teleporter.ReceiveObject(unit, null); } return(unit); }
protected override void OnTick() { base.OnTick(); if (Spawned == null || Spawned.IsSetForDeletion) { spawnTimeElapsed += TickDelta; if (randomSpawnTime) { spawnTime = World.Instance.Random.Next(30, 45); } if (spawnTimeElapsed < spawnTime) { return; } spawnTimeElapsed = 0; int next = World.Instance.Random.Next(0, spawnerItems.Count); Unit newUnit = (Unit)Entities.Instance.Create(spawnerItems[next].UnitType, Parent); if (spawnerItems[next].AIType != null) { newUnit.InitialAI = spawnerItems[next].AIType; } if (faction != null) { newUnit.InitialFaction = faction; } newUnit.Position = Position + new Vec3(0, 0, spawnerItems[next].UnitType.SpawnHeight); newUnit.Rotation = Rotation; Spawned = newUnit; newUnit.PostCreate(); selectedUnit = null; } }
private Unit ServerOrSingle_CreatePlayerUnit(PlayerManager.ServerOrSingle_Player player, MapObject spawnPoint) { string unitTypeName; if (!player.Bot) { if (player.Intellect.Faction.Name == "AssaultKnights" && GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights) { unitTypeName = "AKSoldier"; } else if (player.Intellect.Faction.Name == "Omni" && GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights) { unitTypeName = "OmniSoldier"; } else if (GameMap.Instance.PlayerUnitType != null) { unitTypeName = GameMap.Instance.PlayerUnitType.Name; } else { unitTypeName = "Girl"; } } else if (player.Bot) { unitTypeName = player.Name; } else { unitTypeName = "Rabbit"; } Unit unit = (Unit)Entities.Instance.Create(unitTypeName, Map.Instance); Vec3 posOffset = new Vec3(0, 0, 1.5f); unit.Position = spawnPoint.Position + posOffset; unit.Rotation = spawnPoint.Rotation; unit.PostCreate(); if (player.Intellect != null) { player.Intellect.ControlledObject = unit; unit.SetIntellect(player.Intellect, false); } Teleporter teleporter = spawnPoint as Teleporter; if (teleporter != null) { teleporter.ReceiveObject(unit, null); } //Incin -- Custom Box teleporter BoxTeleporter boxteleporter = spawnPoint as BoxTeleporter; if (boxteleporter != null) { boxteleporter.ReceiveObject(unit, null); } return(unit); }