示例#1
0
        public void LoadData()
        {
            positions = new PositionStorage();

            if (!File.Exists(filename))
            {
                //Nothing to load if file does not exist
                return;
            }
            try
            {
                string[] lines = File.ReadAllLines(filename);
                for (int i = 0; i < lines.Length; i++)
                {
                    string[] linesplit = lines[i].Split(';');
                    try
                    {
                        int[] pos = positions.StringToPos(linesplit[1]);
                        positions.Store(linesplit[0], pos[0], pos[1], pos[2]);
                    }
                    catch
                    {
                        //Skip line when read fails
                        Console.WriteLine("[WARNING] Skipping invalid entry on line {0}.", i + 1);
                    }
                }
            }
            catch
            {
                Console.WriteLine("[ERROR] StoredPositions.txt could not be read!");
            }
        }
示例#2
0
        public void OnLeave(int player)
        {
            if (m.IsBot(player))
            {
                //Don't store bot positions
                return;
            }

            //Do not save position if it is outside the map
            int x = (int)m.GetPlayerPositionX(player);
            int y = (int)m.GetPlayerPositionY(player);
            int z = (int)m.GetPlayerPositionZ(player);

            if (x > 0 && y > 0 && z > 0)
            {
                if (x < m.GetMapSizeX() && y < m.GetMapSizeY() && z < m.GetMapSizeZ())
                {
                    positions.Store(m.GetPlayerName(player), x, y, z);
                }
            }
        }
示例#3
0
        public void LoadData()
        {
            positions = new PositionStorage();

            if (!File.Exists(filename))
            {
                //Nothing to load if file does not exist
                return;
            }
            try
            {
                string[] lines = File.ReadAllLines(filename);
                for (int i = 0; i < lines.Length; i++)
                {
                    string[] linesplit = lines[i].Split(';');
                    try
                    {
                        int[] pos = positions.StringToPos(linesplit[1]);
                        positions.Store(linesplit[0], pos[0], pos[1], pos[2]);
                    }
                    catch
                    {
                        //Skip line when read fails
                        Console.WriteLine("[WARNING] Skipping invalid entry on line {0}.", i + 1);
                    }
                }
            }
            catch
            {
                Console.WriteLine("[ERROR] StoredPositions.txt could not be read!");
            }
        }