private void CreateBarrier()
    {
        var minNumber    = LEVEL_BARRIER_MIN[difficulty];
        var maxNumber    = LEVEL_BARRIER_MAX[difficulty];
        var wayDict      = WorldHelper.RandomFixedXS(minNumber, maxNumber);
        var blockMinimum = 2;
        var blockCount   = 0;

        foreach (var kv in wayDict)
        {
            var way  = kv.Key;
            var x    = kv.Value;
            var type = EBarrierType.BLOCK;
            if (++blockCount > blockMinimum)
            {
                type = (EBarrierType)MathKit.RandomType(CREATE_BARRIER_PROBS);
            }

            var gameObject = Object.Instantiate(stage.barrierPrefab, stage.barrierCanvas.transform);
            gameObject.transform.position = new Vector3(x, Screen.height + 100, 0);

            var barrier = gameObject.GetComponent <Barrier>();
            barrier.Way = way;
            barrier.Morph(type);
            world.BarrierManager.Add(barrier);
        }
    }
    private void CalculateDifficulty()
    {
        var meters = WorldHelper.PixelsToMeters(GameData.Instance.Distance);

        if (meters <= 150)
        {
            difficulty = 0;
        }
        else if (meters <= 300)
        {
            difficulty = 1;
        }
        else if (meters <= 600)
        {
            difficulty = 2;
        }
        else if (meters <= 1000)
        {
            difficulty = 3;
        }
        else
        {
            difficulty = 4;
        }
    }
        /// <summary>
        /// Updates particle emiter.
        /// </summary>
        /// <param name="gameTime">Current game time.</param>
        public void Update(GameTime gameTime)
        {
            if (DecayTime > 0f)
            {
                DecayTime -= gameTime.ElapsedGameTime.Milliseconds;

                if (DecayTime <= 0f)
                {
                    Enabled   = false;
                    _decaying = true;
                }
            }

            if (Enabled)
            {
                _sinceLastEmision += gameTime.ElapsedGameTime.Milliseconds;
                var toEmit = MillisecondsToEmit / Intensity;

                while (_sinceLastEmision >= toEmit)
                {
                    float angle = (float)(_rng.NextDouble() * (2 * OpeningAngle)) - OpeningAngle;
                    _sinceLastEmision -= toEmit;
                    var particle = new Particle(_level, _particleTexture, Position, ParticleStates)
                    {
                        Opacity  = Intensity,
                        Momentum = Momentum + Direction.Rotate(angle) * WorldHelper.PixelsToMeters(ParticleSpeed)
                    };
                    _particles.Add(particle);
                    _level.AddEntity(particle);
                    particle.OnDecay += Particle_OnDecay;
                }
            }
        }
Example #4
0
 public override void OnZombieInRangeOfPlayer()
 {
     if (TargetInCorrectLayer())
     {
         WorldHelper.AddExplosion(transform.position, 3f, 0.4f, 5, this);
         Destroy(gameObject);
     }
 }
Example #5
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
Example #6
0
        private Individual GetParent()
        {
            // Grab two candidate parents from the population.
            var(candidate1, candidate2) = WorldHelper.GetCandidateParents(this.Population);

            // Perform the tournament selection
            return(WorldHelper.TournamentSelection(candidate1, candidate2));
        }
Example #7
0
        public static void LoadSelectedWorld()
        {
            if (SELECTED_WORLDBUTTON == null)
            {
                return;
            }

            Game.GameState = GameState.LOADING;
            WorldHelper.LoadWorld(SELECTED_WORLDBUTTON.GetWorldName());
        }
 void OnMouseOver()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if (inRange && WorldHelper.CloseEnoughToInteract(player, gameObject))
         {
             Interact(player);
         }
     }
 }
Example #9
0
 void Start()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Example #10
0
        public void GenerateIndividualTest()
        {
            TownHelper.Initialize();

            var individual = WorldHelper.GenerateIndividual(Configuration.TownCount);

            // Ensure that individual contains no repeated values
            var uniqueValueGroups = individual.Sequence.GroupBy(s => s);

            Assert.IsTrue(uniqueValueGroups.All(g => g.Count() == 1));
        }
Example #11
0
        public void EnsureCandidateParentsUniqueTest()
        {
            var population = DefaultPopulationHelper.GetTestPopulation();

            for (int i = 0; i < 10; i++)
            {
                var(candidateA, candidateB) = WorldHelper.GetCandidateParents(population);

                Assert.IsFalse(candidateA.Sequence.SequenceEqual(candidateB.Sequence));
            }
        }
Example #12
0
        public void EnsureUniqueTownsTest()
        {
            var sequence = new List <int> {
                0, 9, 1, 2, 3, 4, 5, 6, 7, 8
            };

            for (int i = 0; i < 10; i++)
            {
                var(townA, townB) = WorldHelper.GetUniqueTowns(sequence);

                Assert.AreNotEqual(townA, townB);
            }
        }
Example #13
0
      private ServerWorldManager()
      {
         _Configuration = ConfigurationManager.ReadConfiguration<ServerConfiguration>();
         // save the configuration to update with possibly new contents
         ConfigurationManager.SaveConfiguration(_Configuration);

         InitializeConfiguration(Configuration);

         // set delegates
         WorldHelper.SetGetPooledBoxDelegate(GetPooledBox);
         WorldHelper.SetGetPooledSegmentDelegate(GetPooledSegment);
         WorldHelper.SetGetSegmentDelegate(GetSegment);
      }
Example #14
0
        private ClientWorldManager()
        {
            // read configuration
            Configuration = ConfigurationManager.ReadConfiguration <ClientConfiguration>();
            InitializeConfiguration(Configuration);

            _RenderDistance = Configuration.Video.VisibilityRange * Configuration.Video.VisibilityRange;
            _Fog            = Configuration.Video.Fog;
            _SkyColor       = Configuration.Video.SkyColor.ToArray();
            _Width          = Configuration.Video.ResolutionWidth;
            _Height         = Configuration.Video.ResolutionHeight;

            // load skin
            byte[] skin = File.ReadAllBytes(Path.Combine("..", "..", SkinsDir, Configuration.Customization.SkinFileName));
            _SkinHash = skin.GetMd5Checksum();
            SkinManager.SaveSkin(ref _SkinHash, ref skin);

            // set singleplayer provider
            if (Configuration.Network.AutoConnect)
            {
                IsSinglePlayer = false;
                WorldHelper.SetMessagingProviders(MultiPlayerProvider.ClientToServerProvider, MultiPlayerProvider.ServerToClientProvider);
            }
            else
            {
                IsSinglePlayer = true;
                WorldHelper.SetMessagingProviders(SinglePlayerProvider.ClientToServerProvider, SinglePlayerProvider.ServerToClientProvider);
                // dummy client connection
                _Client = new ClientConnection(true);
            }

            // set delegates
            WorldHelper.SetGetPooledBoxDelegate(GetPooledBox);
            WorldHelper.SetGetPooledSegmentDelegate(GetPooledSegment);
            WorldHelper.SetGetSegmentDelegate(GetSegment);

            // Sets keyboard events
            Events.KeyboardDown    += new EventHandler <KeyboardEventArgs>(KeyDown);
            Events.KeyboardUp      += new EventHandler <KeyboardEventArgs>(KeyUp);
            Events.MouseButtonDown += new EventHandler <MouseButtonEventArgs>(MouseButtonDown);
            Events.MouseButtonUp   += new EventHandler <MouseButtonEventArgs>(MouseButtonUp);
            Events.MouseMotion     += new EventHandler <MouseMotionEventArgs>(MouseMotion);
            Events.TargetFps        = 1000;

            // Sets Window icon and title
            this.WindowAttributes();

            // Creates SDL.NET Surface to hold an OpenGL scene
            _Screen = Video.SetVideoMode(_Width, _Height, true, true);
            CenterMouseCursor();
        }
Example #15
0
    //-----------------------------------------------------------------------------//

    void HandleInput()
    {
        if (Input.GetAxis("Interact") != 0)
        {
            foreach (GameObject o in interactibles)
            {
                if (WorldHelper.FacingInteractible(this, o))
                {
                    o.GetComponent <b_InteractibleWorld>().Interact(gameObject);
                    break;
                }
            }
        }

        if (collided)
        {
            return;
        }

        float hor  = Input.GetAxis("Horizontal");
        float vert = Input.GetAxis("Vertical");

        if (Mathf.Abs(hor) > Mathf.Abs(vert))
        {
            vert = 0;
        }
        else if (Mathf.Abs(vert) > Mathf.Abs(hor))
        {
            hor = 0;
        }

        if (hor == 0 && vert == 0)
        {
            StopMoving();
        }
        else
        {
            if (hor != 0 && (int)(transform.position.y * 10000) % 10000 == 0)
            {
                SetHorizontalMovement(hor);
            }
            if (vert != 0 && (int)(transform.position.x * 10000) % 10000 == 0)
            {
                SetVerticalMovement(vert);
            }
        }
    }
Example #16
0
    public ushort GetCube(long lTestX, long lTestY, long lTestZ, out ushort lValue, out byte lFlags)
    {
        if (lTestX < 100000L)
        {
            Debug.LogError((object)("Error, either you travelled 500 light years, or the mob is lost! X is " + (object)lTestX));
        }
        if (lTestY < 100000L)
        {
            Debug.LogError((object)("Error, either you travelled 500 light years, or the mob is lost! Y is " + (object)lTestY));
        }
        if (lTestZ < 100000L)
        {
            Debug.LogError((object)("Error, either you travelled 500 light years, or the mob is lost! Z is " + (object)lTestZ));
        }
        Segment segment;

        if (this.mSegment.ContainsCoordinate(lTestX, lTestY, lTestZ))
        {
            segment = this.mSegment;
        }
        else
        {
            long segX;
            long segY;
            long segZ;
            WorldHelper.GetSegmentCoords(lTestX, lTestY, lTestZ, out segX, out segY, out segZ);
            segment = WorldScript.instance.GetSegment(segX, segY, segZ);
            if (segment == null)
            {
                this.AttemptGetSegment(segX, segY, segZ);
            }
        }
        if (segment == null || !segment.mbInitialGenerationComplete || segment.mbDestroyed)
        {
            //CentralPowerHub.mnMinecartX = lTestX;
            //CentralPowerHub.mnMinecartY = lTestY;
            //CentralPowerHub.mnMinecartZ = lTestZ;
            lFlags           = (byte)0;
            lValue           = (ushort)0;
            this.mPrevGetSeg = (Segment)null;
            return(0);
        }
        lValue           = segment.GetCubeData(lTestX, lTestY, lTestZ).mValue;
        lFlags           = segment.GetCubeData(lTestX, lTestY, lTestZ).meFlags;
        this.mPrevGetSeg = segment;
        return(segment.GetCube(lTestX, lTestY, lTestZ));
    }
Example #17
0
        /// <summary>
        /// Updates the Physics of the entity.
        /// </summary>
        /// <param name="gameTime">How much time have passed since the last update.</param>
        public override void Update(GameTime gameTime)
        {
            float secs = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Vector2 accelSecs = _acceleration * secs;

            Momentum += _instantaneousAcceleration;
            Momentum *= Vector2.One - Friction;
            var toMove = Momentum + accelSecs / 2;

            Position += WorldHelper.MetersToPixels(toMove.LimitSize(MaxSpeed) * secs);

            Momentum += accelSecs;

            if (RotateToMomentum)
            {
                Rotation = Momentum.GetAngle();
            }
            else
            {
                var angularAccelSecs = _angularAcceleration * secs;

                AngularMomentum += _instantaneousAngularAcceleration;
                AngularMomentum *= 1 - RotationFriction;

                AngularMomentum = MathHelper.Clamp(AngularMomentum, -MaxRotationSpeed, MaxRotationSpeed);

                var toRotate = AngularMomentum + angularAccelSecs / 2;
                Rotation += MathHelper.Clamp(toRotate, -MaxRotationSpeed, MaxRotationSpeed) * secs;

                AngularMomentum += angularAccelSecs;

                _instantaneousAngularAcceleration = _angularAcceleration = 0;
            }

            _instantaneousAcceleration = _acceleration = Vector2.Zero;


            AngularMomentum = MathHelper.Clamp(AngularMomentum, -MaxRotationSpeed, MaxRotationSpeed);
            if (Speed > MaxSpeed)
            {
                Momentum *= MaxSpeed / Speed;
            }

            base.Update(gameTime);
        }
Example #18
0
        public void EnsureSwapMutationResultTest()
        {
            TownHelper.Initialize();

            var individual = new Individual(new List <int> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            });

            var result = WorldHelper.DoSwapMutate(individual);

            // Ensure that all values are still in the list
            var distinctResultCount = result.Sequence.Distinct().Count();

            Assert.AreEqual(distinctResultCount, 10);

            // Ensure that there are no duplicate entries
            var sequences = result.Sequence.GroupBy(s => s);

            Assert.IsTrue(sequences.All(s => s.Count() == 1));

            // Perform manual swap to ensure result is correct
            var firstIndex = -1;
            var lastIndex  = -1;

            for (int i = 0; i < individual.Sequence.Count; i++)
            {
                if (firstIndex == -1 && result.Sequence[i] != individual.Sequence[i])
                {
                    firstIndex = i;
                    continue;
                }

                if (firstIndex != -1 && result.Sequence[i] != individual.Sequence[i])
                {
                    lastIndex = i;
                    break;
                }
            }

            var originalSequence = individual.Sequence.ToList();

            originalSequence.SwapInPlace(firstIndex, lastIndex);

            Assert.IsTrue(originalSequence.SequenceEqual(result.Sequence));
        }
Example #19
0
        public void EnsureCrowdingDistanceTournamentSelectionTest()
        {
            var population = DefaultPopulationHelper.GetTestPopulation();

            MultiObjectiveHelper.UpdatePopulationFitness(population);

            // Rank 1, float.MaxValue crowding distance
            var individualA = population[0];

            // Rank 1, ~5.65 crowding distance
            var individualB = population[1];

            var fitterIndividualA = WorldHelper.TournamentSelection(individualA, individualB);
            var fitterIndividualB = WorldHelper.TournamentSelection(individualB, individualA);

            Assert.AreEqual(individualA, fitterIndividualA);
            Assert.AreEqual(individualA, fitterIndividualB);
        }
Example #20
0
        public void EnsureRankedTournamentSelectionTest()
        {
            var population = DefaultPopulationHelper.GetTestPopulation();

            MultiObjectiveHelper.UpdatePopulationFitness(population);

            // Rank 1
            var individualA = population[1];

            // Rank 2
            var individualB = population[3];

            var fitterIndividualA = WorldHelper.TournamentSelection(individualA, individualB);
            var fitterIndividualB = WorldHelper.TournamentSelection(individualB, individualA);

            Assert.AreEqual(individualA, fitterIndividualA);
            Assert.AreEqual(individualA, fitterIndividualB);
        }
Example #21
0
        private ServerManager()
        {
            WorldHelper.SetMessagingProviders(_ClientToServer, _ServerToClient);

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            NetPeerConfiguration peerConfig = ServerWorldManager.Instance.Configuration.Network.CreateNetPeerConfigurationUdp();

            peerConfig.SetMessageTypeEnabled(NetIncomingMessageType.DebugMessage, true);
            peerConfig.SetMessageTypeEnabled(NetIncomingMessageType.ErrorMessage, true);
            peerConfig.SetMessageTypeEnabled(NetIncomingMessageType.VerboseDebugMessage, true);
            peerConfig.SetMessageTypeEnabled(NetIncomingMessageType.WarningMessage, true);

            _Server = new NetServer(peerConfig);
            _Server.RegisterReceivedCallback(new SendOrPostCallback(ReceivedMessage));

            _WebServer = new WebHost(ServerWorldManager.Instance.Configuration.Network.Web);
        }
Example #22
0
    public void CreateWorld(Map map)
    {
        foreach (var pair in map._map)
        {
            if (pair.Value is Wall)
            {
                var item = Instantiate(wall, WorldHelper.GetPosition(pair.Key), Quaternion.identity);
                item.AddComponent <WallView>();
                item.transform.SetParent(mapRoot);
            }

            if (pair.Value is Floor)
            {
                var item = Instantiate(floor, WorldHelper.GetPosition(pair.Key), Quaternion.identity);
                item.AddComponent <FloorView>();
                item.transform.SetParent(mapRoot);
            }
        }
    }
Example #23
0
    public void Update()
    {
        for (var i = entities.Count - 1; i >= 0; --i)
        {
            var isOutside = WorldHelper.IsOutside(entities[i].transform.position);
            if (isOutside)
            {
                entities[i].SwitchState(EEntityState.DEAD);
            }

            var isLive = entities[i].IsLive();
            var isBusy = entities[i].IsBusy();
            if (!isLive && !isBusy)
            {
                Object.Destroy(entities[i].gameObject);
                entities.RemoveAt(i);
            }
        }
    }
Example #24
0
        public void EnsureRotationMutationResultTest()
        {
            TownHelper.Initialize();

            var individual = new Individual(new List <int> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            });

            var result = WorldHelper.DoRotateMutate(individual);

            // Ensure that all values are still in the list
            var distinctResultCount = result.Sequence.Distinct().Count();

            Assert.AreEqual(distinctResultCount, 10);

            // Ensure that there are no duplicate entries
            var sequences = result.Sequence.GroupBy(s => s);

            Assert.IsTrue(sequences.All(s => s.Count() == 1));
        }
Example #25
0
        public void EnsureSpawningUniqueTest()
        {
            TownHelper.Initialize();

            var population = WorldHelper.SpawnPopulation();

            var populationSequences = population.Select(i => i.Sequence);

            // Manually check that each individual in the population is unique
            foreach (var sequenceA in populationSequences)
            {
                foreach (var sequenceB in populationSequences)
                {
                    if (sequenceA == sequenceB)
                    {
                        continue;
                    }

                    Assert.IsTrue(!sequenceA.SequenceEqual(sequenceB));
                }
            }
        }
Example #26
0
        /// <summary>
        /// Draw the stars background, based on the camera position.
        /// </summary>
        /// <param name="gameTime">Current game time.</param>
        void DrawStars(GameTime gameTime)
        {
            SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap, null, null);
            SpriteBatch.Draw(_background,
                             drawRectangle: GraphicsDevice.Viewport.Bounds,
                             sourceRectangle: new Rectangle(
                                 (int)(_camera.X * GamePlay.BackgroundSlideFactor),
                                 (int)(_camera.Y * GamePlay.BackgroundSlideFactor),
                                 _stars.Width, _stars.Height)
                             .Scale(1.1f));
            SpriteBatch.Draw(_stars,
                             drawRectangle: GraphicsDevice.Viewport.Bounds,
                             sourceRectangle: new Rectangle(
                                 (int)(_camera.X * GamePlay.StarsSlideFactor),
                                 (int)(_camera.Y * GamePlay.StarsSlideFactor),
                                 _stars.Width, _stars.Height));
            SpriteBatch.End();

            Vector2 cameraDirection = new Vector2(2, 0);

            _camera += WorldHelper.MetersToPixels(cameraDirection) * (float)gameTime.ElapsedGameTime.TotalSeconds;
        }
Example #27
0
        public void EnsureCrossoverTest()
        {
            TownHelper.Initialize();

            var individualA = new Individual(new List <int> {
                0, 9, 1, 8, 2, 7, 3, 6, 4, 5
            });
            var individualB = new Individual(new List <int> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            });

            var crossoverPointA = 3;
            var crossoverPointB = 1;
            var crossoverPointC = 8;

            var childA = WorldHelper.DoCrossover(individualA, individualB, crossoverPointA);
            var childB = WorldHelper.DoCrossover(individualA, individualB, crossoverPointB);
            var childC = WorldHelper.DoCrossover(individualA, individualB, crossoverPointC);

            var expectedChildASequence = new List <int> {
                0, 9, 1, 2, 3, 4, 5, 6, 7, 8
            };
            var expectedChildBSequence = new List <int> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            };
            var expectedChildCSequence = new List <int> {
                0, 9, 1, 8, 2, 7, 3, 6, 4, 5
            };

            Assert.IsTrue(childA.Sequence.SequenceEqual(expectedChildASequence));
            Assert.IsTrue(childB.Sequence.SequenceEqual(expectedChildBSequence));
            Assert.IsTrue(childC.Sequence.SequenceEqual(expectedChildCSequence));

            Assert.AreEqual(childA.Sequence.Count(), individualA.Sequence.Count());
            Assert.AreEqual(childB.Sequence.Count(), individualA.Sequence.Count());
            Assert.AreEqual(childC.Sequence.Count(), individualA.Sequence.Count());
        }
Example #28
0
        public static void RecalcStockpileMaxSize(Colony colony)
        {
            var pos = GetStockpilePosition(colony);
            var blocksAroundStockpile = WorldHelper.GetBlocksInArea(pos.Min, pos.Max);
            int total = 0;
            Dictionary <string, int> byCategory = new Dictionary <string, int>();
            Dictionary <string, int> byType     = new Dictionary <string, int>();

            foreach (var blockType in blocksAroundStockpile.Values)
            {
                if (StorageBlockTypes.TryGetValue(blockType.Name, out var storageUpgradeBlock))
                {
                    total += storageUpgradeBlock.GlobalStorageUpgrade;

                    if (storageUpgradeBlock.CategoryStorageUpgrades != null)
                    {
                        foreach (var kvp in storageUpgradeBlock.CategoryStorageUpgrades)
                        {
                            if (!byCategory.ContainsKey(kvp.Key))
                            {
                                byCategory.Add(kvp.Key, 0);
                            }

                            byCategory[kvp.Key] = byCategory[kvp.Key] + kvp.Value;
                        }
                    }

                    if (storageUpgradeBlock.ItemStorageUpgrades != null)
                    {
                        foreach (var kvp in storageUpgradeBlock.ItemStorageUpgrades)
                        {
                            if (!byType.ContainsKey(kvp.Key))
                            {
                                byType.Add(kvp.Key, 0);
                            }

                            byType[kvp.Key] = byType[kvp.Key] + kvp.Value;
                        }
                    }
                }
            }

            if (!StockpileMaxStackSize.ContainsKey(colony))
            {
                StockpileMaxStackSize[colony] = new Dictionary <ushort, int>();
            }

            if (total == 0)
            {
                total = StorageBlockTypes[StockpileBlock.Name].GlobalStorageUpgrade;
            }

            float stacksTotal = 0;

            foreach (var item in ItemTypes._TypeByUShort.Values)
            {
                var totalStack = total;
                DefaultMax[colony] = total;

                if (item.Categories != null)
                {
                    foreach (var cat in item.Categories)
                    {
                        if (byCategory.TryGetValue(cat, out int catTotal))
                        {
                            totalStack += catTotal;
                        }
                    }
                }

                if (byType.TryGetValue(item.Name, out int itemTotal))
                {
                    totalStack += itemTotal;
                }

                StockpileMaxStackSize[colony][item.ItemIndex] = totalStack;

                var count = colony.Stockpile.AmountContained(item.ItemIndex);

                if (count > 0)
                {
                    stacksTotal += count;
                }
            }

            var maxItems = colony.Stockpile.ItemCount * total;
            var fillPct  = System.Math.Round(stacksTotal / maxItems, 2) * 100;

            foreach (var player in colony.Owners)
            {
                if (player.ActiveColony == colony)
                {
                    UIManager.AddorUpdateUIImage("ColonyStockpile" + colony.ColonyID, colonyshared.NetworkUI.UIGeneration.UIElementDisplayType.Colony, "StockpileBackground", new Vector3Int(135, -119, 0), colonyshared.NetworkUI.AnchorPresets.TopLeft, player);
                    UIManager.AddorUpdateUILabel("ColonyStockpile" + colony.ColonyID, colonyshared.NetworkUI.UIGeneration.UIElementDisplayType.Colony, LocalizationHelper.LocalizeOrDefault("StockpileSize", player, total.ToKMB(), fillPct.ToString()), new Vector3Int(137, -119, 0), colonyshared.NetworkUI.AnchorPresets.TopLeft, 270, player, 14);
                }
            }
        }
Example #29
0
        private void _InitSelectMenu()
        {
            Select_Load   = new Button(Game.X_MID + 128, Game.CANVAS_HEIGHT - 128, 128, 32, "Load", C.MFont, delegate() { Game.GameState = GameState.LOADING; WorldHelper.LoadWorld(WorldButton.SELECTED_WORLDBUTTON.GetWorldName()); });
            Select_Edit   = new Button(Game.X_MID + 128, Game.CANVAS_HEIGHT - 64, 128, 32, "Edit", C.MFont, delegate() {  });
            Select_Create = new Button(Game.X_MID - 256, Game.CANVAS_HEIGHT - 128, 128, 32, "Create", C.MFont, delegate() { });
            Select_Delete = new Button(Game.X_MID - 256, Game.CANVAS_HEIGHT - 64, 128, 32, "Delete", C.MFont, delegate() { });

            Select_Load.preRender = delegate(Button b)
            {
                if (WorldButton.SELECTED_WORLDBUTTON == null)
                {
                    b.Disable();
                }
                else
                {
                    b.Enable();
                }
            };

            // Iterate subfolders in worlds dir to generate world buttons
            string worldsDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\Sap\Worlds\";

            string[] worlds = Directory.GetDirectories(worldsDir);
            for (var i = 0; i < worlds.Length; i++)
            {
                var w = worlds[i];
                Buttons.Add(new WorldButton((int)(Game.CANVAS_WIDTH * 0.25), 96 * i, (int)(Game.CANVAS_WIDTH * 0.5), 64, w, delegate() { }));
            }
        }
 protected GridAnimatedBehaviour(char[,] world, Point start)
 {
     Grid = WorldHelper.GenerateGraphOfOpenSpaces(world, start);
 }