Exemplo n.º 1
0
        static void ChangeMap(Map map)
        {
            if (MapList == null)
            {
                MapList = new List <Map>();
            }
            switch (map.ChangeType)
            {
            case (int)ChangeMapType.新增:
                MapList.Add(map);
                break;

            case (int)ChangeMapType.修改:
                var item = MapList.Find(c => c.id == map.id);
                if (item != null)
                {
                    item = map;
                }
                else
                {
                    MapList.Add(map);
                }
                break;

            case (int)ChangeMapType.除:
                MapList.RemoveAll(c => c.id == map.id);
                break;
            }
            HandleLog.WriteLine($"映射{Enum.GetName(typeof(ChangeMapType), map.ChangeType)}成功:{JsonHelper.Instance.Serialize(map)}", false);
            HandleLog.WriteLine($"【{map.name}】映射{Enum.GetName(typeof(ChangeMapType), map.ChangeType)}成功:{map.local} --> {map.remote}");
        }
Exemplo n.º 2
0
 public bool PlaceCell(int row, int col)
 {
     if (MapList.Count(c => c == CellType._AVAILABLE) == 0)
     {
         return(false);
     }
     if (row == picked.Row && col == picked.Col)
     {
         return(false);
     }
     if (Map[row, col] == CellType._AVAILABLE)
     {
         Map[row, col] = picked.Type;
         if (picked.Type == CellType.RED_ && row == 0)
         {
             Map[row, col] = CellType.RED_K;
         }
         if (picked.Type == CellType.BLACK_ && row == 7)
         {
             Map[row, col] = CellType.BLACK_K;
         }
         Map[picked.Row, picked.Col] = CellType._EMPTY;
         curr = CellType._NONE;
         ResetPick();
         if (Hit(row, col))
         {
             TryPickAgain(row, col);
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
        public MapList<ComplexTerrainEntity> GenerateMap()
        {
            int length = 10;
            int width = 10;

            MapList<ComplexTerrainEntity> result = new MapList<ComplexTerrainEntity>(length, width);

            int x = 0;
            int y = 0;

            while (x < length)
            {
                while (y < width)
                {
                    result.Put(GenerateEntity(result, x, y), x, y);

                    y++;
                }

                y = 0;

                x++;
            }

            Genero.Entities.MetaEntities.RoomMeta RoomGenerator = new Entities.MetaEntities.RoomMeta(5, 5);

            MapList<ComplexTerrainEntity> Room = RoomGenerator.Generate(_content);

            result.Put(Room, 3, 3);

            return result;
        }
Exemplo n.º 4
0
        static void ChangeMapList(Map map)
        {
            try
            {
                switch (map.ChangeType)
                {
                case (int)ChangeMapType.新增:
                    MapList.Add(map);
                    break;

                case (int)ChangeMapType.修改:
                    MapList.RemoveAll(c => c.id == map.id);
                    MapList.Add(map);
                    break;

                case (int)ChangeMapType.除:
                    MapList.RemoveAll(c => c.id == map.id);
                    break;
                }
                HandleLog.WriteLine($"服务映射缓存{Enum.GetName(typeof(ChangeMapType), map.ChangeType)}成功:{JsonHelper.Instance.Serialize(map)}", false);
                HandleLog.WriteLine($"【{map.name}】服务映射缓存{Enum.GetName(typeof(ChangeMapType), map.ChangeType)}成功:{map.local_endpoint} --> {map.remote_endpoint}");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
        public void Start()
        {
            Instance     = this;
            AsyncTasks   = new Queue <Action>(300);
            FrameActions = new MapList <Action>(300);

            Config.InitConfig();
            DataService.LoadData();
            TextureService.LoadTextures();
            DeckService.LoadForbiddenLists();

            imgSelector    = new Lazy <ImageSelector>();
            tglSelector    = new Lazy <ToggleSelector>();
            confirmWindow  = new Lazy <ConfirmWindow>();
            annWindow      = new Lazy <AnnounceWindow>();
            opSelector     = new Lazy <OptionSelector>();
            inputBox       = new Lazy <InputBox>();
            hint           = new Lazy <HintBox>();
            lazyDescriptor = new Lazy <CardDescriptor>();
            lazyChat       = new Lazy <ChatWindow>();

            ToolStrip    = new ToolStrip();
            DuelWindow   = new DuelWindow();
            DeckBuilder  = new DeckBuilder();
            RoomWindow   = new RoomWindow();
            Menu         = new MainMenu();
            ConfigWindow = new ConfigWindow();
            ServerWindow = new ServerWindow();

            Field = new Field();
            Duel  = new ClientDuel();

            Menu.Show();
        }
Exemplo n.º 6
0
        private static void ChangeMapList(Map map)
        {
            try
            {
                switch (map.ChangeType)
                {
                case (int)ChangeMapType.新增:
                    MapList.Add(map);
                    break;

                case (int)ChangeMapType.修改:
                    MapList.RemoveAll(c => c.id == map.id);
                    MapList.Add(map);
                    break;

                case (int)ChangeMapType.除:
                    MapList.RemoveAll(c => c.id == map.id);
                    break;
                }
                LogHelper.Info($"服务映射缓存{Enum.GetName(typeof(ChangeMapType), map.ChangeType)}成功:{map.ToJson()}", false);
                LogHelper.Info($"【{map.name}】服务映射缓存{Enum.GetName(typeof(ChangeMapType), map.ChangeType)}成功:{map.local_endpoint} --> {map.remote_endpoint}");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 7
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var minimal = AppSettings.Default.Interface.MinimalMode;

            if (minimal != _minimal)
            {
                if (minimal)
                {
                    MapCardList.ItemsSource = null;
                    MapList.SetBinding(ItemsControl.ItemsSourceProperty, _sourceBinding);
                    MapCardList.Visibility = Visibility.Collapsed;
                    MapList.Visibility     = Visibility.Visible;
                }
                else
                {
                    MapList.ItemsSource = null;
                    MapCardList.SetBinding(ItemsControl.ItemsSourceProperty, _sourceBinding);
                    MapList.Visibility     = Visibility.Collapsed;
                    MapCardList.Visibility = Visibility.Visible;
                }

                _minimal = minimal;
            }

            var item = ViewModel.DataList?.FirstOrDefault(k =>
                                                          k.Model.Id.Equals(_controller.PlayList.CurrentInfo?.Beatmap?.Id)
                                                          );

            if (item != null)
            {
                MapList.SelectedItem = item;
            }
        }
Exemplo n.º 8
0
 public static void Stop()
 {
     NATServer?.Stop();
     HttpServerList.ForEach(c => c.Stop());
     TcpServerList.ForEach(c => c.Stop());
     MapList.Clear();
 }
Exemplo n.º 9
0
 public void Init(int port)
 {
     Debuger.Log("port:{0}", port);
     m_port       = port;
     m_mapSession = new MapList <uint, FSPSession>();
     Start();
 }
Exemplo n.º 10
0
        private void GeneratePlace_Click(object sender, EventArgs e)
        {
            Place.ForeColor = Color.Black;
            int cnt = 0;

            for (int i = 0; i <= (MapListBox.Items.Count - 1); i++)
            {
                if (MapListBox.GetItemChecked(i))
                {
                    cnt = (i + 1);
                }
            }
            if (cnt >= 2)
            {
                for (i = 0; i <= (MapListBox.Items.Count - 1); i++)
                {
                    if (MapListBox.GetItemChecked(i))
                    {
                        MapList.Add(MapListBox.Items[i].ToString());
                    }
                }
                result = Convert.ToString((string)MapList[random.Next(0, MapList.Count)]);
                DesidePlace.Start();
            }
            else
            {
                MessageBox.Show("2つ以上の選択が必要", "Error");
            }
        }
Exemplo n.º 11
0
        public Field()
        {
            cardPool        = new ObjectPool <ClientCard>();
            chainPool       = new ObjectPool <Chain>();
            activeCards     = new List <ClientCard>();
            sequencePointer = new Dictionary <int, ClientCard>();

            HandCards = new List <ClientCard>[]
            {
                new List <ClientCard>(),
                new List <ClientCard>(),
            };
            CurrentChains    = new List <Chain>();
            InteractiveCards = new MapList <ClientCard>();

            inertiaTransform          = new GameObject().transform;
            inertiaTransform.name     = "InertiaSlider";
            inertiaTransform.position = Vector3.zero;
            orginalChildCount         = 0;
            spreadingTranforms        = new Dictionary <Transform, ClientCard>();
            SelectableCards           = new List <ClientCard>();
            SelectedCards             = new List <ClientCard>();
            sumAssist   = new List <int>(256);
            fieldObject = null;
        }
Exemplo n.º 12
0
        private void ButtonDeleteMap_Click(object sender, EventArgs e)
        {
            if (MapIndex == -1)
            {
                return;
            }

            string Name          = MapList[MapIndex].name + "?";
            var    confirmResult = MessageBox.Show(Parent, deleteText + Name, "Delete " + Name, MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                MapList.RemoveAt(MapIndex);
                listViewMap.Items.RemoveAt(MapIndex);
                if (MapList.Count >= 1)
                {
                    listViewMap.Items[MapList.Count - 1].Selected = true;
                }
                else
                {
                    MapIndex = -1;
                }

                listViewLayers.Clear();
                ed.Draw();
            }
        }
Exemplo n.º 13
0
 public void BuildObject(ijsonEvent2 evt)
 {
     if (evt.Type == ijsonTokenType.MapKey)
     {
         ((MapList)Container.Peek().Target).MapKey = evt.Value.ToString();
     }
     else if (evt.Type == ijsonTokenType.StartMap)
     {
         var mapList = new MapList();
         Container.Peek()(ValueType.MapList, mapList);
         Container.Push(new ItemSetter(mapList.MapItemSetter));
     }
     else if (evt.Type == ijsonTokenType.StartArray)
     {
         var arrList = new ArrayList();
         Container.Peek()(ValueType.ArrayList, arrList);
         Container.Push(new ItemSetter(arrList.ArrayItemSetter));
     }
     else if (evt.Type == ijsonTokenType.EndMap || evt.Type == ijsonTokenType.EndArray)
     {
         Container.Pop();
     }
     else
     {
         Container.Peek()((ValueType)Enum.Parse(typeof(ValueType), evt.Type.ToString()), evt.Value);
     }
 }
Exemplo n.º 14
0
    public void LoadNextLevel()
    {
        EndLevel();

        if (m_currentMapIdx < MapList.Count - 1)
        {
            ++m_currentMapIdx;
        }
        else
        {
            DialogsController.GetInstance().ShowDialog(DialogType.MapSelectorMenu);
            return;
        }

        var mapPahs = MapList.GetMapPaths(m_currentMapIdx);

        if (mapPahs == null)
        {
            return;
        }

        ResetTempMapData();
        MapInfo map_info = (mapPahs.GetMapPrefab()).GetComponent <MapInfo>();

        map_info.m_mapName = mapPahs.Name;
        map_info.m_mapIcon = mapPahs.GetMapIcon();
        GameProgress.SetMap(m_currentMapIdx, false);

        DialogsController.GetInstance().ShowMapDescriptionMenu(m_currentMapIdx);
    }
Exemplo n.º 15
0
 public void Init(ISkillContext context)
 {
     this.mContext = context;
     buffMap       = new MapList <int, IBuff>();
     stateMap      = new Dictionary <int, int>();
     buffTimerMap  = new Dictionary <int, Queue <int> >();
     timerService  = ServiceLocate.Instance.GetService <TimerService>();
 }
Exemplo n.º 16
0
 public ServiceLocate(IFacade facade)
 {
     _facade = facade;
     if (_map == null)
     {
         _map = new MapList <Type, IService>();
     }
 }
Exemplo n.º 17
0
 public void ObjectFilter(IRunAsChain SelChain)
 {
     MapList.Clear();
     foreach (var ch in SelChain.Chain)
     {
         MapList.Add(ch);
     }
     ObjectFilter(MapList[0]);
 }
Exemplo n.º 18
0
        private void ButtonNewMap_Click(object sender, EventArgs e)
        {
            MapList.Add(new Map("Map " + ++MapCount));
            listViewMap.Items.Add("Map " + MapCount);

            SetMap setMap = new SetMap(this);

            setMap.ShowDialog();
        }
Exemplo n.º 19
0
        private MapSettings()
        {
            InitList();
            Load();
            InitDict();
            Configuration.OnSaveAll += (sender, args) => { Save(); };

            MapList = MapList.OrderByDescending(m => m.Priority).ToList();
        }
Exemplo n.º 20
0
 public void Init(int port)
 {
     Debuger.Log("port:{0}", port);
     m_gateway = new FSPGateway();
     m_gateway.Init(port);
     m_param.port = m_gateway.Port;
     m_param.host = m_gateway.Host;
     m_mapGame    = new MapList <uint, FSPGame>();
 }
Exemplo n.º 21
0
        public void Init(int port, ISessionListener listener)
        {
            Debuger.Log("port:{0}", port);
            m_port       = port;
            m_listener   = listener;
            m_mapSession = new MapList <uint, ISession>();

            Start();
        }
Exemplo n.º 22
0
    public static void SetStartupScene(string mapName)
    {
        MapList    mapList   = AssetDatabase.LoadAssetAtPath <MapList>("Assets/Resources/Configs/MapList.asset");
        string     mapPath   = "Assets/Prefabs/Maps/" + mapName + ".prefab";
        GameObject mapPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(mapPath);

        mapList.TestMap = mapPrefab.GetComponent <BaseMap>();
        EditorUtility.SetDirty(mapList);
        AssetDatabase.SaveAssets();
    }
Exemplo n.º 23
0
        public RoomMeta(int width, int height)
        {
            _width = width;
            _height = height;

            _floorFactory = CaveFloorTextureFactory.Instance;
            _random = RandomFactory.Instance;

            _map = new MapList<ComplexTerrainEntity>(_width, _height);
        }
Exemplo n.º 24
0
 public static void UpdateMapList()
 {
     MapList.Clear();
     foreach (string file in Directory.GetFiles("Content/Map"))
     {
         //string s = TexturePath + "/" + Path.GetFileName(dir) + "/" + Path.GetFileNameWithoutExtension(file);
         //Textures.Add(Path.GetFileNameWithoutExtension(file), Content.Load<Texture2D>(s));
         MapList.Add(Path.GetFileNameWithoutExtension(file));
     }
 }
Exemplo n.º 25
0
        public void Init(ServerContext context)
        {
            m_net = context.net;
            m_net.SetAuthCmd(ProtoCmd.LoginReq);
            m_net.AddListener <LoginReq>(ProtoCmd.LoginReq, OnLoginReq);
            m_net.AddListener <HeartBeatReq>(ProtoCmd.HeartBeatReq, OnHeartBeatReq);
            m_net.RegisterRPCListener(this);

            m_mapUserData = new MapList <uint, UserData>();
        }
Exemplo n.º 26
0
        public static Project CreateNewProject(string ProjectPath, string ProjectName, Dictionary <string, string> FilesToAdd, string ProjectMap = null)
        {
            try
            {
                Project newproj = new Project();
                newproj.ProjectName = ProjectName;
                newproj.SetLocation(ProjectPath);

                MapList MapList = MapList.GetByName(ProjectMap);

                if (MapList.MapFiles != null)
                {
                    foreach (MapFile file in MapList.MapFiles)
                    {
                        FilesToAdd.Add(file.FileName, file.LocalFileName);
                    }
                }

                foreach (KeyValuePair <string, string> Entry in FilesToAdd)
                {
                    try
                    {
                        ProjectMeta meta = new ProjectMeta(newproj, Entry.Key);

                        string path = Path.Combine(newproj.GetSourceDirectory(), Entry.Key);
                        string p    = Path.GetDirectoryName(path);

                        if (!Directory.Exists(p))
                        {
                            Directory.CreateDirectory(p);
                        }

                        File.WriteAllText(path, meta.ParseFileContents(File.ReadAllText(Entry.Value)));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Configuration.DEBUGMODE ? ex.ToString() : ex.Message);
                    }
                }

                ProjectManager.SaveProject(ProjectPath, newproj);

                Properties.Settings.Default.ProjectLocations.Add(ProjectPath);
                Properties.Settings.Default["CurrentOpenProject"] = ProjectPath;
                Properties.Settings.Default.Save();

                return(newproj);
            }
            catch (Exception ex)
            {
                MessageBox.Show(Configuration.DEBUGMODE ? ex.ToString() : ex.Message);
                return(null);
            }
        }
Exemplo n.º 27
0
 public static Terrain GetCurrentMap(int level)
 {
     if (MapList.TryGetValue(level, out Terrain foundTerrain))
     {
         return(foundTerrain);
     }
     else
     {
         throw new Exception("Failed to locate the current level in the TerrainManager!");
     }
 }
Exemplo n.º 28
0
 public static Point GetMapSize(int level)
 {
     if (MapList.TryGetValue(level, out Terrain foundTerrain))
     {
         return(foundTerrain.MapSize);
     }
     else
     {
         throw new Exception("Failed to retrieve the mapsize for level " + level + "!");
     }
 }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            MapList mapList = new MapList();

            mapList.Add(3, "Fuzz");
            mapList.Add(5, "Buzz");

            foreach (string s in NumberList.GetNameNumberList(20, mapList))
            {
                Console.WriteLine(s);
            }
        }
        /*
         * Retrives the 2-n pages of a Google Maps Engine project request
         */
        private List <Map> getMapsByProjectId(Extension.Auth.OAuth2Token token, string projectId, string nextPageToken)
        {
            // create a new blank list of maps
            log.Debug("Creating a blank set of maps.");
            List <Map> maps = new List <Map>();

            // build the request url to the GME API
            log.Debug("Building the Google Maps Engine API request URL.");
            string apiRequestUrl = GME_API_PROTOCOL
                                   + "://" + GME_API_DOMAIN
                                   + "/" + GME_API_SERVICE
                                   + "/" + GME_API_VERSION
                                   + "/" + "maps"
                                   + "?" + "key=" + GOOGLE_API_KEY
                                   + "&" + "projectId=" + projectId
                                   + "&" + "pageToken=" + nextPageToken;

            log.Debug("Request Url: " + apiRequestUrl);

            // attempt to make the request to the Google Maps Engine API
            try
            {
                // make the Google Maps Engine Request
                log.Debug("Making the Google Maps Engine Request.");
                String jsonResponse = makeGoogleMapsEngineRequest(apiRequestUrl, token.access_token);

                // Deserialize the Json object into a maps list object
                log.Debug("Deserializing the Json response from the API into a MapList object.");
                MapList mapsList = JsonConvert.DeserializeObject <MapList>(jsonResponse);

                // add the maps to the list
                log.Debug("Adding the maps to the maps list.");
                maps.AddRange(mapsList.maps);

                // determine if there is a next page
                log.Debug("Determining if there is a next page.");
                if (mapsList.nextPageToken != null && mapsList.nextPageToken.Length > 0)
                {
                    // a next page token does exist, fetch it and add it to the list
                    log.Debug("Next page exists, fetching next page.");
                    maps.AddRange(getMapsByProjectId(token, projectId, mapsList.nextPageToken));
                }
            }
            catch (System.Exception ex)
            {
                // an exception has occured, log and throw
                log.Error(ex);
                throw new System.Exception(Properties.Resources.GoogleMapsEngineAPI_getMaps_unknownexception);
            }

            // return the maps list
            return(maps);
        }
Exemplo n.º 31
0
 private void Awake()
 {
     mapLists = new List <MapList>();
     for (int i = 0; i < mapHeightSize; i++)
     {
         MapList list = new MapList();
         mapLists.Add(list);
         mapLists[i].nodes = new List <MapNode>();
     }
     path = new List <MapNode>();
     initiateMapData();
 }
        //Add map name to list
        private void AddMapButton_Click(object sender, RoutedEventArgs e)
        {
            if (_maps.Contains(MapsBox.Text))
            {
                return;
            }

            _maps.Add(MapsBox.Text);
            MapList.Items.Refresh();
            MapList.SelectedIndex = MapList.Items.Count - 1;
            MapList.ScrollIntoView(MapList.SelectedItem);
        }
Exemplo n.º 33
0
    public static void TestCount()
    {
      for (var i = 0; i < 100; i++)
      {
        var x = MonteCarlo.Unordered().ToList();

        var mapped = new MapList<int, int>(Mod3, x);

        Console.WriteLine("   {0}", x.ToCSV(100));
        Console.WriteLine(" = {0}", mapped);
        Console.WriteLine();

        Assert.That(mapped.Count, Is.EqualTo(x.Count));
      }
    }
Exemplo n.º 34
0
    public static void TestIndexer()
    {
      for (var i = 0; i < 100; i++)
      {
        var x = MonteCarlo.Unordered().ToList();

        var mapped = new MapList<int, int>(Mod3, x);

        Console.WriteLine("   {0}", x.ToCSV(100));
        Console.WriteLine(" = {0}", mapped);
        Console.WriteLine();

        for (var j = 0; j < x.Count; j++)
          Assert.That(mapped[j], Is.EqualTo(Mod3(x[j])));
      }
    }
Exemplo n.º 35
0
        /**
         * Load the map data into memory for faster load time.
         */
        public static void load() {
            Console.WriteLine("Loading mapdata definitions. This is slow too much I/O maybe pack in XML? :P");
            if (!Directory.Exists(misc.getServerPath() + @"\data\mapdata\"))
            {
                misc.WriteError(@"mapdata directory not found, data\mapdata directory doesn't exist.");
                return;
            }

            int curId = 0;
            for (int i = 0; i < 16000; i++)
            {
                if(!File.Exists(misc.getServerPath() + @"\data\mapdata\" + i + ".txt")) 
                    continue;

                MapList list = mapLists[curId++] = new MapList();
                try
                {
                    using (StreamReader sr = new StreamReader(misc.getServerPath() + @"\data\mapdata\" + i + ".txt"))
                    {
                        string line;
                        // Read and display lines from the file until the end of 
                        // the file is reached.
                        int regionId = 0;
                        list.region = i;

                        while ((line = sr.ReadLine()) != null)
                        {
                            if (!line.Equals(""))
                                list.data[regionId++] = int.Parse(line.Trim());
                        }
                    }
                }
                catch (Exception)
                {
                    // Let the user know what went wrong.
                    misc.WriteError("[MapData]: map region " + i + " was not found!");
                }
            }
            Console.WriteLine("Loaded " + curId + " MapData.");
        }
Exemplo n.º 36
0
        /// <summary>
        /// Filters the log file based on <see cref="shipLoc"/> and the sector range listed in <see cref="textRange.Text"/>.</summary>
        /// Range calculation is simplified into a box shape for speed; min and max sector values are calculated for all three axis and the Map Log coordinates are kept if they fit in this box.
        private bool filterLog()
        {
            // Temporary storage for the new contents of the log file
            MapList tempLog = new MapList ();
            int range = MapPoint.intParse (txtRange.Text);
            // calculate sector ranges (+1 to make the range inclusive)
            int xmin = (int)shipLoc [0] - (range + 1);
            int xmax = (int)shipLoc [0] + (range + 1);
            int ymin = (int)shipLoc [1] - (range + 1);
            int ymax = (int)shipLoc [1] + (range + 1);
            int zmin = (int)shipLoc [2] - (range + 1);
            int zmax = (int)shipLoc [2] + (range + 1);

            // search for Map Log entries that are within the specified range
            foreach (MapPoint point in lstMasterLog) {
                if (point.sx > xmin && point.sx < xmax &&
                    point.sy > ymin && point.sy < ymax &&
                    point.sz > zmin && point.sz < zmax) {
                    tempLog.Add (point);
                }
            }

            // sort the new list, if desired
            if (chkSort.Active && sortNeeded) {
                tempLog.Sort (sorter);
                sortNeeded = false;
            }

            // convert the new list into a string before opening the file for write (minimize the time the file is open)
            string tempLogText = tempLog.ToString();
            // Replace the Map Log with the filtered resaults
            try {
                // delete the contents of the file before re-writing it. It's the easy way to ensure the file is overwritten and not appended to.
                deleteFile(btnMapLog.Label);
                using (System.IO.StreamWriter newLog = new System.IO.StreamWriter(OpenFile(btnMapLog.Label,true))) {
                    newLog.Write(tempLog.ToString());
                    newLog.Close();
                    // remember what was written
                    textMapLogFile = tempLogText;
                    // remember when the file was last written
                    lastLogged = getLastWriteTimeUTC(btnMapLog.Label);
                }
            } catch (System.ArgumentNullException) {
                // OpenFile should have already given an error message since OpenFile() returns null on error
            }
            return true;
        }
Exemplo n.º 37
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.</summary>
        public MainWindow()
            : base(Gtk.WindowType.Toplevel)
        {
            // disable event handling until everything is setup
            disableSettingsEvents = true;
            // start the program with filter/timer off
            enabled = false;
            // Will change this to true when the sort order is chosen (before anything loads is too soon)
            sortNeeded = false;

            try {
                // Create the GUI
                Build ();

                // assign text/translations to the interface text variables
                loadInterfaceText ();

                // find the translation options
                loadLanguages();

                // list of the directories to search for the files in
                // first element is the directory path
                // second element is "1" to search subdirectories, "" to search top directory
                searchFolders = new string[,] {{@"C:\",""},
                                               {@"C:\sw3dg\","1"},
                                               {@"C:\Program Files\","1"}};

                // apply text content
                setInterfaceText ();

                if (System.IO.File.Exists("ErrorLog.txt")) {
                    MsgBox(textErrorLogFound,0);
                }

                // setup the clock
                clock = new System.Timers.Timer ();
                clock.Elapsed += new System.Timers.ElapsedEventHandler (OnTimedEvent);
                clock.AutoReset = true;
                clock.Enabled = false;

                // initialize the list to store all the Log entries in
                lstMasterLog = new MapList();
                // make sure shipLoc isn't null
                shipLoc = new int[0];

                // load settings, but if that fails search for the files
                if (!loadSettings ()) {
                    this.Title = textWaitSearching;
                    // look for savedata.txt for tracking info
                        string filepath = findEvochronFile ("savedata.txt");
                        if (!filepath.Equals ("")) {
                            btnSaveData.Label = filepath;
                    }
                    // get the current system's language
                        string temp = System.Globalization.CultureInfo.InstalledUICulture.NativeName.ToLower();
                        if (temp.Contains("(")) {
                            temp = temp.Substring(0, temp.IndexOf("(") - 1).Trim();
                    }
                        setLanguage(temp);
                    this.Title = textWaitSearching;
                    // look for savedatasettings.txt in order to preset cycle timing
                        pathSaveDataSettings = findEvochronFile ("SaveDataSettings.txt");
                    // get the update interval for savedata.txt
                        if (!pathSaveDataSettings.Equals ("")) {
                            try {
                                using (System.IO.StreamReader sr = new System.IO.StreamReader (OpenFile (pathSaveDataSettings, false))) {
                                    int txt = MapPoint.intParse (readLine(sr,pathSaveDataSettings), true);
                                    cycletxt = txtCycle.Text = ((txt / 1000) * 4).ToString (); // default to x4 of the rate savedata.txt is updated at
                                    setClock ();
                                    sr.Close ();
                            }
                        } catch (System.ArgumentNullException) {
                                // OpenFile should have already given an error message since OpenFile returns null on error
                        }
                    }

                    this.Title = textWindowTitle;
            //					writeSettings ();
                }
                disableSettingsEvents = false;
            //				// Setup the master log
            //				if (btnMapLog.Label.Equals("(None)")) {
            //					loadLogs ();
            //				}
            } catch (System.Exception ex) {
                // ideally this code will never execute, but it's here in case bad stuff happens.
                UnHandledError (ex);
            }
        }
Exemplo n.º 38
0
        private ComplexTerrainEntity GenerateEntity(MapList<ComplexTerrainEntity> map, int x, int y)
        {
            float _x = x * 50;
            float _y = y * 50;

            Vector2 position = new Vector2(_x, _y);
            Texture2D texture;

            #region "neighbor Entities"
            Dictionary<DirectionTypes, ComplexTerrainEntity> neighbors = new Dictionary<DirectionTypes, ComplexTerrainEntity>();

            neighbors.Add(DirectionTypes.Bottom, map.Get(x + 1, y));
            neighbors.Add(DirectionTypes.BottomLeft, map.Get(x + 1, y - 1));
            neighbors.Add(DirectionTypes.BottomRight, map.Get(x + 1, y + 1));
            neighbors.Add(DirectionTypes.Center, map.Get(x, y));
            neighbors.Add(DirectionTypes.Left, map.Get(x, y - 1));
            neighbors.Add(DirectionTypes.Right, map.Get(x, y + 1));
            neighbors.Add(DirectionTypes.Top, map.Get(x - 1, y));
            neighbors.Add(DirectionTypes.TopLeft, map.Get(x - 1, y - 1));
            neighbors.Add(DirectionTypes.TopRight, map.Get(x - 1, y + 1));
            #endregion

            #region "optionsLeft"
            //List<DirectionTypes> optionsLeft = new List<DirectionTypes>
            //{
            //    DirectionTypes.Bottom,
            //    DirectionTypes.BottomLeft,
            //    DirectionTypes.BottomRight,
            //    DirectionTypes.Center,
            //    DirectionTypes.Left,
            //    DirectionTypes.Right,
            //    DirectionTypes.Top,
            //    DirectionTypes.TopLeft,
            //    DirectionTypes.TopRight
            //};

            Dictionary<DirectionTypes, bool> optionsLeft = new Dictionary<DirectionTypes, bool>();
            optionsLeft.Add(DirectionTypes.Bottom, true);
            optionsLeft.Add(DirectionTypes.BottomLeft, true);
            optionsLeft.Add(DirectionTypes.BottomRight, true);
            optionsLeft.Add(DirectionTypes.Center, true);
            optionsLeft.Add(DirectionTypes.Left, true);
            optionsLeft.Add(DirectionTypes.Right, true);
            optionsLeft.Add(DirectionTypes.Top, true);
            optionsLeft.Add(DirectionTypes.TopLeft, true);
            optionsLeft.Add(DirectionTypes.TopRight, true);
            #endregion

            // True means that it collides on this side
            #region "neighborCollisionMap"
            Dictionary<DirectionTypes, bool> neighborCollisionMap = new Dictionary<DirectionTypes, bool>();
            neighborCollisionMap.Add(DirectionTypes.Bottom, false);
            neighborCollisionMap.Add(DirectionTypes.BottomLeft, false);
            neighborCollisionMap.Add(DirectionTypes.BottomRight, false);
            neighborCollisionMap.Add(DirectionTypes.Center, false);
            neighborCollisionMap.Add(DirectionTypes.Left, false);
            neighborCollisionMap.Add(DirectionTypes.Right, false);
            neighborCollisionMap.Add(DirectionTypes.Top, false);
            neighborCollisionMap.Add(DirectionTypes.TopLeft, false);
            neighborCollisionMap.Add(DirectionTypes.TopRight, false);

            neighborCollisionMap[DirectionTypes.Top] = neighbors[DirectionTypes.Top].IfActive(o => o.CollisionMap[DirectionTypes.Bottom]);
            neighborCollisionMap[DirectionTypes.TopRight] = neighbors[DirectionTypes.TopRight].IfActive(o => o.CollisionMap[DirectionTypes.BottomLeft]);
            neighborCollisionMap[DirectionTypes.Right] = neighbors[DirectionTypes.Right].IfActive(o => o.CollisionMap[DirectionTypes.Left]);
            neighborCollisionMap[DirectionTypes.BottomRight] = neighbors[DirectionTypes.BottomRight].IfActive(o => o.CollisionMap[DirectionTypes.TopLeft]);
            neighborCollisionMap[DirectionTypes.Bottom] = neighbors[DirectionTypes.Bottom].IfActive(o => o.CollisionMap[DirectionTypes.Top]);
            neighborCollisionMap[DirectionTypes.BottomLeft] = neighbors[DirectionTypes.BottomLeft].IfActive(o => o.CollisionMap[DirectionTypes.TopRight]);
            neighborCollisionMap[DirectionTypes.Left] = neighbors[DirectionTypes.Left].IfActive(o => o.CollisionMap[DirectionTypes.Right]);
            neighborCollisionMap[DirectionTypes.TopLeft] = neighbors[DirectionTypes.TopLeft].IfActive(o => o.CollisionMap[DirectionTypes.BottomRight]);
            #endregion

            // True means that it needs to be connected on this side
            #region "neighborEdgeMap"
            Dictionary<DirectionTypes, bool> neighborEdgeMap = new Dictionary<DirectionTypes, bool>();
            neighborEdgeMap.Add(DirectionTypes.Bottom, false);
            neighborEdgeMap.Add(DirectionTypes.BottomLeft, false);
            neighborEdgeMap.Add(DirectionTypes.BottomRight, false);
            neighborEdgeMap.Add(DirectionTypes.Center, false);
            neighborEdgeMap.Add(DirectionTypes.Left, false);
            neighborEdgeMap.Add(DirectionTypes.Right, false);
            neighborEdgeMap.Add(DirectionTypes.Top, false);
            neighborEdgeMap.Add(DirectionTypes.TopLeft, false);
            neighborEdgeMap.Add(DirectionTypes.TopRight, false);

            neighborEdgeMap[DirectionTypes.Top] = neighbors[DirectionTypes.Top].IfActive(o => o.CollisionMap[DirectionTypes.Bottom]);
            neighborEdgeMap[DirectionTypes.TopRight] = neighbors[DirectionTypes.TopRight].IfActive(o => o.CollisionMap[DirectionTypes.BottomLeft]);
            neighborEdgeMap[DirectionTypes.Right] = neighbors[DirectionTypes.Right].IfActive(o => o.CollisionMap[DirectionTypes.Left]);
            neighborEdgeMap[DirectionTypes.BottomRight] = neighbors[DirectionTypes.BottomRight].IfActive(o => o.CollisionMap[DirectionTypes.TopLeft]);
            neighborEdgeMap[DirectionTypes.Bottom] = neighbors[DirectionTypes.Bottom].IfActive(o => o.CollisionMap[DirectionTypes.Top]);
            neighborEdgeMap[DirectionTypes.BottomLeft] = neighbors[DirectionTypes.BottomLeft].IfActive(o => o.CollisionMap[DirectionTypes.TopRight]);
            neighborEdgeMap[DirectionTypes.Left] = neighbors[DirectionTypes.Left].IfActive(o => o.CollisionMap[DirectionTypes.Right]);
            neighborEdgeMap[DirectionTypes.TopLeft] = neighbors[DirectionTypes.TopLeft].IfActive(o => o.CollisionMap[DirectionTypes.BottomRight]);
            #endregion

            if (neighborEdgeMap.Where(o => o.Value).Any())
            {
                optionsLeft[DirectionTypes.Center] = false;

                if (neighborEdgeMap[DirectionTypes.Right])
                {
                    switch (neighbors[DirectionTypes.Right].IfActive(o => o.FacingDirection))
                    {
                        case DirectionTypes.Bottom:
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            break;

                        case DirectionTypes.BottomLeft:
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.Top:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;
                    }
                }

                if (neighborEdgeMap[DirectionTypes.Top])
                {
                    switch (neighbors[DirectionTypes.Top].IfActive(o => o.FacingDirection))
                    {
                        case DirectionTypes.Right:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.BottomRight:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.Left:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.BottomLeft:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;
                    }
                }

                if (neighborEdgeMap[DirectionTypes.Left])
                {
                    switch (neighbors[DirectionTypes.Left].IfActive(o => o.FacingDirection))
                    {
                        case DirectionTypes.BottomRight:
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.Bottom:
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.TopRight:
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.Top:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;
                    }
                }

                if (neighborEdgeMap[DirectionTypes.Top])
                {
                    switch (neighbors[DirectionTypes.Bottom].IfActive(o => o.FacingDirection))
                    {
                        case DirectionTypes.Right:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            break;

                        case DirectionTypes.BottomRight:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.Right] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.Left:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;

                        case DirectionTypes.BottomLeft:
                            optionsLeft[DirectionTypes.Top] = false;
                            optionsLeft[DirectionTypes.TopRight] = false;
                            optionsLeft[DirectionTypes.BottomRight] = false;
                            optionsLeft[DirectionTypes.Bottom] = false;
                            optionsLeft[DirectionTypes.BottomLeft] = false;
                            optionsLeft[DirectionTypes.Left] = false;
                            optionsLeft[DirectionTypes.TopLeft] = false;
                            break;
                    }
                }
            }
            else
            {

            }

            DirectionTypes? direction = null;

            if (optionsLeft.Where(o => o.Value).Any())
            {
                while (direction.IsNull())
                {
                    int pick = _random.Next(1, 9);

                    if (optionsLeft.ElementAt(pick).Value)
                    {
                        direction = optionsLeft.ElementAt(pick).Key;
                    }
                }
            }
            else
            {
                direction = DirectionTypes.Center;
            }

            texture = _floorFactory.GetTexture(direction.Value, _content);

            ComplexTerrainEntity result = new ComplexTerrainEntity(texture, position);

            switch (direction)
            {
                case DirectionTypes.Top:
                    result.FacingDirection = DirectionTypes.Bottom;

                    result.EdgeMap[DirectionTypes.Left] = true;
                    result.EdgeMap[DirectionTypes.Right] = true;

                    break;

                case DirectionTypes.TopRight:
                    result.FacingDirection = DirectionTypes.BottomLeft;

                    result.EdgeMap[DirectionTypes.Bottom] = true;
                    result.EdgeMap[DirectionTypes.Left] = true;

                    break;

                case DirectionTypes.Right:
                    result.FacingDirection = DirectionTypes.Left;

                    result.EdgeMap[DirectionTypes.Top] = true;
                    result.EdgeMap[DirectionTypes.Bottom] = true;

                    break;

                case DirectionTypes.BottomRight:
                    result.FacingDirection = DirectionTypes.TopLeft;

                    result.EdgeMap[DirectionTypes.Left] = true;
                    result.EdgeMap[DirectionTypes.Top] = true;

                    break;

                case DirectionTypes.Bottom:
                    result.FacingDirection = DirectionTypes.Top;

                    result.EdgeMap[DirectionTypes.Left] = true;
                    result.EdgeMap[DirectionTypes.Right] = true;

                    break;

                case DirectionTypes.BottomLeft:
                    result.FacingDirection = DirectionTypes.TopRight;

                    result.EdgeMap[DirectionTypes.Top] = true;
                    result.EdgeMap[DirectionTypes.Right] = true;

                    break;

                case DirectionTypes.Left:
                    result.FacingDirection = DirectionTypes.Right;

                    result.EdgeMap[DirectionTypes.Top] = true;
                    result.EdgeMap[DirectionTypes.Bottom] = true;

                    break;

                case DirectionTypes.TopLeft:
                    result.FacingDirection = DirectionTypes.BottomRight;

                    result.EdgeMap[DirectionTypes.Bottom] = true;
                    result.EdgeMap[DirectionTypes.Right] = true;

                    break;
            }

            return result;
        }