Ejemplo n.º 1
0
 static void UpdateConfig(Player p, LSMapConfig cfg)
 {
     cfg.Save(p.level.name);
     if (p.level == LSGame.Instance.Map)
     {
         LSGame.Instance.UpdateMapConfig();
     }
 }
Ejemplo n.º 2
0
        static LSMapConfig RetrieveConfig(Player p)
        {
            LSMapConfig cfg = new LSMapConfig();

            cfg.SetDefaults(p.level);
            cfg.Load(p.level.name);
            return(cfg);
        }
Ejemplo n.º 3
0
        bool SetLayerPos(Player p, Vec3S32[] m, object state, BlockID block)
        {
            LSMapConfig cfg = (LSMapConfig)state;

            cfg.LayerPos = (Vec3U16)m[0];
            SaveMapConfig(p, cfg);

            p.Message("Layer position set to &b({0})", m[0]);
            return(false);
        }
Ejemplo n.º 4
0
        static bool SetFloodPos(Player p, Vec3S32[] m, object state, BlockID block)
        {
            LSMapConfig cfg = (LSMapConfig)state;

            cfg.FloodPos = (Vec3U16)m[0];
            UpdateConfig(p, cfg);

            p.Message("Flood position set to &b({0})", m[0]);
            return(false);
        }
Ejemplo n.º 5
0
        bool SetSafeZone(Player p, Vec3S32[] m, object state, BlockID block)
        {
            LSMapConfig cfg = (LSMapConfig)state;

            cfg.SafeZoneMin = (Vec3U16)Vec3S32.Min(m[0], m[1]);
            cfg.SafeZoneMax = (Vec3U16)Vec3S32.Max(m[0], m[1]);
            SaveMapConfig(p, cfg);

            p.Message("Safe zone set! &b({0}) ({1})", cfg.SafeZoneMin, cfg.SafeZoneMax);
            return(false);
        }
Ejemplo n.º 6
0
        void HandleSetOther(Player p, string[] args, LSMapConfig cfg)
        {
            if (args.Length < 3)
            {
                p.Message("Layer time: &b" + cfg.LayerInterval.Shorten(true));
                p.Message("Round time: &b" + cfg.RoundTime.Shorten(true));
                p.Message("Flood time: &b" + cfg.FloodTime.Shorten(true));
                p.Message("Safe zone: &b({0}) ({1})", cfg.SafeZoneMin, cfg.SafeZoneMax);
                return;
            }

            string prop = args[2];

            if (prop.CaselessEq("safe"))
            {
                if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
                {
                    p.Message("Place or break two blocks to determine the edges.");
                }
                p.MakeSelection(2, cfg, SetSafeZone);
                return;
            }

            if (args.Length < 4)
            {
                Help(p, "other"); return;
            }
            bool ok = false;

            if (prop.CaselessEq("layer"))
            {
                ok = ParseTimespan(p, "layer time", args, ref cfg.LayerInterval);
            }
            else if (prop.CaselessEq("round"))
            {
                ok = ParseTimespan(p, "round time", args, ref cfg.RoundTime);
            }
            else if (prop.CaselessEq("flood"))
            {
                ok = ParseTimespan(p, "flood time", args, ref cfg.FloodTime);
            }
            else
            {
                Help(p, "other");
            }

            if (ok)
            {
                SaveMapConfig(p, cfg);
            }
        }
Ejemplo n.º 7
0
        void HandleSetBlock(Player p, string[] args)
        {
            LSMapConfig cfg = RetrieveConfig(p);

            if (args.Length < 3)
            {
                p.Message("Fast lava chance: &b" + cfg.FastChance + "%");
                p.Message("Killer lava/water chance: &b" + cfg.KillerChance + "%");
                p.Message("Destroy blocks chance: &b" + cfg.DestroyChance + "%");
                p.Message("Water flood chance: &b" + cfg.WaterChance + "%");
                return;
            }

            string prop = args[2];

            if (args.Length < 4)
            {
                Help(p, "block"); return;
            }
            bool ok = false;

            if (prop.CaselessEq("fast"))
            {
                ok = ParseChance(p, "fast lava", args, ref cfg.FastChance);
            }
            else if (prop.CaselessEq("killer"))
            {
                ok = ParseChance(p, "killer lava/water", args, ref cfg.KillerChance);
            }
            else if (prop.CaselessEq("destroy"))
            {
                ok = ParseChance(p, "destroy blocks", args, ref cfg.DestroyChance);
            }
            else if (prop.CaselessEq("water"))
            {
                ok = ParseChance(p, "water flood", args, ref cfg.WaterChance);
            }
            else
            {
                Help(p, "block");
            }

            if (ok)
            {
                UpdateConfig(p, cfg);
            }
        }
Ejemplo n.º 8
0
        void lsMapUse_SelectedIndexChanged(object sender, EventArgs e)
        {
            SaveLSMapSettings();
            if (ls_lstUsed.SelectedIndex == -1)
            {
                ls_grpMapSettings.Text    = "Map settings";
                ls_grpMapSettings.Enabled = false;
                lsCurCfg = null;
                return;
            }

            lsCurMap = ls_lstUsed.SelectedItem.ToString();
            ls_grpMapSettings.Text    = "Map settings (" + lsCurMap + ")";
            ls_grpMapSettings.Enabled = true;

            try {
                lsCurCfg = new LSMapConfig();
                lsCurCfg.Load(lsCurMap);
            } catch (Exception ex) {
                Logger.LogError(ex);
                lsCurCfg = null;
            }

            if (lsCurCfg == null)
            {
                return;
            }
            ls_numKiller.Value  = lsCurCfg.KillerChance;
            ls_numFast.Value    = lsCurCfg.FastChance;
            ls_numWater.Value   = lsCurCfg.WaterChance;
            ls_numDestroy.Value = lsCurCfg.DestroyChance;

            ls_numLayer.Value  = lsCurCfg.LayerChance;
            ls_numCount.Value  = lsCurCfg.LayerCount;
            ls_numHeight.Value = lsCurCfg.LayerHeight;

            ls_numRound.Value     = lsCurCfg.RoundTime;
            ls_numFlood.Value     = lsCurCfg.FloodTime;
            ls_numLayerTime.Value = lsCurCfg.LayerInterval;
        }
Ejemplo n.º 9
0
        protected override void HandleSet(Player p, RoundsGame game, string[] args)
        {
            string      prop = args[1];
            LSMapConfig cfg  = new LSMapConfig();

            LoadMapConfig(p, cfg);

            if (prop.CaselessEq("spawn"))
            {
                HandleSetSpawn(p, args, cfg);
            }
            else if (prop.CaselessEq("block"))
            {
                HandleSetBlock(p, args, cfg);
            }
            else if (prop.CaselessEq("other"))
            {
                HandleSetOther(p, args, cfg);
            }
            else
            {
                Help(p, "set");
            }
        }
Ejemplo n.º 10
0
        void HandleSetSpawn(Player p, string[] args, LSMapConfig cfg)
        {
            if (args.Length < 3)
            {
                p.Message("Flood position: &b" + cfg.FloodPos);
                p.Message("Layer position: &b" + cfg.LayerPos);
                p.Message("Layer flood chance: &b" + cfg.LayerChance + "%");
                p.Message("  &b{0} %Slayers, each &b{1} %Sblocks tall",
                          cfg.LayerCount, cfg.LayerHeight);
                return;
            }

            string prop = args[2];

            if (prop.CaselessEq("flood"))
            {
                p.Message("Place or destroy the block you want to be the total flood block spawn point.");
                p.MakeSelection(1, cfg, SetFloodPos);
                return;
            }
            else if (prop.CaselessEq("layer"))
            {
                p.Message("Place or destroy the block you want to be the layer flood base spawn point.");
                p.MakeSelection(1, cfg, SetLayerPos);
                return;
            }

            if (args.Length < 4)
            {
                Help(p, "spawn"); return;
            }
            bool ok = false;

            if (prop.CaselessEq("height"))
            {
                ok = CommandParser.GetInt(p, args[3], "Height", ref cfg.LayerHeight, 0);
                if (ok)
                {
                    p.Message("Set layer height to &b" + cfg.LayerHeight + " blocks");
                }
            }
            else if (prop.CaselessEq("count"))
            {
                ok = CommandParser.GetInt(p, args[3], "Count", ref cfg.LayerCount, 0);
                if (ok)
                {
                    p.Message("Set layer count to &b" + cfg.LayerCount);
                }
            }
            else if (prop.CaselessEq("chance"))
            {
                ok = ParseChance(p, "layer flood", args, ref cfg.LayerChance);
            }
            else
            {
                Help(p, "spawn");
            }

            if (ok)
            {
                SaveMapConfig(p, cfg);
            }
        }