コード例 #1
0
        public void Update(Point mousePosition, Point mouseOffset, GameTime gameTime, MouseState mouseState)
        {
            if (mouseState.LeftButton != ButtonState.Pressed || Game1.AlreadyPressing)
            {
                return;
            }

            if (WaitingForAnimation)
            {
                (SelectedAction as Explosion).Update(gameTime);
                return;
            }

            LogicalPosition logicalPosition = LogicalPosition.GetLogicalPosition(mousePosition + mouseOffset);

            foreach (Action action in Actions)
            {
                action.Update(mousePosition, mouseOffset);
                if (action.Selected)
                {
                    return;
                }
            }

            //Kolla ifall någon av actionsen utlöstes, ActionPerformed sätts till true via event-handlern HandleActionPerformed
            if (ActionPerformed)
            {
                ActionPerformed = false;
                return;
            }

            if (Grids.TryGetValue(logicalPosition, out Grid grid) && grid.Mark == null)
            {
                if (TrappedGrids.TryGetValue(logicalPosition, out Player player) && player != null && player != this)
                {
                    TrappedGrids.Remove(logicalPosition);
                    if (Waiting)
                    {
                        Waiting = false;
                    }
                    else
                    {
                        PlayerTurnEnd(this);
                    }
                    return;
                }

                grid.Mark = new Mark(logicalPosition, Mark);
                MarkPlaced(this, logicalPosition);
                //Avsluta ens tur
                if (Waiting)
                {
                    Waiting = false;
                }
                else
                {
                    PlayerTurnEnd(this);
                }
            }
        }
コード例 #2
0
        private bool MarkMatch(int x, int y, MarkType mark)
        {
            LogicalPosition positionToCheck = new LogicalPosition(x, y);

            if (!Grids.TryGetValue(positionToCheck, out Grid grid) || grid.Mark?.Type != mark)
            {
                return(false);
            }
            return(true);
        }
コード例 #3
0
ファイル: LayoutObject.cs プロジェクト: NerdDev/Hackmobile
 public override bool TryGetValue(int x, int y, out GenSpace val)
 {
     return(Grids.TryGetValue(x - ShiftP.x, y - ShiftP.y, out val));
 }