Esempio n. 1
0
 public Grid()
 {
     GridBlocks            = new GridBlockCollection(true);
     GridObjects           = new GridObjectCollection();
     GridObjectDefinitions = new GridObjectDefinitionCollection();
     Thins    = new ThinCollection();
     Tiles    = new TileCollection(true);
     Triggers = new TriggerCollection(true);
     Pools    = new PoolCollection();
 }
Esempio n. 2
0
        public Grid(Grid grid)
        {
            GridBlocks = grid.GridBlocks;
            Thins      = grid.Thins;
            Tiles      = grid.Tiles;
            Triggers   = new TriggerCollection(false);

            foreach (Trigger t in grid.Triggers)
            {
                Trigger nTrigger = new Trigger
                {
                    Duration          = null,
                    Cooldown          = new Interval(2000, false),
                    Enabled           = t.Enabled,
                    EndAngle          = t.EndAngle,
                    InitialState      = t.InitialState,
                    IsFromValhalla    = t.IsFromValhalla,
                    MaxAngleRate      = t.MaxAngleRate,
                    MaxRate           = t.MaxRate,
                    MoveCeiling       = t.MoveCeiling,
                    MoveFloor         = t.MoveFloor,
                    MoveRooftop       = t.MoveRooftop,
                    NextTrigger       = t.NextTrigger,
                    NextTriggerTiming = t.NextTriggerTiming,
                    OffHeight         = t.OffHeight,
                    OffSound          = t.OffSound,
                    OffText           = t.OffText,
                    OnHeight          = t.OnHeight,
                    OnSound           = t.OnSound,
                    OnText            = t.OnText,
                    Position          = new Vector3(t.Position.X, t.Position.Y, t.Position.X),
                    Random            = t.Random,
                    ResetTimer        = t.ResetTimer,
                    SlideAmount       = t.SlideAmount,
                    SlideAxis         = t.SlideAxis,
                    Speed             = t.Speed,
                    StartAngle        = t.StartAngle,
                    CurrentState      = TriggerState.Inactive,
                    Team        = t.Team,
                    TextureOff  = t.TextureOff,
                    TextureOn   = t.TextureOn,
                    TriggerId   = t.TriggerId,
                    TriggerType = t.TriggerType,
                    X0          = t.X0,
                    X1          = t.X1,
                    X2          = t.X2,
                    X3          = t.X3,
                    X4          = t.X4,
                    Y0          = t.Y0,
                    Y1          = t.Y1,
                    Y2          = t.Y2,
                    Y3          = t.Y3,
                    Y4          = t.Y4
                };

                Triggers.Add(nTrigger);
            }

            BalanceShrine = new Shrine(grid.BalanceShrine.Team, grid.BalanceShrine.ShrineId, grid.BalanceShrine.Power, grid.BalanceShrine.CurrentBias);
            ChaosShrine   = new Shrine(grid.ChaosShrine.Team, grid.ChaosShrine.ShrineId, grid.ChaosShrine.Power, grid.ChaosShrine.CurrentBias);
            OrderShrine   = new Shrine(grid.OrderShrine.Team, grid.OrderShrine.ShrineId, grid.OrderShrine.Power, grid.OrderShrine.CurrentBias);

            GameName     = grid.GameName;
            GridFilename = grid.GridFilename;
            GridId       = grid.GridId;
            MaxPlayers   = grid.MaxPlayers;
            MiscFilename = grid.MiscFilename;
            Name         = grid.Name;

            Pools = new PoolCollection();
            foreach (Pool p in grid.Pools)
            {
                Pools.Add(new Pool(p));
            }

            ShortGameName   = grid.ShortGameName;
            TimeLimit       = grid.TimeLimit;
            TriggerFilename = grid.TriggerFilename;
            WorldFilename   = grid.WorldFilename;
            ExpBonus        = grid.ExpBonus;
        }
Esempio n. 3
0
        public String Load(String folderName)
        {
            try
            {
                String arenaDatFilename = String.Format("{0}\\Arenas.dat", Directory.GetCurrentDirectory());

                const String gridDatLocation = "{0}\\{1}";

                WorldFilename   = String.Format(gridDatLocation, folderName, "World.dat");
                GridFilename    = String.Format(gridDatLocation, folderName, "Grid.dat");
                ObjectsFilename = String.Format(gridDatLocation, folderName, "Objects.dat");
                MiscFilename    = String.Format(gridDatLocation, folderName, "Misc.dat");
                TriggerFilename = String.Format(gridDatLocation, folderName, "Trigger.dat");

                if (!File.Exists(WorldFilename))
                {
                    return("File not found: World.dat");
                }

                if (!File.Exists(GridFilename))
                {
                    return("File not found: Grid.dat");
                }

                if (!File.Exists(ObjectsFilename))
                {
                    return("File not found: Objects.dat");
                }

                if (!File.Exists(MiscFilename))
                {
                    return("File not found: Misc.dat");
                }

                if (!File.Exists(TriggerFilename))
                {
                    return("File not found: Trigger.dat");
                }

                GridId = NativeMethods.GetPrivateProfileInt32("map", "grid_id", WorldFilename);

                if (GridId == -1)
                {
                    return("grid_id is not defined in World.dat.");
                }

                String keyName = String.Format("arena{0:00}", GridId);

                Name          = NativeMethods.GetPrivateProfileString(keyName, "grid", arenaDatFilename);
                GameName      = NativeMethods.GetPrivateProfileString(keyName, "name", arenaDatFilename);
                ShortGameName = NativeMethods.GetPrivateProfileString(keyName, "short_name", arenaDatFilename);
                MaxPlayers    = NativeMethods.GetPrivateProfileByte(keyName, "maxplayers", arenaDatFilename);
                TimeLimit     = NativeMethods.GetPrivateProfileInt16(keyName, "timelimit", arenaDatFilename);
                ExpBonus      = NativeMethods.GetPrivateProfileSingle(keyName, "expbonus", arenaDatFilename);

                Pools = new PoolCollection();

                Int32 poolCount = NativeMethods.GetPrivateProfileInt32("earthblooddefs", "numearthblood", WorldFilename);
                for (Int32 x = 0; x < poolCount; x++)
                {
                    Pools.Add(new Pool(Convert.ToByte(x), NativeMethods.GetPrivateProfileInt16(String.Format("earthblood{0:00}", x), "power", WorldFilename), 100));
                }

                Int32 shrineCount = NativeMethods.GetPrivateProfileInt32("shrinedefs", "numshrines", WorldFilename);
                for (Int32 x = 0; x < shrineCount; x++)
                {
                    String shrineString = String.Format("shrine{0:00}", x);

                    Int16 power = NativeMethods.GetPrivateProfileInt16(shrineString, "power", WorldFilename);
                    Int16 bias  = NativeMethods.GetPrivateProfileInt16(shrineString, "bias", WorldFilename);

                    switch (NativeMethods.GetPrivateProfileString(shrineString, "alignment", WorldFilename))
                    {
                    case "chaos":
                    {
                        ChaosShrine = new Shrine(Team.Chaos, (Byte)x, power, bias);
                        break;
                    }

                    case "balance":
                    {
                        BalanceShrine = new Shrine(Team.Balance, (Byte)x, power, bias);
                        break;
                    }

                    case "order":
                    {
                        OrderShrine = new Shrine(Team.Order, (Byte)x, power, bias);
                        break;
                    }
                    }
                }

                LoadTriggers();
                LoadThins();
                LoadTiles();
                LoadObjectDefinitions();
                LoadGrid(false);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return("");
        }
Esempio n. 4
0
        public Boolean Load(Int32 gridId)
        {
            try
            {
                String       arenaDatFilename = String.Format("{0}\\Arenas.dat", Directory.GetCurrentDirectory());
                const String gridDatLocation  = "{0}\\Grids\\Grid{1:00}\\{2}";

                String keyName = String.Format("arena{0:00}", gridId);

                WorldFilename   = String.Format(gridDatLocation, Directory.GetCurrentDirectory(), gridId, "World.dat");
                GridFilename    = String.Format(gridDatLocation, Directory.GetCurrentDirectory(), gridId, "Grid.dat");
                ObjectsFilename = String.Format(gridDatLocation, Directory.GetCurrentDirectory(), gridId, "Objects.dat");
                MiscFilename    = String.Format(gridDatLocation, Directory.GetCurrentDirectory(), gridId, "Misc.dat");
                TriggerFilename = String.Format(gridDatLocation, Directory.GetCurrentDirectory(), gridId, "Trigger.dat");
                GridId          = gridId;
                Name            = NativeMethods.GetPrivateProfileString(keyName, "grid", arenaDatFilename);
                GameName        = NativeMethods.GetPrivateProfileString(keyName, "name", arenaDatFilename);
                ShortGameName   = NativeMethods.GetPrivateProfileString(keyName, "short_name", arenaDatFilename);
                MaxPlayers      = NativeMethods.GetPrivateProfileByte(keyName, "maxplayers", arenaDatFilename);
                TimeLimit       = NativeMethods.GetPrivateProfileInt16(keyName, "timelimit", arenaDatFilename);
                ExpBonus        = NativeMethods.GetPrivateProfileSingle(keyName, "expbonus", arenaDatFilename);

                Pools = new PoolCollection();

                Int32 poolCount = NativeMethods.GetPrivateProfileInt32("earthblooddefs", "numearthblood", WorldFilename);
                for (Int32 x = 0; x < poolCount; x++)
                {
                    Pools.Add(new Pool(Convert.ToByte(x), NativeMethods.GetPrivateProfileInt16(String.Format("earthblood{0:00}", x), "power", WorldFilename), 100));
                }

                Int32 shrineCount = NativeMethods.GetPrivateProfileInt32("shrinedefs", "numshrines", WorldFilename);
                for (Int32 x = 0; x < shrineCount; x++)
                {
                    String shrineString = String.Format("shrine{0:00}", x);

                    Int16 power = NativeMethods.GetPrivateProfileInt16(shrineString, "power", WorldFilename);
                    Int16 bias  = NativeMethods.GetPrivateProfileInt16(shrineString, "bias", WorldFilename);

                    switch (NativeMethods.GetPrivateProfileString(shrineString, "alignment", WorldFilename))
                    {
                    case "chaos":
                    {
                        ChaosShrine = new Shrine(Team.Chaos, (Byte)x, power, bias);
                        break;
                    }

                    case "balance":
                    {
                        BalanceShrine = new Shrine(Team.Balance, (Byte)x, power, bias);
                        break;
                    }

                    case "order":
                    {
                        OrderShrine = new Shrine(Team.Order, (Byte)x, power, bias);
                        break;
                    }
                    }
                }

                LoadTriggers();
                LoadThins();
                LoadTiles();
                LoadObjectDefinitions();
                LoadGrid(true);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }