Esempio n. 1
0
        public object Clone()
        {
            Player player = new Player();
            player.Color = this.Color;
            player.Name = this.Name;
            player.Race = this.Race;
            player.Score = this.Score;

            return player;
        }
 /// <summary> Creates and starts a proper ColorAnimation when the color changes for Player 2. </summary>
 /// <param name="player"> The player.  </param>
 private void Player2ColorChanged(Player player)
 {
     var converter = new PlayerColorConverter();
     var color = (Color)converter.Convert(player.Color, typeof(Color), null, null);
     var anim = new ColorAnimation(color, new TimeSpan(0, 0, 0, 0, 500));
     this.player2Color.BeginAnimation(GradientStop.ColorProperty, anim);
 }
        /// <summary>
        /// Applies the hotkey for the attached key to the attached player.
        /// </summary>
        /// <param name="key">
        /// The key which was pressed in the hotkey sequence.  
        /// </param>
        /// <param name="player">
        /// The player to apply the change to.  
        /// </param>
        /// <returns>
        /// Whether the key pressed was a valid hotkey, and was applied to the player.  
        /// </returns>
        private static bool ApplyHotkey(Key key, Player player)
        {
            var handled = true;

            switch (key)
            {
                case Key.P:
                    player.Race = Race.Protoss;
                    break;
                case Key.T:
                    player.Race = Race.Terran;
                    break;
                case Key.Z:
                    player.Race = Race.Zerg;
                    break;
                case Key.R:
                    player.Race = Race.Random;
                    break;
                case Key.D1:
                case Key.NumPad1:
                    player.Color = PlayerColor.Red;
                    break;
                case Key.D2:
                case Key.NumPad2:
                    player.Color = PlayerColor.Blue;
                    break;
                case Key.D3:
                case Key.NumPad3:
                    player.Color = PlayerColor.Teal;
                    break;
                case Key.D4:
                case Key.NumPad4:
                    player.Color = PlayerColor.Purple;
                    break;
                case Key.D5:
                case Key.NumPad5:
                    player.Color = PlayerColor.Yellow;
                    break;
                case Key.D6:
                case Key.NumPad6:
                    player.Color = PlayerColor.Orange;
                    break;
                case Key.D7:
                case Key.NumPad7:
                    player.Color = PlayerColor.Green;
                    break;
                case Key.D8:
                case Key.NumPad8:
                    player.Color = PlayerColor.LightPink;
                    break;
                case Key.OemPlus:
                case Key.Add:
                    player.Score++;
                    break;
                case Key.OemMinus:
                case Key.Subtract:
                    player.Score--;
                    break;
                default:
                    handled = false;
                    break;
            }

            return handled;
        }
        /// <summary>
        /// Applies the hotkey for the attached key to the attached player.
        /// </summary>
        /// <param name="key">
        /// The key which was pressed in the hotkey sequence.  
        /// </param>
        /// <param name="player">
        /// The player to apply the change to.  
        /// </param>
        /// <returns>
        /// Whether the key pressed was a valid hotkey, and was applied to the player.  
        /// </returns>
        private static bool ApplyHotkey(Key key, Player player)
        {
            var handled = true;

            switch (key)
            {
                case Key.OemPlus:
                case Key.Add:
                    player.Score++;
                    break;
                case Key.OemMinus:
                case Key.Subtract:
                    player.Score--;
                    break;
                default:
                    handled = false;
                    break;
            }

            return handled;
        }
Esempio n. 5
0
        public object Clone()
        {
            var player = new Player { Name = this.Name, Score = this.Score, TeamLogo = this.TeamLogo };

            return player;
        }