상속: MonoBehaviour
예제 #1
0
    private void Event_OnEncounterInCameraView(FocusCamera camera)
    {
        foreach (var health in FindObjectsOfType <PawnHealth>())
        {
            health.ApplyHeal(m_HealAmount);
        }

        gameObject.SetActive(false);
        EncounterManager.Instance.EndCurrentEncounter();
    }
예제 #2
0
    private void OnCameraFocusReached()
    {
        if (m_CurrCamera != null)
        {
            EventHandler.Invoke("OnEncounterInCameraView", m_CurrCamera);

            m_CurrCamera.OnTargetReached.RemoveListener(OnCameraFocusReached);
            m_CurrCamera = null;
        }
    }
예제 #3
0
    private void Event_OnEncounterInCameraView(FocusCamera camera)
    {
        if (m_NewPawn)
        {
            PopupManager.Instance.CreatePopup3D("New Ally '" + m_NewPawn.PawnName + "'", transform.position, 1.0f, Color.green, FontStyle.Normal);
            m_NewPawn.MoveToTile(m_NewPawn.CurrentTile, true);
        }
        else
        {
            PopupManager.Instance.CreatePopup3D("No new ally today :(", transform.position, 1.0f, Color.yellow, FontStyle.Normal);
        }

        gameObject.SetActive(false);
        EncounterManager.Instance.EndCurrentEncounter();
    }
예제 #4
0
        public void Draw(SpriteBatch sb, FocusCamera camera, RenderTarget2D renderTarget)
        {
            foreach (var entry in renderList)
            {
                if (entry.Value.getRenderCount() > 0)
                {
                    entry.Value.Render(sb, camera.getViewMatrix(ScrollSpeed));
                }
            }

            if (_postProcessors.Count > 0)
            {
                for (var i = 0; i < _postProcessors.Count; i++)
                {
                    _postProcessors[i].Process(sb, renderTarget);
                }
            }
        }
예제 #5
0
        public PlayState(DemoGame game, string LevelFile) : base(game)
        {
            spriteBatch     = game.Services.GetService <SpriteBatch>();
            camera          = game.Services.GetService <FocusCamera>();
            settings        = game.Services.GetService <GameSettings>();
            scriptingEngine = game.Services.GetService <ScriptingEngine>();
            context         = game.Services.GetService <GameContext>();
            monitor         = new FpsMonitor();

            lvlFile = LevelFile;
            //var dir = Path.Combine(DemoGame.ContentManager.RootDirectory,"Scripts");
            //var files = Directory.GetFiles(dir);
            //scriptingEngine.LoadScript(files);

            hud = new HeadsUpDisplay();


            LoadContent(game.ContentManager);
            Initialize();
        }
예제 #6
0
        public void DrawDebug(SpriteBatch sb, SpriteFont font, FocusCamera camera)
        {
            var projection = Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(sb.GraphicsDevice.Viewport.Width), ConvertUnits.ToSimUnits(sb.GraphicsDevice.Viewport.Height), 0f, 0f, 1f);

            debugView.RenderDebugData(projection, camera.getScaledViewMatrix());

            var projection2 = Matrix.CreateOrthographicOffCenter(0f, sb.GraphicsDevice.Viewport.Width, sb.GraphicsDevice.Viewport.Height, 0f, 0f, 1f);

            debugView.BeginCustomDraw(projection2, camera.getViewMatrix());

            foreach (var ray in player.controller.castList)
            {
                debugView.DrawSegment(ray.from, ray.to, Color.Blue);
            }

            var areaPoints = new Vector2[] {
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.left, camera.focusArea.top)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.right, camera.focusArea.top)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.right, camera.focusArea.bottom)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.left, camera.focusArea.bottom))
            };

            debugView.DrawSolidPolygon(areaPoints, 4, Color.Red);

            debugView.DrawPoint(ConvertUnits.ToDisplayUnits(camera.focusPosition), 3, Color.White);

            debugView.DrawPoint(camera.Position, 3, Color.Pink);

            var cameraBounds = new Vector2[] {
                new Vector2(camera.Bounds.Left, camera.Bounds.Top),
                new Vector2(camera.Bounds.Right, camera.Bounds.Top),
                new Vector2(camera.Bounds.Right, camera.Bounds.Bottom),
                new Vector2(camera.Bounds.Left, camera.Bounds.Bottom)
            };

            debugView.DrawPolygon(cameraBounds, 4, Color.Green);

            debugView.EndCustomDraw();
        }
예제 #7
0
        public void Draw(SpriteBatch sb, FocusCamera camera)
        {
            context.graphics.SetRenderTarget(render_target);
            foreach (var layer in Layers)
            {
                if (layer.Visible)
                {
                    layer.Draw(sb, camera, render_target);
                }
            }


            if (_postProcessors.Count > 0)
            {
                _postProcessors[0].Process(sb, render_target);
            }


            context.graphics.SetRenderTarget(null);

            sb.Begin();
            sb.Draw(render_target, new Rectangle(0, 0, this.render_target.Width, this.render_target.Height), Color.White);
            sb.End();
        }
예제 #8
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()
        {
            Content.RootDirectory = "Content";
            ContentManager        = Content;
            Services.AddService(Content);


            Services.AddService(graphics);

            gameManager = new GameStateManager(this);
            Services.AddService(gameManager);


            var soundDir = new DirectoryInfo(Path.Combine(Content.RootDirectory, "SFX"));
            var musicDir = new DirectoryInfo(Path.Combine(Content.RootDirectory, "Music"));

            AudioManager.Initialize(this, soundDir, musicDir);


            inputHandler = InputHandler.InitializeSingleton(this);
            Components.Add(inputHandler);
            Components.Add(gameManager);


            var settings = GameSettings.LoadFromFile();

            Services.AddService(settings);

            graphics.PreferredBackBufferWidth  = graphics.GraphicsDevice.DisplayMode.Width;
            graphics.PreferredBackBufferHeight = graphics.GraphicsDevice.DisplayMode.Height;
            graphics.ApplyChanges();
            Window.IsBorderless = true;


            camera = new FocusCamera(GraphicsDevice.Viewport, null);

            Services.AddService(camera);

            spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(spriteBatch);



            var transMan = new TransitionManager(this, gameManager);

            context = new GameContext
            {
                camera            = camera,
                gameManager       = gameManager,
                transitionManager = transMan,
                input             = inputHandler,
                scripter          = scriptManager,
                spriteBatch       = spriteBatch,
                content           = Content,
                graphics          = GraphicsDevice
            };

            scriptManager = new ScriptingEngine(context);
            Services.AddService(scriptManager);

            context.scripter = scriptManager;

            Services.AddService(context);



            var console = new ConsoleComponent(this);

            console.Initialize();
            console.TimeToToggleOpenClose = 0.25f;
            console.Interpreter           = scriptManager;
            Services.AddService(console);

            base.Initialize();
        }