public SpawnPoint(int x, int y, SpawnPointType type) { this.x = x; this.y = y; this.type = type; lastSpawned = 0; }
/// <summary> /// Creates slave item of the first spawnpoint of the given type. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="type"></param> /// <returns></returns> private T CreateSlaveItem <T>(SpawnPointType type) where T : PrefabSlaveItem, new() { var first = clonedPoints.First(x => x.Type == type); var item = CreateSlaveItem <T>(first); clonedPoints.Remove(first); return(item); }
private void CreateServiceItemsOfType(SpawnPointType type, ServiceType serviceType) { foreach (var point in clonedPoints.Where(x => x.Type == type)) { var item = CreateSlaveItem <Service>(point); item.ServiceType = serviceType; } clonedPoints.RemoveAll(x => x.Type == type); }
public Vector3 GetSpawnPoint(SpawnPointType type) { int t = (int)type; if (t < spawnPositions.Length) { return(spawnPositions[t]); } else { Debug.LogWarning("Spawn Point is not found."); return(new Vector3(MapOriginX, 0, MapOriginZ)); } }
/// <summary> /// Creates map nodes for all spawn points of the given type. /// </summary> /// <param name="item">The company item.</param> /// <param name="spawnPointType">The spawn point type.</param> /// <param name="node0Pos">The ppd position of the prefab's red control node.</param> /// <returns>A list of map nodes.</returns> private List <INode> CreateSpawnPointNodes(PrefabSlaveItem item, SpawnPointType spawnPointType) { var selected = clonedPoints.Where(x => x.Type == spawnPointType).ToList(); var list = new List <INode>(selected.Count); foreach (var spawnPoint in selected) { var spawnPos = GetAbsolutePosition(spawnPoint.Position); var spawnNode = map.AddNode(spawnPos, false); spawnNode.Rotation = Quaternion.Normalize( spawnPoint.Rotation * prefabRot); spawnNode.ForwardItem = item; list.Add(spawnNode); } for (int i = 0; i < selected.Count; i++) { clonedPoints.Remove(selected[i]); } return(list); }
internal bool Load(INIFile ini, string key) { string[] vals = ini.GetValueArray <string>("SpawnPoints", key, ','); UniqueID = key; if (vals.Length < 3) { return(false); } try { Coordinates = new Coordinates(Toolbox.StringToDouble(vals[0]), Toolbox.StringToDouble(vals[1])); PointType = (SpawnPointType)Enum.Parse(typeof(SpawnPointType), vals[2], true); } catch (Exception) { return(false); } return(true); }
private Material GetMaterialByEnemyType(SpawnPointType enemyType) { return(_indicatorMats[(int)enemyType]); }
private IEnumerator ActivateEnemy() { // first enemy waiting time. float waitingTime = Random.Range(0, 101) / 100.0f; yield return(new WaitForSeconds(waitingTime)); //record which spot index has been used and must be avoided being used again until there is no vacancy List <int>[] mapping = new List <int> [(int)SpawnPointType.Count]; for (int i = _startEnemyIndex; i < _endEnemyIndex; ++i) { //randomly choose a spawn point for this enemy, the enemy type must fit //require: spawn points with the same enemy type must stay together SpawnPointType spawnType = LevelManager.Singleton.GetEnemySpawnPointTypeByIndex(i); List <int> spotList = mapping[(int)spawnType]; //available spot list not built yet or spots have been used up, in both cases, need to rebuild if (spotList == null) { spotList = new List <int>(); mapping[(int)spawnType] = spotList; int count = this.transform.childCount; while (spawnType >= SpawnPointType.Type1) { for (int childIndex = 0; childIndex < count; childIndex++) { EnemySpot spot = this.transform.GetChild(childIndex).GetComponent <EnemySpot>(); if (spot.acceptedSpawnType == spawnType) { spotList.Add(childIndex); } } if (spotList.Count > 0) { break; //found a suitable spawn point } else { if (spawnType == SpawnPointType.Type1) //the bottom has been reached, report error. { Assertion.Check(spotList.Count > 0, string.Format("Spawn point type {0} not found for trigger {1}", spawnType.ToString(), this.name)); } else { spawnType--; Debug.LogWarning(string.Format("Required spawn point {0} not found, degrad it and search again.", spawnType.ToString())); } } } //randomize the elements for (int k = 0; k < spotList.Count - 1; k++) { int rdm = Random.Range(k + 1, spotList.Count); int a = spotList[rdm]; spotList[rdm] = spotList[k]; spotList[k] = a; } //Debug show foreach (int spotIndex in spotList) { Debug.Log(string.Format("Spot index list for enemy type [{0}]: {1}", spawnType.ToString(), spotIndex)); } } //Get delay time of an ememy group, which is attached to the first enemy of the group float delayTime = LevelManager.Singleton.GetDelayTimeByEnemyIndex(i); if (delayTime > 0) { Debug.Log(string.Format("Waiting {0} seconds on enemy index {1}", delayTime, i)); yield return(new WaitForSeconds(delayTime)); } LevelManager.Singleton.ActivateEnemyAtSpot(i, this.transform.GetChild(spotList[0]).GetComponent <EnemySpot>()); Debug.Log(string.Format("\t\tEnemy created. Trigger name: {0} Spawn point: {1} Enemy index: {2}", this.name, spotList[0], i)); //move the 1st to last spotList.Add(spotList[0]); spotList.RemoveAt(0); waitingTime = Random.Range(0, 101) / 100.0f; yield return(new WaitForSeconds(waitingTime)); } }
// Use this for initialization void Awake() { if (XkGameCtrl.GameJiTaiSt == GameJiTaiType.FeiJiJiTai) { PointType = SpawnPointType.KongZhong; } if (HuoCheNpcTran != null) { HuoCheNpcTran.gameObject.SetActive(false); } if (NpcObj == null) { if (!XkGameCtrl.GetInstance().IsCartoonShootTest) { Debug.LogWarning("NpcObj was null"); GameObject obj = null; obj.name = "null"; } return; } else { NetworkView netView = NpcObj.GetComponent <NetworkView>(); if (netView == null) { Debug.LogWarning("npc cannot find NetworkView"); GameObject obj = null; obj.name = "null"; return; } } XKNpcMoveCtrl npcScript = NpcObj.GetComponent <XKNpcMoveCtrl>(); if (npcScript != null) { if (npcScript.IsFireMove && IsAimPlayer) { Debug.LogWarning("Npc.IsFireMove and SpawnPoint.IsAimPlayer is true!"); GameObject obj = null; obj.name = "null"; } if (npcScript.IsAniMove) { SetFeiJiSpawnPointInfo(); } if (npcScript.NpcState == NpcType.FlyNpc) { if (NpcPath != null && NpcPath.childCount < 2) { Debug.LogWarning("NpcPath.childCount was wrong!"); GameObject obj = null; obj.name = "null"; } } } if (NpcPath != null) { if (NpcPath.childCount < 1) { Debug.LogWarning("NpcPath.childCount was wrong! childCount = " + NpcPath.childCount); GameObject obj = null; obj.name = "null"; } if (NpcPath.GetComponent <NpcPathCtrl>() == null) { Debug.LogWarning("NpcPath was wrong! cannot find NpcPathCtrl script"); GameObject obj = null; obj.name = "null"; } } if (FirePointGroup.Length > 0) { for (int i = 0; i < FirePointGroup.Length; i++) { if (FirePointGroup[i] == null) { Debug.LogWarning("FirePointGroup was wrong! index " + (i + 1)); GameObject obj = null; obj.name = "null"; break; } } if (SpeedFangZhenFireRun <= 0f) { Debug.LogWarning("SpeedFangZhenFireRun was wrong! SpeedFangZhenFireRun " + SpeedFangZhenFireRun); GameObject obj = null; obj.name = "null"; } } if (NpcSpawnLoop.Length > 0) { for (int i = 0; i < NpcSpawnLoop.Length; i++) { if (NpcSpawnLoop[i] == null) { Debug.LogWarning("NpcSpawnLoop was wrong! index " + (i + 1)); GameObject obj = null; obj.name = "null"; break; } } } if (ChildSpawnPoint.Length > 0) { for (int i = 0; i < ChildSpawnPoint.Length; i++) { if (ChildSpawnPoint[i] == null) { Debug.LogWarning("ChildSpawnPoint was wrong! index " + (i + 1)); GameObject obj = null; obj.name = "null"; break; } } } if (ChildSpawnPoint.Length > 0 && NpcFangZhen == null) { Debug.LogWarning("NpcFangZhen is null! fangZhenLength " + ChildSpawnPoint.Length); GameObject obj = null; obj.name = "null"; } Invoke("CheckIsRemoveTrigger", 1f); }
public void Deserialize(BinaryReader r) { Position = r.ReadVector3(); Rotation = r.ReadQuaternion(); Type = (SpawnPointType)r.ReadUInt32(); }
private static void CreateAirDefenseGroups( MissionTemplateRecord template, UnitMaker unitMaker, Side side, Coalition coalition, AmountNR airDefenseAmount, AirDefenseRange airDefenseRange, Coordinates centerPoint, Coordinates opposingPoint) { var commonAirDefenseDB = Database.Instance.Common.AirDefense; DBCommonAirDefenseLevel airDefenseLevelDB = commonAirDefenseDB.AirDefenseLevels[(int)airDefenseAmount]; int groupCount = airDefenseLevelDB.GroupsInArea[(int)airDefenseRange].GetValue(); if (groupCount < 1) { return; // No groups to add, no need to go any further } List <UnitFamily> unitFamilies; SpawnPointType[] validSpawnPoints; switch (airDefenseRange) { case AirDefenseRange.MediumRange: unitFamilies = new List <UnitFamily> { UnitFamily.VehicleSAMMedium }; validSpawnPoints = new SpawnPointType[] { SpawnPointType.LandLarge }; break; case AirDefenseRange.LongRange: unitFamilies = new List <UnitFamily> { UnitFamily.VehicleSAMLong }; validSpawnPoints = new SpawnPointType[] { SpawnPointType.LandLarge }; break; default: // case AirDefenseRange.ShortRange: unitFamilies = new List <UnitFamily> { UnitFamily.VehicleAAA, UnitFamily.VehicleAAAStatic, UnitFamily.VehicleInfantryMANPADS, UnitFamily.VehicleSAMShort, UnitFamily.VehicleSAMShort, UnitFamily.VehicleSAMShortIR, UnitFamily.VehicleSAMShortIR }; validSpawnPoints = new SpawnPointType[] { SpawnPointType.LandSmall, SpawnPointType.LandMedium, SpawnPointType.LandLarge }; break; } for (int i = 0; i < groupCount; i++) { // Find spawn point at the proper distance Coordinates?spawnPoint = unitMaker.SpawnPointSelector.GetRandomSpawnPoint( validSpawnPoints, centerPoint, commonAirDefenseDB.DistanceFromCenter[(int)side, (int)airDefenseRange], opposingPoint, new MinMaxD(commonAirDefenseDB.MinDistanceFromOpposingPoint[(int)side, (int)airDefenseRange], 99999), GeneratorTools.GetSpawnPointCoalition(template, side)); // No spawn point found, stop here. if (!spawnPoint.HasValue) { BriefingRoom.PrintToLog($"No spawn point found for {airDefenseRange} air defense unit groups", LogMessageErrorLevel.Warning); return; } var groupInfo = unitMaker.AddUnitGroup( unitFamilies, 1, side, "GroupVehicle", "UnitVehicle", spawnPoint.Value); if (!groupInfo.HasValue) // Failed to generate a group { BriefingRoom.PrintToLog( $"Failed to add {airDefenseRange} air defense unit group for {coalition} coalition.", LogMessageErrorLevel.Warning); } } }
private bool Has(SpawnPointType type) => clonedPoints.Any(x => x.Type == type);
private void AddSpawnPoint(int x, int y, SpawnPointType type) { if (type == SpawnPointType.Enemy) AddEnemySpawnPoint(x, y); else AddPlayerSpawnPoint(x, y); }