protected override IEnumerator OnShow(params object[] parameters)
    {
        yield return(base.OnShow(parameters));

        IPlayerControllerRepositoryService service = base.Game.Services.GetService <IPlayerControllerRepositoryService>();

        this.interactionsAllowed      = service.ActivePlayerController.CanSendOrders();
        this.previousCursor           = AgeManager.Instance.Cursor;
        this.WorkerGroupsTable.Enable = true;
        this.updateDrag = true;
        UnityCoroutine.StartCoroutine(this, this.UpdateDrag(), null);
        base.GuiService.GetGuiPanel <WorkersDragPanel>().Hide(true);
        if (this.City != null)
        {
            base.NeedRefresh = true;
        }
        if (this.BoostersEnumerator == null)
        {
            bool highDefinition = AgeUtils.HighDefinition;
            AgeUtils.HighDefinition = false;
            GameEmpireScreen guiPanel = base.GuiService.GetGuiPanel <GameEmpireScreen>();
            this.BoostersEnumerator = UnityEngine.Object.Instantiate <BoosterEnumerator>(guiPanel.BoostersEnumerator);
            AgeUtils.HighDefinition = highDefinition;
        }
        yield break;
    }
 private void OnSaveCB(GameObject obj)
 {
     if (string.IsNullOrEmpty(this.TextInputLabel.Text))
     {
         return;
     }
     if (this.saving == null)
     {
         string text  = this.TextInputLabel.Text;
         string text2 = System.IO.Path.Combine(global::Application.GameSaveDirectory, string.Format("{0}.sav", text));
         if (File.Exists(text2))
         {
             string message = string.Format(AgeLocalizer.Instance.LocalizeString("%ConfirmFileSaveOverwriteFormat"), System.IO.Path.GetFileNameWithoutExtension(text2));
             MessagePanel.Instance.Show(message, string.Empty, MessagePanelButtons.YesNo, new MessagePanel.EventHandler(this.OnConfirmFileSaveOverwrite), MessagePanelType.WARNING, new MessagePanelButton[0]);
         }
         else
         {
             this.saving = UnityCoroutine.StartCoroutine(this, this.SaveGameAsync(text, text2), new EventHandler <CoroutineExceptionEventArgs>(this.SaveGameAsync_CoroutineExceptionHandler));
             if (this.saving.IsFinished)
             {
                 this.saving = null;
             }
         }
     }
 }
Exemple #3
0
        protected override IEnumerator Start()
        {
            yield return(base.StartCoroutine(base.Start()));

            UnityCoroutine.StartCoroutine(this, this.Ignite(), new EventHandler <CoroutineExceptionEventArgs>(this.Ignite_CoroutineExceptionCallback));
            yield break;
        }
Exemple #4
0
 public static void Quit()
 {
     if (Application.Instance != null && Application.Instance.shutdown == null)
     {
         Application.Instance.shutdown = UnityCoroutine.StartCoroutine(Application.Instance, Application.Instance.Shutdown(), null);
     }
 }
Exemple #5
0
    private void BeginTurn()
    {
        while (true)
        {
            if (currentPlayer.numberOfTurns > 0)
            {
                --currentPlayer.numberOfTurns;
                break;
            }
            else
            {
                //This increment guarantees that at some point one of the players will have a positive number of turns.
                ++currentPlayer.numberOfTurns;
                currentPlayerIndex += turnDirection;

                while (currentPlayerIndex < 0)
                {
                    currentPlayerIndex += players.Length;
                }
                currentPlayerIndex %= players.Length;
            }
        }

        m_GameRoutine = new UnityCoroutine(TurnRountine());
        StartCoroutine(m_GameRoutine.StartSafe());
    }
Exemple #6
0
    public static Coroutine StartCoroutineEx(this MonoBehaviour self, IEnumerator routine, out UnityCoroutine unityCoroutine)
    {
        if (routine == null)
        {
            throw new ArgumentNullException("routine");
        }

        unityCoroutine = new UnityCoroutine(routine);
        return(self.StartCoroutine(unityCoroutine.Start()));
    }
Exemple #7
0
        /// <inheritdoc />
        public void Remove(ICoroutine coroutine)
        {
            UnityCoroutine asUnity = coroutine as UnityCoroutine;

            if (asUnity == null)
            {
                throw new ArgumentException("coroutine must be a UnityCoroutine");
            }
            StopCoroutine(asUnity.OriginalCoroutine);
        }
Exemple #8
0
    public static IEnumerator MoveBy(CardDefinition definition, Card card, Player player)
    {
        var count = GetIntParam(definition, card, "count", 0);

        if (count == 0)
        {
            yield break;
        }

        var allPlayers = GetIntParam(definition, card, "allPlayers", 0);

        if (allPlayers != 0)
        {
            FollowCamera.Push(Board.instance.ground);
            yield return(new WaitForCamera());

            var game     = GameController.instance;
            var routines = new UnityCoroutine[game.playersCount];

            for (int i = 0; i < game.playersCount; ++i)
            {
                var currentPlayer = game.players[i];
                routines[i] = new UnityCoroutine(currentPlayer.MoveBy(count));
                currentPlayer.StartCoroutineEx(routines[i].Start());
                while (routines[i].state != UnityCoroutine.CoroutineState.Finished)
                {
                    yield return(null);
                    //buggy all moving but just the first one get card effect from moving
                }
            }

            foreach (var routine in routines)
            {
                yield return(new WaitForRoutine(routine));
            }

            FollowCamera.Pop();
        }
        else
        {
            var playerIdx = GetIntParam(definition, card, "playerIdx", player.playerNumber);
            if (playerIdx < 0 || playerIdx >= GameController.instance.playersCount)
            {
                yield break;
            }

            var targetPlayer = GameController.instance.players[playerIdx];
            FollowCamera.Push(targetPlayer);
            yield return(new WaitForCamera());

            yield return(targetPlayer.MoveBy(count));

            FollowCamera.Pop();
        }
    }
 public void ReloadRuntime(params RuntimeModuleConfiguration[] configuration)
 {
     if (this.reloading == null)
     {
         this.reloading = UnityCoroutine.StartCoroutine(this, this.ReloadRuntimeAsync(configuration), new EventHandler <CoroutineExceptionEventArgs>(this.ReloadRuntime_CoroutineExceptionCallback));
         if (this.reloading.IsFinished)
         {
             this.reloading = null;
         }
     }
 }
Exemple #10
0
        public IDisposable Play(ICursor cursor)
        {
            if (cursor == null)
            {
                throw new NotImplementedException();
            }

            IEnumerator coroutine = new Coroutine(this, cursor);
            var         canceler  = UnityCoroutine.Start(coroutine);

            return(canceler);
        }
    private void OnConfirmFileSaveOverwrite(object sender, MessagePanelResultEventArgs e)
    {
        MessagePanelResult result = e.Result;

        if (result == MessagePanelResult.Ok || result == MessagePanelResult.Yes)
        {
            string text           = this.TextInputLabel.Text;
            string outputFileName = System.IO.Path.Combine(global::Application.GameSaveDirectory, string.Format("{0}.sav", text));
            this.saving = UnityCoroutine.StartCoroutine(this, this.SaveGameAsync(text, outputFileName), new EventHandler <CoroutineExceptionEventArgs>(this.SaveGameAsync_CoroutineExceptionHandler));
            if (this.saving.IsFinished)
            {
                this.saving = null;
            }
        }
    }
 public void UnloadRuntime(bool instant = false)
 {
     if (this.unloading == null)
     {
         this.unloading = UnityCoroutine.StartCoroutine(this, this.UnloadRuntimeAsync(), new EventHandler <CoroutineExceptionEventArgs>(this.UnloadRuntime_CoroutineExceptionCallback));
         if (this.unloading.IsFinished)
         {
             this.unloading = null;
         }
         else if (instant)
         {
             this.unloading.RunUntilIsFinished();
             this.unloading = null;
         }
     }
 }
Exemple #13
0
        protected IEnumerator Ignite()
        {
            yield return(this.SetupDiagnosticsLogFile());

            Diagnostics.Log("Starting the application, version is {0}...", new object[]
            {
                Application.Version.ToString()
            });
            Diagnostics.Log("Running 64-bit mode...");
            Diagnostics.Log("Game directory is \"{0}\".", new object[]
            {
                Application.GameDirectory
            });
            yield return(this.SteamRestartAppIfNecessary());

            yield return(this.SteamInitialize());

            yield return(this.SteamGetCurrentGameLanguage());

            yield return(this.SteamGetSteamUserName());

            Application.LoadRegistry();
            yield return(this.OnApplicationIgnitionStarted());

            this.Managers = base.gameObject.GetComponentsInChildren <Manager>();
            foreach (Manager manager in this.Managers)
            {
                UnityCoroutine.StartCoroutine(manager, manager.Ignite(), new EventHandler <CoroutineExceptionEventArgs>(this.Manager_Ignite_CoroutineExceptionCallback));
            }
            foreach (Manager manager2 in this.Managers)
            {
                while (!manager2.HasBeenIgnited)
                {
                    yield return(null);
                }
                if (manager2.LastError != 0)
                {
                }
            }
            Application.Bootstrapper = (UnityEngine.Object.FindObjectOfType(typeof(Bootstrapper)) as Bootstrapper);
            this.LastRevision        = Databases.CurrentRevision;
            Databases.Commit();
            yield return(this.OnApplicationIgnitionComplete());

            yield break;
        }
Exemple #14
0
 private void LoadScene()
 {
     if (this.SceneObject == null)
     {
         if (this.loadLevelAsyncOperation != null)
         {
             return;
         }
         if (this.LevelNames != null && this.LevelNames.Length != 0)
         {
             this.LevelNames = this.LevelNames.Distinct <string>().ToArray <string>();
             string text = this.LevelNames[UnityEngine.Random.Range(0, this.LevelNames.Length)];
             if (!string.IsNullOrEmpty(this.lastLevelName))
             {
                 text = this.lastLevelName;
             }
             else if (string.IsNullOrEmpty(text))
             {
                 foreach (string text2 in this.LevelNames)
                 {
                     if (!string.IsNullOrEmpty(text2))
                     {
                         text = text2;
                         break;
                     }
                 }
             }
             if (text != null)
             {
                 if (this.KeepSameLevel)
                 {
                     this.lastLevelName = text;
                 }
                 UnityCoroutine.StartCoroutine(this, this.LoadSceneAsync(text), null);
             }
         }
     }
 }
    public override void RefreshContent()
    {
        base.RefreshContent();
        if (this.listing != null)
        {
            this.ListingNumber++;
            this.listing = null;
        }
        if (this.listing == null)
        {
            this.listing = UnityCoroutine.StartCoroutine(this, this.ListGamesAsync(this.ListingNumber), new EventHandler <CoroutineExceptionEventArgs>(this.ListGamesAsync_CoroutineExceptionHandler));
            if (this.listing.IsFinished)
            {
                this.listing = null;
            }
        }
        SortedLinesTable component = this.LoadSaveContainer.GetComponent <SortedLinesTable>();

        if (component != null)
        {
            component.SortLines();
        }
        this.RefreshButtons();
    }
Exemple #16
0
 public WaitForRoutine(UnityCoroutine routine)
 {
     m_Routine = routine;
 }