Пример #1
0
 private void UnCheckOtherPurchaseButton(TDTowerButton other)
 {
     if (other != this &&
         other.Checked)
     {
         other.Checked = false;
     }
 }
Пример #2
0
        private void SetTowerButtonState(TDTowerButton b)
        {
            if (b.Tower != null)
            {
                bool state = TDSession.thisSession.gold >= b.Tower.Cost;

                if (!state && b.Checked)
                {
                    SetControlChecked(b, false);
                    if (TDForm.ThisForm._CursorState == CursorStates.PlaceTower)
                    {
                        TDForm.ThisForm._CursorState = CursorStates.Normal;
                        TDForm.ThisForm.Focus();
                    }
                }

                SetControlState(b, state);
            }
            else
            {
                SetControlChecked(b, false);
                SetControlState(b, false);
            }
        }
Пример #3
0
        /// <summary>
        /// The main panel's action event handler.
        /// </summary>
        private void panelAction_Click(object sender, EventArgs e)
        {
            MouseEventArgs m            = (e as MouseEventArgs);
            bool           shiftPressed = Control.ModifierKeys.HasFlag(Keys.Shift);

            // placing a tower
            if (this._CursorState == CursorStates.PlaceTower)
            {
                TDTowerButton b = GetSelectedTowerButton();
                if (b == null)
                {
                    return;
                }

                TDTower newTower = b.Tower;
                // if on path - no
                newTower.Location = new TDLocation(m.X, m.Y);

                if (TDSession.thisSession.CurrentLevel.CanPlaceTower(newTower))
                {
                    // actually place the tower
                    placeTower((e as MouseEventArgs).Location);

                    // and after we place the tower, unselect the tower if we did not have shift down (or right clicked)
                    if (m.Button == System.Windows.Forms.MouseButtons.Left &&
                        !shiftPressed)
                    {
                        this.CursorState = CursorStates.Normal;
                        GetSelectedTowerButton().Checked = false;
                    }
                }
            }
            // selecting something
            else
            {
                if (TDSession.thisSession == null)
                {
                    return;
                }

                // attempt to highlight tower selected
                this.CurrentlySelectedEntity = GetTowerAtPoint((e as MouseEventArgs).Location);
                if (CurrentlySelectedEntity != null)
                {
                    UnhighlightAll();
                    CurrentlySelectedEntity.IsHighlighted = true;
                    LoadDetailsOfTower(CurrentlySelectedEntity as TDEntity);
                    if (CurrentlySelectedEntity is TDTower)
                    {
                        btnDelete.Enabled = true;
                        ResetPurchaseButtons();
                        ResetAIButtons();
                    }
                    else
                    {
                        btnDelete.Enabled  = false;
                        btn_Repair.Enabled = false;
                        btnUpgrade.Enabled = false;
                    }
                }
                else // nothing was clicked on
                {
                    UnhighlightAll();
                    ClearDetails();
                    ResetPurchaseButtons();
                    ResetAIButtons();
                }
            }
        }