예제 #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));
 }