public void Spawn() { var newObject = Instantiate(spawnObject, transform); SpawnedObjects.Add(newObject.transform); SetRandomPosition(newObject.transform); }
public override RunObject Spawn() { if (IsPipelineIsEmpty) { ProcessError("RunObjects.Dequeue(): Pipeline is empty"); return(null); } var build = Pipeline.Dequeue(); var objType = build.GetObjectType(); var obj = Spawn(objType); if (obj == null) { ProcessError("RunObjects.Dequeue(): Spawn(objType) == null"); return(null); } build.Build(obj); SpawnedObjects.Add(obj); obj.OnObjectSpawned(build); if (IsPipelineIsEmpty) { OnPipelineBecameEmpty(); } return(obj); }
public void AddObjects(GameObject[] ObjectsToAdd) { foreach (var ObjectToAdd in ObjectsToAdd.ToList()) { SpawnedObjects.Add(ObjectToAdd); } }
public void RegisterObjectAsSpawned(GameObject inst) { if (SpawnedObjects == null) { SpawnedObjects = new List <GameObject>(); } SpawnedObjects.Add(inst); }
private void Add(ISpawnable spawn) { SpawnedObjects.Add(spawn); spawn.Spawner = this; if (spawn is BaseCreature creature) { creature.RemoveIfUntamed = RemoveIfUntamed; } }
private void OnTriggerStay2D(Collider2D collision) { if ((!destroyFlag || SpawnedObjects.Any(x => x == null)) && collision.gameObject.tag == "Player") { ClearAllObjects(); SpawnedObjects.Clear(); destroyFlag = true; for (int i = 0; i < NumberOfObjects; i++) { if (SpawnedObjects.Count == 0 || i + 1 == NumberOfObjects) { SpawnedObjects.Add(Instantiate(objectToSpawn, new Vector3((transform.position.x + (transform.localScale.x / 2)) - (OffSetSpawn + OffsetOfObjects * i), transform.position.y, transform.position.z), Quaternion.identity)); } else { SpawnedObjects.Add(Instantiate(objectToSpawn, new Vector3((transform.position.x + (transform.localScale.x / 2)) - (OffSetSpawn + OffsetOfObjects * i), SpawnedObjects.Last().transform.position.y + Random.Range(-YAxisOffset / 2, YAxisOffset / 2), transform.position.z), Quaternion.identity)); } } StartCoroutine(destroyObjectsAfter()); } }
// Update is called once per frame void Update() { if (CMapGenerator.bTool) { return; } if (!bSpawnStart) { return; } if (CurSpawnCount == 0) { if (false == bLoopSpawn) { bSpawnStart = false; } else if (bLoopSpawn && 0 == SpawnedObjects.Count) { RemainTime = SpawnTime; CurSpawnCount = MaxSpawnCount; } return; } if (RemainTime <= 0) { GameObject spawnObj = Instantiate(CResourceMgr.LoadCharacter(GetLoadCharacterName(), ECharacterType.Enemy) /*, gameObject.transform*/); spawnObj.transform.position = gameObject.transform.position; SpawnedObjects.Add(spawnObj); RemainTime = SpawnTime; --CurSpawnCount; } else { RemainTime -= Time.fixedDeltaTime; } }
internal void RegisterObject(Object obj) { lock (ManagedObjects) { if (ManagedObjects.Contains(obj)) { return; } OnObject.Invoke(obj); ManagedObjects.Add(obj); if (!(obj is GameObject gameObject)) { return; } if ((gameObject.Id.Flags & ObjectIdFlags.Spawned) != 0) { SpawnedObjects.Add(gameObject); } } }