コード例 #1
0
ファイル: Level.cs プロジェクト: colincapurso/LevelIso
 public void Update(Player player)
 {
     for (int i = 0; i < enemyList.Count; i++)
     {
         enemyList[i].Update(player);
     }
 }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: colincapurso/LevelIso
        public void Update(Player player)
        {
            this.Position += this.Velocity;

            // if (this.Position.X > 800 || this.Position.X < 0) direction = -direction;
            if (this.Position.X > 800 || this.Position.X < 0)
            {
                this.Velocity.X = -this.Velocity.X;
                this.Velocity.Y = -this.Velocity.Y;
            }

            float distance = Vector2.Distance(new Vector2(player.Position.X + player.Width / 2, player.Position.Y + player.Height / 2), new Vector2(this.Position.X + this.Width / 2, this.Position.Y + this.Height / 2));

            int red, green, blue;
            if (distance < 510)
            {
                int unit = (int)distance / 2;
                red = 255;
                green = unit;
                blue = unit;
            }
            else
            {
                red = 255;
                green = 255;
                blue = 255;
            }

            this.color = new Color(red, green, blue, 255);
        }
コード例 #3
0
ファイル: Input.cs プロジェクト: colincapurso/LevelIso
        public void Update(Player player)
        {
            // Save previous keyboard/gamepad states
            previousKeyboardState = currentKeyboardState;
            previousGamepadState = currentGamepadState;

            // Read current keyboard/gamepad
            currentKeyboardState = Keyboard.GetState();
            currentGamepadState = GamePad.GetState(PlayerIndex.One);

            // Movement (iso & 8dir)
            //if (currentKeyboardState.IsKeyDown(Keys.Left) || currentGamepadState.ThumbSticks.Left.X < 0)
            //    player.Move("left");
            //else if (currentKeyboardState.IsKeyDown(Keys.Right) || currentGamepadState.ThumbSticks.Left.X > 0)
            //    player.Move("right");
            //if (currentKeyboardState.IsKeyDown(Keys.Up) || currentGamepadState.ThumbSticks.Left.Y < 0)
            //    player.Move("up");
            //else if (currentKeyboardState.IsKeyDown(Keys.Down) || currentGamepadState.ThumbSticks.Left.Y > 0)
            //    player.Move("down");

            // Bools for simpler looking conditions
            bool left = currentKeyboardState.IsKeyDown(Keys.Left)   || currentGamepadState.ThumbSticks.Left.X < 0;
            bool right = currentKeyboardState.IsKeyDown(Keys.Right) || currentGamepadState.ThumbSticks.Left.X > 0;
            bool up = currentKeyboardState.IsKeyDown(Keys.Up)       || currentGamepadState.ThumbSticks.Left.Y < 0;
            bool down = currentKeyboardState.IsKeyDown(Keys.Down)   || currentGamepadState.ThumbSticks.Left.Y > 0;

            // Movement Combination
            if (left && !up && !down)
                player.Move("left");
            else if (right && !up && !down)
                player.Move("right");
            else if (up && !left && !right)
                player.Move("up");
            else if (down && !left && !right)
                player.Move("down");
            else if (up && left)
                player.Move("upleft");
            else if (up && right)
                player.Move("upright");
            else if (down && left)
                player.Move("downleft");
            else if (down && right)
                player.Move("downright");

            // Dash
            if (currentKeyboardState.IsKeyDown(Keys.Left) && currentKeyboardState.IsKeyDown(Keys.Space))
                player.Dash("dashLeft");
            if (currentKeyboardState.IsKeyDown(Keys.Right) && currentKeyboardState.IsKeyDown(Keys.Space))
                player.Dash("dashRight");
            if (currentKeyboardState.IsKeyDown(Keys.Up) && currentKeyboardState.IsKeyDown(Keys.Space))
                player.Dash("dashUp");
            if (currentKeyboardState.IsKeyDown(Keys.Down) && currentKeyboardState.IsKeyDown(Keys.Space))
                player.Dash("dashDown");

            // Stop movement
            if (!left && !right && !up && !down)
                player.Move("stop");
        }
コード例 #4
0
ファイル: Game1.cs プロジェクト: colincapurso/LevelIso
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            BuildingArtAndPolygons();

            Texture2D enemyTexture = Content.Load<Texture2D>("Textures/enemy");
            Texture2D tileTexture = Content.Load<Texture2D>("Textures/tile");
            Texture2D kid = Content.Load<Texture2D>("Textures/kid");
            Texture2D faceless = Content.Load<Texture2D>("Textures/faceless");

            player = new Player(kid, new Vector2(1024 / 2, 768 / 2));
            escortee = new Escortee(faceless, new Vector2(player.Position.X, player.Position.Y), "girl");
            escortee2 = new Escortee(faceless, new Vector2(player.Position.X, player.Position.Y), "boy");
            testTexture = kid;
            CurrentLevel = new Level(enemyTexture, tileTexture);
        }
コード例 #5
0
ファイル: Enemy.cs プロジェクト: colincapurso/LevelIso
 private void PlayerNearCheck(Player player)
 {
     // Check for distance with player
 }