Beispiel #1
0
 /// <summary>
 /// Trigger move command when move button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void handleMoveButtonClick(object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled && !e.Handled)
     {
         e.Handled = true;
     }
 }
        internal void MouseUp(XnaMouseEventArgs e)
        {
            if (!e.Handled)
            {
                if (OnMouseUp != null)
                {
                    OnMouseUp(this, e);
                }
                if (e.Target != this)
                {
                    XnaUIComponent nextTarget = e.Target;
                    while (nextTarget.Parent != this)
                    {
                        nextTarget = nextTarget.Parent;
                    }
                    Point currentPoint = e.ClickLocation;
                    Point offsetPoint  = new Point(currentPoint.X, currentPoint.Y);
                    offsetPoint.X  -= ScrollX;
                    offsetPoint.X  -= nextTarget.drawBox.X;
                    offsetPoint.Y  -= ScrollY;
                    offsetPoint.Y  -= nextTarget.drawBox.Y;
                    e.ClickLocation = offsetPoint;
                    nextTarget.MouseUp(e);

                    // Repair event
                    e.ClickLocation = currentPoint;
                }
                e.Bubbled = true;
                if (!e.Handled && (OnMouseUp != null))
                {
                    OnMouseUp(this, e);
                }
            }
        }
 /// <summary>
 /// Triggered if this unit is being attacked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void getAttacked(Object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled && !e.Handled && e.ButtonPressed == MouseButton.Right)
     {
         ((XnaUITestGame)Game).Controller.TellSelectedUnitsToAttack(unit);
         e.Handled = true;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Trigger action when stop button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void handleStopButtonClick(object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled && !e.Handled)
     {
         e.Handled = true;
         ((XnaUITestGame)Game).Controller.OnSelectUnitToStop();
     }
 }
Beispiel #5
0
 /// <summary>
 /// Trigger move command when move button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void handleMoveButtonClick(object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled && !e.Handled)
     {
         //System.Console.Out.WriteLine("Move button is clicked!");
         e.Handled = true;
     }
 }
Beispiel #6
0
 /// <summary>
 /// Trigger function in the event of selected unit is moving
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void moveSelectedUnits(Object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled && !e.Handled && e.ButtonPressed == MouseButton.Right)
     {
         PointF gamePoint = new PointF((float)(e.ClickLocation.X + ScrollX) / (float)cellDimension, (float)(e.ClickLocation.Y + ScrollY) / (float)cellDimension);
         ((XnaUITestGame)Game).Controller.MoveSelectedUnitsToPoint(gamePoint);
         e.Handled = true;
     }
 }
Beispiel #7
0
 private void handleUnitProduceButtonClick(object sender, XnaMouseEventArgs e)
 {
     if (Math.Abs(e.time) - lastClick > MSECONDS_PER_CLICK)
     {
         ((XnaUITestGame)Game).Controller.TellSelectedBuildingToBuild();
         e.Handled = true;
         lastClick = e.time;
     }
 }
Beispiel #8
0
 // Harvest Button
 private void handleHarvestButtonClick(object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled && !e.Handled)
     {
         e.Handled = true;
         // TODO: Change this to reflect the mouseclick location where the unit needs to move and harvest
         ((XnaUITestGame)Game).Controller.OnSelectedUnitsToHarvest();
     }
 }
Beispiel #9
0
 /// <summary>
 /// Trigger action when stop button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void handleStopButtonClick(object sender, XnaMouseEventArgs e)
 {
     //System.Console.Out.WriteLine("STOP BUTTON IS CLICKED!");
     if (e.Bubbled && !e.Handled)
     {
         e.Handled = true;
         ((XnaUITestGame)Game).Controller.OnSelectUnitToStop();
     }
 }
 private void selectBuilding(Object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled)
     {
         List <ModelComponent> entities = new List <ModelComponent>();
         entities.Add(building);
         ((XnaUITestGame)Game).Controller.SelectEntities(entities);
         e.Handled = true;
     }
 }
Beispiel #11
0
 /// <summary>
 /// Open the build panel when build button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void handleBuildButtonClick(Object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled && !e.Handled)
     {
         mainPanel.Visible   = false;
         workerPanel.Visible = false;
         buildPanel.Visible  = true;
         e.Handled           = true;
     }
 }
Beispiel #12
0
 /// <summary>
 /// A building is selected to build, sets buttons back to workerpanel
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void handleBuildingButtonClick(Object sender, XnaMouseEventArgs e)
 {
     if (e.Bubbled && !e.Handled)
     {
         string buildingType = uiToBuildingType[sender] as string;
         ((XnaUITestGame)Game).Controller.OnSelectBuildingToBuild(buildingType);
         workerPanel.Visible = true;
         buildPanel.Visible  = false;
         e.Handled           = true;
     }
 }
 private void placeBuilding(Object sender, XnaMouseEventArgs e)
 {
     if (building.Tint.Equals(new Color(0, 125, 0, 0)))
     {
         mapView.RemoveChild(building);
         building.OnClick -= placeBuilding;
         Point drawPoint = new Point();
         drawPoint.X = building.DrawBox.X / MapView.CellDimension;
         drawPoint.Y = building.DrawBox.Y / MapView.CellDimension;
         ((XnaUITestGame)mapView.Game).Controller.TellSelectedUnitsToBuildAt(buildingType, drawPoint);
         changeLeftClickStrategy();
     }
 }
Beispiel #14
0
 /// <summary>
 /// Event triggered function when the button being clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="agrs"></param>
 public void handleClick(object sender, XnaMouseEventArgs agrs)
 {
     ((XnaUITestGame)Game).Controller.TellSelectedBuildingToBuild();
 }