예제 #1
0
        public void Explode(Map m, Game g)
        {
            var toBeDestroyed = new List<Entity>();
            var thecompletelist = m.GetCompleteList();
            m.ListOfBomb.Remove(this);
            var l = thecompletelist.Where(c => c.X == this.X || c.Y == this.Y);
            var theRightDestroyed = this.GiveTheFirst(l, Direction.Right);
            if (theRightDestroyed != null && !g.ToDelete.Contains(theRightDestroyed))
            {
                toBeDestroyed.Add(theRightDestroyed);
            }
            var theLeftDestroyed = this.GiveTheFirst(l, Direction.Left);
            if (theLeftDestroyed != null && !g.ToDelete.Contains(theLeftDestroyed))
            {
                toBeDestroyed.Add(theLeftDestroyed);
            }
            var theUpDestroyed = this.GiveTheFirst(l, Direction.Up);
            if (theUpDestroyed != null && !g.ToDelete.Contains(theUpDestroyed))
            {
                toBeDestroyed.Add(theUpDestroyed);
            }
            var theDownDestroyed = this.GiveTheFirst(l, Direction.Down);
            if (theDownDestroyed != null && !g.ToDelete.Contains(theDownDestroyed))
            {
                toBeDestroyed.Add(theDownDestroyed);
            }

            foreach (var e in toBeDestroyed)
            {
                if (e is Bomb)
                {
                    var theBomb = m.ListOfBomb.First(c => c.X == e.X && c.Y == e.Y);
                    theBomb.Explode(m, g);
                }
            }
            g.ToDelete.AddRange(toBeDestroyed);
            if (!g.ToDelete.Contains(this))
            {
                g.ToDelete.Add(this);
            }
            Owner.BombExploded(this);
        }
예제 #2
0
파일: Bomb.cs 프로젝트: SsSanzo/BombEISTIv2
        public bool Teleport(Map m)
        {
            if(itération < 3)
            {
                var list = m.GetCompleteList().ToList();
                var l = new List<HardBlock>();
                for (var i = 0; i < Game.Length; i++)
                {
                    for (var j = 0; j < Game.Length; j++)
                    {
                        if (list.FirstOrDefault(c => c != null && c.X == i && c.Y == j) == null)
                        {
                            Texture._.Mw.Dispatcher.Invoke(DispatcherPriority.Normal,
                                                       (Action)(() => l.Add(new HardBlock(i, j))));
                        }
                    }
                }

                if (l == null || l.Count() == 0) return true;
                var rand = new Random();
                var n = rand.Next(l.Count);
                this.X = l.ElementAt(n).X;
                this.Y = l.ElementAt(n).Y;
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action((reloadTickLeft)));
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action((reloadTickTop)));
                itération++;
                return true;
            }
            return false;
        }