Пример #1
0
        private void SwitchPrev()
        {
            BaseTile oldPrev = this.Prev;

            this.Prev        = DisconnectedTile;
            DisconnectedTile = oldPrev;
        }
Пример #2
0
        private void GameTimer(object sender, EventArgs e)
        {
            int             tPoint   = r.Next(1, 4);
            List <BaseTile> tileList = _board.GetTiles();

            for (int i = tileList.Count; i-- > 0;)
            {
                BaseTile currentTile = tileList[i];

                // Do action for specific tile
                currentTile.DoAction(this);

                // Check for collission
                if (currentTile.CheckIfCollission())
                {
                    GameOver();
                    break;
                }
            }

            if (CartStart())
            {
                Cart c = new Cart();
                _view.PlaceCart(_startY[tPoint - 1]);
                InsertCart(c, _startY[tPoint - 1]);
            }
        }
Пример #3
0
        private void SwitchNext()
        {
            BaseTile oldNext = this.Next;

            this.Next        = DisconnectedTile;
            DisconnectedTile = oldNext;
        }
Пример #4
0
        private bool CanMoveThroughSwitch(BaseTile tile)
        {
            if (tile.Next == null)
            {
                return(true);
            }

            return(tile.Equals(tile.Next.Prev));
        }
Пример #5
0
        private bool CheckCartCollision(BaseTile tile)
        {
            if (tile.Next == null)
            {
                return(true);
            }

            return(tile.Next.Cart == null);
        }
Пример #6
0
        public virtual BaseTile ChainTiles(BaseTile tileTo)
        {
            if (tileTo != null)
            {
                this.Next = tileTo;

                if (tileTo.Prev == null)
                {
                    tileTo.Prev = this;
                }
                else
                {
                    tileTo.DisconnectedTile = this;
                }
            }

            return(tileTo);
        }
Пример #7
0
        public void addVisualObject(BaseTile tile)
        {
            Image img = new Image();

            img.Visibility = Visibility.Visible;
            string type = tile.GetType().ToString().Split('.').Last();

            img.Source = new BitmapImage(new Uri(@"Assets/Images/" + type + tile.Direction + ".png", UriKind.Relative));
            if (type == "SwitchTile")
            {
                img.MouseEnter += Img_MouseEnter;
                img.MouseDown  += Img_MouseDown;
            }
            img.Width  = 50;
            img.Height = 50;
            tPart.Children.Add(img);
            Grid.SetColumn(img, (int)tile.Pos.X);
            Grid.SetRow(img, 7 - (int)tile.Pos.Y);
        }
Пример #8
0
        public override BaseTile ChainTiles(BaseTile tileTo)
        {
            if (tileTo != null)
            {
                tileTo.Prev = this;

                if (this.Next == null)
                {
                    this.Next = tileTo;
                    this.Type = TileType.Backward;
                }
                else
                {
                    this.DisconnectedTile = tileTo;
                    this.Type             = TileType.Forward;
                }
            }

            return(tileTo);
        }
Пример #9
0
 private bool CheckIfRestTile(BaseTile tile)
 {
     return(tile.GetType() == typeof(RestTile));
 }