예제 #1
0
 public EntityWeapon(Vector2 position)
 {
     Weapon            = new WeaponDefinition();
     PositionComponent = new PositionComponent(position);
     RenderComponent   = new RenderComponent(Game1.Weapon, new Vector2((int)Weapon.Type, 0), Game1.Shadow, 57, Weapon.FormattedColor, false);
     HoverComponent    = new HoverComponent(this);
     Console.WriteLine("Generated " + Weapon.FormattedName);
 }
예제 #2
0
        public void Stun()
        {
            if (IsAnimating)
            {
                return;
            }

            if (null != HoverComponent)
            {
                HoverComponent.StopHovering();
            }

            if (null != ClimbingComponent)
            {
                ClimbingComponent.StopClimbing();
            }

            Player.NetworkPlayer.Stun(PlayerControllerData.FallStunTimeSeconds);
        }
예제 #3
0
파일: Game1.cs 프로젝트: CalmBit/Robotica
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            var keyboard = Keyboard.GetState();

            // TODO: Add your update logic here
            switch (gameState)
            {
            case GameState.PLAYING:
            {
                //Ugly little hack to keep animations uniform
                HoverComponent.UpdateAnimation();
                Player.Update(gameTime);
                foreach (var e in Entities)
                {
                    e.Update(gameTime);
                }
                break;
            }

            case GameState.MENU:
            {
                if (keyboard.GetPressedKeys().Length > 0)
                {
                    if (keyboard.IsKeyDown(Keys.Escape))
                    {
                        return;
                    }
                    gameState = GameState.SELECTION;
                    SoundEffectsBank.PlayCue("Selection");
                }
                break;
            }

            case GameState.CHOOSING_PLAYER:
            {
                if (keyboard.IsKeyDown(Keys.Left) && !DebounceList[Keys.Left])
                {
                    DebounceList[Keys.Left] = true;
                    PlayerSprite            = (PlayerSprite + 1 >= Characters.Keys.Count ? 0 : PlayerSprite + 1);
                    SoundEffectsBank.PlayCue("Selection");
                }
                if (keyboard.IsKeyDown(Keys.Right) && !DebounceList[Keys.Right])
                {
                    DebounceList[Keys.Right] = true;
                    PlayerSprite             = (PlayerSprite - 1 < 0 ? Characters.Keys.Count - 1 : PlayerSprite - 1);
                    SoundEffectsBank.PlayCue("Selection");
                }
                if (keyboard.IsKeyDown(Keys.Enter) && !DebounceList[Keys.Enter])
                {
                    DebounceList[Keys.Enter] = true;
                    gameState = GameState.PLAYING;
                    Player    = new EntityPlayer(PlayerSprites, PlayerSprite, Shadow, 57);
                }
                if (keyboard.IsKeyDown(Keys.Escape) && !DebounceList[Keys.Escape])
                {
                    DebounceList[Keys.Escape] = true;
                    gameState = GameState.SELECTION;
                    SoundEffectsBank.PlayCue("AntiSelection");
                }
                if (DebounceList[Keys.Left] && keyboard.IsKeyUp(Keys.Left))
                {
                    DebounceList[Keys.Left] = false;
                }
                if (DebounceList[Keys.Right] && keyboard.IsKeyUp(Keys.Right))
                {
                    DebounceList[Keys.Right] = false;
                }
                if (DebounceList[Keys.Enter] && keyboard.IsKeyUp(Keys.Enter))
                {
                    DebounceList[Keys.Enter] = false;
                }
                if (DebounceList[Keys.Escape] && keyboard.IsKeyUp(Keys.Escape))
                {
                    DebounceList[Keys.Escape] = false;
                }
                break;
            }

            case GameState.SELECTION:
            {
                if (keyboard.IsKeyDown(Keys.Up) && !DebounceList[Keys.Up])
                {
                    DebounceList[Keys.Up] = true;
                    Selection             = (Selection - 1 < 0 ? Options.Count - 1 : Selection - 1);
                    SoundEffectsBank.PlayCue("Selection");
                }
                if (keyboard.IsKeyDown(Keys.Down) && !DebounceList[Keys.Down])
                {
                    DebounceList[Keys.Down] = true;
                    Selection = (Selection + 1 >= Options.Count ? 0 : Selection + 1);
                    SoundEffectsBank.PlayCue("Selection");
                }
                if (keyboard.IsKeyDown(Keys.Enter) && !DebounceList[Keys.Enter])
                {
                    DebounceList[Keys.Enter] = true;
                    switch (Selection)
                    {
                    case 0:
                    {
                        currentColor    = Color.White;
                        backgroundColor = Color.Black;
                        gameState       = GameState.CHOOSING_PLAYER;
                        break;
                    }

                    case 1:
                    {
                        gameState = GameState.OPTIONS;
                        break;
                    }

                    case 2:
                    {
                        Exit();
                        break;
                    }
                    }
                }
                if (DebounceList[Keys.Up] && keyboard.IsKeyUp(Keys.Up))
                {
                    DebounceList[Keys.Up] = false;
                }
                if (DebounceList[Keys.Down] && keyboard.IsKeyUp(Keys.Down))
                {
                    DebounceList[Keys.Down] = false;
                }
                if (DebounceList[Keys.Enter] && keyboard.IsKeyUp(Keys.Enter))
                {
                    DebounceList[Keys.Enter] = false;
                }
                break;
            }
            }

            base.Update(gameTime);
        }