/// <summary> /// Creates new big UFO at the positon. /// </summary> /// <returns>Reference to created GameObject. So they can be tracked.</returns> public override GameObject Create(Vector3 position) { GameObject NewEnemy = Instantiate(Product, position, Quaternion.identity); //подписка нового врага на события, если требуется. //получение направления движения для врага Vector3 MovementDirection = UFOMovementDirection.Get(position); //назначение направления движения врагу NewEnemy.GetComponent <IFlyingObject>().SetFlightParameters(MovementDirection); return(NewEnemy); }
private IEnumerator ChangeDirection(float time) { yield return(new WaitForSeconds(time)); if (Flight == FlightType.Horizontal) { SetFlightParameters(UFOMovementDirection.GetDiagonalDirection(FlightDirection)); Flight = FlightType.Diagonal; } else if (Flight == FlightType.Diagonal) { SetFlightParameters(UFOMovementDirection.GetHorizontalDirection(FlightDirection)); Flight = FlightType.Horizontal; } StartCoroutine(ChangeDirection(GetChangeDirectionTime())); }