Пример #1
0
        private void Awake()
        {
            if (!started)
            {
                // Activate the Google Play Games platform
                PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();

                PlayGamesPlatform.InitializeInstance(config);
                PlayGamesPlatform.DebugLogEnabled = true;
                PlayGamesPlatform.Activate();

                // initialize progress (replace by google save)
                ProgressManager.LoadProgressData();

                // Initialize Ads
                Admob.Instance().initAdmob("ca-app-pub-2906510767249222/2074269594", "ca-app-pub-2906510767249222/2353471190");//admob id with format ca-app-pub-279xxxxxxxx/xxxxxxxx
                //Admob.Instance().setTesting(true);

                currentScene = ActiveScene.home;

#if UNITY_ANDROID
                Social.localUser.Authenticate((bool success) =>
                {
                });
#endif
            }

            if (_instance != null && _instance != this)
            {
                Destroy(this.gameObject);
                return;
            }
            _instance = this;
            DontDestroyOnLoad(this.gameObject);
        }
Пример #2
0
        /// <summary>
        /// Draw everything.
        /// Note: need to be called after clearing the device.
        /// </summary>
        /// <param name="clearBuffer">If true, will also clear buffer.</param>
        public void Draw(bool clearBuffer = true)
        {
            // get graphic device
            GraphicsDevice device = Core.Graphics.GraphicsManager.GraphicsDevice;

            // call the before-draw update function
            ActiveScene.BeforeDraw();

            // start drawing frame
            Core.Graphics.GraphicsManager.StartDrawFrame();

            // reset diagnostic drawings count
            Diagnostic.ResetDrawCounters();

            // render everything
            ActiveScene.Draw();

            // end drawing frame (will also draw all rendering queues)
            Core.Graphics.GraphicsManager.EndDrawFrame();

            // reset stencil state
            device.DepthStencilState = DepthStencilState.Default;

            // draw ui
            if (UiEnabled)
            {
                UI.UserInterface.Active.Draw(_spriteBatch);
            }
        }
Пример #3
0
        public uint Execute(PacketDistributed ipacket)
        {
            GC_PLAY_MODELSOTRY packet = (GC_PLAY_MODELSOTRY)ipacket;

            if (null == packet)
            {
                return((uint)PACKET_EXE.PACKET_EXE_ERROR);
            }
            //enter your logic
            if (packet.ModelStoryID == GlobeVar.YanMenGuan_ModelStoryID)
            {
                Obj_MainPlayer mainplayer = Singleton <ObjManager> .Instance.MainPlayer;
                if (mainplayer == null)
                {
                    return((uint)PACKET_EXE.PACKET_EXE_ERROR);
                }
                //mainplayer.CameraController.InitCameraTrack(mainplayer.Position, curBoss.Position);
                mainplayer.ModelStoryID = packet.ModelStoryID;

                mainplayer.StopMove();
                Vector3 posTarget        = new Vector3(13.9f, 0, 27.4f);
                Vector3 posTargetTerrain = ActiveScene.GetTerrainPosition(posTarget);
                mainplayer.MoveTo(posTargetTerrain);
            }
            return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
        }
        private void DrawItem(Rect rect, HierarchyEntityGroupGraph item, RowGUIArgs args)
        {
            if (null == item)
            {
                return;
            }

            var indent = GetContentIndent(item);

            if (!args.selected)
            {
                var headerRect = rect;
                headerRect.width += 1;

                var topLine = headerRect;
                topLine.height = 1;
                UTinyGUI.BackgroundColor(topLine, UTinyColors.Hierarchy.SceneSeparator);

                headerRect.y += 2;
                UTinyGUI.BackgroundColor(headerRect, UTinyColors.Hierarchy.SceneItem);

                var bottomLine = headerRect;
                bottomLine.y     += bottomLine.height - 1;
                bottomLine.height = 1;
                UTinyGUI.BackgroundColor(bottomLine, UTinyColors.Hierarchy.SceneSeparator);
            }


            rect.y     += 2;
            rect.x      = indent;
            rect.width -= indent;

            var iconRect = rect;

            iconRect.width = 20;

            var image = ActiveScene.Equals(item.Value.EntityGroupRef) ? UTinyIcons.ActiveEntityGroup : UTinyIcons.EntityGroup;

            EditorGUI.LabelField(iconRect, new GUIContent {
                image = image
            });

            rect.x     += 20;
            rect.width -= 40;

            item.displayName = item.Value.EntityGroupRef.Dereference(Registry).Name;
            var style = ActiveScene.Equals(item.Value.EntityGroupRef) ? EditorStyles.boldLabel : GUI.skin.label;

            EditorGUI.LabelField(rect, item.displayName, style);
            rect.x    += rect.width;
            rect.width = 16;

            rect.y      = rect.center.y - 5.5f;
            rect.height = 11;

            if (GUI.Button(rect, GUIContent.none, UTinyStyles.PaneOptionStyle))
            {
                HierarchyContextMenus.ShowEntityGroupContextMenu(this, item.Value.EntityGroupRef);
            }
        }
Пример #5
0
 /// <summary>
 /// Processes a Render.
 /// </summary>
 /// <param name="spriteBatch">The SpriteBatch.</param>
 /// <param name="gameTime">The GameTime.</param>
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     if (ActiveScene != null)
     {
         ActiveScene.Draw(spriteBatch, gameTime);
     }
 }
Пример #6
0
 /// <summary>
 /// Updates the object.
 /// </summary>
 /// <param name="gameTime">The GameTime.</param>
 public void Update(GameTime gameTime)
 {
     if (ActiveScene != null)
     {
         ActiveScene.Update(gameTime);
     }
 }
Пример #7
0
 private void onKeyDown(int key, dynamic obj)
 {
     ActiveScene.RegisterKeyCallback(KeyAction.KeyDown, key, () =>
     {
         try
         {
             if (ActiveScene.Running)
             {
                 obj();
             }
         }
         catch (ThreadAbortException)
         {
             Thread.ResetAbort();
         }
         catch (ScriptEngineException e)
         {
             _output.AppendLine(e.ErrorDetails);
         }
         catch (Exception e)
         {
             _output.AppendLine("[external error] " + e.Message);
         }
     });
 }
Пример #8
0
        private void UpdateFellowMove()
        {
            SetMoveSpeedAsMainPlayer();
            Obj_MainPlayer mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

            //TODO 判读是否在战斗
            Vector3 targetPos = GetFellowPos(mainPlayer);

            if (Vector3.Distance(Position, targetPos) >= 6)
            {
                //距离太远 直接拉过去
                if (NavAgent != null)
                {
                    UnityEngine.GameObject.DestroyImmediate(NavAgent);
                }
                m_ObjTransform.position = ActiveScene.GetTerrainPosition(new Vector3(targetPos.x, 0f, targetPos.z));
                if (NavAgent == null)
                {
                    InitNavAgent();
                }
            }
            else if (Vector3.Distance(Position, targetPos) >= 2 || (IsMoving && Vector3.Distance(Position, targetPos) >= 1))
            {
                MoveTo(targetPos, null, 0f);
            }
        }
Пример #9
0
        public static void Update(GameTime gametime, ContentManager contentmanager)
        {
            if (ActiveScene != null)
            {
                RenderContext.GameTime = gametime;
                ActiveScene.Update(RenderContext, contentmanager);

                // initialisasi scene
                if (!IsInitialized)
                {
                    var chosenscene = GameScenes.FirstOrDefault(scene =>
                                                                scene.SceneName.Equals("MainMenu"));
                    chosenscene.Update(RenderContext, contentmanager);

                    chosenscene = GameScenes.FirstOrDefault(scene =>
                                                            scene.SceneName.Equals("TitleScreen"));
                    chosenscene.Update(RenderContext, contentmanager);

                    chosenscene = GameScenes.FirstOrDefault(scene =>
                                                            scene.SceneName.Equals("LevelSelect"));
                    chosenscene.Update(RenderContext, contentmanager);

                    chosenscene = GameScenes.FirstOrDefault(scene =>
                                                            scene.SceneName.Equals("Level1"));
                    chosenscene.Update(RenderContext, contentmanager);

                    chosenscene = GameScenes.FirstOrDefault(scene =>
                                                            scene.SceneName.Equals("Archive"));
                    chosenscene.Update(RenderContext, contentmanager);

                    IsInitialized = true;
                }
            }
            RenderContext.TouchPanelState = TouchPanel.GetState();
        }
Пример #10
0
    void OnSceneMapClick()
    {
        Vector3 worldPos = UICamera.currentCamera.ScreenToWorldPoint(UICamera.lastTouchPosition);
        Vector3 localPos = m_TextureMap.transform.InverseTransformPoint(worldPos);
        Vector3 mapPos   = MapPosToScenePos(localPos, m_curTabScene);

        AutoSearchPoint point = new AutoSearchPoint(m_curSceneID, mapPos.x, mapPos.z);

        if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
        {
            if (Singleton <ObjManager> .GetInstance().MainPlayer)
            {
                //验证导航是否可达,如果不可达,不进行移动
                Vector3 testVec = new Vector3(point.PosX, 0, point.PosZ);
                testVec = ActiveScene.GetTerrainPosition(testVec);
                if (!Singleton <ObjManager> .GetInstance().MainPlayer.IsMoveNavAgent(testVec))
                {
                    return;
                }
            }

            GameManager.gameManager.AutoSearch.ProcessAutoSearch(point);
        }

        if (m_ClickEffectSprite != null && m_ClickEffectTran != null)
        {
            m_ClickEffectTran.localPosition = localPos;
            m_ClickEffectSprite.gameObject.SetActive(true);
        }
        else
        {
            LogModule.ErrorLog("OnSceneMapClick::m_ClickEffectSprite = null || m_ClickEffectTran = null");
        }
    }
        public void Evaluate()
        {
            ReevaluateLockStatuses();

            if (ActiveScene == null)
            {
                return;
            }

            SceneModel dest = ActiveScene.GetFirstPassingTransition(this);

            if (dest == null && ActiveScene.UseAnySceneTransitions)
            {
                dest = AnyScene.GetFirstPassingTransition(this);

                if (dest != null && dest.SceneId == ANY_SCENE_ID)
                {
                    dest = ActiveScene;
                }
            }
            if (dest != null)
            {
                TransitionToScene(dest);
            }
        }
Пример #12
0
 public void SwitchScene(Guid guid)
 {
     if (Scenes.Any(s => s.SceneId.Equals(guid)))
     {
         ActiveScene = Scenes.First(s => s.SceneId.Equals(guid));
         ActiveScene.OnSceneSwitch();
     }
 }
Пример #13
0
        Task ICommandHandler <AddScriptCommandDefinition> .Run(Command command)
        {
            Script script = ActiveScene.AddInstance <Script>() as Script;

            IoC.Get <IShell>().OpenDocument(new ScriptViewModel(script));

            return(TaskUtility.Completed);
        }
Пример #14
0
        private void _host_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            int key = (int)e.Key;

            if (ActiveScene.Running)
            {
                ActiveScene.RunKeyCallback(KeyAction.KeyUp, key);
            }
        }
Пример #15
0
 public void Input()
 {
     if (InputQueued)
     {
         InputManager.Update();
         ActiveScene.InvokeInput();
         InputQueued = false;
     }
 }
Пример #16
0
        internal static void PreUpdate()
        {
            if (SceneChanging)             // TODO: Check the transition is complete first as well, once implemented
            {
                DoSceneChange();
            }

            ActiveScene?.DoPreUpdate();
        }
Пример #17
0
        public void KeyboardTick()
        {
            foreach (int key in ActiveScene.GetRegisteredKeyPressKeys())
            {
                bool down = false;
                Engine.RunOnUIThread(() =>
                {
                    down = Keyboard.IsKeyDown((Key)key);
                });
                if (down)
                {
                    ActiveScene.RunKeyCallback(KeyAction.KeyPress, key);
                }
            }
            bool   none            = true;
            bool   aDown           = false;
            bool   wDown           = false;
            bool   sDown           = false;
            bool   dDown           = false;
            double shiftMultiplier = 1.0d;

            Engine.RunOnUIThread(() =>
            {
                wDown           = Keyboard.IsKeyDown(Key.W);
                aDown           = Keyboard.IsKeyDown(Key.A);
                sDown           = Keyboard.IsKeyDown(Key.S);
                dDown           = Keyboard.IsKeyDown(Key.D);
                shiftMultiplier = Keyboard.IsKeyDown(Key.LeftShift) ? 2.0d : shiftMultiplier;
            });
            if (wDown)
            {
                ActiveScene.Context.ActiveWorld.Camera.move(Engine.Renderer.Camera.Direction * (float)(_defaultSpeed * _wA * shiftMultiplier));
                none = false;
            }
            if (aDown)
            {
                ActiveScene.Context.ActiveWorld.Camera.move(-Engine.Renderer.Camera.Right * (float)(_defaultSpeed * _aA * shiftMultiplier));
                none = false;
            }
            if (sDown)
            {
                ActiveScene.Context.ActiveWorld.Camera.move(-Engine.Renderer.Camera.Direction * (float)(_defaultSpeed * _sA * shiftMultiplier));
                none = false;
            }
            if (dDown)
            {
                ActiveScene.Context.ActiveWorld.Camera.move(Engine.Renderer.Camera.Right * (float)(_defaultSpeed * _dA * shiftMultiplier));
                none = false;
            }
            if (none)
            {
                _wA = 1;
                _aA = 1;
                _sA = 1;
                _dA = 1;
            }
        }
Пример #18
0
 public void Update(TimeSpan timeSpan, TimeSpan elapsedGameTime)
 {
     Accumulator += timeSpan.TotalMilliseconds * GameSpeed;
     if (Accumulator >= (1000d / 60))
     {
         Accumulator -= 1000d / 60;
         ActiveScene.InvokeUpdate((float)(timeSpan.TotalMilliseconds * GameSpeed / 1000));
         InputQueued = true;
     }
 }
Пример #19
0
        public void Dispose()
        {
            if (ActiveScene != null)
            {
                ActiveScene.Dispose();
                ActiveScene = null;
            }

            GC.SuppressFinalize(this);
        }
    /// <summary>
    /// 重计算路径
    /// </summary>
    /// <returns><c>true</c>, if path was calculated, <c>false</c> otherwise.</returns>
    private bool CalculatePath()
    {
        if (null == m_mainPlayer)
        {
            return(false);
        }
        m_fReCalcPathtimer = m_fReCalcPathInterval;
        if (m_mainPlayer.NavAgent == null || m_mainPlayer.NavAgent.enabled == false)
        {
            return(false);
        }
        // navMeshAgent寻路的当前场景目标点
        Vector3 currentSceneDestination = Vector3.zero;

        // 如果目标点在当前场景
        if (m_Destination.SceneID == GameManager.gameManager.RunningScene)
        {
            currentSceneDestination = new Vector3(m_Destination.PosX, 0, m_Destination.PosZ);
            currentSceneDestination = ActiveScene.GetTerrainPosition(currentSceneDestination);
            // 判断是否已经到了目标点
            Vector3 playerPos   = m_mainPlayer.Position;
            float   distanceSqr = (playerPos.x - currentSceneDestination.x) * (playerPos.x - currentSceneDestination.x) +
                                  (playerPos.y - currentSceneDestination.y) * (playerPos.y - currentSceneDestination.y) +
                                  (playerPos.z - currentSceneDestination.z) * (playerPos.z - currentSceneDestination.z);
            if (distanceSqr < m_fCornerReachCheckDistanceSqr)
            {
                return(false);
            }
        }
        else
        {
            // todo
            AutoSearchPoint startPoint = AutoSearchPoint.MakePoint(m_mainPlayer.gameObject);

            m_Path.ResetPath();
            if (GameManager.gameManager.AutoSearch.FindPath(startPoint, m_Destination, ref m_Path))
            {
            }
            return(false);
        }

        // 利用NavMeshAgent寻得路径
        if (m_mainPlayer.NavAgent.CalculatePath(currentSceneDestination, m_NavPath))
        {
            m_NavPathCorners = m_NavPath.corners;
            // 第0个点是当前位置
            m_nNextCornerIdx = 1;
            return(true);
        }
        else
        {
            CancelGuide();
            return(false);
        }
    }
Пример #21
0
        public bool Init(ObjSnare_Init_Data initData)
        {
            if (null == m_ObjTransform)
            {
                m_ObjTransform = transform;
            }

            //服务器发过来的信息
            ServerID  = initData.m_ServerID;
            SnareId   = initData.m_SnareID;
            OwerobjID = initData.m_OwnerObjId;
            OwnerGuid = initData.m_OwerGuid;
            m_ObjTransform.position = ActiveScene.GetTerrainPosition(new Vector3(initData.m_fX, 0, initData.m_fZ));
            Obj_Character ownerCharacter = Singleton <ObjManager> .GetInstance().FindObjCharacterInScene(OwerobjID);

            //修正陷阱的高度和陷阱释放者一样
            if (ownerCharacter != null)
            {
                Vector3 newPosVector3 = m_ObjTransform.position;
                newPosVector3.y         = ownerCharacter.ObjTransform.position.y;
                m_ObjTransform.position = newPosVector3;
            }

            //初始化特效
            if (ObjEffectController == null)
            {
                ObjEffectController = gameObject.AddComponent <ObjEffectBehaviourController>();
            }

            Tab_SnareObjInfo SnareInfo = TableManager.GetSnareObjInfoByID(SnareId, 0);

            if (SnareInfo != null)
            {
                //播放生存期特效
                for (int i = 0; i < SnareInfo.getAliveEffectIdCount(); i++)
                {
                    int AliveEffectId = SnareInfo.GetAliveEffectIdbyIndex(i);
                    if (AliveEffectId != -1 && ObjEffectController != null)
                    {
                        PlayEffect(AliveEffectId);
                    }
                }
                //播放生存期音效
                for (int i = 0; i < SnareInfo.getAliveSoundIdCount(); i++)
                {
                    int AliveSoundId = SnareInfo.GetAliveSoundIdbyIndex(i);
                    if (AliveSoundId != -1)
                    {
                        GameManager.gameManager.SoundManager.PlaySoundEffect(AliveSoundId);
                    }
                }
            }
            return(true);
        }
Пример #22
0
        public uint Execute(PacketDistributed ipacket)
        {
            GC_TELEMOVE packet = (GC_TELEMOVE )ipacket;

            if (null == packet)
            {
                return((uint)PACKET_EXE.PACKET_EXE_ERROR);
            }
            //enter your logic
            Obj_Character _objChar = Singleton <ObjManager> .GetInstance().FindObjCharacterInScene(packet.ObjId);

            if (_objChar == null)
            {
                return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
            }
            Vector3 targetPos = new Vector3(packet.TargetPosX / 100.0f, 0, packet.TargetPosZ / 100.0f);

            targetPos = ActiveScene.GetTerrainPosition(targetPos);
            //如果_objChar为轻功状态,则打断轻功
            if (_objChar.IsLightState)
            {
                //_objChar.EndLightSkillMove();
                _objChar.BeginTeleMoveInLight(targetPos);
            }
            //是否需要改变朝向
            if (packet.NeedChangeFaceto == 1)
            {
                _objChar.FaceTo(targetPos);
            }
            else
            {
                _objChar.IsMoveToNoFaceTo = true;
            }
            AutoMove autoMove = _objChar.AutoMoveComponent;

            if (autoMove != null)
            {
                autoMove.ResetAutoMove();
            }
            //向目标点移动
            _objChar.MoveTo(targetPos, null, 0);
            //是否需要播放附加动作
            if (packet.HasAnimaId && _objChar.AnimLogic != null)
            {
                _objChar.AnimLogic.Stop();
                _objChar.AnimLogic.Play(packet.AnimaId);
                //现在这里播放击退效果 todo临时的
                _objChar.PlayEffect(121);
            }

            return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
        }
Пример #23
0
 /// <summary>
 /// Sets the active scene of the scenemanager.
 /// </summary>
 /// <param name="name">The name of the scene that is already in the scenemanager.</param>
 public void SetActiveScene(string name)
 {
     if (scenes.ContainsKey(name))
     {
         ActiveScene = scenes[name];
         ActiveScene.LoadContent(ActiveScene.Content);
         ActiveSceneChanged?.Invoke(this, new SceneEventArgs(ActiveScene));
     }
     else
     {
         throw new Exception("The scene '" + name + "' isn't in the scene manager.");
     }
 }
Пример #24
0
        public void Update(GameTime gameTime)
        {
            if (ActiveScene.GetType().Name == "MenuScene")
            {
                MenuItemSprite s = ActiveScene.AllTheSpritesWithinTheScene.OfType <MenuItemSprite>().FirstOrDefault(x => x.Bounds.Contains(InputEngine.MousePosition) && InputEngine.IsMouseLeftClick());

                if (s != null)
                {
                    if (s.SpriteID == "MI1")
                    {
                        PreviousScene = ActiveScene;
                        ActiveScene   = AllScenes.Pop();
                        AllScenes.Push(PreviousScene);
                    }
                    else if (s.SpriteID == "MI2")
                    {
                        PreviousScene = ActiveScene;
                        ActiveScene   = CreateHighscoreScene();
                        AllScenes.Push(PreviousScene);
                    }
                    else if (s.SpriteID == "MI3")
                    {
                        Helper.CurrentGame.Exit();
                    }
                }
            }
            else if (InputEngine.IsKeyPressed(ChangeSceneKey))
            {
                if (ActiveScene.GetType().Name == "PlayScene")
                {
                    PreviousScene = ActiveScene;
                    ActiveScene   = AllScenes.Pop();
                    AllScenes.Push(PreviousScene);
                }
                else if (ActiveScene.GetType().Name == "HighscoreScene")
                {
                    ActiveScene = AllScenes.Pop();
                }
            }


            if (ActiveScene.GetType().Name == "PlayScene")
            {
                ActiveScene.Update(gameTime);
                PlayScene playScene = (PlayScene)ActiveScene;
                if (playScene.Gameover)
                {
                    ActiveScene = CreateHighscoreScene();
                }
            }
        }
    /// <summary>
    /// 设置引导目的地,外部调用接口
    /// </summary>
    /// <param name="sceneId">Scene identifier.</param>
    /// <param name="posX">Position x.</param>
    /// <param name="posZ">Position z.</param>
    public void SetDest(int sceneId, float posX, float posZ, int showDestEffect)
    {
        if (null == m_mainPlayer)
        {
            m_mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;
        }
        if (sceneId == -1)
        {
            CancelGuide();
            return;
        }
        m_bHasDestination     = true;
        m_Destination.SceneID = sceneId;
        m_Destination.PosX    = posX;
        m_Destination.PosZ    = posZ;
        m_bShowDestEffect     = (showDestEffect != 0);

        if (CalculatePath() == false)
        {
            Invoke("ReTrySetDest", 2);
//			CancelGuide();
            return;
        }
        ShowGuideArrow();

        // 设定指针初始位置
        Vector3 rotateTo = new Vector3(m_NavPathCorners[m_nNextCornerIdx].x, m_arrowTrans.position.y, m_NavPathCorners[m_nNextCornerIdx].z);

        m_arrowTrans.LookAt(rotateTo);

        if (sceneId == GameManager.gameManager.RunningScene && m_bShowDestEffect)
        {
            if (m_destEffectTrans == null)
            {
                if (LoadDestEffect() == false)
                {
                    return;
                }
            }
            Vector3 currentSceneDestination = new Vector3(m_Destination.PosX, 0, m_Destination.PosZ);
            currentSceneDestination    = ActiveScene.GetTerrainPosition(currentSceneDestination);
            m_destEffectTrans.position = currentSceneDestination + new Vector3(0, -0.14f, 0);
            ShowDestEffect();
            ShowArrawEffect();
        }
        else
        {
            HideDestEffect();
        }
    }
Пример #26
0
    private void Awake()
    {
        S = this;
        generateAudioSources(); //MUST BE CALLED BEFORE ANY SOUNDS ARE MADE


        if (SceneManager.GetActiveScene().name == "Main")
        {
            scene = ActiveScene.Main;
        }
        else
        {
            scene = ActiveScene.Menu;
        }
    }
Пример #27
0
    // 不要写Monobehaviour的构造函数
    // 当这个monobehaviour被从prefab中反序列化出来的时候,构造函数会被执行两次,第一次在Resource.Load时,第二次在Instantiate时
//    private GameManager()
//    {
//        m_ActiveScene = new ActiveScene();
//        m_MissionManager = new MissionManager();
//		m_TableManager = new TableManager();
//        m_UILoadResource = new UILoadResource();
//        m_PlayerDataPool = new PlayerData();
//        m_OtherPlayerData = new OtherPlayerData();
//    }

    /// <summary>
    /// 初始化数据,代替原来的构造函数,只能由SceneLogic调用(因为GameManager实例在SceneLogic里创建)
    /// </summary>
    public void Init()
    {
        if (dataInitialized)
        {
            return;
        }

        m_ActiveScene     = new ActiveScene();
        m_FlyWingMananger = new FlyWingMananger();
        m_MissionManager  = new MissionManager();
        m_TableManager    = new TableManager();
        m_PlayerDataPool  = new PlayerData();
        m_OtherPlayerData = new OtherPlayerData();

        dataInitialized = true;
    }
Пример #28
0
        public override void OnAttach()
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(GetType());
#endif
            LoadFonts();

            var loadedSound = AssetManager.LoadSound("assets\\sounds\\loaded.mp3", false);
            Styles.SetDarkTheme();

            EditorHelper.LoadStandardShaders();

            LoadScene();

            var     e  = ActiveScene.CreateEntity("White");
            ref var tc = ref e.GetComponent <TransformComponent>();
Пример #29
0
 /// <summary>
 /// 加载场景
 /// </summary>
 public static void Load(Scene newScene, LoadSceneMode loadSceneMode = LoadSceneMode.Single)
 {
     if (newScene == null)
     {
         throw new Exception("Null Exception");
     }
     if (loadSceneMode == LoadSceneMode.Single)
     {
         //如果原来激活的不是默认场景, 则销毁原来的场景
         if (ActiveScene != DefaultScene)
         {
             //销毁所有之前场景的游戏物体, 如果dontdestroy保存着它的对象,则不销毁
             foreach (GameObject gameObject in ActiveScene.GameObjects)
             {
                 if (!DontDestroyOnLoadScene.GameObjects.Contains(gameObject))
                 {
                     GameObject.Destroy(gameObject);
                 }
             }
             //移除之前场景的引用
             Scenes.Remove(ActiveScene.Name);
             //销毁回调事件
             ActiveScene.OnDestroy();
         }
         //设置新场景为激活场景
         ActiveScene = newScene;
         //将DontDestroyOnLoad中保存的对象加入新的激活场景
         foreach (GameObject gameObject in DontDestroyOnLoadScene.GameObjects)
         {
             gameObject.AddToScene(ActiveScene);
         }
         newScene.OnStart();
         //初始化新场景
     }
     if (loadSceneMode == LoadSceneMode.Additive)
     {
         Scene lastScene = ActiveScene;
         //切换当前Scene为Active, 然后新建的GameObject都是这个Scene的
         ActiveScene = newScene;
         //调用这个场景的初始化方法 创建属于这个场景的对象等等
         ActiveScene.OnStart();
         //切回之前的Scene作为主场景
         ActiveScene = lastScene;
     }
     //将这个Scene加入dict
     Scenes.Add(newScene.Name, newScene);
 }
Пример #30
0
    public void GotoNextScene()
    {
        if (CurrentSceneTag == 1)
        {
            ShowSceneObject("SceneModel/Scene");

            //关闭导航
            if (Singleton <ObjManager> .GetInstance().MainPlayer != null)
            {
                if (Singleton <ObjManager> .GetInstance().MainPlayer.NavAgent != null)
                {
                    Singleton <ObjManager> .GetInstance().MainPlayer.NavAgent.gameObject.SetActive(false);
                }
            }

            CurrentSceneTag = 2;
            if (Singleton <ObjManager> .GetInstance().MainPlayer != null)
            {
                Vector3 curPosition = Singleton <ObjManager> .GetInstance().MainPlayer.Position;

                Singleton <ObjManager> .GetInstance().MainPlayer.Position = ActiveScene.GetTerrainPosition(curPosition);

                if (Singleton <ObjManager> .GetInstance().MainPlayer.NavAgent != null)
                {
                    Singleton <ObjManager> .GetInstance().MainPlayer.NavAgent.gameObject.SetActive(true);

                    Singleton <ObjManager> .GetInstance().MainPlayer.InitNavAgent();

                    Singleton <ObjManager> .GetInstance().MainPlayer.Rotation = Quaternion.Euler(0, 30, 0);
                }
            }

            if (ShaChenGameObject != null)
            {
                ShaChenGameObject.SetActive(true);
            }

            GCGame.Utils.PlaySceneMusic(207);    //second scene

            if (m_OldSceneObject != null)
            {
                DestroyObject(m_OldSceneObject);
                Resources.UnloadUnusedAssets();
                GC.Collect();
            }
        }
    }