Example #1
0
        public static Tile MakeTile(Beagle.Hit hit, Beagle.Query query)
        {
            TileActivator best = null;

            try {
                foreach (TileActivator activator in activators)
                {
                    if (!activator.Validate(hit))
                    {
                        continue;
                    }

                    if (best == null)
                    {
                        best = activator;
                        continue;
                    }

                    if (activator.Weight > best.Weight)
                    {
                        best = activator;
                    }
                }

                if (best != null)
                {
                    return(best.BuildTile(hit, query));
                }
            } catch (Exception e) {
                Console.WriteLine("Error instantiating tile:\n{0}", e);
            }

            return(null);
        }
Example #2
0
        public int CompareTo(object o)
        {
            TileActivator other = (TileActivator)o;

            if (other == null)
            {
                return(1);
            }

            return(this.Weight - other.Weight);
        }