예제 #1
0
        public static void Populate(Gamefield gamefield)
        {
            if (!AllInvaderChuzzles.Any() || AllInvaderChuzzles.Count == MaxInvadersOnLevel)
            {
                return;
            }

            var search = new PrimeSearch(AllInvaderChuzzles.Count);
            int p;
            while ((p = search.GetNext()) != -1)
            {
                var currentInvader = AllInvaderChuzzles[p];

                var targetTile =
                    gamefield.Level.Chuzzles.GetTiles(x=>x is ColorChuzzle).FirstOrDefault(
                                                                                           x =>
                                                                                           (x.Current == currentInvader.Current.Left || x.Current == currentInvader.Current.Right ||
                                                                                            x.Current == currentInvader.Current.Top || x.Current == currentInvader.Current.Bottom));

                if (targetTile != null)
                {
                    Instance.TilesFactory.CreateInvader(targetTile.Current);
                    targetTile.Destroy(false,true,true);
                    break;
                }
            }

            //  var listInvaders = AllInvaderChuzzles.Aggregate("", (current, allInvaderChuzzle) => current + (allInvaderChuzzle + "\n"));
            //  Debug.Log("Invaders: \n"+listInvaders);
        }
예제 #2
0
    public static void Populate(Gamefield gamefield)
    {
        if (!AllInvaderChuzzles.Any() || AllInvaderChuzzles.Count == MaxInvadersOnLevel)
        {
            return;
        }

        var search = new PrimeSearch(AllInvaderChuzzles.Count);
        int p;

        while ((p = search.GetNext()) != -1)
        {
            var currentInvader = AllInvaderChuzzles[p];

            var targetTile =
                gamefield.Level.ActiveChuzzles.Where(x => x is ColorChuzzle).FirstOrDefault(
                    x =>
                    (x.Current == currentInvader.Current.Left || x.Current == currentInvader.Current.Right ||
                     x.Current == currentInvader.Current.Top || x.Current == currentInvader.Current.Bottom));

            if (targetTile != null)
            {
                TilesFactory.Instance.CreateInvader(targetTile.Current);
                targetTile.Destroy(false, true, true);
                break;
            }
        }

        //  var listInvaders = AllInvaderChuzzles.Aggregate("", (current, allInvaderChuzzle) => current + (allInvaderChuzzle + "\n"));
        //  Debug.Log("Invaders: \n"+listInvaders);
    }