Example #1
0
        public HubLevel(SkyCoreAPI plugin, string gameId, string levelPath, GameLevelInfo gameLevelInfo, bool modifiable = false) :
            base(plugin, "hub", gameId, levelPath, gameLevelInfo, modifiable)
        {
            AddPendingTask(() =>
            {
                PlayerLocation portalInfoLocation = new PlayerLocation(256.5, 79.5, 276.5);

                const string hologramContent = "  §d§lSkytonia§r §f§lNetwork§r" + "\n" +
                                               " §7Enter the portal and§r" + "\n" +
                                               "§7enjoy your adventure!§r" + "\n" +
                                               "     §ewww.skytonia.com§r";

                new Hologram(hologramContent, this, portalInfoLocation).SpawnEntity();

                RunnableTask.RunTaskLater(() =>
                {
                    try
                    {
                        PlayerNPC.SpawnAllHubNPCs(this);

                        //SpawnHubMaps();
                    }
                    catch (Exception e)
                    {
                        BugSnagUtil.ReportBug(e, this);
                    }
                }, 250);
            });
        }
Example #2
0
        public MurderLevel(SkyCoreAPI plugin, string gameId, string levelPath, GameLevelInfo gameLevelInfo) : base(plugin, "murder", gameId, levelPath, gameLevelInfo)
        {
            if (!(gameLevelInfo is MurderLevelInfo))
            {
                throw new Exception($"Could not load MurderLevelInfo for level {LevelName}");
            }

            foreach (PlayerLocation playerSpawnLocation in ((MurderLevelInfo)GameLevelInfo).PlayerSpawnLocations)
            {
                //TODO: Remove - Causes locations to rise above the roof
                //				 Clone if this is still required
                //playerSpawnLocation.Y += 0.1f; //Ensure this spawn is not inside the ground

                //Round to the centre of the block.
                playerSpawnLocation.X = (float)(Math.Floor(playerSpawnLocation.X) + 0.5f);
                playerSpawnLocation.Z = (float)(Math.Floor(playerSpawnLocation.Z) + 0.5f);
            }

            if (((MurderLevelInfo)GameLevelInfo).PlayerSpawnLocations.Count == 0 ||
                ((MurderLevelInfo)GameLevelInfo).GunPartLocations.Count == 0)
            {
                SkyUtil.log($"Player Spawns -> {((MurderLevelInfo)GameLevelInfo).PlayerSpawnLocations.Count}");
                SkyUtil.log($"Gun Part Locations -> {((MurderLevelInfo)GameLevelInfo).GunPartLocations.Count}");

                throw new Exception("Defined spawns below range!");
            }

            //SkyUtil.log($"Initialized Player Spawns with {((MurderLevelInfo) GameLevelInfo).PlayerSpawnLocations.Count} unique locations");
            //SkyUtil.log($"Initialized Gun Part Locations with {((MurderLevelInfo)GameLevelInfo).GunPartLocations.Count} unique locations");
        }
Example #3
0
        public BuildBattleGameController(SkyCoreAPI plugin) : base(plugin, "build-battle", "Build Battle",
                                                                   new List <string> {
            "build-battle-template"
        })
        {
            string themeFilePath =
                $"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\\config\\build-battle-themes.json";

            //Generate Example Config
            if (!File.Exists(themeFilePath))
            {
                List <BuildBattleTheme> tempThemeList = new List <BuildBattleTheme>
                {
                    new BuildBattleTheme("Theme #1",
                                         new List <CachedItem> {
                        new CachedItem(1, 1), new CachedItem(5, 0)
                    }),
                    new BuildBattleTheme("Theme #2",
                                         new List <CachedItem> {
                        new CachedItem(1, 1), new CachedItem(5, 0)
                    })
                };

                File.WriteAllText(themeFilePath, JsonConvert.SerializeObject(tempThemeList, Formatting.Indented));
            }

            object jObject = JsonConvert.DeserializeObject(File.ReadAllText(themeFilePath));

            if (jObject is JArray array)
            {
                try
                {
                    _themeList = array.ToObject <List <BuildBattleTheme> >();

                    foreach (BuildBattleTheme theme in _themeList)
                    {
                        //Automatic Bolding
                        if (theme.ThemeName.StartsWith("§"))
                        {
                            theme.ThemeName = theme.ThemeName.Substring(0, 2) + "§l" +
                                              theme.ThemeName.Substring(2, theme.ThemeName.Length - 2);
                        }
                    }
                }
                catch (Exception e)
                {
                    BugSnagUtil.ReportBug(e, this, new AnonMetadatable((metadata) =>
                    {
                        metadata.AddToTab("JSON", "Theme List Content", jObject);
                    }));
                }
            }
            else
            {
                SkyUtil.log($"Unable to load theme list. Parsed Object was of type {(jObject == null ? "null" : $"{jObject.GetType()}")}");
            }

            SkyUtil.log($"Initialized {_themeList.Count} Themes");
        }
Example #4
0
        public HubController(SkyCoreAPI plugin) : base(plugin, "hub", "Hub", new List <string> {
            "hub"
        })
        {
            Tick = 1;

            //Register all hubs
            for (int i = 0; i < MaxHubCount; i++)
            {
                InitializeNewGame();
            }
        }
Example #5
0
        //

        protected GameLevel(SkyCoreAPI plugin, string gameType, string gameId, String levelPath, GameLevelInfo gameLevelInfo, bool modifiable = false)
            : base(plugin.Server.LevelManager, gameId,
                   AnvilProviderFactory.GetLevelProvider(plugin.Server.LevelManager, levelPath, !modifiable, true, !modifiable),
                   plugin.Server.LevelManager.EntityManager, GameMode.Creative)
        {
            string levelName;

            {
                string[] split = levelPath.Split('\\');
                levelName = split[split.Length - 1];
            }

            LevelName = levelName;

            Plugin        = plugin;
            GameId        = gameId;
            GameType      = gameType;
            GameLevelInfo = gameLevelInfo;

            EnableBlockTicking = false;
            EnableChunkTicking = false;

            //SkyUtil.log($"Initializing world {gameId}");
            Initialize();

            SpawnPoint = GameLevelInfo.LobbyLocation;

            SetupWorldTime();

            if (!plugin.Server.LevelManager.Levels.Contains(this))
            {
                plugin.Server.LevelManager.Levels.Add(this);
            }

            InitializeTeamMap();

            CurrentState = GetInitialState();
            CurrentState.EnterState(this);

            GameLevelTickThread = new Thread(() =>
            {
                Thread.CurrentThread.IsBackground = true;

                GameLevelTick = new HighPrecisionTimer(500, PreGameTick, true);
            });
            GameLevelTickThread.Start();

            BlockBreak += HandleBlockBreak;
            BlockPlace += HandleBlockPlace;
        }
Example #6
0
	    protected GameController(SkyCoreAPI plugin, string gameName, string neatName, List<string> levelNames)
        {
            Plugin = plugin;
            
            GameName = neatName;
            RawName = gameName;
            
            foreach(var levelName in levelNames)
            {
                string fullLevelPath = $@"C:\Users\Administrator\Desktop\worlds\{gameName}\{levelName}";
	            if (!Directory.Exists(fullLevelPath))
	            {
					SkyUtil.log($"Unable to find world at ({fullLevelPath})");
				}
	            else
	            {
					LevelNames.Add(fullLevelPath);

		            SkyUtil.log($"Added world at ({fullLevelPath})");

					//Pre-load GameLevelInfo
		            GetGameLevelInfo(levelName);

					//Pre-cache the WorldProvider
		            AnvilProviderFactory.GetLevelProvider(plugin.Server.LevelManager, fullLevelPath);
	            }
            }

			if (LevelNames.Count == 0)
			{
				SkyUtil.log($"No Levels configured for {gameName}");
				return;
			}

			RedisGameIdKey = $"next_game_id_{GameName}";

	        ExternalGameHandler.RegisterInternalGame(RawName);

			GameTickThread = new Thread(() =>
	        {
		        Thread.CurrentThread.IsBackground = true;

		        GameTick = new HighPrecisionTimer(50, _CoreGameTick, true);
	        });
	        GameTickThread.Start();
		}
Example #7
0
        public SkyPlayer(MiNetServer server, IPEndPoint endpoint, SkyCoreAPI skyCoreApi) : base(server, endpoint)
        {
            SkyCoreApi = skyCoreApi;

            Inventory = new SkyPlayerInventory(this);
        }
 public BuildBattleLevel(SkyCoreAPI plugin, string gameId, string levelPath, GameLevelInfo gameLevelInfo, List <BuildBattleTheme> themeList) :
     base(plugin, "build-battle", gameId, levelPath, gameLevelInfo, true)
 {
     ThemeList = themeList;
 }
Example #9
0
 public SkyPermissions(SkyCoreAPI skyCoreApi)
 {
     _skyCoreApi = skyCoreApi;
 }
 public MurderGameController(SkyCoreAPI plugin) : base(plugin, "murder", "Murder Mystery",
                                                       new List <string> {
     "murder-grandlibrary", "murder-funzone", "murder-sunsetresort"
 })
 {
 }
Example #11
0
        public SkyCommands(SkyCoreAPI skyCoreApi)
        {
            Instance = this;

            _skyCoreApi = skyCoreApi;
        }
Example #12
0
 public SkyLevelManager(SkyCoreAPI skyCoreApi)
 {
     SkyCoreApi = skyCoreApi;
 }