Ejemplo n.º 1
0
        public Planet(int id, int seed, GraphicsDeviceManager graphics, PlanetTypes planetType, PlanetSizes planetSize)
        {
            Id           = id;
            PlanetType   = planetType;
            PlanetSize   = planetSize;
            ChunksWidth  = PlanetSizeDImensions[(int)planetSize][0];
            ChunksHeight = PlanetSizeDImensions[(int)planetSize][1];
            CellsWidth   = ChunksWidth * CHUNK_WIDTH;
            CellsHeight  = ChunksHeight * CHUNK_HEIGHT;

            noiseGenerator = new NoiseGenerator(planetType, seed, CellsWidth, CellsHeight);

            Map = new Map.Map(id, seed, ChunksWidth, ChunksHeight, noiseGenerator, graphics, planetType);

            List <Vector2> greens = PoissonSample.GeneratePoints(new Random(seed), 15, new Vector2(CellsWidth, CellsHeight));
            List <Vector2> blues  = PoissonSample.GeneratePoints(new Random(seed), 20, new Vector2(CellsWidth, CellsHeight));
            List <Vector2> reds   = PoissonSample.GeneratePoints(new Random(seed), 25, new Vector2(CellsWidth, CellsHeight));

            for (int i = 0; i < greens.Count; i++)
            {
                Structures.Add(new Ore(GetCellAtPosition(greens[i]), Ore.OreTypes.Green));
            }
            for (int i = 0; i < blues.Count; i++)
            {
                Structures.Add(new Ore(GetCellAtPosition(blues[i]), Ore.OreTypes.Blue));
            }
            for (int i = 0; i < reds.Count; i++)
            {
                Structures.Add(new Ore(GetCellAtPosition(reds[i]), Ore.OreTypes.Red));
            }
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            Map<int, string> map = new Map<int, string>();
            map.Add(1, "Gosho");
            map.Add(2, "Pesho");
            map.Add(3, "Ivan");
            map.Add(4, "Tisho");
            Console.WriteLine(map[1]);
            Console.WriteLine(map[2]);
            Console.WriteLine(map[3]);
            Console.WriteLine(map[4]);
            map[7] = "Mitko";
            Console.WriteLine(map[7]);

            //map.Clear();
            //Console.WriteLine(map[1]);
            Console.WriteLine();

            map.Remove(1);
            // Console.WriteLine(map[1]); -> exception
            Console.WriteLine(map[2]);
            Console.WriteLine(map[3]);
            Console.WriteLine(map[4]);
            Console.WriteLine(map[7]);

            Console.WriteLine();
            Console.WriteLine(map.ContainsKey(2));
            Console.WriteLine(map.ContainsValue("Pesho"));
            Console.WriteLine(map.ContainsKey(5));
            Console.WriteLine(map.ContainsValue("Koko"));
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var map = new Map<int, string>();
            map.Add(1, "Stormwind");
            map.Add(2, "Ogrimar");
            map.Add(3, "Ironforge");
            map.Add(4, "Darnasus");

            Console.WriteLine(map[1]);
            Console.WriteLine(map[2]);
            Console.WriteLine(map[3]);
            Console.WriteLine(map[4]);
            Console.WriteLine();

            map[9] = "Thunder Bluff";
            map.Remove(4);

            Console.WriteLine(map[1]);
            Console.WriteLine(map[2]);
            Console.WriteLine(map[3]);
            //Console.WriteLine(map[4]); // throw an Exception
            Console.WriteLine(map[9]);
            Console.WriteLine();

            Console.WriteLine(map.CointainsKey(2));
            Console.WriteLine(map.ContainsValue("Dalaran"));
        }
Ejemplo n.º 4
0
 public void DisplayMap(Map map)
 {
     for (var j = 0; j < map.MapSize; j++)
     {
         for (var i = 0; i < map.MapSize; i++)
         {
             this.DisplayTile(map, i, j);
         }
         Console.WriteLine(' ');
     }
 }
Ejemplo n.º 5
0
 public void DrawMap(Map.Map map)
 {
     if (File.Exists("map.txt"))
     {
         File.Delete("map.txt");
     }
     using (StreamWriter writer = new StreamWriter("map.txt"))
     {
         Draw(writer, map.Squares);
     }
 }
Ejemplo n.º 6
0
        public void LoadMap(MapFile mapFile)
        {
            Debug.Log($"Load mapFile: {mapFile}");

            Map = MapLoader.Load(mapFile);

            //Create map texture
            DomEdit.I.Ui.Get <MapPicture>().LoadMap(Map);

            //Open menus
            DomEdit.I.Ui.Get <SearchMenu>().Show();
            DomEdit.I.Ui.Get <PlayersMenu>().Show();
            DomEdit.I.Ui.Get <ControlButtonsMenu>().Show();
        }
Ejemplo n.º 7
0
 public void DisplayTile(Map map, int i, int j)
 {
     Console.SetCursorPosition(i, j);
     Console.BackgroundColor = map.mapArray[i][j].Terrain.Color;
     if (map.mapArray[i][j].listOfObjects.Count == 0)
     {
         Console.Write(map.mapArray[i][j].Terrain.Icon);
     }
     else
     {
         //map.mapArray[i][j].listOfObjects.Find(x => x is StonedCat);
         //тут надо как-то узнать, что из объектов печатать
         Console.Write(map.mapArray[i][j].listOfObjects[0].Image);
     }
 }
Ejemplo n.º 8
0
 public Map AutoCreator(int mapSize, GameplayController controller)
 {
     this.mapSize = mapSize;
     newMap = new Map(mapSize);
     notWaterTile = 0;
     while (notWaterTile < mapSize * mapSize * 6 / 7)//цифры изменить на что
     {
         this.CreateObject(new Field());
         this.CreateObject(new Forest());
         this.CreateObject(new Swamp());
     }
     this.RemoveIsolatedTwoTileGroup();
     this.DeleteSingleTile();
     this.AddTree(controller);
     return newMap;
 }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            Map<int, string> myMap = new Map<int, string>();
            myMap.Add(1, "one");
            myMap.Add(2, "two");
            myMap.Add(3, "three");
            myMap.Add(4, "four");

            Console.WriteLine(myMap[2]);
            Console.WriteLine(myMap.ContainsKey(5));
            Console.WriteLine(myMap.ContainsValue("three"));

            myMap.Remove(1);
            for (int i = 0; i < myMap.Count; i++)
            {
                Console.WriteLine(myMap[myMap.Keys[i]]);
            }
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            var seed      = args.Length > 1 ? Convert.ToInt32(args[0]) : int.MaxValue;
            var moves     = args.Length > 2 ? Convert.ToInt32(args[0]) : 10000;
            var maxPath   = args.Length > 3 ? Convert.ToInt32(args[1]) : 100;
            var map       = new Map.Map();
            var generator = new StraightPathGenerator(seed, map);
            var explorer  = new RandomExplorer(map, new List <Explorer.ILocationListener>()
            {
                generator
            });

            explorer.Explore(seed, moves);

            MapDrawer drawer = new MapDrawer();

            drawer.DrawMap(map);
            drawer.DrawPath(explorer.Path);
        }
Ejemplo n.º 11
0
 public override Decision Think(Map map)
 {
     if (renderer == null)
     {
         renderer = new MapRenderer(map, player.CoordinateX, player.CoordinateY);
     }
     renderer.DisplayMap(map);
     renderer.DisplayObject(player);
     var key = Console.ReadKey();
     switch (key.Key)
     {
         case ConsoleKey.LeftArrow:
             return Decision.WishLeft;
         case ConsoleKey.RightArrow:
             return Decision.WishRight;
         case ConsoleKey.DownArrow:
             return Decision.WishDown;
         case ConsoleKey.UpArrow:
             return Decision.WishUp;
     }
     return Decision.NoWish;
 }
Ejemplo n.º 12
0
 public Generator(Map.Map map)
 {
     Map = map;
     Map.AddSquare(new MapSquare(0, 0, new MapSquareEdge(MapSquareEdgeType.Path), new MapSquareEdge(MapSquareEdgeType.Path), new MapSquareEdge(MapSquareEdgeType.Path), new MapSquareEdge(MapSquareEdgeType.Path)));
 }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            Console.WriteLine("###      LinkedList tests");

            var list = new LinkedList<string>();
            list.Add("x");
            list.Add("g");
            list.Add("s");

            Console.WriteLine(list.Count); //output: 3

            list.InsertAfter("g", "a");
            list.InsertAt(10, "z");
            list.InsertAt(2, "z");
            list.Remove("z");
            list[1] = "m";

            foreach (string value in list)
            {
                Console.WriteLine(value);
            }
            //output:
            //x
            //m
            //a
            //s

            Console.WriteLine("\n###      DynamicArray tests");

            var dArray = new DynamicArray<string>();
            dArray.Add("x");
            dArray.Add("g");
            dArray.Add("s");

            Console.WriteLine(dArray.Count); //output: 3

            dArray.InsertAt(10, "z");
            dArray.InsertAt(2, "z");
            dArray.Remove("z");
            dArray[1] = "m";

            for (int i = 0; i < dArray.Count; i++)
            {
                Console.WriteLine(dArray[i]);
            }
            //output:
            //x
            //m
            //a
            //s

            Console.WriteLine("\n###      Map tests");

            var map = new Map<int, string>();

            map.Add(1, "a");
            map.Add(2, "a");
            map.Add(3, "s");

            Console.WriteLine(map.Count); //output: 3

            try
            {
                map.Add(2, "v");
            }
            catch (ArgumentException argEx)
            {
                Console.WriteLine(argEx.Message); //exception message
            }

            Console.WriteLine(map.ContainsKey(2)); //output: True
            Console.WriteLine(map.ContainsValue("a")); //output: True
            map.Remove(2);
            Console.WriteLine(map.ContainsKey(2)); //output: False
            Console.WriteLine(map.ContainsValue("a")); //output: True

            Console.WriteLine(map.Count); //output: 2

            Console.WriteLine("\n###      HashMap tests");

            var hashMap = new Map<int, string>();

            hashMap.Add(1, "a");
            hashMap.Add(2, "a");
            hashMap.Add(3, "s");

            Console.WriteLine(hashMap.Count); //output: 3

            try
            {
                hashMap.Add(2, "v");
            }
            catch (ArgumentException argEx)
            {
                Console.WriteLine(argEx.Message); //exception message
            }

            Console.WriteLine(hashMap.ContainsKey(2)); //output: True
            Console.WriteLine(hashMap.ContainsValue("a")); //output: True
            hashMap.Remove(2);
            Console.WriteLine(hashMap.ContainsKey(2)); //output: False
            Console.WriteLine(hashMap.ContainsValue("a")); //output: True

            Console.WriteLine(hashMap.Count); //output: 2
        }
Ejemplo n.º 14
0
 public RandomExplorer(Map.Map map, List <ILocationListener> listeners)
     : base(map, listeners)
 {
 }
Ejemplo n.º 15
0
 public GameplayController()
 {
     mapSize = 20;
     var mapCreator = new MapCreator();
     map = mapCreator.AutoCreator(mapSize, this);
 }
Ejemplo n.º 16
0
        static void Main ( string[] args )
        {
            LListDefinition<int> list = new LListDefinition<int>();
            list.Add(5);
            list.Add(6);
            list.Add(7);
            list[1] = 5;
            if(!list.InsertAfter(5 , 9))
            {
                Console.WriteLine("Invalid operation!");
            }
            if(!list.InsertAfter(5 , 10))
            {
                Console.WriteLine("Invalid!");
            }
            else if(!list.InsertAt(3 , 8))
            {
                Console.WriteLine("Invalid");
            }
            else if(!list.InsertBefore(5 , 10))
            {
                Console.WriteLine("Invalid!");
            }
            else if(!list.Remove(10))
            {
                Console.WriteLine("Invalid!");
            }
            else
            {
                Console.WriteLine("Great!");
            }
            foreach(var item in list)
            {
                Console.Write(item);
            }
            Console.WriteLine();
            Console.WriteLine();
            var list1 = new LListDefinition<string>();
            list1.Add("x");
            list1.Add("g");
            list1.Add("s");

            Console.WriteLine(list.Counter); //output: 3

            list1.InsertAfter("g" , "a");
            list1.InsertAt(10 , "z"); //throws an exception - IndexOutOfRangeException
            list1.InsertAt(2 , "z");
            list1.Remove("z");
            list1[1] = "m";

            foreach(var value in list1)
            {
                Console.WriteLine(value);
            }

            Map<int , string> m = new Map<int , string>();
            m.Add(8 , "eight");
            m.Add(9 , "nine");
            m.Add(11 , "eleven");
            m[7] = "seven";
            m[10] = "ten";
            m[12] = "twelve";
            m[3] = "three";
            m[4] = "four";
            m[5] = "five";
            m[6] = "six";
            m[69] = "sex";
            m[70] = "seventy";
            Console.WriteLine(m.Keys.Count);
            Console.WriteLine(m.Keys.Capacity);
            Console.WriteLine(m.ContainsKey(7));
            Console.WriteLine(m.ContainsKey(1));
            Console.WriteLine(m.ContainsValue("ten"));
            Console.WriteLine(m.ContainsValue("pen"));
            m.Remove(8);
            Console.WriteLine(m.ContainsKey(8));
            m.Clear();
            Console.ReadKey();
        }
Ejemplo n.º 17
0
 public StraightPathGenerator(int seed, Map.Map map) : base(map)
 {
     Random = new Random(seed);
 }
Ejemplo n.º 18
0
 public bool DrawMarker(Map.Marker marker, float angle = 0f, float scale = 1f)
 {
     Vector2 center = new Vector2(Screen.width / 2f, Screen.height / 2f) + Position * Zoom;
     Vector2 wholeSize = new Vector2(Screen.width, Screen.height) * Zoom;
     Vector2 mapPos = WorldToMap(marker.WorldPosition);
     mapPos.x *= wholeSize.x;
     mapPos.y *= wholeSize.y;
     float markerSize = GetMarkerSize() * scale;
     Rect texCoords = GetTextureCoords(marker.Class.Texture);
     Vector2 mPos = new Vector2(center.x + mapPos.x, center.y + mapPos.y);
     Rect markerRect = new Rect(mPos.x - markerSize / 2f, mPos.y - markerSize / 2f, markerSize, markerSize);
     GUI.color = marker.Class.Color;
     if (angle != 0f)
     {
         Matrix4x4 bkpMatrix = GUI.matrix;
         GUIUtility.RotateAroundPivot(180f + TheForest.Utils.LocalPlayer.Transform.rotation.eulerAngles.y, mPos);
         GUI.DrawTextureWithTexCoords(markerRect, Markers, texCoords);
         GUI.matrix = bkpMatrix;
     }
     else
     {
         GUI.DrawTextureWithTexCoords(markerRect, Markers, texCoords);
     }
     GUI.color = Color.white;
     return markerRect.Contains(Event.current.mousePosition);
 }
Ejemplo n.º 19
0
 public TongueExplorer(Map.Map map, List <ILocationListener> listeners)
     : base(map, listeners)
 {
 }
Ejemplo n.º 20
0
 public SimpleGenerator(Map.Map map) : base(map)
 {
 }
Ejemplo n.º 21
0
 public override Decision Think(Map map)
 {
     return (Decision)(rnd.Next(5));
 }
Ejemplo n.º 22
0
 public void DisplayMenu(Map map, string str)
 {
     Console.SetCursorPosition(0, map.MapSize);
     Console.ForegroundColor = ConsoleColor.White;
     Console.WriteLine(str);
 }
Ejemplo n.º 23
0
        void Start()
        {
            try
            {
                Categories = new Dictionary<string, MarkerCategory>();
                foreach (MarkerSetting setting in markerSettings.Values)
                {
                    if (!Categories.ContainsKey(setting.Category))
                    {
                        Categories.Add(setting.Category, new MarkerCategory());
                        Categories[setting.Category].Color = setting.Color;
                    }
                    Categories[setting.Category].Markers.Add(setting);
                }
                
                playerMarker = new Map.Marker()
                {
                    Class = new MarkerSetting()
                    {
                        ID = "Player",
                        Color = Color.white,
                        Label = "You",
                        Texture = 31,
                        Category = "Player"
                    },
                    Description = "You",
                    WorldPosition = Vector3.zero,
                };

                Markers = ModAPI.Resources.GetTexture("Markers.png");
                background = new Texture2D(2, 2);
                background.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.7f));
                background.SetPixel(1, 0, new Color(0f, 0f, 0f, 0.7f));
                background.SetPixel(0, 1, new Color(0f, 0f, 0f, 0.7f));
                background.SetPixel(1, 1, new Color(0f, 0f, 0f, 0.7f));
                background.filterMode = FilterMode.Point;
                background.Apply();

                foreground = new Texture2D(2, 2);
                foreground.SetPixel(0, 0, new Color(1f, 1f, 1f, 1f));
                foreground.SetPixel(1, 0, new Color(1f, 1f, 1f, 1f));
                foreground.SetPixel(0, 1, new Color(1f, 1f, 1f, 1f));
                foreground.SetPixel(1, 1, new Color(1f, 1f, 1f, 1f));
                foreground.filterMode = FilterMode.Point;
                foreground.Apply();

                WhiteLabel = new GUIStyle(ModAPI.GUI.Skin.label);
                WhiteLabel.normal.textColor = Color.white;

                Overworld = new Map("http://theforestmap.com/map/map-4096.jpg", "http://theforestmap.com/map/md5.php?map=forest", "http://theforestmap.com/inc/api/?json&map=forest", "Mods/Map/Cache/Overworld/map.jpg");
                Underworld = new Map("http://theforestmap.com/map/cave-4096.jpg", "http://theforestmap.com/map/md5.php?map=cave", "http://theforestmap.com/inc/api/?json&map=cave", "Mods/Map/Cache/Underworld/map.jpg");
            }
            catch (Exception e)
            {
                ModAPI.Log.Write(e.ToString());
            }
        }
Ejemplo n.º 24
0
 void Update()
 {
     try
     {
         Overworld.Update();
         Underworld.Update();
         if (ModAPI.Input.GetButtonDown("OpenMap"))
         {
             if (TheForest.Utils.Scene.Atmosphere.InACave)
                 currentMap = Underworld;
             else
                 currentMap = Overworld;
             Opened = !Opened;
             ShowPhase = 0f;
             //Zoom = 1f;
             //Position = Vector2.zero;
         }
         if (Opened)
         {
             if (currentMap.TexturesLoaded)
             {
                 if (ShowPhase < 1f)
                     ShowPhase += Time.unscaledDeltaTime;
             }
             TheForest.Utils.LocalPlayer.FpCharacter.LockView();
         }
         else
         {
             if (visible)
                 TheForest.Utils.LocalPlayer.FpCharacter.UnLockView();
         }
         this.visible = this.Opened;
     }
     catch (Exception e)
     {
         ModAPI.Log.Write(e.ToString());
     }
 }
Ejemplo n.º 25
0
 public MapRenderer(Map map, int x, int y)
 {
     Console.Title = "Map";
     Console.Clear();
     this.DisplayMap(map);
 }
Ejemplo n.º 26
0
 public Explorer(Map.Map map, List <ILocationListener> listeners)
 {
     Map  = map;
     Path = new Path(listeners);
     Go(0, 0);
 }