示例#1
0
 public Scene(GameObjectManager objectManager, ISceneManager sceneManager, SceneType sceneType)
 {
     this.sceneManager = sceneManager;
     this.sceneType    = sceneType;
     ObjectManager     = objectManager;
     GameObjectState   = objectManager;
 }
示例#2
0
        void HookupApplicationEvents()
        {
            IInjectionBinder   binder    = ((MainContext)context).injectionBinder;
            IApplicationEvents appEvents = GameApplication.Instance.ApplicationEvents;


            appEvents.Paused      += () => binder.GetInstance <GamePausedSignal>().Dispatch();
            appEvents.Resumed     += t => binder.GetInstance <GameResumedSignal>().Dispatch(t);
            appEvents.LostFocus   += () => binder.GetInstance <FocusLostSignal>().Dispatch();
            appEvents.GainedFocus += () => binder.GetInstance <FocusGainedSignal>().Dispatch();

            ISceneManager sceneManager = _moduleContainer.ServiceResolver.Get <ISceneManager>();

            sceneManager.TransitionOutStarted += s
                                                 => binder.GetInstance <SceneTransitionOutStartedSignal>().Dispatch(s);
            sceneManager.TransitionOutEnded += s =>
                                               binder.GetInstance <SceneTransitionOutEndedSignal>().Dispatch(s);
            sceneManager.TransitionInStarted += s =>
                                                binder.GetInstance <SceneTransitionInStartedSignal>().Dispatch(s);
            sceneManager.TransitionInEnded += s
                                              => binder.GetInstance <SceneTransitionInEndedSignal>().Dispatch(s);
            sceneManager.SceneLoadStarted += s =>
                                             binder.GetInstance <SceneLoadStartedSignal>().Dispatch(s);
            sceneManager.SceneLoaded += s =>
                                        binder.GetInstance <SceneLoadedSignal>().Dispatch(s);
        }
示例#3
0
 public ApplicationWindow(ILogger logger, IShaderLoader shaderLoader,
                          ISceneManager sceneManager) : base(1280, 720, new GraphicsMode(new ColorFormat(8, 8, 8, 8), 0, 0, 8), "")
 {
     this.logger       = logger;
     this.shaderLoader = shaderLoader;
     this.sceneManager = sceneManager;
 }
示例#4
0
 //Pause Screen is dismissed with Space!
 public override void HandleKeys(InputHelper aInputHelper, ISceneManager aSceneManager)
 {
     if (aInputHelper.IsNewPress(Keys.Space))
     {
         aSceneManager.HideOverlay();
     }
 }
示例#5
0
 public override void Initialize()
 {
     base.Initialize();
     _sceneManager = Game.Services.GetService <ISceneManager>();
     _sceneManager.SceneActivated += _sceneManager_SceneActivated;
     _spriteBatch = new SpriteBatch(Game.GraphicsDevice);
 }
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        public SoundComponent()
        {
            m_SoundManager = GameFrameworkEntry.GetModule <ISoundManager>();
            if (m_SoundManager == null)
            {
                Log.Fatal("Sound manager is invalid.");
                return;
            }

            m_SoundManager.PlaySoundSuccess         += OnPlaySoundSuccess;
            m_SoundManager.PlaySoundFailure         += OnPlaySoundFailure;
            m_SoundManager.PlaySoundUpdate          += OnPlaySoundUpdate;
            m_SoundManager.PlaySoundDependencyAsset += OnPlaySoundDependencyAsset;

            //  m_AudioListener = gameObject.GetOrAddComponent<AudioListener>();
            m_AudioListener = new GameObject("AudioListener").GetOrAddComponent <AudioListener>();

            SceneManager.sceneLoaded   += OnSceneLoaded;
            SceneManager.sceneUnloaded += OnSceneUnloaded;
            ISceneManager sceneManager = GameFrameworkEntry.GetModule <ISceneManager>();

            if (sceneManager == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            sceneManager.LoadSceneSuccess   += OnLoadSceneSuccess;
            sceneManager.LoadSceneFailure   += OnLoadSceneFailure;
            sceneManager.UnloadSceneSuccess += OnUnloadSceneSuccess;
            sceneManager.UnloadSceneFailure += OnUnloadSceneFailure;
        }
 private void ProcessMoneyTransferRequest(UUID fromID, UUID toID, int amount, int type, string description)
 {
     if (toID != UUID.Zero)
     {
         ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager>();
         if (manager != null && manager.Scene != null)
         {
             ISceneChildEntity ent = manager.Scene.GetSceneObjectPart(toID);
             if (ent != null)
             {
                 bool success = m_connector.UserCurrencyTransfer(ent.OwnerID, fromID, UUID.Zero, UUID.Zero, (uint)amount, description,
                                                                 (TransactionType)type, UUID.Random());
                 if (success)
                 {
                     FireObjectPaid(toID, fromID, amount);
                 }
             }
             else
             {
                 m_connector.UserCurrencyTransfer(toID, fromID, UUID.Zero, UUID.Zero, (uint)amount, description,
                                                  (TransactionType)type, UUID.Random());
             }
         }
     }
 }
示例#8
0
        public object SendAttachments(string funct, object param)
        {
            object[]       parameters = (object[])param;
            IScenePresence sp         = (IScenePresence)parameters[1];

            Interfaces.GridRegion dest    = (Interfaces.GridRegion)parameters[0];
            ISceneManager         manager = sp.Scene.RequestModuleInterface <ISceneManager>();

            if (manager != null)
            {
                foreach (var scene in manager.GetAllScenes())
                {
                    if (dest.RegionID == scene.RegionInfo.RegionID)
                    {
                        return(null);
                    }
                }
            }
            if (m_userAttachments.ContainsKey(sp.UUID))
            {
                Util.FireAndForget(delegate
                {
                    foreach (ISceneEntity attachment in m_userAttachments[sp.UUID])
                    {
                        Connectors.Simulation.SimulationServiceConnector ssc = new Connectors.Simulation.SimulationServiceConnector();
                        attachment.IsDeleted = false;//Fix this, we 'did' get removed from the sim already
                        //Now send it to them

                        ssc.CreateObject(dest, (ISceneObject)attachment);
                        attachment.IsDeleted = true;
                    }
                });
            }
            return(null);
        }
示例#9
0
 private void NextScene()
 {
     if (sceneManager != null)
     {
         sceneManager.Finish -= SceneManager_Finish;
         sceneManager.Destroy();
     }
     if (sceneManager == null)
     {
         sceneManager = new Scene1Manager();
     }
     else if (sceneManager is Scene1Manager)
     {
         sceneManager = new Scene2Manager();
     }
     else if (sceneManager is Scene2Manager)
     {
         sceneManager = new Scene3Manager();
     }
     else
     {
         Application.Exit();
     }
     sceneManager.Finish += SceneManager_Finish;
     sceneManager.Init();
 }
示例#10
0
        public bool IsAuthorizedForRegion(GridRegion region, AgentCircuitData agent, bool isRootAgent, out string reason)
        {
            ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager>();

            if (manager != null)
            {
#if (!ISWIN)
                foreach (IScene scene in manager.GetAllScenes())
                {
                    if (scene.RegionInfo.RegionID == region.RegionID)
                    {
                        //Found the region, check permissions
                        return(scene.Permissions.AllowedIncomingAgent(agent, isRootAgent, out reason));
                    }
                }
#else
                foreach (IScene scene in manager.GetAllScenes().Where(scene => scene.RegionInfo.RegionID == region.RegionID))
                {
                    //Found the region, check permissions
                    return(scene.Permissions.AllowedIncomingAgent(agent, isRootAgent, out reason));
                }
#endif
            }
            reason = "Not Authorized as region does not exist.";
            return(false);
        }
示例#11
0
        public LoadingScene(Game game, ISceneManager sceneManager, IGraphicsSystem graphicsSystem, IGameSettings gameSettings, IGameLogger logger, IGameKeys gameKeys) :
            base(game, sceneManager, graphicsSystem, gameSettings, logger, gameKeys)
        {
            IsLoaded = false;

            _uiBatch = new SpriteBatch(Game.GraphicsDevice);
        }
示例#12
0
 /// <summary>
 ///     Region side
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 protected OSDMap OnMessageReceived(OSDMap message)
 {
     //We need to check and see if this is an AgentStatusChange
     if (message.ContainsKey("Method") && message["Method"] == "EstateUpdated")
     {
         OSDMap innerMessage = (OSDMap)message["Message"];
         //We got a message, deal with it
         uint          estateID = innerMessage["EstateID"].AsUInteger();
         UUID          regionID = innerMessage["RegionID"].AsUUID();
         ISceneManager manager  = m_registry.RequestModuleInterface <ISceneManager>();
         if (manager != null)
         {
             foreach (IScene scene in manager.Scenes)
             {
                 if (scene.RegionInfo.EstateSettings.EstateID == estateID)
                 {
                     IEstateConnector estateConnector =
                         Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();
                     if (estateConnector != null)
                     {
                         EstateSettings es = null;
                         if ((es = estateConnector.GetEstateSettings(regionID)) != null && es.EstateID != 0)
                         {
                             scene.RegionInfo.EstateSettings = es;
                             MainConsole.Instance.Debug("[EstateProcessor]: Updated estate information.");
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
示例#13
0
        public GameState(
            ISceneManager sceneManager,
            IResourceManager resourceManager,
            IPaletteProvider paletteProvider,
            IEngineDataManager engineDataManager,
            IRenderWindow renderWindow,
            ISoundProvider soundProvider,
            IMPQProvider mpqProvider,
            Func <IMapRenderer> getMapEngine,
            Func <eSessionType, ISessionManager> getSessionManager,
            Func <string, IRandomizedMapGenerator> getRandomizedMapGenerator
            )
        {
            this.sceneManager              = sceneManager;
            this.resourceManager           = resourceManager;
            this.paletteProvider           = paletteProvider;
            this.getMapEngine              = getMapEngine;
            this.getSessionManager         = getSessionManager;
            this.engineDataManager         = engineDataManager;
            this.renderWindow              = renderWindow;
            this.soundProvider             = soundProvider;
            this.mpqProvider               = mpqProvider;
            this.getRandomizedMapGenerator = getRandomizedMapGenerator;

            originalMouseCursor = renderWindow.MouseCursor;
            PlayerInfos         = new List <PlayerInfo>();
            mapDataLookup       = new List <MapCellInfo>();
        }
示例#14
0
 void ProcessMoneyTransferRequest(UUID fromID, UUID toID, int amount, int type, string description)
 {
     if (toID != UUID.Zero)
     {
         ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager>();
         if (manager != null)
         {
             bool paid = false;
             foreach (IScene scene in manager.Scenes)
             {
                 ISceneChildEntity ent = scene.GetSceneObjectPart(toID);
                 if (ent != null)
                 {
                     bool success = m_connector.UserCurrencyTransfer(ent.OwnerID, fromID, ent.UUID, ent.Name, UUID.Zero, "",
                                                                     (uint)amount, description, (TransactionType)type, UUID.Random());
                     if (success)
                     {
                         FireObjectPaid(toID, fromID, amount);
                     }
                     paid = true;
                     break;
                 }
             }
             if (!paid)
             {
                 m_connector.UserCurrencyTransfer(toID, fromID, (uint)amount, description,
                                                  (TransactionType)type, UUID.Random());
             }
         }
     }
 }
示例#15
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected internal override void Awake()
        {
            base.Awake();

            m_SceneManager = GameFrameworkEntry.GetModule <ISceneManager>();
            if (m_SceneManager == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            m_SceneManager.LoadSceneSuccess    += OnLoadSceneSuccess;
            m_SceneManager.LoadSceneFailure    += OnLoadSceneFailure;
            m_SceneManager.LoadSceneUpdate     += OnLoadSceneUpdate;
            m_SceneManager.LoadSceneDependency += OnLoadSceneDependency;
            m_SceneManager.UnloadSceneSuccess  += OnUnloadSceneSuccess;
            m_SceneManager.UnloadSceneFailure  += OnUnloadSceneFailure;

            m_GameFrameworkScene = SceneManager.GetSceneAt(BaseComponent.GameFrameworkSceneId);
            if (m_GameFrameworkScene == null)
            {
                Log.Fatal("Game framework scene is invalid.");
                return;
            }
        }
示例#16
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_SceneManager = GameFrameworkEntry.GetModule <ISceneManager>();
            if (m_SceneManager == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            m_SceneManager.LoadSceneSuccess         += OnLoadSceneSuccess;
            m_SceneManager.LoadSceneFailure         += OnLoadSceneFailure;
            m_SceneManager.LoadSceneUpdate          += OnLoadSceneUpdate;
            m_SceneManager.LoadSceneDependencyAsset += OnLoadSceneDependencyAsset;
            m_SceneManager.UnloadSceneSuccess       += OnUnloadSceneSuccess;
            m_SceneManager.UnloadSceneFailure       += OnUnloadSceneFailure;

            m_GameFrameworkScene = SceneManager.GetSceneAt(GameEntry.GameFrameworkSceneId);
            if (!m_GameFrameworkScene.IsValid())
            {
                Log.Fatal("Game framework scene is invalid.");
                return;
            }
        }
示例#17
0
 public DungeonLoader(ILoadingScreenPM i_loadingPM, IBackendManager i_backend, ICurrentDungeonGameManager i_currentDungeon, ISceneManager i_sceneManager)
 {
     mLoadingPM          = i_loadingPM;
     mBackendManager     = i_backend;
     mCurrentDungeonData = i_currentDungeon;
     mSceneManager       = i_sceneManager;
 }
示例#18
0
        private void Start()
        {
            Vector3 toCam = new Vector3(1, 1, 1);

            bool useSceneViewInput = SelectionController is RuntimeSceneView;

            if (!useSceneViewInput)
            {
                EditorCamera.transform.position = m_pivot + toCam * EditorCamDistance;
                EditorCamera.transform.LookAt(m_pivot);

                RuntimeTools.DrawSelectionGizmoRay = true;
            }

            UpdateUIState(IsInPlayMode);
            AutoFocus           = TogAutoFocus.isOn;
            AutoUnitSnapping    = TogUnitSnap.isOn;
            BoundingBoxSnapping = TogBoundingBoxSnap.isOn;
            ShowSelectionGizmos = TogShowGizmos.isOn;
            EnableCharacters    = TogEnableCharacters.isOn;

            ExposeToEditor.Awaked    += OnAwaked;
            ExposeToEditor.Destroyed += OnDestroyed;

            m_sceneManager = Dependencies.SceneManager;
            if (m_sceneManager != null)
            {
                m_sceneManager.ActiveScene.Name = SaveFileName;
                m_sceneManager.Exists(m_sceneManager.ActiveScene, exists =>
                {
                    m_saveFileExists        = exists;
                    LoadButton.interactable = exists;
                });
            }
        }
示例#19
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            // set ScreenHeight
            ScreenHeight = GraphicsDevice.Viewport.Height;
            // set ScreenWidth
            ScreenWidth = GraphicsDevice.Viewport.Width;
            // set cameraPos
            cameraPos = new Vector3(ScreenWidth / 2, 0, 0);
            // initialise a new sceneGraph
            sceneGraph = new SceneGraph();
            // initialise a new sceneManager
            sceneManager = new SceneManager(sceneGraph);
            // initialise a new collisionManager
            collisionManager = new CollisionManager(sceneManager);
            // initialise a new inputManager
            inputManager = new InputManager();
            // Initialise render manager
            _renderManager = new RenderManager(graphics, sceneManager, Content);
            // Initialise audio manager
            _audioManager = new SoundManager(Content);
            // initialise a new aiComponontManager
            aiComponentManager = new AIComponentManager(inputManager, _audioManager, sceneManager, Content);
            // initialise a new entityManager
            entityManager = new EntityManager(collisionManager, sceneGraph, aiComponentManager);
            // set headerLoaction
            backgroundLocation  = new Vector2(-ScreenWidth / 2, 0);
            backgroundLocation2 = new Vector2(backgroundLocation.X + ScreenWidth + 1, 0);
            backgroundLocation3 = new Vector2(-ScreenWidth / 2, 0);
            backgroundLocation4 = new Vector2(-ScreenWidth / 2, 0);

            // initialise
            base.Initialize();
        }
示例#20
0
        public Credits(
            IRenderWindow renderWindow,
            ISceneManager sceneManager,
            IMPQProvider mpqProvider,
            Func <eButtonType, IButton> createButton
            )
        {
            this.renderWindow = renderWindow;
            this.sceneManager = sceneManager;
            this.mpqProvider  = mpqProvider;

            backgroundSprite = renderWindow.LoadSprite(ResourcePaths.CreditsBackground, Palettes.Sky);

            btnExit            = createButton(eButtonType.Medium);
            btnExit.Text       = "Exit".ToUpper();
            btnExit.Location   = new Point(20, 550);
            btnExit.OnActivate = OnActivateClicked;

            textFont = renderWindow.LoadFont(ResourcePaths.FontFormal10, Palettes.Static);

            creditsText = new Stack <string>((
                                                 File.ReadAllLines(Path.Combine(Path.GetDirectoryName(Environment.GetCommandLineArgs().First()), "credits.txt"))
                                                 .Concat(mpqProvider.GetTextFile(ResourcePaths.CreditsText))
                                                 ).Reverse());
        }
示例#21
0
        /// <summary>
        /// Constructor for the engine.
        /// </summary>
        /// <param name="collisionComponent">The collision component to use for collision detection.</param>
        /// <param name="backgroundColour">The game background colour after flushing graphics.
        /// Transparent by default.</param>
        public Engine(ICollisionComponent collisionComponent, Color?backgroundColour = null)
        {
            // Setup graphics device manager and content directory.
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Set background colour.
            if (backgroundColour.HasValue)
            {
                this.backgroundColour = backgroundColour.Value;
            }
            else
            {
                this.backgroundColour = Color.Transparent;
            }

            // Initialise systems.
            collisionSystem = new CollisionSystem(collisionComponent);
            inputSystem     = new InputSystem();
            loadSystem      = new LoadSystem(Content);
            renderSystem    = new RenderSystem(graphics);
            updateSystem    = new UpdateSystem();

            // Create scene manager and entity manager.
            sceneManager  = new SceneManager(collisionSystem, inputSystem, renderSystem, updateSystem);
            entityManager = new EntityManager(loadSystem, sceneManager, (ISceneStateManager)sceneManager);
        }
示例#22
0
 /// <summary>
 ///     Region side
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 protected OSDMap OnMessageReceived(OSDMap message)
 {
     // We need to check and see if this is an AgentStatusChange
     if (message.ContainsKey("Method") && message ["Method"] == "UpdateAvatarAppearance")
     {
         var           appearance = new AvatarAppearance(message ["AgentID"], (OSDMap)message ["Appearance"]);
         ISceneManager manager    = m_registry.RequestModuleInterface <ISceneManager> ();
         if (manager != null)
         {
             foreach (IScene scene in manager.Scenes)
             {
                 IScenePresence sp = scene.GetScenePresence(appearance.Owner);
                 if (sp != null && !sp.IsChildAgent)
                 {
                     var avappmodule = sp.RequestModuleInterface <IAvatarAppearanceModule> ();
                     if (avappmodule != null)
                     {
                         avappmodule.Appearance = appearance;
                         avappmodule.SendAppearanceToAgent(sp);
                         avappmodule.SendAppearanceToAllOtherAgents();
                     }
                 }
             }
         }
     }
     return(null);
 }
示例#23
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected internal override void Awake()
        {
            base.Awake();

            m_SoundManager = GameFrameworkEntry.GetModule <ISoundManager>();
            if (m_SoundManager == null)
            {
                Log.Fatal("Sound manager is invalid.");
                return;
            }

            m_SoundManager.PlaySoundSuccess         += OnPlaySoundSuccess;
            m_SoundManager.PlaySoundFailure         += OnPlaySoundFailure;
            m_SoundManager.PlaySoundUpdate          += OnPlaySoundUpdate;
            m_SoundManager.PlaySoundDependencyAsset += OnPlaySoundDependencyAsset;

            m_SceneManager = GameFrameworkEntry.GetModule <ISceneManager>();
            if (m_SceneManager == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            m_SceneManager.LoadSceneSuccess   += OnLoadSceneSuccess;
            m_SceneManager.LoadSceneFailure   += OnLoadSceneFailure;
            m_SceneManager.UnloadSceneSuccess += OnUnloadSceneSuccess;
            m_SceneManager.UnloadSceneFailure += OnUnloadSceneFailure;
        }
    private void Initialize(IPlayerLocator player_locator, ISceneManager scene_manager, INetworkEngineConnector network_connector)
    {
        scene_manager.OnRoomLoaded
        .Subscribe(_ =>
        {
            SubscribeEvents();
        })
        .AddTo(this);

        network_connector.OnJoinedRoomAsObservable
        .Subscribe(_ =>
        {
            m_AvatarSpawner = new PlayerAvatarSpawner(m_RuntimeModelLoader, player_locator);
            m_AvatarSpawner.Spawn(AvatarPath, m_SpawnPosTag);
        })
        .AddTo(this);

        network_connector.OnLeftRoomAsObservable
        .Subscribe(_ =>
        {
            UnsubscribeEvents();
            DestroyAvatar();
        })
        .AddTo(this);


        m_RuntimeModelLoader.OnLoadModelCompleted
        .Subscribe(model =>
        {
            m_AvatarModel = model;
            m_LoadModelCompleted.OnNext(model);
        })
        .AddTo(this);
    }
示例#25
0
        /// <summary>
        ///     Iterates through all Scenes, doing a deep scan through assets
        ///     to cache all assets present in the scene or referenced by assets
        ///     in the scene
        /// </summary>
        /// <returns></returns>
        private int CacheScenes()
        {
            //Make sure this is not null
            if (m_AssetService == null)
            {
                return(0);
            }

            Dictionary <UUID, AssetType> assets = new Dictionary <UUID, AssetType>();
            ISceneManager manager = m_simulationBase.ApplicationRegistry.RequestModuleInterface <ISceneManager>();

            if (manager != null)
            {
                UuidGatherer gatherer = new UuidGatherer(m_AssetService);

                StampRegionStatusFile(manager.Scene.RegionInfo.RegionID);
                manager.Scene.ForEachSceneEntity(e => gatherer.GatherAssetUuids(e, assets, manager.Scene));

                foreach (UUID assetID in assets.Keys)
                {
                    string filename = GetFileName(assetID.ToString());

                    if (File.Exists(filename))
                    {
                        File.SetLastAccessTime(filename, DateTime.Now);
                    }
                    else
                    {
                        m_AssetService.Get(assetID.ToString());
                    }
                }
            }

            return(assets.Keys.Count);
        }
示例#26
0
 public GameScene(Game game, ISceneManager sceneManager, IGraphicsSystem graphicsSystem, IGameSettings gameSettings, IGameLogger logger, IGameKeys gameKeys) : base(
         game, sceneManager, graphicsSystem, gameSettings, logger, gameKeys)
 {
     _spriteBatch = new SpriteBatch(Game.GraphicsDevice);
     _debugBatch  = new SpriteBatch(Game.GraphicsDevice);
     _uiBatch     = new SpriteBatch(Game.GraphicsDevice);
 }
示例#27
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            // INITIALISE the EntityManager variable
            _entityMgr = new EntityManager();
            // INITIALISE the SceneManager variable
            _sceneMgr = new SceneManager();
            // INITIALISE the CollisionManager variable
            // PASSING IN reference to the SceneMgr.SceneEntitiesDelegate method
            // as well a new QuadTree whos position is set to 0,0 and width and height is the screen width and height
            _collisionMgr = new CollisionManager(_sceneMgr.SceneEntitiesDelegate, _sceneMgr.StaticEntitiesDelegate,
                                                 new QuadTree <IShape>(new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight),
                                                                       1));
            // INITIALISE the MindManager variable
            _mindMgr = new MindManager();
            // INITIALISE the InputManager variable
            _inputMgr = new InputManager(PauseGameState);
            // INITIALISE the level to the first level
            // FUTURE IMPROVEMENT ------ possibly in the future make the level selectable
            _levelX = new SplashScreen();
            // CALL to InjectManagers into the level selected
            (_levelX as IManagerInject).InjectManagers(_entityMgr, _collisionMgr,
                                                       _inputMgr, _sceneMgr, _mindMgr, Content);
            // Give the splash screen a rectangle
            (_levelX as SplashScreen).TitleArea = new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            // CALL to Initialise the current level
            _levelX.Initialise();

            base.Initialize();
        }
示例#28
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_SoundManager = GameFrameworkEntry.GetModule <ISoundManager>();
            if (m_SoundManager == null)
            {
                Log.Fatal("Sound manager is invalid.");
                return;
            }

            m_SoundManager.PlaySoundSuccess         += OnPlaySoundSuccess;
            m_SoundManager.PlaySoundFailure         += OnPlaySoundFailure;
            m_SoundManager.PlaySoundUpdate          += OnPlaySoundUpdate;
            m_SoundManager.PlaySoundDependencyAsset += OnPlaySoundDependencyAsset;

            m_AudioListener = gameObject.GetOrAddComponent <AudioListener>();

#if UNITY_5_4_OR_NEWER
            SceneManager.sceneLoaded   += OnSceneLoaded;
            SceneManager.sceneUnloaded += OnSceneUnloaded;
#else
            ISceneManager sceneManager = GameFrameworkEntry.GetModule <ISceneManager>();
            if (sceneManager == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            sceneManager.LoadSceneSuccess   += OnLoadSceneSuccess;
            sceneManager.LoadSceneFailure   += OnLoadSceneFailure;
            sceneManager.UnloadSceneSuccess += OnUnloadSceneSuccess;
            sceneManager.UnloadSceneFailure += OnUnloadSceneFailure;
#endif
        }
示例#29
0
        private OSDMap syncRecievedService_OnMessageReceived(OSDMap message)
        {
            string method = message["Method"];

            if (method == "SendInstantMessages")
            {
                List <GridInstantMessage> messages =
                    ((OSDArray)message["Messages"]).ConvertAll <GridInstantMessage>((o) =>
                {
                    GridInstantMessage im =
                        new GridInstantMessage();
                    im.FromOSD((OSDMap)o);
                    return(im);
                });
                ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager>();
                if (manager != null)
                {
                    IMessageTransferModule messageTransfer =
                        manager.Scene.RequestModuleInterface <IMessageTransferModule>();
                    if (messageTransfer != null)
                    {
                        foreach (GridInstantMessage im in messages)
                        {
                            messageTransfer.SendInstantMessage(im);
                        }
                    }
                }
            }
            return(null);
        }
示例#30
0
        public CharacterSelection(IRenderWindow renderWindow,
                                  ISceneManager sceneManager, ITextDictionary textDictionary, Func <eButtonType, IButton> createButton)
        {
            this.renderWindow = renderWindow;

            backgroundSprite         = renderWindow.LoadSprite(ResourcePaths.CharacterSelectionBackground, Palettes.Sky);
            createNewCharacterButton = createButton(eButtonType.Tall);
            // TODO: use strCreateNewCharacter -- need to get the text to split after 10 chars though.
            createNewCharacterButton.Text       = textDictionary.Translate("strCreateNewCharacter");// "Create New".ToUpper();
            createNewCharacterButton.Location   = new Point(33, 467);
            createNewCharacterButton.OnActivate = () => sceneManager.ChangeScene(eSceneType.SelectHeroClass);

            deleteCharacterButton          = createButton(eButtonType.Tall);
            deleteCharacterButton.Text     = textDictionary.Translate("strDelete");
            deleteCharacterButton.Location = new Point(433, 467);

            exitButton            = createButton(eButtonType.Medium);
            exitButton.Text       = textDictionary.Translate("strExit");
            exitButton.Location   = new Point(33, 540);
            exitButton.OnActivate = () => sceneManager.ChangeScene(eSceneType.MainMenu);

            okButton          = createButton(eButtonType.Medium);
            okButton.Text     = textDictionary.Translate("strOk");
            okButton.Location = new Point(630, 540);
            okButton.Enabled  = false;
        }
示例#31
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     // set ScreenHeight
     ScreenHeight = GraphicsDevice.Viewport.Height;
     // set ScreenWidth
     ScreenWidth = GraphicsDevice.Viewport.Width;
     // set cameraPos
     cameraPos = new Vector3(ScreenWidth / 2, 0, 0);
     // initialise a new sceneGraph
     sceneGraph = new SceneGraph();
     // initialise a new sceneManager
     sceneManager = new SceneManager(sceneGraph);
     // initialise a new collisionManager
     collisionManager = new CollisionManager(sceneManager);
     // initialise a new inputManager
     inputManager = new InputManager();
     // initialise a new aiComponontManager
     aiComponentManager = new AIComponentManager(inputManager);
     // initialise a new entityManager
     entityManager = new EntityManager(collisionManager, sceneGraph, aiComponentManager);
     // initialise a new engineDemo
     gameDemo = new GameDemo();
     // run engineDemo initialise method
     gameDemo.Initialise(entityManager, sceneManager, collisionManager, aiComponentManager, inputManager, sceneGraph);
     // add input listeners to the engineDemo
     inputManager.AddListener(((IKeyboardListener)gameDemo).OnNewKeyboardInput);
     inputManager.AddListener(((IMouseListener)gameDemo).OnNewMouseInput);
     // set headerLoaction
     headerLocation = new Vector2(-ScreenWidth / 2, 0);
     // initialise
     base.Initialize();
 }
示例#32
0
 public SpawnerManager()
 {
     this._sceneManager = null; // post init
     this._spawnRequestConcurrentQueue = new ConcurrentQueue<GameObjectSpawnRequest>();
     this._removeGameObjectRequestConcurrentQueue = new ConcurrentQueue<IGameObject>();
     this._firstTime = true;
 }
 public RGBA_D Shade(Ray ray, Vector3D pos, uint subIdx, out Ray reflection, out Ray refraction,
                     ISceneManager scene)
 {
     if (shader != null)
         return shader.Shade(ray, pos, subIdx, this, scene, out reflection, out refraction);
     reflection = null;
     refraction = null;
     return RGBA_D.Empty;
 }
示例#34
0
 public Ray(Vector3D origin, Vector3D directionUV, double intensity,
            double length, double maxLength, ISceneManager scene)
 {
     this.origin = origin;
     this.directionUV = directionUV;
     this.intensity = intensity;
     this.length = length;
     this.maxLength = maxLength;
     this.scene = scene;
 }
示例#35
0
        public RayGroup(bool divide, double maxLength,
                        Rectangle area, ISceneManager scene, IRayDispatch dispatch,
                        FrameData frameData, CameraView view)
        {
            this.divide = divide;
            this.maxLength = maxLength;
            this.area = area;

            this.scene = scene;
            this.dispatch = dispatch;
            this.frameData = frameData;
            this.view = view;
        }
示例#36
0
        //Show Pause screen with P
        public override void HandleKeys(InputHelper aInputHelper, ISceneManager aSceneManager)
        {
            //Show Pause Screen
            if (aInputHelper.IsNewPress(Keys.P))
            {
                aSceneManager.ShowOverlay(new Pause());
            }

            //Show The exit screen
            if (aInputHelper.IsNewPress(Keys.Escape))
            {
                aSceneManager.ShowOverlay(new ExitGameIntsance());
            }
        }
示例#37
0
        public void awaken()
        {
            if (this._firstTime)
            {
                this._sceneManager = GameLoop.getSceneManager();

                this.addGameObjectToScene(this.spawnGameObjectsOnStart());
                this._firstTime = false;
            }

            this.processSpecialSpawnRequest();
            this.addGameObjectToScene(this.spawnGameObjectsPerFrame());
            this.processSpecialRemoveRequest();
        }
示例#38
0
        /// <summary>
        /// 
        /// </summary>
        private GameLoop()
        {
            this.gameStillRunning = true;

            this.sceneManager = null;
            this.sceneBrain = null;
            this.spawnerManager = null;
            this.updateRenderer = null;
            this.timerManager = null;
            this.collisionManager = null;

            gameLoopThread = new Thread(new ThreadStart(this.runLoop));
            gameLoopThread.SetApartmentState(ApartmentState.STA);
            gameLoopThread.Name = "GameLoopThread";
            gameLoopThread.IsBackground = true; //ensures that will be terminated on application close
        }
        public override void HandleKeys(InputHelper aInputHelper, ISceneManager aSceneManager)
        {
            //Close/Quit :)

            if(aInputHelper.IsNewPress(Keys.Q) || aInputHelper.IsNewPress(Keys.Enter) || aInputHelper.IsNewPress(Keys.Y))
            {
                Game1.ForceClose();
                return;
            }

            //We don't want to close quit - return to previous screen
            if (aInputHelper.IsNewPress(Keys.N) || aInputHelper.IsNewPress(Keys.Back))
            {
                aSceneManager.HideOverlay();
                return;
            }
        }
示例#40
0
 private void NextScene()
 {
     if (sceneManager != null)
     {
         sceneManager.Finish -= SceneManager_Finish;
         sceneManager.Destroy();
     }
     if (sceneManager == null)
         sceneManager = new Scene1Manager();
     else if (sceneManager is Scene1Manager)
         sceneManager = new Scene2Manager();
     else if (sceneManager is Scene2Manager)
         sceneManager = new Scene3Manager();
     else
         Application.Exit();
     sceneManager.Finish += SceneManager_Finish;
     sceneManager.Init();
 }
示例#41
0
        public override void HandleKeys(InputHelper aInputHelper, ISceneManager aSceneManager)
        {
            //Does the user want to quit?
            if (aInputHelper.IsNewPress(Keys.Q) || aInputHelper.IsNewPress(Keys.Escape))
            {
                aSceneManager.ShowOverlay(new ExitGameIntsance());
                return;
            }

            //Else - Let's be silly!
            if (aInputHelper.IsCurPress(Keys.E) &&
                aInputHelper.IsCurPress(Keys.W) &&
                aInputHelper.IsCurPress(Keys.A) &&
                aInputHelper.IsCurPress(Keys.N))
            {
                //aSceneManager.SetScene(new SuperSpecialAwesomeScene());
                Console.WriteLine("Dylan smells!");
                return;
            }
        }
示例#42
0
        public RGBA_D Shade(Ray ray, Vector3D hitPoint, uint subIdx, IOpticalSceneObject obj,
                            ISceneManager scene, out Ray reflection, out Ray refraction)
        {
            RGBA_D color = RGBA_D.Empty;

            // needed?
            // normal.Normalize();
            
            Vector3D normal = obj.GetNormal(hitPoint, subIdx);

            //color.R = normal.X * 255;
            //color.G = normal.Y * 255;
            //color.B = normal.Z * 255;
            //color.A = 255;
            //refraction = null;
            //reflection = null;
            //return color;

            /*double len = (ray.Origin - hitPoint).Length();
            len -= 2;
            color.R = color.G = color.B = len * 42.5;*/

            foreach (Light light in scene.Lights)
            {
                Vector3D lv = light.Position - hitPoint;
                lv.Normalize();

                // deal with light ray first (diffuse)
                if (true)//ray.TraceRayToLight(hitPoint, light.Position))
                {
                    // light pixel
                    double cost = Vector3D.GetCosAngle(lv, normal);
                    Vector3D vRefl = Vector3D.Reflect(-lv, normal);
                    vRefl.Normalize();

                    double cosf = Vector3D.GetCosAngle(ray.DirectionUV, vRefl);
                    double result1 = Math.Max(0, cost) * 255;
                    double result2 = Math.Pow(Math.Max(0, cosf), shininess) * 255;

                    double luminosity = light.LuminosityForPoint(hitPoint);

                    double r = ((clr.R * diffuse * light.Clr3D.X * result1) +
                                (light.Clr3D.X * result2)) * luminosity;
                    double g = ((clr.G * diffuse * light.Clr3D.Y * result1) +
                                (light.Clr3D.Y * result2)) * luminosity;
                    double b = ((clr.B * diffuse * light.Clr3D.Z * result1) +
                                (light.Clr3D.Z * result2)) * luminosity;

                    color.R += r;
                    color.G += g;
                    color.B += b;
                }
            }
            
            // add ambient
            double alpha = 1 - transmission;
            color.R += (diffuse * scene.Ambient.R + (clr.R * emmissive)) * 255;
            //color.R *= alpha;
            color.G += (diffuse * scene.Ambient.G + (clr.G * emmissive)) * 255;
            //color.G *= alpha;
            color.B += (diffuse * scene.Ambient.B + (clr.B * emmissive)) * 255;
            //color.B *= alpha;
            
            color.A = alpha * 255;

            // blend texture (if any)
            /*if (texture != null)
            {
                Vector2D tCoord = obj.GetTexCoord(hitPoint, subIdx);
                // clamp for now
                if (tCoord.X < 0)
                    tCoord.X = 0;
                if (tCoord.Y < 0)
                    tCoord.Y = 0;
                if (tCoord.X > 1)
                    tCoord.X = 1;
                if (tCoord.Y > 1)
                    tCoord.Y = 1;

                int tX = (int)(tCoord.X * (texture.Width - 1));
                int tY = (int)(tCoord.Y * (texture.Height - 1));

                Color tClr = ((Bitmap)texture).GetPixel(tX, tY);
                color.R = (color.R + tClr.R) / 2;
                color.G = (color.G + tClr.G) / 2;
                color.B = (color.B + tClr.B) / 2;
            }*/

            if (ray.Intensity > 0)
            {
                /*if (this.reflection > 0)
                {
                    Vector3D refl = Vector3D.Reflect(ray.DirectionUV, normal);
                    reflection = new Ray(hitPoint, refl, ray.Intensity * this.reflection, ray.Length, ray.MaxLength, ray.scene);
                }
                else*/
                    reflection = null;
                /*if (transmission > 0)
                    refraction = new Ray(hitPoint, Vector3D.Normalize(Vector3D.Refract(1, 1.33, -ray.DirectionUV, normal)), ray.Intensity * transmission, ray.Length, ray.MaxLength, ray.scene);
                else*/
                refraction = null;
            }
            else
                reflection = refraction = null;

            ray.Intensity = 0;

            return color;
        }
示例#43
0
 public ExitState(ISceneManager sceneManager, ILogManager logManager, IMessageManager messageManager)
     : base("exit", null, sceneManager, logManager)
 {
     this.MessageManager = messageManager;
 }
示例#44
0
 /// <summary>
 /// Is invoked by <see cref="Mortar.Events.Incidents.GameStarted"/>.
 /// </summary>
 public void OnGameStarted(IEvent e)
 {
     try
     {
         SceneManager = new UnitySceneManager();
         PrepareConsistentObjects();
     }
     catch(Exception expection)
     {
         Logger.LogException(expection);
     }
 }
示例#45
0
 public abstract void HandleKeys(InputHelper aInputHelper, ISceneManager aSceneManager);
示例#46
0
 public TestState( ILogManager logManager, ISceneManager sceneManager, ISystemsManager systemsManager )
     : base("test", null, sceneManager, logManager)
 {
     this.SystemsManager = systemsManager;
 }
示例#47
0
 public void Initialize(ISimulationBase simBase)
 {
     _regionInfoConnector = Aurora.DataManager.DataManager.RequestPlugin<IRegionInfoConnector>();
     _sceneManager = m_registry.RequestModuleInterface<ISceneManager>();
 }
示例#48
0
 public void Initialize(ISimulationBase simBase)
 {
     _sceneManager = m_registry.RequestModuleInterface<ISceneManager>();
 }
示例#49
0
 public TestState( ILogManager logManager, ISceneManager sceneManager, ISystemsManager systemsManager, IMessageManager messageManager )
     : base("test", null, sceneManager, logManager, new ExitState( sceneManager, logManager, messageManager ))
 {
     this.SystemsManager = systemsManager;
 }
示例#50
0
 public void PostFinishStartup(IScene scene, IConfigSource source, ISimulationBase openSimBase)
 {
     m_manager = scene.RequestModuleInterface<ISceneManager>();
     m_backup[scene].FinishStartup();
 }
示例#51
0
 public SmTestState( ISceneManager scm, ILogManager lm )
     : base("test", "init", scm, lm)
 {
 }
示例#52
0
        public void Initialize(RegionInfo regionInfo, ISimulationDataStore dataStore, 
            AgentCircuitManager authen, List<IClientNetworkServer> clientServers)
        {
            Initialize(regionInfo);

            //Set up the clientServer
            m_clientServers = clientServers;
            foreach (IClientNetworkServer clientServer in clientServers)
            {
                clientServer.AddScene(this);
            }

            m_sceneManager = RequestModuleInterface<ISceneManager>();
            m_simDataStore = dataStore;

            m_config = m_sceneManager.ConfigSource;
            m_authenticateHandler = authen;

            m_AuroraEventManager = new AuroraEventManager();
            m_eventManager = new EventManager();
            m_permissions = new ScenePermissions(this);

            m_sceneGraph = new SceneGraph(this, m_regInfo);

            #region Region Config

            IConfig aurorastartupConfig = m_config.Configs["AuroraStartup"];
            if (aurorastartupConfig != null)
            {
                //Region specific is still honored here, the RegionInfo checks for it, and if it is 0, it didn't set it
                if (RegionInfo.ObjectCapacity == 0)
                    RegionInfo.ObjectCapacity = aurorastartupConfig.GetInt("ObjectCapacity", 80000);
            }

            IConfig packetConfig = m_config.Configs["PacketPool"];
            if (packetConfig != null)
            {
                PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
                PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
            }

            #endregion Region Config

            m_basesimfps = 45f;
            m_basesimphysfps = 45f;

            m_basesimphysfps = Config.Configs["Physics"].GetFloat("BasePhysicsFPS", 45f);
            if (m_basesimphysfps > 45f)
                m_basesimphysfps = 45f;

            m_basesimfps = Config.Configs["Protection"].GetFloat("BaseRateFramesPerSecond", 45f);
            if (m_basesimfps > 45f)
                m_basesimfps = 45f;

            if (m_basesimphysfps > m_basesimfps)
                m_basesimphysfps = m_basesimfps;

            m_updatetimespan = 1000/m_basesimfps;
            m_physicstimespan = 1000/m_basesimphysfps;

            #region Startup Complete config

            EventManager.OnAddToStartupQueue += AddToStartupQueue;
            EventManager.OnModuleFinishedStartup += FinishedStartup;
            //EventManager.OnStartupComplete += StartupComplete;

            AddToStartupQueue("Startup");

            #endregion
        }
示例#53
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sceneManager"></param>
 public void setSceneManager(ISceneManager sceneManager)
 {
     this.sceneManager = sceneManager;
 }
示例#54
0
            /// <summary>
            /// remove IGameObject's pair are no longer in collision
            /// </summary>
            public void removeNotCollidableElementsInCurrentFrame(ISceneManager sceneManager)
            {
                if (collisionStateMapByGameObjectPair.Count > 0)
                {

                    for (int i=0; i < collisionStateMapByGameObjectPair.Count; i++ )
                    {
                    //foreach (KeyValuePair<KeyValuePair<IGameObject, IGameObject>, bool> dictionaryElement in collisionRecordDictionary)
                    //{
                        //if (collisionRecordDictionary[dictionaryElement.Key] == false)
                        //{
                        //    collisionRecordDictionary.Remove(dictionaryElement.Key);
                        //    dictionaryElement.Key.Key.onCollisionExitDelegate(dictionaryElement.Key.Value);
                        //    dictionaryElement.Key.Value.onCollisionExitDelegate(dictionaryElement.Key.Key);
                        //}
                        KeyValuePair<IGameObject, IGameObject> gameObjectPair = collisionStateMapByGameObjectPair.ElementAt(i).Key;
                        if (collisionStateMapByGameObjectPair[gameObjectPair] == false)
                        {

                            List<IGameObject> firstGameObjectList = sceneManager.getCollaidableGameObjectList(gameObjectPair.Key.getGameObjectTag());
                            List<IGameObject> secondGameObjectList = sceneManager.getCollaidableGameObjectList(gameObjectPair.Value.getGameObjectTag());

                            if(firstGameObjectList.Contains(gameObjectPair.Key)){
                                gameObjectPair.Key.onCollisionExitDelegate(gameObjectPair.Value);
                            }
                            if (secondGameObjectList.Contains(gameObjectPair.Value))
                            {
                                gameObjectPair.Value.onCollisionExitDelegate(gameObjectPair.Key);
                            }

                            //remove element from dictionary
                            collisionStateMapByGameObjectPair.Remove(gameObjectPair);
                        }

                    }
                }
            }
示例#55
0
 public override void HandleKeys(InputHelper aInputHelper, ISceneManager aSceneManager)
 {
     return;
 }