コード例 #1
0
ファイル: GameManager.cs プロジェクト: yazici/FRONTIERS
        protected IEnumerator StartupGame()
        {
            while (GUILoading.SplashScreen)                     //wait for splash screen
            {
                yield return(null);
            }
            yield return(StartCoroutine(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack)));

            GUILoading.Lock(this);
            GUILoading.DetailsInfo = "Starting up...";
            yield return(StartCoroutine(InitializeGameEnvironment()));

            GUILoading.Unlock(this);
            yield return(StartCoroutine(GUILoading.LoadFinish()));

            //initialization only happens once
            //after we're done, wait for the start menu to choose a game
            gState = FGameState.WaitingForGame;
            if (TestingEnvironment)
            {
                yield return(StartCoroutine(WaitForGameTestingEnvironment()));
            }
            else
            {
                yield return(StartCoroutine(WaitForGame()));
            }
            yield break;
        }
コード例 #2
0
        protected IEnumerator SendPlayerToActionNode(int chunkID, string actionNodeName, float delay)
        {
            if (!GUILoading.IsLoading)
            {
                yield return(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack));
            }
            Player.Local.Despawn();
            //start off by setting the primary chunk
            GameWorld.Get.SetPrimaryChunk(chunkID);
            //action nodes won't exist unless it's primary
            while (GameWorld.Get.PrimaryChunk.CurrentMode != ChunkMode.Primary)              //wait for the chunk to load before we send it there
            //Debug.Log("Waiting for primary chunk to load");
            {
                yield return(null);
            }
            ActionNodeState nodeState = null;

            if (GameWorld.Get.PrimaryChunk.GetNode(actionNodeName, false, out nodeState))
            {
                //send player to location
                string     locationPath  = WIGroup.AllButLastInPath(nodeState.ParentGroupPath);
                string     locationName  = WIGroup.LastInPath(nodeState.ParentGroupPath);
                STransform spawnPosition = nodeState.Transform;
                if (nodeState.IsLoaded)
                {
                    spawnPosition = new STransform(nodeState.actionNode.transform, false);
                }
                yield return(StartCoroutine(SendPlayerToLocation(chunkID, locationPath, locationName, spawnPosition, GameWorld.Get.PrimaryChunk.ChunkOffset, delay)));
            }
            if (GUILoading.IsLoading)
            {
                yield return(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack));
            }
            yield break;
        }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: yazici/FRONTIERS
        protected IEnumerator WaitForUnload()
        {
            yield return(StartCoroutine(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack)));

            GUILoading.Lock(this);
            GUILoading.ActivityInfo = "Unloading World";
            string detailsInfo = "Unloading in game manager";

            GUILoading.DetailsInfo = "Waiting for managers to unload...";
            while (!Manager.FinishedUnloading)
            {
                while (GameWorld.Get.UnloadingGameWorld(out detailsInfo))                       //report GameWorld progress as it loads the game
                {
                    yield return(null);

                    GUILoading.DetailsInfo = detailsInfo;
                }
                Debug.Log("Waiting for manager to finish unloading...");
                yield return(null);
            }
            Application.LoadLevel("BlankLevel");            //this nukes anything but managers and worlditems
            GUILoading.Unlock(this);
            yield return(StartCoroutine(GUILoading.LoadFinish()));

            gState = FGameState.GameLoading;
        }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: yazici/FRONTIERS
        public override void WakeUp()
        {
            base.WakeUp();

            //Application.targetFrameRate = 60; yeah right
            ExceptionHandler.SetupExceptionHandling();

            Debug.Log("Waking up game manager");
            Get = this;
            mParentUnderManager = false;
            //initialize data paths so we can load stuff
            string errorMessage = string.Empty;

            if (!GameData.IO.InitializeSystemPaths(out errorMessage))              //aw shit son what did you do
            {
                GUILoading.DisplayError(errorMessage);
                //StartCoroutine(WaitForAnyKeyToQuit());
                return;
            }
            //load our globals so we can initialize stuff
            List <KeyValuePair <string, string> > globalPairs = null;

            if (!GameData.IO.LoadGlobals(ref globalPairs, out errorMessage))
            {
                GUILoading.DisplayError(errorMessage);
                return;
            }
            Globals.LoadData(globalPairs);
            GameData.IO.SaveGlobals(Globals.GetData());
            //set some stuff right off the bat
            //these are taken care of elsewhere after we've started up
            GameCamera.farClipPlane  = Globals.ClippingDistanceFar;
            GameCamera.nearClipPlane = Globals.ClippingDistanceNear;
            //(removed rest)
        }
コード例 #5
0
        protected IEnumerator FinishSequenceOverTime()
        {
            yield return(StartCoroutine(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack, true)));

            GUILoading.Lock(this);
            Player.Local.Despawn();
            yield return(null);

            yield return(StartCoroutine(SpawnManager.Get.SendPlayerToStartupPosition(State.StartupPositionName, State.Delay)));

            GUILoading.Unlock(this);
            yield return(null);

            yield return(StartCoroutine(GUILoading.LoadFinish()));
        }
コード例 #6
0
    void ReturnLastestPort()
    {
        GUILoading loading = Globals.Instance.MGUIManager.GetGUIWindow <GUILoading>();

        if (null != loading)
        {
            loading.SetVisible(true);
            loading.Progress      = 0.0f;
            loading.MLoadingState = LoadingState.REQUEST_CHANGE_SCENE;
            loading.LoadingType   = GUILoading.ELoadingType.ENTER_PORT;
        }

        long roleID = Globals.Instance.MGameDataManager.MActorData.PlayerID;
        int  seaID  = Globals.Instance.MGameDataManager.MCurrentSeaAreaData.SeaAreaID;

        NetSender.Instance.RequestEnterPort(roleID, seaID);
    }
コード例 #7
0
    public void SetGameState(GameState state)
    {
        // Release last GameState logic
        if (_mGameState == GameState.GAME_STATE_COPY &&
            state == GameState.GAME_STATE_BATTLE)
        {
            // Do not Release
        }
        else
        {
            if (_mCurrentGameStatus != null)
            {
                _mCurrentGameStatus.Release();
            }
        }

        GameState lastState = _mGameState;

        _mGameState = state;

        _mLastGameStatus = _mCurrentGameStatus;
        _mGameNextState  = GameState.GAME_STATE_INVALID;
        switch (_mGameState)
        {
        case GameState.GAME_STATE_INITIAL:
        {
            _mGameStatusPublisher.NotifyGameStateInitial();
            break;
        }

        case GameState.GAME_STATE_LOADING:
        {
            _mGameStatusPublisher.NotifyGameStateLoading();
            break;
        }

        case GameState.GAME_STATE_ROLE_CREATE:
        {
            //_mGameStatusPublisher.NotifyGameStateRoleCreate();

            //long roleID = Globals.Instance.MGameDataManager.MActorData.PlayerID;
            //string testRoleName = "yingpan";
            //string roleName =  testRoleName + roleID.ToString();
            //int gender = 1;

            //string avatarName = "AvatarMan1";
            //int templateId = 1217001000;
            //int countryID = -1;
            //NetSender.Instance.RequestCreatePlayer(roleName, gender, countryID, avatarName, templateId);

            //break;
            GUIGuoChang.Show();
            Globals.Instance.MGUIManager.CreateWindow <GUICreateRole>
            (
                delegate(GUICreateRole gui)
                {
                    GUIGuoChang.SetTweenPlay(0, delegate {
                        gui.UpdateZeroStep();
                    });
                }
            );

            break;
        }

        case GameState.GAME_STATE_LOGIN:
        {
            _mGameStatusPublisher.NotifyGameStateLogin();
            break;
        }

        case GameState.GAME_STATE_PORT:
        {
            _mGameStatusPublisher.NotifyGameStatePort();
            //Globals.Instance.MTeachManager.NewQianZhiFinshed();

            _mCurrentGameStatus = _pPortStatus;

            if (Globals.Instance.MGUIManager.GetGUIWindow <GUIMain>() == null)
            {
                Globals.Instance.MGUIManager.CreateWindow <GUIMain>(delegate(GUIMain gui)
                    {
                        NetSender.Instance.GetLotteryInfoReq();
                        Globals.Instance.MGameDataManager.MActorData.NotifyWorthUpdate();
                        Globals.Instance.MGameDataManager.MActorData.NotifyPlayerInfoUpdate();
                        gui.SetUISceneStatus(GUIMain.ESceneType.PORT);
                        if (!Globals.Instance.MTeachManager.IsOpenTeach)
                        {
                            gui.FunctionButtonState();
                        }
                        TaskManager.ReadGameFinishDataFilename();

                        NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.Recharge);
                        NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.GameInner);
                        NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.PromotionGift);

//					if (GameDefines.OutputVerDefs == OutputVersionDefs.Windows)
//					{
////						NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.Recharge);
////						NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.GameInner);
////						NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.PromotionGift);
//					}
//					else    if (GameDefines.OutputVerDefs == OutputVersionDefs.AppStore)
//					{
//						#if UNITY_IPHONE
//						PlayerData actorData = Globals.Instance.MGameDataManager.MActorData;
//						string str = "101119" + Globals.Instance.MGameDataManager.MActorData.PlayerID.ToString();
//						string str2 = actorData.BasicData.Name;
//						U3dAppStoreSender.LoginKTPlay(str,str2);
//						Debug.Log("IPHONE KTPlayLogin:"******"IPHONE CYLogin:"******"RequestVipStoreRechargeInfo");
////						NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.Recharge);
////						NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.GameInner);
////						NetSender.Instance.RequestVipStoreRechargeInfo((int)CommodityType.PromotionGift);
//						#endif
//					}
//					else if(GameDefines.OutputVerDefs==OutputVersionDefs.WPay)
//					{
//						PlayerData actorData = Globals.Instance.MGameDataManager.MActorData;
//						string str = "103214" + Globals.Instance.MGameDataManager.MActorData.PlayerID.ToString();
//						string str2 = actorData.BasicData.Name;
//						AndroidSDKAgent.LoginKTPlay(str,str2);
//						Debug.Log("ANDROID KTPlayLogin:"******"x03") == 0)
            {
                Globals.Instance.MTeachManager.NewOpenTeach("x03", 1);
            }
            break;
        }

        case GameState.GAME_STATE_HOME:
        {
            _mCurrentGameStatus = _homeStatus;
            _mCurrentGameStatus.Initialize();

            GUIBuildExplore guiBuildExplore = Globals.Instance.MGUIManager.GetGUIWindow <GUIBuildExplore>();
            if (guiBuildExplore != null)
            {
                guiBuildExplore.Close();
            }

            Globals.Instance.MGUIManager.GetGUIWindow <GUIMain>().SetVisible(false);
            break;
        }

        case GameState.GAME_STATE_COPY:
        {
            _mGameStatusPublisher.NotifyGameStateCopy();
            _mCurrentGameStatus = _pCopyStatus;

            // Battle and Copy is mutex in some time
            if (lastState == GameState.GAME_STATE_BATTLE)
            {
                // When switch from BattleStatus, we need do something in CopyStatus
                _pCopyStatus.OnBattleEnd(_pBattleStatus.MBattleResult);
            }
            else
            {
                _mCurrentGameStatus.Initialize();
            }

            Globals.Instance.MGUIManager.GetGUIWindow <GUIMain>().SetVisible(true);
            Globals.Instance.MGUIManager.GetGUIWindow <GUIMain>().SetUISceneStatus(GUIMain.ESceneType.COPY);

            /*GUIPublicWarn gui = Globals.Instance.MGUIManager.GetGUIWindow<GUIPublicWarn>();
             * if (null != gui)
             *      gui.SetVisible(true);
             */
            GUITaskTrack GUITaskTrack = Globals.Instance.MGUIManager.GetGUIWindow <GUITaskTrack>();
            if (null != GUITaskTrack)
            {
                GUITaskTrack.SetVisible(true);
                GUITaskTrack.UpdateData();
            }

            break;
        }

        case GameState.GAME_STATE_BATTLE:
        {
            EnterPKBattleByPlayerDock = (lastState == GameState.GAME_STATE_PLAYER_DOCK);

            _mGameStatusPublisher.NotifyGameStateBattle();
            _mCurrentGameStatus = _pBattleStatus;

            Globals.Instance.MGUIManager.GetGUIWindow <GUIMain>().SetVisible(false);
            //Globals.Instance.MGUIManager.GetGUIWindow<GUIPublicWarn>().SetVisible(false);

            GUITaskTrack GUITaskTrack = Globals.Instance.MGUIManager.GetGUIWindow <GUITaskTrack>();
            if (null != GUITaskTrack)
            {
                GUITaskTrack.SetVisible(false);
            }

            _mCurrentGameStatus.Initialize();

            break;
        }

        case GameState.GAME_STATE_PLAYER_DOCK:
        {
            _mCurrentGameStatus.Release();
            _mCurrentGameStatus = _pPlayerDockStatus;
            _mCurrentGameStatus.Initialize();

            Globals.Instance.MGUIManager.GetGUIWindow <GUIMain>().SetUISceneStatus(GUIMain.ESceneType.DOCK);

            break;
        }
        }
    }
コード例 #8
0
        public IEnumerator SendPlayerToStartupPosition(PlayerStartupPosition startupPosition)
        {
            if (mSpawningPlayer)
            {
                //whoops
                yield break;
            }

            mSpawningPlayer = true;

            if (!GUILoading.IsLoading)
            {
                //let that go on its own, don't wait for it
                StartCoroutine(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack));
            }

            //if the startup position is null
            //use the character's state as a startup position
            if (startupPosition == null)
            {
                //the player state should be not-null by now
                Debug.Log("Using player startup position");
                startupPosition = Player.Local.GetStartupPosition();
            }

            if (Player.Local.HasSpawned)
            {
                Player.Local.Despawn();
            }
            //set the current spawn position
            CurrentStartupPosition = startupPosition;
            yield return(null);

            //set all existing world chunks to unclaimed
            mLoadingInfo = "Unloading chunks";
            //suspend chunk loading so the player's position doesn't get the world confused
            GameWorld.Get.SuspendChunkLoading = true;
            for (int i = 0; i < GameWorld.Get.WorldChunks.Count; i++)
            {
                if (GameWorld.Get.WorldChunks [i].State.ID != startupPosition.ChunkID)
                {
                    GameWorld.Get.WorldChunks [i].TargetMode = ChunkMode.Unloaded;
                }
            }
            //suspend worlditem loading so worlditems don't start spawning stuff till we're ready
            WorldItems.Get.SuspendWorldItemUpdates = true;
            //WorldItems.Get.SetAllWorldItemsToInvisible();
            //wait a moment to let that sink in
            yield return(null);

            //put the player in the middle of the chunk to be loaded first
            WorldChunk startChunk = null;

            if (GameWorld.Get.ChunkByID(startupPosition.ChunkID, out startChunk))
            {
                Player.Local.Position = startChunk.ChunkOffset + startupPosition.ChunkPosition.Position;
            }
            else
            {
                mLoadingInfo = "ERROR: Couldn't find startup chunk";
            }
            //we send the player to the chunk / location specified in the world settings
            mLoadingInfo = "Sending player to startup position";
            //re-enable chunk loading so everything can load
            GameWorld.Get.SuspendChunkLoading      = false;
            WorldItems.Get.SuspendWorldItemUpdates = false;
            //set the primary chunk and let it load
            //put the player in the middle of the chunk to be loaded first
            mLoadingInfo = "Waiting for chunks to load";
            while (!GameWorld.Get.ChunksLoaded)
            {
                yield return(null);
            }
            if (startupPosition.ForceUnloadAllNonPrimaryChunks)
            {
                Debug.Log("Force-unloading all primary chunks, structures, worlditems");
                //unload all chunks except the primary chunk
                var unloadChunks = GameWorld.Get.UnloadAllChunks(startupPosition.ChunkID);
                while (unloadChunks.MoveNext())
                {
                    mLoadingInfo = "Unloading all chunks...";
                    yield return(unloadChunks.Current);
                }
                var unloadStructures = Structures.Get.UnloadAllStructures();
                while (unloadStructures.MoveNext())
                {
                    mLoadingInfo = "Unloading all structures...";
                    yield return(unloadStructures.Current);
                }
                var unloadWorldItems = WorldItems.Get.UnloadAllWorldItems();
                while (unloadWorldItems.MoveNext())
                {
                    mLoadingInfo = "Unloading all worlditems...";
                    yield return(unloadWorldItems.Current);
                }
                Resources.UnloadUnusedAssets();
            }
            mLoadingInfo = "Chunks unloaded, setting primary chunk";
            //set all the non-distant chunks to load
            GameWorld.Get.SetDistantChunks(Player.Local.Position);
            if (!GameWorld.Get.SetPrimaryChunk(startupPosition.ChunkID))
            {
                mLoadingInfo = "Couldn't set primary chunk, halting load: " + startupPosition.ChunkID.ToString();
                yield break;
            }
            //set the startup position so managers know where the player will end up
            startupPosition.WorldPosition.Position = (GameWorld.Get.PrimaryChunk.ChunkOffset + startupPosition.ChunkPosition.Position);
            startupPosition.WorldPosition.Rotation = startupPosition.ChunkPosition.Rotation;
            //set all the non-distant chunks to load
            GameWorld.Get.SetDistantChunks(startupPosition.WorldPosition.Position);
            //wait for the rest of the chunk to load
            while (GameWorld.Get.PrimaryChunk.CurrentMode != ChunkMode.Primary)
            {
                //turn on the camera so it starts rendering grass meshes
                //this will fight with camera FX but that's ok
                CameraFX.Get.Default.cam.enabled     = true;
                CameraFX.Get.Default.cam.cullingMask = CameraFX.Get.Default.CullingMask;
                mLoadingInfo = "Waiting for primary chunk to load";
                //Debug.Log("waiting for primary chunk to load");
                yield return(null);
            }

            //initialize time
            if (startupPosition.RequiresStructure)
            {
                mLoadingInfo = "Loading structures";
                yield return(StartCoroutine(SendPlayerToStructure(
                                                startupPosition.ChunkID,
                                                startupPosition.LocationReference,
                                                startupPosition.StructureName,
                                                startupPosition.Interior,
                                                startupPosition.ChunkPosition,
                                                startChunk.ChunkOffset)));
            }
            else
            {
                mLoadingInfo = "Loading location";
                yield return(StartCoroutine(SendPlayerToLocation(
                                                startupPosition.ChunkID,
                                                startupPosition.LocationReference.GroupPath,
                                                startupPosition.LocationReference.FileName,
                                                startupPosition.ChunkPosition,
                                                startChunk.ChunkOffset,
                                                0.1f)));

                //since we're not inside a structure
                //we could be standing on something
                //either a minor structure or chunk prefab
                if (startupPosition.RequiresMeshTerrain)
                {
                    //wait for something to show up below the player before letting them go
                    GameWorld.TerrainHeightSearch terrainHit = new GameWorld.TerrainHeightSearch();
                    terrainHit.feetPosition   = startupPosition.WorldPosition.Position;
                    terrainHit.groundedHeight = Globals.DefaultCharacterGroundedHeight;
                    terrainHit.overhangHeight = Globals.DefaultCharacterHeight;
                    bool   foundSomethingBelowPlayer = false;
                    double timeOut = WorldClock.RealTime + 30f;
                    mLoadingInfo = "Waiting for mesh below player's feet";
                    while (WorldClock.RealTime < timeOut)
                    {
                        GameWorld.Get.TerrainHeightAtInGamePosition(ref terrainHit);
                        //see if we hit a mesh
                        if (terrainHit.hitTerrainMesh)
                        {
                            break;
                        }
                        yield return(null);
                    }
                }
            }

            //immediately add the game offset
            if (startupPosition.AbsoluteTime)
            {
                WorldClock.ResetAbsoluteTime();
                Profile.Get.CurrentGame.SetWorldTimeOffset(
                    startupPosition.TimeHours,
                    startupPosition.TimeDays,
                    startupPosition.TimeMonths,
                    startupPosition.TimeYears);
            }
            else
            {
                Profile.Get.CurrentGame.AddWorldTimeOffset(
                    startupPosition.TimeHours,
                    startupPosition.TimeDays,
                    startupPosition.TimeMonths,
                    startupPosition.TimeYears);
            }

            //unload anything we're not using
            //GC.Collect();
            //Resources.UnloadUnusedAssets();
            //yield return null;
            yield return(null);

            if (GUILoading.IsLoading)
            {
                StartCoroutine(GUILoading.LoadFinish());
            }

            Player.Local.SpawnAtPosition(startupPosition.WorldPosition);

            mSpawningPlayer = false;
            yield break;
        }
コード例 #9
0
ファイル: GameManager.cs プロジェクト: yazici/FRONTIERS
        //loads the current game and world
        //starts it up
        protected IEnumerator LoadOverTime()
        {
            Biomes.Get.UseTimeOfDayOverride = false;
            if (mStartupScenePrefab != null)
            {
                GameObject.Destroy(mStartupScenePrefab, 0.5f);
            }
            //Load all the things!
            yield return(StartCoroutine(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack)));

            GUILoading.Lock(this);
            string detailsInfo = string.Empty;

            //load all textures first
            //------------------
            Manager.TexturesLoadStart();
            //------------------
            yield return(null);

            GUILoading.ActivityInfo = "Loading Textures";
            GUILoading.DetailsInfo  = "Compiling mods";
            while (!Manager.FinishedLoadingTextures)
            {
                yield return(null);
            }
            GUILoading.ActivityInfo = "Generating World";
            GUILoading.DetailsInfo  = "Compiling mods";
            yield return(null);

            //------------------
            Manager.ModsLoadStart();
            //------------------
            //wait for the actual mods manager to finish loading mods
            while (!Mods.Get.ModsLoaded)
            {
                yield return(null);
            }
            //------------------
            Manager.ModsLoadFinish();
            //------------------
            yield return(null);

            //then jump straight ahead to the world loading
            GUILoading.ActivityInfo = "Loading World";
            GUILoading.DetailsInfo  = "Loading mods from generated world";
            //during this section we report on what the world manager is doing
            //it accomplishes nothing but looks nice on the loading screen
            GUILoading.ActivityInfo = "Creating World";
            while (GameWorld.Get.LoadingGameWorld(out detailsInfo))              //report GameWorld progress as it loads the game
            {
                yield return(null);

                GUILoading.DetailsInfo = detailsInfo;
            }
            //wait for other mods as normal
            //------------------
            while (!Manager.FinishedLoadingMods)
            {
                //Debug.Log ("Waiting for mods to finish loading");
                yield return(null);
            }
            //this only happens once per game
            if (!Profile.Get.CurrentGame.HasLoadedOnce)
            {
                GUILoading.ActivityInfo = "Creating World for First Time";
                //Debug.Log ("Creating world for first time");
                //------------------
                Manager.GameLoadStartFirstTime();
                //------------------
            }
            yield return(null);

            //------------------
            Manager.GameLoadStart();
            //------------------
            //give managers a tick to figure out what they're doing
            yield return(null);

            //------------------
            Manager.GameLoadFinish();
            //------------------
            while (!Manager.FinishedLoading)
            {
                //Debug.Log ("Waiting to finish loading...");
                yield return(null);
            }
            //during this section we report on what the spawn manager is up to
            while (SpawnManager.Get.SpawningPlayer(out detailsInfo))
            {
                yield return(null);

                GUILoading.DetailsInfo = detailsInfo;
            }
            //start the game!
            gState = FGameState.GameStarting;
            //wait a tick
            yield return(null);

            //this only happens once per game
            if (!Profile.Get.CurrentGame.HasStarted)
            {
                //------------------
                Manager.GameStartFirstTime();
                //------------------
                Profile.Get.CurrentGame.HasStarted = true;
                yield return(null);
            }
            //------------------
            Manager.GameStart();
            //------------------
            yield return(null);

            if (NetworkManager.Instance.IsHost)
            {
                //if we're the host, then the game can begin here
                //HostState = NHostState.Started;
            }
            //we pause the game immediately while we wait for the player to spawn
            //------------------
            Manager.GamePause();
            //------------------
            yield return(null);

            //save the game so we know that we've started once
            Profile.Get.SaveCurrent(ProfileComponents.Profile);
            //wait for the player to finish spawning then turn off the loading screen
            while (!Player.Local.HasSpawned)
            {
                //Debug.Log("Waiting for player to spawn");
                yield return(null);
            }
            //turn off the loading screen
            GUILoading.Unlock(this);
            yield return(StartCoroutine(GUILoading.LoadFinish()));

            //now that the player has spawned continue the game
            //------------------
            Manager.GameContinue();
            //------------------
            //this will set the state to InGame
            yield break;
        }
コード例 #10
0
        protected IEnumerator MakeTradeoverTime()
        {
            Debug.Log("Starting to make trade");
            var loadStart = GUILoading.LoadStart(GUILoading.Mode.SmallInGame);

            while (loadStart.MoveNext())
            {
                yield return(null);
            }
            GUILoading.ActivityInfo = "Making Trade... " + CharacterGoods.Count.ToString() + " character goods going to player";
            //give stuff to player...
            foreach (BarterGoods good in CharacterGoods)
            {
                foreach (KeyValuePair <WIStack, int> goodPair in good)
                {
                    if (goodPair.Key.HasTopItem)
                    {
                        Debug.Log("Adding " + goodPair.Key.TopItem.FileName + " to player inventory...");
                    }
                    var addItem = PlayerInventory.AddItems(goodPair.Key, goodPair.Value);
                    while (addItem.MoveNext())
                    {
                        yield return(null);
                    }
                }
                yield return(null);
            }
            //wait a tick...
            yield return(null);

            //give stuff to character...
            foreach (BarterGoods good in PlayerGoods)
            {
                foreach (KeyValuePair <WIStack, int> goodPair in good)
                {
                    var enumerator = CharacterInventory.AddItems(goodPair.Key, goodPair.Value);
                    while (enumerator.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            //TODO determine what counts as a 'successful use'
            BarterManager.Use(true);

            PlayerBank.Absorb(CharacterGoodsBank);
            CharacterBank.Absorb(PlayerGoodsBank);

            ClearGoodsAndCurrency();
            MadeTradeThisSession = true;
            Player.Get.AvatarActions.ReceiveAction(AvatarAction.BarterMakeTrade, WorldClock.AdjustedRealTime);
            var loadFinish = GUILoading.LoadFinish();

            while (loadFinish.MoveNext())
            {
                yield return(null);
            }
            Debug.Log("Finished making trade");
            mMakingTrade = false;
            yield break;
        }