/// <summary> /// Sequence of action of a spawning elevator from spawning to release and back to spawn-ready state(simplified) /// </summary> public override void Spawn(int count) { //abort if not ready if (!IsAvailable) { return; } float delay = 0f; IsAvailable = false; StopAllCoroutines(); //spawn AIs _spawnedAIs.Clear(); InstantiateAIs(count); //todo : rename this to Instantiate or soemthing along that line //Move to release pos delay += 0.5f; StartCoroutine(IEMove(delay, _downPos, 2f)); delay += 2f; //Open door and after a short delay, release AIs StartCoroutine(_door.IEMove(_door.GetOpenPos(), delay)); delay += 1f; StartCoroutine(IERelease(delay, _releaseMoveTarget.position)); delay += 3f; //wait until elevator is clear(empty) StartCoroutine(IEWaitUntilClear(delay)); //old // //Then close the door // StartCoroutine (_door.IEMove (_door.GetClosePos (), delay)); // delay += 1f; // //Move underwater to clear any remaning or new objects on board // StartCoroutine (IEMove (delay, _drawnPos, 2f)); // delay += 2f; // //Move up to spawning position // StartCoroutine (IEMove (delay, _upPos, 3f)); // delay += 3f; // Debug.Break (); //Set availability for next spawn depending on the total delay // IsAvailable = false; // StartCoroutine (CoroutineHelper.IEChangeBool ((x) => IsAvailable = x, true, delay)); }