Esempio n. 1
0
        private void DoUpdateGridLines(UIElementCollection target, double[] source, Orientation orientation)
        {
            if (source == null)
            {
                return;
            }

            var newCt = source.Length;
            var oldCt = target.Count;

            if (oldCt > newCt)
            {
                target.RemoveRange(newCt, oldCt - newCt);
            }

            for (int i = 0; i < source.Length; i++)
            {
                var newValue = source[i];
                if (i < oldCt)
                {
                    ((Line)target[i]).DataContext = newValue;
                }
                else
                {
                    var line = new Line();
                    line.DataContext = newValue;
                    SetGridLineBindings(line, orientation);
                    target.Add(line);
                }
            }
        }
Esempio n. 2
0
 void RemoveOrders()
 {
     if (orderElements.Count >= 2)
     {
         orderElements.RemoveRange(2, orderElements.Count - 2);
         positionPanels.RemoveRange(1, positionPanels.Count - 1);
     }
 }
Esempio n. 3
0
        public void Dispose()
        {
            if (count == -1)
            {
                return;
            }

            if (count < collection.Count)
            {
                collection.RemoveRange(count, collection.Count - count);
            }

            count = -1;
        }
Esempio n. 4
0
        /// <summary>
        /// Moves a character from a position up, down, left, or right depending on whether
        /// it is able to move to that position
        /// </summary>
        /// <param name="characterNo">The character to move</param>
        /// <param name="dir">The direction to move the character in</param>
        public void MoveCharacter(int characterNo, Direction dir)
        {
            //Cleanup canvas if using a debugging mode
            if (_gridManager.DebuggingCanvasLeftovers > 0)
            {
                UIElementCollection canvasItems = _gridManager.GameCanvas.Children;
                canvasItems.RemoveRange(canvasItems.Count - _gridManager.DebuggingCanvasLeftovers, _gridManager.DebuggingCanvasLeftovers);
                _gridManager.DebuggingCanvasLeftovers = 0;
            }

            if (GameGridManager.Instance.Characters is null)
            {
                //Game is over so return
                return;
            }

            GridItem characterView = GetCharacterView(characterNo);

            //If character won't collide with the wall
            if (!Collisions.WallCollisionDetection(ref characterView, dir))
            {
                MoveCharacterInternal(ref characterView, dir);
                if (GameGridManager.Instance.Characters is null)
                {
                    //Game is over so return
                    return;
                }
            }

            if (Collisions.EnemyCollisionDetection() && !CommunicationManager.Instance.IsNetworked)
            {
                //Goto the lose page
                TopFrameManager.Instance.OverlayFrame.Navigate(new LosePage(this, protagonistType, enemyType, isNetworked: false));
                if (GameGridManager.Instance.Characters is null)
                {
                    //Game is over so return
                    return;
                }
            }
        }
Esempio n. 5
0
 public static void RemoveRange(this UIElementCollection collection, Range range)
 {
     var(offset, len) = range.GetOffsetAndLength(collection.Count);
     collection.RemoveRange(offset, len);
 }