private void on_mouse_enter(object sender, MouseEventArgs e) { if (!Enabled || Selected) { return; } UserControlAnimation.FadeInElement(glowPath, true); //added sound effect for the button VolumeManager.play(@"Resources/Audio/UserControlButtonHover.wav"); }
public GameBoardUserControl(Board board, Player playerOne, Player playerTwo, PieceType firstType) { InitializeComponent(); //this gets the board configuration and shows the proper mask on the gameboard setGameboardConfig(BoardSetup.FromBoard(board)); HumanPlayerName.Content = playerOne.GetName(); RobotPlayerName.Content = playerTwo.GetName(); engine = new GameEngine(board, playerOne, playerTwo, firstType); inactiveImages = new[, ] { { p00, p01, p02, p03, p04, p05, p06, p07 }, { p10, p11, p12, p13, p14, p15, p16, p17 }, { p20, p21, p22, p23, p24, p25, p26, p27 }, { p30, p31, p32, p33, p34, p35, p36, p37 }, { p40, p41, p42, p43, p44, p45, p46, p47 }, { p50, p51, p52, p53, p54, p55, p56, p57 }, { p60, p61, p62, p63, p64, p65, p66, p67 }, { p70, p71, p72, p73, p74, p75, p76, p77 } }; activeImages = new Image[8, 8]; humanTurn = false; humanMove = Move.None; validMoves = new Move[0]; playedMoves = new List <Move>(); PlayerOne = playerOne; PlayerTwo = playerTwo; engine.OnPlayerChanged += on_player_changed; engine.OnPlayerMove += on_player_moved; engine.OnGameEnd += on_game_end; setUpPlayerCustom(playerOne); setUpPlayerCustom(playerTwo); difficultyIsHard = !(playerTwo is EasyAiPlayer); engine.start(); VolumeManager.playBattleTheme(); }
//credit goes to infiniteLoop, the creators of Locomotion private Sprite addPod(PieceType playerMoved, Image flyToImage, Move move) { string podType; Storyboard dropPod; string sound; //determines the relative size of the sprite depending on row position int wid; int hit; if (move.Row > 6) { wid = 125; hit = 125; } else if (move.Row > 4) { wid = 115; hit = 115; } else if (move.Row > 2) { wid = 105; hit = 105; } else { wid = 95; hit = 95; } if (playerMoved == PieceType.Red) { podType = "dropPodHuman"; dropPod = FindResource("DropHumanPod") as Storyboard; sound = "Resources/Audio/HumanPodDown.wav"; } else { if (difficultyIsHard) { podType = "HardRobotSprite"; dropPod = FindResource("DropRobotPod") as Storyboard; sound = "Resources/Audio/HardRobotSound.wav"; } else { podType = "EasyRobotSprite"; dropPod = FindResource("DropRobotPod") as Storyboard; sound = "Resources/Audio/EasyRobotSound.wav"; } } // Sprite resource name and width Sprite podImage = new Sprite(podType, 311) { Width = wid, Height = hit, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Stretch = Stretch.Fill, Name = podType }; //attempt to resolve the location of the piece Vector offset = VisualTreeHelper.GetOffset(flyToImage); double left = offset.X; //getPegLeft(row, col) - 6 + (col - row); double top = offset.Y - 20; //getPegTop(row, col) + 109 + (row + col); podImage.Margin = new Thickness(left, top, 0, 0); //podImage.Visibility = Visibility.Hidden; PlayableGameBoardGridEventListener.Children.Add(podImage); Panel.SetZIndex(podImage, 3); if (podType.Equals("dropPodHuman")) { podImage.BeginStoryboard(dropPod); MoveTo(podImage, offset.X, offset.Y); } VolumeManager.play(sound); return(podImage); }