protected override void DoMouseDownEvent(MouseEventArgs eventArgs)
        {
            base.DoMouseDownEvent(eventArgs);

            if (eventArgs.Button == MouseButton.mbLeft)
            {
                for (int i = 0; i <= 9; i++)
                {
                    ExtRect r = GetFileOpRect(i, MI_FILEDELETE);
                    if (r.Contains(eventArgs.X, eventArgs.Y) && fFiles[i].Exist)
                    {
                        GlobalVars.nwrGame.EraseGame(i);
                        fFiles[i].Exist = false;
                        UpdateList();
                        break;
                    }

                    r = GetFileOpRect(i, MI_FILENUM);
                    if (r.Contains(eventArgs.X, eventArgs.Y))
                    {
                        PrepareFile(i);
                        break;
                    }
                }
            }
        }
        private static SearchResult SearchMapLocation(int aX, int aY)
        {
            aX -= 8;
            aY -= 8;

            int num = GlobalVars.nwrGame.LayersCount;

            for (int idx = 0; idx < num; idx++)
            {
                NWLayer    layer      = GlobalVars.nwrGame.GetLayer(idx);
                LayerEntry layerEntry = layer.Entry;

                ExtRect rt = ExtRect.Create(layerEntry.MSX, layerEntry.MSY, layerEntry.MSX + (layerEntry.W << 5), layerEntry.MSY + layerEntry.H * 30);

                if (rt.Contains(aX, aY))
                {
                    int xx = (aX - layerEntry.MSX) / 32;
                    int yy = (aY - layerEntry.MSY) / 30;

                    NWField fld = layer.GetField(xx, yy);
                    if (fld != null)
                    {
                        SearchResult result = new SearchResult();
                        result.LID    = layerEntry.GUID;
                        result.FieldX = xx;
                        result.FieldY = yy;
                        return(result);
                    }
                }
            }

            return(null);
        }
Example #3
0
        private MouseAction GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent, out TreeChartPerson person)
        {
            var result = MouseAction.maNone;

            person = null;

            Point mpt = GetImageRelativeLocation(e.Location);
            int   aX  = mpt.X;
            int   aY  = mpt.Y;

            int num = fModel.Persons.Count;

            for (int i = 0; i < num; i++)
            {
                TreeChartPerson p      = fModel.Persons[i];
                ExtRect         persRt = p.Rect;

                if (persRt.Contains(aX, aY))
                {
                    person = p;

                    if (e.Buttons == MouseButtons.Primary && mouseEvent == MouseEvent.meDown)
                    {
                        result = MouseAction.maSelect;
                        break;
                    }
                    else if (e.Buttons == MouseButtons.Alternate && mouseEvent == MouseEvent.meUp)
                    {
                        result = MouseAction.maProperties;
                        break;
                    }
                    else if (mouseEvent == MouseEvent.meMove)
                    {
                        result = MouseAction.maHighlight;
                        break;
                    }
                }

                ExtRect expRt = TreeChartModel.GetExpanderRect(persRt);
                if ((e.Buttons == MouseButtons.Primary && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY))
                {
                    person = p;
                    result = MouseAction.maExpand;
                    break;
                }
            }

            if (result == MouseAction.maNone && person == null)
            {
                if (e.Buttons == MouseButtons.Alternate && mouseEvent == MouseEvent.meDown)
                {
                    result = MouseAction.maDrag;
                }
            }

            return(result);
        }
Example #4
0
        private MouseActionRet GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent)
        {
            MouseAction     action = MouseAction.maNone;
            TreeChartPerson person = null;

            ExtPoint offsets = fModel.GetOffsets();
            int      aX      = e.X - offsets.X;
            int      aY      = e.Y - offsets.Y;

            int num = fModel.Persons.Count;

            for (int i = 0; i < num; i++)
            {
                TreeChartPerson p      = fModel.Persons[i];
                ExtRect         persRt = p.Rect;

                if (persRt.Contains(aX, aY))
                {
                    person = p;

                    if (e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meDown)
                    {
                        action = MouseAction.maSelect;
                        break;
                    }
                    else if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meUp)
                    {
                        action = MouseAction.maProperties;
                        break;
                    }
                    else if (mouseEvent == MouseEvent.meMove)
                    {
                        action = MouseAction.maHighlight;
                        break;
                    }
                }

                ExtRect expRt = TreeChartModel.GetExpanderRect(persRt);
                if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY))
                {
                    person = p;
                    action = MouseAction.maExpand;
                    break;
                }
            }

            if (action == MouseAction.maNone && person == null)
            {
                if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meDown)
                {
                    action = MouseAction.maDrag;
                }
            }

            return(new MouseActionRet(action, person));
        }
Example #5
0
        public void Test_ExtRect()
        {
            ExtRect rt = ExtRect.Create(0, 0, 9, 9);

            Assert.AreEqual(0, rt.Left);
            Assert.AreEqual(0, rt.Top);
            Assert.AreEqual(9, rt.Right);
            Assert.AreEqual(9, rt.Bottom);
            Assert.AreEqual(10, rt.GetHeight());
            Assert.AreEqual(10, rt.GetWidth());

            rt = ExtRect.CreateBounds(0, 0, 10, 10);

            Assert.AreEqual(0, rt.Left);
            Assert.AreEqual(0, rt.Top);
            Assert.AreEqual(9, rt.Right);
            Assert.AreEqual(9, rt.Bottom);
            Assert.AreEqual(10, rt.GetHeight());
            Assert.AreEqual(10, rt.GetWidth());

            Assert.AreEqual("{X=0,Y=0,Width=10,Height=10}", rt.ToString());

            Assert.IsTrue(rt.Contains(5, 5));

            rt.Inflate(3, -2);
            Assert.AreEqual("{X=3,Y=-2,Width=4,Height=14}", rt.ToString());

            rt.Offset(2, 5);
            Assert.AreEqual("{X=5,Y=3,Width=4,Height=14}", rt.ToString());

            rt = rt.GetOffset(10, 10);
            Assert.AreEqual("{X=15,Y=13,Width=4,Height=14}", rt.ToString());

            Assert.IsTrue(rt.IntersectsWith(ExtRect.Create(16, 14, 20, 20)));

            rt = ExtRect.CreateEmpty();
            Assert.IsTrue(rt.IsEmpty());

            Assert.IsFalse(rt.Contains(5, 5));
        }
Example #6
0
 private void PrepareShopReturn()
 {
     try {
         NWCreature self      = (NWCreature)fSelf;
         Building   house     = self.FindHouse();
         ExtRect    houseArea = house.Area.Clone();
         if (!houseArea.Contains(self.PosX, self.PosY) && !(FindGoalByKind(GoalKind.gk_ShopReturn) is ShopReturnGoal))
         {
             houseArea.Inflate(-1, -1);
             ShopReturnGoal srGoal = (ShopReturnGoal)CreateGoal(GoalKind.gk_ShopReturn);
             srGoal.Position = RandomHelper.GetRandomPoint(houseArea);
         }
     } catch (Exception ex) {
         Logger.Write("TraderBrain.prepareReturn(): " + ex.Message);
     }
 }
Example #7
0
 protected virtual void DoSelectItem(object Sender, MouseButton Button, int aX, int aY, LBItem Item, ExtRect aRect)
 {
     if (Options.Contains(LBOptions.lboChecks))
     {
         int     d         = (aRect.Bottom - aRect.Top - CheckHeight) / 2;
         ExtRect checkRect = aRect;
         checkRect.Right = checkRect.Left + CheckWidth + (d << 1);
         if (checkRect.Contains(aX, aY) || Options.Contains(LBOptions.lboRadioChecks))
         {
             DoCheck(fSelIndex);
         }
     }
     if (OnItemSelect != null)
     {
         OnItemSelect.Invoke(this, Button, Item);
     }
 }
Example #8
0
 protected override void DoMouseDownEvent(MouseEventArgs eventArgs)
 {
     if (eventArgs.Button == MouseButton.mbLeft) {
         int t = ThumbPos;
         if (fKind == SBK_VERTICAL) {
             ExtRect rBeg = ExtRect.Create(0, 0, Width, ArrowHeight);
             ExtRect rEnd = ExtRect.Create(0, Height - ArrowHeight, Width, Height);
             ExtRect tt = ExtRect.Create(0, t, Width, t + ThumbHeight);
             if (rBeg.Contains(eventArgs.X, eventArgs.Y) && fPos > fMin) {
                 Pos = Pos - 1;
             } else {
                 if (rEnd.Contains(eventArgs.X, eventArgs.Y) && fPos < fMax) {
                     Pos = Pos + 1;
                 } else {
                     if (tt.Contains(eventArgs.X, eventArgs.Y)) {
                         fOldThumbY = eventArgs.Y;
                         fOldThumbPos = t;
                     }
                 }
             }
         } else {
             ExtRect rBeg = ExtRect.Create(0, 0, ArrowWidth, Height);
             ExtRect rEnd = ExtRect.Create(Width - ArrowWidth, 0, Width, Height);
             ExtRect tt = ExtRect.Create(t, 0, t + ThumbWidth, Height);
             if (rBeg.Contains(eventArgs.X, eventArgs.Y) && fPos > fMin) {
                 Pos = Pos - 1;
             } else {
                 if (rEnd.Contains(eventArgs.X, eventArgs.Y) && fPos < fMax) {
                     Pos = Pos + 1;
                 } else {
                     if (tt.Contains(eventArgs.X, eventArgs.Y)) {
                         fOldThumbX = eventArgs.X;
                         fOldThumbPos = t;
                     }
                 }
             }
         }
     }
     base.DoMouseDownEvent(eventArgs);
 }
        public override void Execute()
        {
            NWCreature self = (NWCreature)Self;

            ExtRect r = Area.Clone();

            r.Inflate(-1, -1);

            if (!r.Contains(self.PosX, self.PosY))
            {
                ExtPoint pos = new ExtPoint();
                pos.X = RandomHelper.GetBoundedRnd(r.Left, r.Right);
                pos.Y = RandomHelper.GetBoundedRnd(r.Top, r.Bottom);
                ExtPoint next = self.GetStep(pos);
                if (!next.IsEmpty)
                {
                    Brain.StepTo(next.X, next.Y);
                }
            }

            IsComplete = false;
            //refComplete.argValue = this.Area.Contains(self.getPosX(), self.getPosY());
        }
Example #10
0
        private bool CanBuild(ExtRect br, ExtRect area)
        {
            try {
                AbstractMap map = (AbstractMap)Owner;

                bool result = area.Contains(br);
                if (result)
                {
                    br.Inflate(+1, +1);

                    bool res = map.ForEachTile(br.Left, br.Top, br.Right, br.Bottom, CanBuildCheck);
                    if (!res)
                    {
                        return(false);
                    }

                    /*for (int y = br.Top; y <= br.Bottom; y++) {
                     *  for (int x = br.Left; x <= br.Right; x++) {
                     *      BaseTile tile = map.GetTile(x, y);
                     *      if (tile != null) {
                     *          int bg = tile.Background;
                     *          if (bg == PlaceID.pid_Floor || bg == PlaceID.pid_RnFloor) {
                     *              return false;
                     *          }
                     *      } else {
                     *          return false;
                     *      }
                     *  }
                     * }*/
                }

                return(true);
            } catch (Exception ex) {
                Logger.Write("Building.canBuild(): " + ex.Message);
                return(false);
            }
        }
Example #11
0
 public bool HasCoord(int x, int y)
 {
     return(LinkRect.Contains(x, y));
 }
Example #12
0
 public virtual bool Contains(int x, int y)
 {
     return(fDestRect.Contains(x, y));
 }
Example #13
0
        private MouseAction GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent, out TreeChartPerson person)
        {
            var result = MouseAction.None;

            person = null;

            ExtPoint offsets = fModel.GetOffsets();
            int      aX      = e.X - offsets.X;
            int      aY      = e.Y - offsets.Y;

            int num = fModel.Persons.Count;

            for (int i = 0; i < num; i++)
            {
                TreeChartPerson p      = fModel.Persons[i];
                ExtRect         persRt = p.Rect;

                if (persRt.Contains(aX, aY))
                {
                    person = p;

                    if (e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meDown)
                    {
                        result = MouseAction.Select;
                        break;
                    }
                    else if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meUp)
                    {
                        result = MouseAction.Properties;
                        break;
                    }
                    else if (mouseEvent == MouseEvent.meMove)
                    {
                        result = MouseAction.Highlight;
                        break;
                    }
                }

                ExtRect expRt = TreeChartModel.GetExpanderRect(persRt);
                if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY))
                {
                    person = p;
                    result = MouseAction.Expand;
                    break;
                }

                expRt = TreeChartModel.GetPersonExpandRect(persRt);
                if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY))
                {
                    person = p;
                    result = MouseAction.PersonExpand;
                    break;
                }

                ExtRect infoRt = TreeChartModel.GetInfoRect(persRt);
                if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && infoRt.Contains(aX, aY))
                {
                    person = p;
                    result = MouseAction.Info;
                    break;
                }
            }

            if (result == MouseAction.None && person == null)
            {
                if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meDown)
                {
                    result = MouseAction.Drag;
                }
            }

            return(result);
        }