コード例 #1
0
ファイル: GameState.cs プロジェクト: Kurdiumov/ToylandSiege
        protected GameObject PickObject(List <Type> types = null)
        {
            var pickRay = CalculateRay(new Vector2(Mouse.GetState().X, Mouse.GetState().Y),
                                       Camera.GetCurrentCamera().ViewMatrix, Camera.GetCurrentCamera().ProjectionMatrix,
                                       ToylandSiege.GetInstance().GraphicsDevice.Viewport);

            GameObject closestObject         = null;
            float?     closestObjectDistance = null;

            foreach (var child in Level.GetCurrentLevel().RootGameObject.GetAllChilds(Level.GetCurrentLevel().RootGameObject))
            {
                if (child.Model == null || child.IsEnabled == false || (types != null && types.All(type => child.GetType() != type)))
                {
                    continue;
                }

                foreach (var mesh in child.Model.Meshes)
                {
                    BoundingSphere sphere = mesh.BoundingSphere;
                    sphere = sphere.Transform(child.TransformationMatrix);

                    var currentDistance = pickRay.Intersects(sphere);
                    if (currentDistance != null)
                    {
                        if (closestObjectDistance == null || currentDistance < closestObjectDistance)
                        {
                            closestObject         = child;
                            closestObjectDistance = currentDistance;
                        }
                    }
                }
            }
            return(closestObject);
        }
コード例 #2
0
ファイル: Camera.cs プロジェクト: Kurdiumov/ToylandSiege
        public void RotateCamera(MouseState _previousMouseState)
        {
            if (!ToylandSiege.GetInstance().IsActive)
            {
                return;
            }
            if (Mouse.GetState() != _previousMouseState)
            {
                Camera.GetCurrentCamera().Direction = Vector3.Transform(
                    Camera.GetCurrentCamera().Direction,
                    Matrix.CreateFromAxisAngle(Camera.GetCurrentCamera().Up,
                                               (-MathHelper.PiOver4 / 150) * (Mouse.GetState().X - _previousMouseState.X)));


                Camera.GetCurrentCamera().Direction = Vector3.Transform(
                    Camera.GetCurrentCamera().Direction,
                    Matrix.CreateFromAxisAngle(
                        Vector3.Cross(Camera.GetCurrentCamera().Up, Camera.GetCurrentCamera().Direction),
                        (MathHelper.PiOver4 / 100) * (Mouse.GetState().Y - _previousMouseState.Y)));


                // Reset PrevMouseState
                Mouse.SetPosition(ToylandSiege.GetInstance().Window.ClientBounds.Width / 2, ToylandSiege.GetInstance().Window.ClientBounds.Height / 2);
            }
        }
コード例 #3
0
ファイル: Board.cs プロジェクト: Kurdiumov/ToylandSiege
        public void CreateFields()
        {
            int index = 0;

            for (int column = 0; column < _numberOfColumns; column++)
            {
                int rowsInCurrentColumn = _numberOfRows;
                if (column % 2 != 0)
                {
                    rowsInCurrentColumn = _numberOfRows - 1;
                }

                for (int row = 0; row < rowsInCurrentColumn; row++)
                {
                    var field = new Field(FieldName + index, index, CalculatePosition(column, row, index), Scale)
                    {
                        Model = ToylandSiege.GetInstance().Content.Load <Model>(FieldModel),
                    };

                    /*
                     * //Setting starting and finishing fields
                     * if (column == 0)
                     *  field.StartingTile = true;
                     * else if (column == _numberOfColumns - 1)
                     *  field.FinishingTile = true;*/


                    Childs["Row" + column].AddChild(field);
                    index++;
                    ++FieldCount;
                }
            }
        }
コード例 #4
0
ファイル: Paused.cs プロジェクト: Kurdiumov/ToylandSiege
 public override void Update(GameTime gameTime)
 {
     ToylandSiege.GetInstance().IsMouseVisible = false;
     ProcessInput();
     _previousKeyboardState = Keyboard.GetState();
     _previousMouseState    = Mouse.GetState();
     return;
 }
コード例 #5
0
        protected override void Initialize()
        {
            Vector3 direction = CalculateDirection(new Vector2(Mouse.GetState().X, Mouse.GetState().Y),
                                                   Camera.GetCurrentCamera().ViewMatrix, Camera.GetCurrentCamera().ProjectionMatrix,
                                                   ToylandSiege.GetInstance().GraphicsDevice.Viewport);

            DirForce = direction * _Speed;
        }
コード例 #6
0
ファイル: UnitBase.cs プロジェクト: Kurdiumov/ToylandSiege
        public override void Draw()
        {
            DrawHealthBar();
            ToylandSiege.GetInstance().GraphicsDevice.BlendState = BlendState.Opaque;
            ToylandSiege.GetInstance().GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            ToylandSiege.GetInstance().GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

            base.Draw();
        }
コード例 #7
0
        public FirstPerson()
        {
            _TimerSpriteBatch = new SpriteBatch(ToylandSiege.GetInstance().GraphicsDevice);
            _TimerSpriteFont = ToylandSiege.GetInstance().Content.Load<SpriteFont>("Fonts/TimerFont");
            _SpawnersFont = ToylandSiege.GetInstance().Content.Load<SpriteFont>("Fonts/SpawnersFont");

            _AimTexture = ToylandSiege.GetInstance().Content.Load<Texture2D>("Aim");
            _AimSpriteBatch = new SpriteBatch(ToylandSiege.GetInstance().GraphicsDevice);
        }
コード例 #8
0
ファイル: Field.cs プロジェクト: Kurdiumov/ToylandSiege
 public Field(string name, int index, Vector3 position, Vector3 scale)
 {
     Name     = name;
     Index    = index;
     Position = position;
     Scale    = scale;
     Type     = "Field";
     effect   = new BasicEffect(ToylandSiege.GetInstance().GraphicsDevice);
     Initialize();
 }
コード例 #9
0
ファイル: GameState.cs プロジェクト: Kurdiumov/ToylandSiege
 public void Init()
 {
     FpsEnabled            = ToylandSiege.GetInstance().configurationManager.FPSEnabled;
     _spriteBatch          = new SpriteBatch(ToylandSiege.GetInstance().GraphicsDevice);
     _spriteFont           = ToylandSiege.GetInstance().Content.Load <SpriteFont>("Fonts/FPS");
     _configurationManager = ToylandSiege.GetInstance().configurationManager;
     Mouse.SetPosition(ToylandSiege.GetInstance().Window.ClientBounds.Width / 2, ToylandSiege.GetInstance().Window.ClientBounds.Height / 2);
     _previousMouseState = Mouse.GetState();
     _frameCounter       = new FPSCounter();
 }
コード例 #10
0
 public override void ProcessInput()
 {
     if (!ToylandSiege.GetInstance().IsActive)
     {
         return;
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Left) || Keyboard.GetState().IsKeyDown(Keys.A))
     {
         Camera.GetCurrentCamera().Position += Vector3.Cross(Camera.GetCurrentCamera().Up, Camera.GetCurrentCamera().Direction) * Camera.GetCurrentCamera().Speed;
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Right) || Keyboard.GetState().IsKeyDown(Keys.D))
     {
         Camera.GetCurrentCamera().Position -= Vector3.Cross(Camera.GetCurrentCamera().Up, Camera.GetCurrentCamera().Direction) * Camera.GetCurrentCamera().Speed;
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Up) || Keyboard.GetState().IsKeyDown(Keys.W))
     {
         Camera.GetCurrentCamera().Position += Camera.GetCurrentCamera().Direction *
                                               Camera.GetCurrentCamera().Speed;
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Down) || Keyboard.GetState().IsKeyDown(Keys.S))
     {
         Camera.GetCurrentCamera().Position -= Camera.GetCurrentCamera().Direction *
                                               Camera.GetCurrentCamera().Speed;
     }
     if (IsSimpleKeyPress(Keys.Tab))
     {
         Camera.SwitchToNextCamera();
     }
     if (Mouse.GetState().LeftButton == ButtonState.Pressed && IsSimpleClick() && _configurationManager.PickingEnabled)
     {
         var PickedObject = PickObject(new List <Type>()
         {
             typeof(Field)
         });                                                              // Use this for pciking only fields
         //var PickedObject = PickObject(); //USe this for picking all abjects
         if (PickedObject != null)
         {
             Logger.Log.Debug("Object picked: " + PickedObject.ToString());
         }
         else
         {
             Logger.Log.Debug("Object picked: NULL");
             System.Diagnostics.Debug.Print("Object picked: NULL");
         }
     }
     if (IsSimpleKeyPress(Keys.P))
     {
         _GameStateManager.SetNewGameState(_GameStateManager.AvailableGameStates["Paused"]);
     }
     if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
         ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
     {
         ToylandSiege.GetInstance().gameStateManager.SetNewGameState(ToylandSiege.GetInstance().gameStateManager.AvailableGameStates["Menu"]);
     }
 }
コード例 #11
0
ファイル: UnitBase.cs プロジェクト: Kurdiumov/ToylandSiege
 public UnitBase()
 {
     Initialize();
     spriteBatch = new SpriteBatch(ToylandSiege.GetInstance().GraphicsDevice);
     spriteFont  = ToylandSiege.GetInstance().Content.Load <SpriteFont>("Fonts/FPS");
     basicEffect = new BasicEffect(ToylandSiege.GetInstance().GraphicsDevice)
     {
         TextureEnabled     = true,
         VertexColorEnabled = true,
     };
 }
コード例 #12
0
ファイル: Field.cs プロジェクト: Kurdiumov/ToylandSiege
 private void _DrawWater(ModelMesh mesh)
 {
     foreach (ModelMeshPart part in mesh.MeshParts)
     {
         part.Effect = effect;
         effect.Parameters["World"].SetValue(TransformationMatrix);
         effect.Parameters["View"].SetValue(Matrix.CreateLookAt(Camera.GetCurrentCamera().Position, Camera.GetCurrentCamera().Position + Camera.GetCurrentCamera().Direction, Camera.GetCurrentCamera().Up));
         effect.Parameters["Projection"].SetValue(Camera.GetCurrentCamera().ProjectionMatrix);
         effect.Parameters["Texture"].SetValue(ToylandSiege.GetInstance().Content.Load <Texture2D>("Water"));
     }
 }
コード例 #13
0
ファイル: Paused.cs プロジェクト: Kurdiumov/ToylandSiege
        public override void Draw(GameTime gameTime)
        {
            this._spriteBatch.Begin();
            string TextToDraw = "Game Paused";

            this._spriteBatch.DrawString(_spritePausedFont, TextToDraw,
                                         new Vector2(ToylandSiege.GetInstance().GraphicsDevice.Viewport.Bounds.Width / 2,
                                                     ToylandSiege.GetInstance().GraphicsDevice.Viewport.Bounds.Height / 2) - _spritePausedFont.MeasureString(TextToDraw) / 2,
                                         Color.Red);
            this._spriteBatch.End();
        }
コード例 #14
0
ファイル: Strategic.cs プロジェクト: Kurdiumov/ToylandSiege
        private void _updateUI()
        {
            _soldierTextureOffset = (ToylandSiege.GetInstance().GraphicsDevice.DisplayMode.Width - (_currentWave.AvailableUnits.Count * _soldierTextureSize)) / 2;

            sodlierstTextures.Clear();

            for (int offset = 0, i = 0; i < _currentWave.AvailableUnits.Count; i++, offset += _soldierTexturePadding)
            {
                sodlierstTextures.Add(new Rectangle(_soldierTextureOffset + (_soldierTextureSize * i) + offset, 10, _soldierTextureSize, _soldierTextureSize));
            }
        }
コード例 #15
0
 public Cannonball()
 {
     this.Name = "Cannonball#" + _CannonballIndex;
     this.Type = "Cannonball";
     this.Collider.CreateSingleBoundingSphereForModel();
     _CannonballIndex++;
     this.Model        = ToylandSiege.GetInstance().Content.Load <Model>("PrimitiveShapes/Sphere");
     this.IsStatic     = false;
     this.IsEnabled    = true;
     this.IsCollidable = true;
     Initialize();
 }
コード例 #16
0
ファイル: Paused.cs プロジェクト: Kurdiumov/ToylandSiege
 public override void ProcessInput()
 {
     if (!ToylandSiege.GetInstance().IsActive)
     {
         return;
     }
     if (IsSimpleKeyPress(Keys.P))
     {
         ToylandSiege.GetInstance().IsMouseVisible = ToylandSiege.GetInstance().configurationManager.IsMouseVisible();
         _GameStateManager.SetNewGameState(_GameStateManager.GetPreviousGameState());
     }
 }
コード例 #17
0
        public virtual void Draw()
        {
            if (!IsEnabled)
            {
                return;
            }
            if (Model != null)
            {
                foreach (ModelMesh mesh in Model.Meshes)
                {
                    if (mesh.Effects.All(e => e is BasicEffect))
                    {
                        foreach (BasicEffect effect in mesh.Effects)
                        {
                            if (ToylandSiege.GetInstance().configurationManager.LigthningEnabled)
                            {
                                effect.EnableDefaultLighting();
                            }
                            effect.AmbientLightColor = new Vector3(0, 0.3f, 0.3f);
                            effect.View = Camera.GetCurrentCamera().ViewMatrix;

                            effect.World      = TransformationMatrix;
                            effect.Projection = Camera.GetCurrentCamera().ProjectionMatrix;
                            GlobalLightning.DrawGlobalLightning(effect);
                        }
                    }
                    else if (AnimationPlayer != null && mesh.Effects.All(e => e is SkinnedEffect))
                    {
                        Matrix[] bones = AnimationPlayer.GetSkinTransforms();

                        foreach (SkinnedEffect effect in mesh.Effects)
                        {
                            (effect).SetBoneTransforms(bones);
                            if (ToylandSiege.GetInstance().configurationManager.LigthningEnabled)
                            {
                                effect.EnableDefaultLighting();
                            }
                            effect.AmbientLightColor = new Vector3(0, 0.3f, 0.3f);
                            effect.View = Camera.GetCurrentCamera().ViewMatrix;

                            effect.World      = TransformationMatrix;
                            effect.Projection = Camera.GetCurrentCamera().ProjectionMatrix;
                            GlobalLightning.DrawGlobalLightning(effect);
                        }
                    }
                    mesh.Draw();
                }
            }
            foreach (var child in Childs.Values)
            {
                child.Draw();
            }
        }
コード例 #18
0
ファイル: Camera.cs プロジェクト: Kurdiumov/ToylandSiege
 public void Zoom(bool zoom)
 {
     if (zoom)
     {
         ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(Angle / _zoomstrength),
                                                                ToylandSiege.GetInstance().GraphicsDevice.Viewport.AspectRatio, NearDistance, FarDistance);
     }
     else
     {
         ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(Angle),
                                                                ToylandSiege.GetInstance().GraphicsDevice.Viewport.AspectRatio, NearDistance, FarDistance);
     }
 }
コード例 #19
0
        public override void ProcessInput()
        {
            if (!ToylandSiege.GetInstance().IsActive)
                return;
            if (IsSimpleKeyPress(Keys.P))
            {
                _GameStateManager.SetNewGameState(_GameStateManager.AvailableGameStates["Paused"]);
            }
            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                if (!aim)
                {
                    Camera.GetCurrentCamera().Zoom(true);
                }
                aim = true;
            }
            else if (aim)
            {
                Camera.GetCurrentCamera().Zoom(false);
                aim = false;
            }
            if (Mouse.GetState().LeftButton == ButtonState.Pressed && aim && _ReloadLeft < 0.1f)
            {
                Logger.Log.Debug("Shot");
                /*
                var PickedObject = PickObject();
                if (PickedObject != null)
                {
                    Logger.Log.Debug("Shot picked: " + PickedObject.ToString());
                }
                */
                SpawnCannonball();

                _ReloadLeft = ReloadTime;
            }
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
             ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                ToylandSiege.GetInstance().gameStateManager.SetNewGameState(ToylandSiege.GetInstance().gameStateManager.AvailableGameStates["Menu"]);

            //Secret combination to switch  to god mode
            if (IsSimpleKeyPress(Keys.G) && Keyboard.GetState().IsKeyDown(Keys.LeftAlt))
            {
                ToylandSiege.GetInstance().gameStateManager.SetNewGameState(ToylandSiege.GetInstance().gameStateManager.AvailableGameStates["GodMode"]);
            }

            //Secret combination to finish wave immediately
            if (IsSimpleKeyPress(Keys.F) && Keyboard.GetState().IsKeyDown(Keys.LeftAlt))
            {
                Level.GetCurrentLevel().WaveController.FinishRound();
            }
        }
コード例 #20
0
ファイル: Menu.cs プロジェクト: Kurdiumov/ToylandSiege
        public Menu()
        {
            _spriteBatch = new SpriteBatch(ToylandSiege.GetInstance().GraphicsDevice);

            var btn1Texture = new Texture2D(ToylandSiege.GetInstance().GraphicsDevice, btnWidth, btnHeight);
            var btn2Texture = new Texture2D(ToylandSiege.GetInstance().GraphicsDevice, btnWidth, btnHeight);
            var btn3Texture = new Texture2D(ToylandSiege.GetInstance().GraphicsDevice, btnWidth, btnHeight);

            btn1Texture.SetData(CreateTexture(Color.Aqua));
            btn2Texture.SetData(CreateTexture(Color.White));
            btn3Texture.SetData(CreateTexture(Color.Red));

            btn1 = new Menubutton(btn1Texture, (ToylandSiege.GetInstance().GraphicsDevice.DisplayMode.Width / 2) - (btnWidth / 2), 150, btnWidth, btnHeight, "Start Tutorial");
            btn2 = new Menubutton(btn2Texture, (ToylandSiege.GetInstance().GraphicsDevice.DisplayMode.Width / 2) - (btnWidth / 2), 300, btnWidth, btnHeight, "Start Level 1");
            btn3 = new Menubutton(btn3Texture, (ToylandSiege.GetInstance().GraphicsDevice.DisplayMode.Width / 2) - (btnWidth / 2), 450, btnWidth, btnHeight, "Exit");
        }
コード例 #21
0
ファイル: Strategic.cs プロジェクト: Kurdiumov/ToylandSiege
        public override void ProcessInput()
        {
            if (!ToylandSiege.GetInstance().IsActive)
            {
                return;
            }
            if (IsSimpleKeyPress(Keys.P))
            {
                _GameStateManager.SetNewGameState(_GameStateManager.AvailableGameStates["Paused"]);
            }

            if (!WaveController.RoundRunning && IsSimpleKeyPress(Keys.Space))
            {
                if (_CanStartWave())
                {
                    Level.GetCurrentLevel().WaveController.StartRound();
                }
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
                ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                ToylandSiege.GetInstance().gameStateManager.SetNewGameState(ToylandSiege.GetInstance().gameStateManager.AvailableGameStates["Menu"]);
            }


            if (Mouse.GetState().LeftButton == ButtonState.Pressed && IsSimpleClick())
            {
                if (_CanStartWave() && StartWaveBtn.rectangle.Contains(new Point(Mouse.GetState().X, Mouse.GetState().Y)))
                {
                    Level.GetCurrentLevel().WaveController.StartRound();
                }
                else
                {
                    Logger.Log.Debug("Clicked in Startegic view!");
                    //_PlacingUnit();
                    _StrategicClick();
                }
            }

            //Secret combination to switch  to god mode
            if (IsSimpleKeyPress(Keys.G) && Keyboard.GetState().IsKeyDown(Keys.LeftAlt))
            {
                ToylandSiege.GetInstance().gameStateManager.SetNewGameState(ToylandSiege.GetInstance().gameStateManager.AvailableGameStates["GodMode"]);
            }
        }
コード例 #22
0
ファイル: Strategic.cs プロジェクト: Kurdiumov/ToylandSiege
        public Strategic()
        {
            soldierTexture2D = ToylandSiege.GetInstance().Content.Load <Texture2D>("soldierTexture");
            scoutTexture2D   = ToylandSiege.GetInstance().Content.Load <Texture2D>("scoutTexture");
            tankTexture2D    = ToylandSiege.GetInstance().Content.Load <Texture2D>("TankTexture");
            _spriteBatch     = new SpriteBatch(ToylandSiege.GetInstance().GraphicsDevice);

            //Create start Wave button
            var startWaveTexture = new Texture2D(ToylandSiege.GetInstance().GraphicsDevice, btnWidth, btnHeight);
            var data             = new Color[btnWidth * btnHeight];

            for (int i = 0; i < data.Length; ++i)
            {
                data[i] = Color.Green;
            }
            startWaveTexture.SetData(data);
            StartWaveBtn = new Menubutton(startWaveTexture, (ToylandSiege.GetInstance().GraphicsDevice.DisplayMode.Width / 2) - (btnWidth / 2), ToylandSiege.GetInstance().GraphicsDevice.DisplayMode.Height - 70, btnWidth, btnHeight, "Start Wave   ");
        }
コード例 #23
0
ファイル: Field.cs プロジェクト: Kurdiumov/ToylandSiege
        public override void Draw()
        {
            if (!IsEnabled)
            {
                return;
            }

            UpdateColors();
            if (Model != null)
            {
                foreach (ModelMesh mesh in Model.Meshes)
                {
                    if (IsWater)
                    {
                        _DrawWater(mesh);
                    }
                    else
                    {
                        foreach (ModelMeshPart part in mesh.MeshParts)
                        {
                            part.Effect = effect;

                            if (ToylandSiege.GetInstance().configurationManager.LigthningEnabled)
                            {
                                (effect as BasicEffect).EnableDefaultLighting();
                            }
                            (effect as BasicEffect).AmbientLightColor = AmbientVector3;
                            (effect as BasicEffect).DiffuseColor      = ColorVector3;

                            (effect as BasicEffect).View = Camera.GetCurrentCamera().ViewMatrix;

                            (effect as BasicEffect).World      = TransformationMatrix;
                            (effect as BasicEffect).Projection = Camera.GetCurrentCamera().ProjectionMatrix;
                            (effect as BasicEffect).Alpha      = Alpha;
                            GlobalLightning.DrawGlobalLightning(effect);
                        }
                    }
                    mesh.Draw();
                }
            }
        }
コード例 #24
0
ファイル: GameState.cs プロジェクト: Kurdiumov/ToylandSiege
        public virtual void Draw(GameTime gameTime)
        {
            Level.GetCurrentLevel().Draw();


            if (FpsEnabled)
            {
                _frameCounter.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
                var fps = string.Format("FPS: {0}", _frameCounter.AverageFramesPerSecond);

                _spriteBatch.Begin();
                _spriteBatch.DrawString(_spriteFont, fps, new Vector2(10, 10), Color.Black);
                _spriteBatch.End();
            }

            if (ToylandSiege.GetInstance().configurationManager.DebugDraw)
            {
                DebugUtilities.DrawColliderWireframes();
            }

            DrawUI();
        }
コード例 #25
0
ファイル: Menu.cs プロジェクト: Kurdiumov/ToylandSiege
        public override void ProcessInput()
        {
            if (!ToylandSiege.GetInstance().IsActive)
            {
                return;
            }

            if (IsSimpleKeyPress(Keys.Escape))
            {
                ToylandSiege.GetInstance().Exit();
            }

            if (Mouse.GetState().LeftButton == ButtonState.Pressed && IsSimpleClick())
            {
                Logger.Log.Debug("Clicked in Menu view!");

                if (btn1.rectangle.Contains(new Point(Mouse.GetState().X, Mouse.GetState().Y)))
                {
                    ToylandSiege.CurrentLevel = new Level("TutorialLevel");
                    SceneParser parser = new SceneParser();
                    ToylandSiege.CurrentLevel.RootGameObject = parser.Parse("TutorialLevel");
                    ToylandSiege.GetInstance().gameStateManager.SetNewGameState(ToylandSiege.GetInstance().gameStateManager.AvailableGameStates["Strategic"]);
                    ToylandSiege.GetInstance().gameStateManager.LevelChanged(Level.GetCurrentLevel());
                }
                else if (btn2.rectangle.Contains(new Point(Mouse.GetState().X, Mouse.GetState().Y)))
                {
                    ToylandSiege.CurrentLevel = new Level("Level1");
                    SceneParser parser = new SceneParser();
                    ToylandSiege.CurrentLevel.RootGameObject = parser.Parse("Level1");
                    ToylandSiege.GetInstance().gameStateManager.SetNewGameState(ToylandSiege.GetInstance().gameStateManager.AvailableGameStates["Strategic"]);
                    ToylandSiege.GetInstance().gameStateManager.LevelChanged(Level.GetCurrentLevel());
                }
                else if (btn3.rectangle.Contains(new Point(Mouse.GetState().X, Mouse.GetState().Y)))
                {
                    ToylandSiege.GetInstance().Exit();
                }
            }
        }
コード例 #26
0
ファイル: UnitBase.cs プロジェクト: Kurdiumov/ToylandSiege
        private Texture2D RecreateHealthRectangle()
        {
            int       width   = 6;
            Texture2D texture = new Texture2D(ToylandSiege.GetInstance().GraphicsDevice, width, 1);

            int coef = (int)MaxHealth / width;
            var data = new Color[width];

            for (int i = 0; i < data.Length; ++i)
            {
                if (i * coef >= Health)
                {
                    data[i] = Color.Red;
                }
                else
                {
                    data[i] = Color.Green;
                }
            }

            texture.SetData(data);
            return(texture);
        }
コード例 #27
0
 public override void DrawUI()
 {
     _TimerSpriteBatch.Begin();
     _TimerSpriteBatch.DrawString(_TimerSpriteFont, Math.Round(Level.GetCurrentLevel().WaveController.CurrentWave.TimeLeft).ToString(), new Vector2((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width / 2) - 12, 10), Color.Black);
     _TimerSpriteBatch.DrawString(_TimerSpriteFont, "Wave " + WaveController.RoundNumber + "/" + WaveController.WawesCount, new Vector2((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width) - 180, 10), Color.DarkRed);
     if (_CurrentBorad != null)
         _TimerSpriteBatch.DrawString(_SpawnersFont, "Spawners: " + _CurrentBorad.GetEnabledEnemiesSpawnersCount() + "/" + _CurrentBorad.GetAllEnemiesSpawnersCount(), new Vector2(10, ToylandSiege.GetInstance().GraphicsDevice.DisplayMode.Height - 30), Color.DarkRed);
     _TimerSpriteBatch.End();
     if (aim)
     {
         _AimSpriteBatch.Begin();
         _AimSpriteBatch.Draw(_AimTexture, new Vector2((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width / 2), (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 2)), Color.White);
         _AimSpriteBatch.End();
     }
 }
コード例 #28
0
 public Enemy()
 {
     effect = ToylandSiege.GetInstance().Content.Load <Effect>("Shaders/Plastic");
 }
コード例 #29
0
ファイル: Paused.cs プロジェクト: Kurdiumov/ToylandSiege
 public Paused()
 {
     _spriteBatch      = new SpriteBatch(ToylandSiege.GetInstance().GraphicsDevice);
     _spritePausedFont = ToylandSiege.GetInstance().Content.Load <SpriteFont>("Fonts/PausedSpriteFont");
 }