コード例 #1
0
 public xCoreLevel(IWorldProvider worldProvider, EntityManager entitymanager, xCoreInterface game, MapInfo map, int id) : base(null, game.NameGame + id, worldProvider, entitymanager, GameMode.Survival, (Difficulty)2, 7)
 {
     Game               = game;
     Id                 = id;
     Status             = Status.Start;
     Time               = xCoreGames.StartTime;
     Map                = map;
     Slots              = map.Slots;
     CurrentWorldTime   = 6000;
     IsWorldTimeStarted = false;
     BlockBreak        += game.BlockBreak;
     BlockPlace        += game.BlockPlace;
     WorldTick         += GameTimer;
 }
コード例 #2
0
 public xCoreNPC(string name, xCoreLevelLobby level, xCoreInterface G, MiNetServer server = null) : base(name, level)
 {
     Game        = G;
     this.server = server;
     LevelLobby  = level;
 }
コード例 #3
0
        public LevelPoolGame(xCoreGames core, xCoreInterface game, bool onlyread, bool parse)
        {
            Random rnd     = new Random();
            var    timings = new Stopwatch();

            timings.Start();
            string basepath = Config.GetProperty("PluginDirectory", "Plugins") + "\\" + game.NameGame;

            for (int id = 1; id <= game.ArenaLoaded; id++)
            {
                if (Maps.Count == 0)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(basepath);
                    foreach (var dir in dirInfo.GetDirectories())
                    {
                        var     provider = new AnvilWorldProvider(basepath + "\\" + dir.Name);
                        var     cfg      = File.ReadAllText(basepath + "\\" + dir.Name + "\\config.json");
                        JObject jobj     = JObject.Parse(cfg);
                        Maps.Add(dir.Name, new MapInfo(dir.Name, jobj));
                        Maps[dir.Name].ProviderCache = provider;
                        Maps[dir.Name].ProviderCache.Initialize();
                        Maps[dir.Name].ProviderCache.PruneAir();
                        Maps[dir.Name].ProviderCache.MakeAirChunksAroundWorldToCompensateForBadRendering();
                    }
                }

                string map = Maps.Keys.ElementAt(rnd.Next(0, Maps.Keys.Count - 1));

                Level levelkey = Levels.FirstOrDefault(l => l.LevelId.Equals(game.NameGame + id, StringComparison.InvariantCultureIgnoreCase));
                if (levelkey == null)
                {
                    AnvilWorldProvider provider;
                    //provider = Maps[map].ProviderCache;
                    //if (!Maps[map].ProviderBool)
                    //{
                    if (onlyread)
                    {
                        provider = Maps[map].ProviderCache;
                    }
                    else
                    {
                        provider = Maps[map].ProviderCache.Clone() as AnvilWorldProvider;
                    }
                    //}
                    var level = new xCoreLevel(provider, game.Context.Server.LevelManager.EntityManager, game, Maps[map], LevelCount);
                    LevelCount++;
                    level.Initialize();
                    SkyLightCalculations.Calculate(level);
                    while (provider.LightSources.Count > 0)
                    {
                        var block = provider.LightSources.Dequeue();
                        block = level.GetBlock(block.Coordinates);
                        BlockLightCalculations.Calculate(level, block);
                    }
                    if (parse)
                    {
                        int X = Maps[map].Center.X;
                        int Z = Maps[map].Center.Z;
                        List <BlockCoordinates> BE = new List <BlockCoordinates>();
                        if (Maps[map].CacheBlockEntites == null)
                        {
                            int startX = Math.Min(X - 256, X + 256);
                            int endX   = Math.Max(X - 256, X + 256);
                            int startY = Math.Min(11, 129);
                            int endY   = Math.Max(11, 129);
                            int startZ = Math.Min(Z - 256, Z + 256);
                            int endZ   = Math.Max(Z - 256, Z + 256);
                            for (int x = startX; x <= endX; ++x)
                            {
                                for (int y = startY; y <= endY; ++y)
                                {
                                    for (int z = startZ; z <= endZ; ++z)
                                    {
                                        var         bc = new BlockCoordinates(x, y, z);
                                        BlockEntity blockentity;
                                        if ((blockentity = level.GetBlockEntity(bc)) != null)
                                        {
                                            if (blockentity is ChestBlockEntity)
                                            {
                                                if (!BE.Contains(blockentity.Coordinates))
                                                {
                                                    BE.Add(blockentity.Coordinates);
                                                }
                                            }
                                            else if (blockentity is Sign)
                                            {
                                                CleanSignText(((Sign)blockentity).GetCompound(), "Text1");
                                                CleanSignText(((Sign)blockentity).GetCompound(), "Text2");
                                                CleanSignText(((Sign)blockentity).GetCompound(), "Text3");
                                                CleanSignText(((Sign)blockentity).GetCompound(), "Text4");
                                                BE.Add(bc);
                                            }
                                        }
                                    }
                                }
                            }
                            for (int x = startX; x <= endX; ++x)
                            {
                                for (int z = startZ; z <= endZ; ++z)
                                {
                                    var bc = new BlockCoordinates(x, 127, z);
                                    MiNET.Blocks.Block b = level.GetBlock(bc);
                                    if (b.Id == 95)
                                    {
                                        level.SetAir(bc, false);
                                    }
                                }
                            }
                        }
                        if (Maps[map].CacheBlockEntites == null)
                        {
                            Maps[map].CacheBlockEntites = BE;
                        }
                    }
                    game.Initialization(level);
                    Levels.Add(level);
                }
            }
            Core     = core;
            Game     = game;
            OnlyRead = onlyread;
            timings.Stop();
            Log.Info("Loaded " + Levels.Count + " arenas . Load time " + timings.ElapsedMilliseconds + " ms");
            _tickerHighPrecisionTimer = new Timer(QueueTimer, null, 0, 1000);
        }
コード例 #4
0
        public xCoreTop(EntityManager m, xCoreInterface G, string[] args, string namegame) : base((int)EntityType.Slime, null)
        {
            m.AddEntity(this);
            Game = G;
            //EntityId = 1000000000;

            var timelevel = new System.Diagnostics.Stopwatch();

            timelevel.Start();
            Log.Info(args.ToLower());
            List <Dictionary <string, string> > sel = Game.Core.Auth.MultipleQuery("SELECT userid, " + args.ToLower() + " FROM " + Game.PrefDB + "_stats ORDER BY wins DESC LIMIT 10", Game.PrefDB + "_users");
            string sql   = "SELECT user, id FROM userdata WHERE ";
            int    sqlss = 1;

            foreach (var top in sel)
            {
                if (sqlss++ == 1)
                {
                    sqlss++;
                    sql += "id IN ('" + top["userid"] + "'";
                }
                else
                {
                    sql += ", '" + top["userid"] + "'";
                }
            }
            sql += ") ORDER BY FIELD(id";
            foreach (var top in sel)
            {
                sql += ", '" + top["userid"] + "'";
            }
            sql += ")";
            List <Dictionary <string, string> > nick = Game.Core.Auth.MultipleQuery(sql, "userdata");
            int           ind  = 1;
            int           list = 1;
            List <string> str  = new List <string>();

            str.Add("§3Cristalix " + namegame);
            str.Add("§eTop 10 players");
            foreach (var top in sel)
            {
                string n = nick[ind - 1]["user"];
                string h = $"§a{ind}. §7{n} §3has ";
                foreach (string line in args)
                {
                    h += $"§e{top[line.ToLower()]} {line.Substring(0,1)}§8,";
                }
                if (list <= h.Length)
                {
                    list = h.Length;
                }
                str.Add(h);
                ind++;
            }
            //s += "Статистика обновляется раз в час!";
            timelevel.Stop();
            string hh = "§4";

            foreach (string line in args)
            {
                hh += line.Substring(0, 1).ToUpper() + " - " + line + ", ";
            }
            str.Add(hh);
            Log.Info("Тест прошел за " + timelevel.ElapsedTicks + " ticks");
            NameTag = str.CenterName();

            /*long flags = 0;
             * //flags |= 1 << 5;
             * flags |= 1 << 14;
             * flags |= 1 << 15;
             * flags |= 1 << 16;
             * MetadataDictionary metadata = new MetadataDictionary();
             * metadata[(int)Entity.MetadataFlags.EntityFlags] = new MetadataLong(flags);
             * //metadata[1] = new MetadataInt(1);
             * //metadata[2] = new MetadataInt(0);
             * metadata[(int)Entity.MetadataFlags.NameTag] = new MetadataString(NameTag ?? string.Empty);
             * metadata[(int)Entity.MetadataFlags.Scale] = new MetadataFloat(0); // Scale
             * metadata[(int)Entity.MetadataFlags.CollisionBoxHeight] = new MetadataFloat(0); // Collision box width
             * metadata[(int)Entity.MetadataFlags.CollisionBoxWidth] = new MetadataFloat(0); // Collision box height
             *
             * Meta = metadata;*/
            Width  = 0;
            Length = 0;
            Height = 0;

            HideNameTag      = false;
            IsAlwaysShowName = true;
        }