public AI( Grid _grid, Grid _gridTopBar, Player _player, int difficulty) { aiTower = new Tower(2000, 50, 250, 1, false, _grid, _gridTopBar); player = _player; grid = _grid; switch (difficulty) { case 1: _op = 0.6; _chanceToGenSoldier = 120000; _chanceToUpgradeTower = 100000; _towerLVlimit = 1; _soldierLimit = 10; _canCounterAttack = false; break; case 2: _op = 1; _chanceToGenSoldier = 85000; _chanceToUpgradeTower = 50000; _towerLVlimit = 3; _soldierLimit = 15; _canCounterAttack = true; break; case 3: _op = 1.5; _chanceToGenSoldier = 60000; _chanceToUpgradeTower = 10000; _towerLVlimit = 5; _soldierLimit = 15; _canCounterAttack = true; break; case 4: _op = 3; _chanceToGenSoldier = 50000; _chanceToUpgradeTower = 1000; _towerLVlimit = 10; _soldierLimit = 20; _canCounterAttack = true; break; default: MessageBox.Show("AI Difficulty Error"); break; } }
private void Reset(int difficulty) { #region 清除遊戲畫面、上方面板與下方面板的LabelCD grid1.Children.Clear(); gridTopBar.Children.Clear(); foreach (Label lb in lbCD) gridControlBar.Children.Remove(lb); lbCD.Clear(); #endregion //Resetting dockpanel, 顯示 BUFF #region BUFF Panel resetting dock1.Width = 105; dock1.Height = 35; dock1.VerticalAlignment = System.Windows.VerticalAlignment.Top; dock1.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; dock1.FlowDirection = System.Windows.FlowDirection.RightToLeft; dock1.Margin = new Thickness(800,17,0,0); //dock1.Background = Brushes.LightGray; grid1.Children.Add(dock1); #endregion //Resetting all btn #region 士兵解鎖與購買按鈕 btnUnlock1.Visibility = System.Windows.Visibility.Visible; btnUnlock2.Visibility = System.Windows.Visibility.Visible; btnUnlock3.Visibility = System.Windows.Visibility.Visible; btnUnlock4.Visibility = System.Windows.Visibility.Visible; btnUnlock5.Visibility = System.Windows.Visibility.Visible; btnUnlock6.Visibility = System.Windows.Visibility.Visible; btnSoldier2.IsEnabled = false; btnSoldier3.IsEnabled = false; btnSoldier4.IsEnabled = false; btnSoldier5.IsEnabled = false; btnSoldier6.IsEnabled = false; btnSoldier7.IsEnabled = false; btnUnlock1.IsEnabled = true; btnUnlock2.IsEnabled = true; btnUnlock3.IsEnabled = true; btnUnlock4.IsEnabled = true; btnUnlock5.IsEnabled = true; btnUnlock6.IsEnabled = true; #endregion #region 技能按鈕與技能冷卻時間倒數 skill1_isEnable = false; skill2_isEnable = false; skill3_isEnable = false; skillCounter1 = 0; skillCounter2 = 0; skillCounter3 = 0; #endregion #region 遊戲進行時間計時面板 grid1.Children.Add(totalTimeDisplay); totalTimeDisplay.Margin = new Thickness(0, 30, 0, 0); totalTimeDisplay.VerticalAlignment = System.Windows.VerticalAlignment.Top; totalTimeDisplay.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; totalTimeDisplay.Content = "00:00"; #endregion isStarted = true; player = new Player(grid1, gridTopBar); ai = new AI(grid1, gridTopBar, player, difficulty); #region 下方面板按鈕 Content btnSpeedUp.Content = ">>"; #region 升級塔按鈕 btnUpgradeTower.Content = "升級塔\n$" + player.UPGRADEPRICE.ToString(); ToolTip tp = new System.Windows.Controls.ToolTip(); tp = new System.Windows.Controls.ToolTip(); tp.Background = Brushes.LightSteelBlue; tp.BorderBrush = Brushes.Black; tp.BorderThickness = new Thickness(2); //tp.Content = btnUpgradeTower.ToolTip.ToString(); tp.Content = "下一級:\n血 量:" + (player.myTower.HP + 100).ToString() + '\n' + "射 程:" + (player.myTower.RANGE + 10).ToString() + '\n' + "攻擊力:" + (player.myTower.ATK + 10).ToString(); btnUpgradeTower.ToolTip = tp; #endregion foreach (Button btn in gridControlBar.Children) if (btn.IsEnabled == false) btn.Opacity = 0.5; #region 解鎖按鈕內容 btnUnlock1.Content = "$" + unlock_s2_price.ToString(); btnUnlock2.Content = "$" + unlock_s3_price.ToString(); btnUnlock3.Content = "$" + unlock_s4_price.ToString(); btnUnlock4.Content = "$" + unlock_s5_price.ToString(); btnUnlock5.Content = "$" + unlock_s6_price.ToString(); btnUnlock6.Content = "$" + unlock_s7_price.ToString(); #endregion #endregion #region 設定計時器 _timeInterval = 25; timeCounter = 0; time = 0; timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(_timeInterval); timer.Tick += timer_Tick; timer.Start(); #endregion }
private void InitializeToolTip() { //動態設定下方面板中部分元件的 Tooltip player = new Player(grid1, gridTopBar); foreach (Button btn in gridControlBar.Children) { ToolTip tp = new System.Windows.Controls.ToolTip(); tp.Background = Brushes.LightSteelBlue; tp.BorderBrush = Brushes.Black; tp.BorderThickness = new Thickness(2); tp.Content = btn.ToolTip; //if (btn.Name == "btnUpgradeTower") // tp.Content = "下一級:\n血 量:" + (player.myTower.HP + 100).ToString() + '\n' + "射 程:" + (player.myTower.RANGE + 10).ToString() + '\n' + "攻擊力:" + (player.myTower.ATK + 10).ToString(); if (btn.Name.ToString().Contains("Unlock")) tp.Content = "解鎖兵種"; btn.ToolTip = tp; } }