Esempio n. 1
0
 // int count = 0;
 public ZeroGPacket SendNewPlayerInfo()
 {
     try
     {
         GameLevelInfo levelnfo = new GameLevelInfo();
         levelnfo.Generate("Urban_02", 4, 2, false);
         //  GamePacket packet = new GamePacket();
         //packet.packetType = "LevelInfo";
         //   LoadingComplete packetSecond = new LoadingComplete();
         //   packetSecond.Generate(true, "yo");
         //   if(count == 2)
         //  {
         //      packet.Generate("LevelInfo", levelnfo, packetSecond);
         //  }
         //   else
         //  {
         //      packet.Generate("LevelInfo", levelnfo,packetSecond);
         //  }
         //  count = count + 1;
         ZeroGPacket packet = PacketGenerator.Generate("LevelInfo", levelnfo);
         return(packet);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error: " + ex.Message + ex.StackTrace);
         return(null);
     }
 }
Esempio n. 2
0
        public void StatGameLevelFinished(GameLevelInfo gameLevelInfo, ILevelFinishStat levelFinishStat)
        {
            if (InfoResolver.Resolve <FortInfo>().Analytic.AnalyticsProvider == null)
            {
                return;
            }

            if (!InfoResolver.Resolve <FortInfo>().Analytic.StatGameLevelFinished)
            {
                return;
            }
            GameLevelCategory gameLevelCategory =
                InfoResolver.Resolve <FortInfo>().GameLevel.LevelCategoriesParentMap[gameLevelInfo.Id];

            InfoResolver.Resolve <FortInfo>()
            .Analytic.AnalyticsProvider.StateEvent(gameLevelInfo.Name, gameLevelInfo.DisplayName,
                                                   "GameLevelFinished",
                                                   new GameLevelFinishedAnalyticStat
            {
                LevelFinishStat       = levelFinishStat,
                GameLevelId           = gameLevelInfo.Id,
                GameLevelName         = gameLevelInfo.Name,
                GameLevelCategoryId   = gameLevelCategory.Id,
                GameLevelCategoryName = gameLevelCategory.Name
            });
        }
Esempio n. 3
0
    public static List<GameLevelInfo> LoadGameLevelInfo()
    {
        List<GameLevelInfo> gameLevelInfoList = new List<GameLevelInfo>();

        TextAsset textAssetGameLevelData = Resources.Load("Text/TargetData") as TextAsset;
        char[] charNewLine ={'\r', '\n'};
        string[] gameLevelDataStrings = textAssetGameLevelData.text.Split(charNewLine);

        foreach(var entityData in gameLevelDataStrings)
        {
            string[] detailData = entityData.Split(',');
            GameLevelInfo levelInfo = new GameLevelInfo();

            levelInfo.GameClearCountLevel = int.Parse(detailData[0]);
            levelInfo.MaxPlayGameTimeRimit = float.Parse(detailData[1]);
            levelInfo.MinGameClearCount = int.Parse(detailData[2]);
            levelInfo.Mass = float.Parse(detailData[3]);
            levelInfo.Drag = float.Parse(detailData[4]);
            levelInfo.AngularDrag = float.Parse(detailData[5]);
            levelInfo.TargetGameObjectName = detailData[6];

            gameLevelInfoList.Add(levelInfo);
        }
        return gameLevelInfoList;
    }
Esempio n. 4
0
        public void Process(ZeroGPacket packet)
        {
            GamePacket origPacket = PacketGenerator.Decompile(packet);

            if (packet.PacketType == "LevelInfo" && (origPacket.GetType() == typeof(GameLevelInfo)))
            {
                GameLevelInfo newPacket = (GameLevelInfo)origPacket;
                LevelInfoProcessor.Process(newPacket);
            }
            else if (packet.PacketType == "PlayerNames" && (origPacket.GetType() == typeof(PlayerNames)))
            {
                PlayerNames newpacket = (PlayerNames)origPacket;
                PlayerNamesProcessor.Process(newpacket);
            }
            else if (packet.PacketType == "PlayerPosition" && (origPacket.GetType() == typeof(PlayerPosition)))
            {
                PlayerPosition newpacket = (PlayerPosition)origPacket;
                PlayerPositionProcessor.Process(newpacket);
            }
            else if (packet.PacketType == "AllLoaded" && (origPacket.GetType() == typeof(AllPlayersLoaded)))
            {
                AllPlayersLoaded newpacket = (AllPlayersLoaded)origPacket;
                AllPlayersLoadedProcessor.Process(newpacket);
            }
        }
Esempio n. 5
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");
        }
Esempio n. 6
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);
            });
        }
Esempio n. 7
0
        public override void EnterState(GameLevel gameLevel)
        {
            gameLevel.DoForAllPlayers(player =>
            {
                player.RemoveAllEffects();

                player.SetGameMode(GameMode.Adventure);
            });

            GameLevelInfo gameLevelInfo = gameLevel.GameLevelInfo;

            //Spawn Lobby NPC
            if (gameLevelInfo.LobbyNPCLocation == null)
            {
                gameLevelInfo.LobbyNPCLocation = new PlayerLocation(260.5, 15, 251.5);

                File.WriteAllText(GameController.GetGameLevelInfoLocation(gameLevel.GameType, gameLevel.LevelName), JsonConvert.SerializeObject(gameLevel.GameLevelInfo, Formatting.Indented));
                SkyUtil.log($"LobbyNPCLocation Updated with default value for {gameLevel.LevelName}");
            }

            _spawnedEntities = PlayerNPC.SpawnLobbyNPC(gameLevel, gameLevelInfo.GameType, gameLevel.GameLevelInfo.LobbyNPCLocation);

            gameLevel.AddPendingTask(() =>
            {
                //Spawn Lobby Map/Image
                if (gameLevelInfo.LobbyMapLocation.Y < 0)         //Default == -1
                {
                    gameLevelInfo.LobbyMapLocation = new BlockCoordinates(252, 15, 249);

                    File.WriteAllText(GameController.GetGameLevelInfoLocation(gameLevel.GameType, gameLevel.LevelName), JsonConvert.SerializeObject(gameLevel.GameLevelInfo, Formatting.Indented));
                }

                _spawnedEntities.AddRange(MapUtil.SpawnMapImage(@"C:\Users\Administrator\Desktop\dl\map-images\TestImage.png", 7, 4, gameLevel, gameLevelInfo.LobbyMapLocation));
            });
        }
Esempio n. 8
0
    void Start()
    {
        //bind to MusicPlayerComponent delegate
        MusicPlayerComponent.Instance.onSequencePlay    = OnSongButtonClicked;
        MusicPlayerComponent.Instance.onEndSequencePlay = PlayEndSequence;

        CurrentLevelInfo = MusicPlayerComponent.Instance.GetGameLevelInfo();
        //condition ? first_expression : second_expression;
        LevelText.text = "Level " + (CurrentLevelInfo.LevelNumber < 10 ? "0" + (CurrentLevelInfo.LevelNumber + 1).ToString() : (CurrentLevelInfo.LevelNumber + 1).ToString());

        ChancesLeft      = ChanceIndicator.Length - 1;
        PlayHintLimit    = HintLimitIndicator.Length - 1;
        Answers          = new List <int>();
        AnswerTCSequence = new List <TuneCardScript>();
        HintButton.GetComponent <Image>().color = HintLimitIndicator[PlayHintLimit];
        TotalTuneCards = CurrentLevelInfo.ShuffledSequence.Count;
        SpawnTuneCards();

        // Setup delegates for button
        SongButton.GetButton().onClick.AddListener(PlaySong);
        HintButton.onClick.AddListener(PlayHint);
        MainMenuButton.onClick.AddListener(delegate { MusicPlayerComponent.Instance.LoadLevel(0); });
        MainMenuButton2.onClick.AddListener(delegate { MusicPlayerComponent.Instance.LoadLevel(0); });
        ReloadButton.onClick.AddListener(delegate { MusicPlayerComponent.Instance.LoadLevel(1); });

        ToggleInteractableButtons(true);
        GameMenuPanel.SetActive(false);

        PlaySong();
    }
Esempio n. 9
0
    public static List <GameLevelInfo> LoadGameLevelInfo()
    {
        List <GameLevelInfo> gameLevelInfoList = new List <GameLevelInfo>();

        TextAsset textAssetGameLevelData = Resources.Load("Text/TargetData") as TextAsset;

        char[]   charNewLine          = { '\r', '\n' };
        string[] gameLevelDataStrings = textAssetGameLevelData.text.Split(charNewLine);

        foreach (var entityData in gameLevelDataStrings)
        {
            string[]      detailData = entityData.Split(',');
            GameLevelInfo levelInfo  = new GameLevelInfo();

            levelInfo.GameClearCountLevel  = int.Parse(detailData[0]);
            levelInfo.MaxPlayGameTimeRimit = float.Parse(detailData[1]);
            levelInfo.MinGameClearCount    = int.Parse(detailData[2]);
            levelInfo.Mass                 = float.Parse(detailData[3]);
            levelInfo.Drag                 = float.Parse(detailData[4]);
            levelInfo.AngularDrag          = float.Parse(detailData[5]);
            levelInfo.TargetGameObjectName = detailData[6];

            gameLevelInfoList.Add(levelInfo);
        }
        return(gameLevelInfoList);
    }
Esempio n. 10
0
        public static void ImportGameLevels()
        {
            string path = EditorUtility.OpenFilePanel("Import Game Levels", "", "xls");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            using (Stream reader = File.OpenRead(path))
            {
                IDictionary <string, PropertyInfo> customPossibleProperties =
                    ExportData.GetCustomPossibleProperties(
                        TypeHelper.GetAllTypes(AllTypeCategory.Game)
                        .Where(type => typeof(GameLevelInfo).IsAssignableFrom(type))
                        .ToArray());
                Dictionary <string, Type> parameters = new Dictionary <string, Type>();
                parameters["Id"] = typeof(string);
                //parameters["Scene"] = typeof(string);
                //parameters["DisplayName"] = typeof(string);
                parameters["Name"] = typeof(string);
                foreach (KeyValuePair <string, PropertyInfo> pair in customPossibleProperties)
                {
                    parameters[pair.Key] = pair.Value.PropertyType;
                }
                HSSFWorkbook workbook   = new HSSFWorkbook(reader);
                ExportData   exportData = ExportData.DeserializeFromSheet(parameters, workbook.GetSheetAt(0));
                foreach (ExportRow exportRow in exportData.ExportRows)
                {
                    if (!exportRow.ContainsParameter("Id"))
                    {
                        continue;
                    }
                    string id = (string)exportRow.GetValue("Id").Value;
                    if (!InfoResolver.Resolve <FortInfo>().GameLevel.GameLevelInfos.ContainsKey(id))
                    {
                        continue;
                    }
                    GameLevelInfo gameLevelInfo = InfoResolver.Resolve <FortInfo>().GameLevel.GameLevelInfos[id];
                    if (exportRow.ContainsParameter("Scene"))
                    {
/*                        gameLevelInfo.Scene = new FortScene();
 *                      gameLevelInfo.Scene.SceneName = (string)exportRow.GetValue("Scene").Value;*/
                    }

/*                    if (exportRow.ContainsParameter("DisplayName"))
 *                  {
 *                      gameLevelInfo.DisplayName = (string)exportRow.GetValue("DisplayName").Value;
 *                  }*/
                    if (exportRow.ContainsParameter("Name"))
                    {
                        gameLevelInfo.Name = (string)exportRow.GetValue("Name").Value;
                    }
                    exportRow.FillCustomExportParameter(gameLevelInfo);
                }
            }
            InfoResolver.Resolve <FortInfo>().Save();
        }
Esempio n. 11
0
        public ILevelFinishStat GetGameFinishStat(GameLevelInfo level)
        {
            GameSavedData gameSavedData = ServiceLocator.Resolve <IStorageService>().ResolveData <GameSavedData>() ??
                                          new GameSavedData();

            if (gameSavedData.LevelFinishStats.ContainsKey(level.Id))
            {
                return(gameSavedData.LevelFinishStats[level.Id]);
            }
            return(null);
        }
    void Start()
    {
        this.reader = new StringReader (csv.text);

        // 最初の行読み込み位置をあわせる
        //for (int i = 0; i < initLine; i++) {
            this.reader.ReadLine ();
        //}

        this.gameLevelInfo = new GameLevelInfo ();
    }
Esempio n. 13
0
    public static GameLevelInfo SetLadGameLevelInfo(List <GameLevelInfo> targetList, int clearCount)
    {
        IEnumerable <GameLevelInfo> list = from item in targetList
                                           where item.GameClearCountLevel == clearCount
                                           select item;

        int index = Random.Range(0, list.Count());
        List <GameLevelInfo> hoge = list.ToList();
        GameLevelInfo        info = hoge[index];

        return(info);
    }
Esempio n. 14
0
        private void CountDownTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            //  throw new NotImplementedException();
            Console.WriteLine("60 sec elapsed, starting game");
            GameLevelInfo packet = new GameLevelInfo();

            packet.Generate(levelname, players.PlayersCount() - 1, 3, false);
            ZeroGPacket fullPacket = PacketGenerator.Generate("LevelInfo", packet);

            serverInst.SendToAll(fullPacket, DeliveryMethod.ReliableOrdered);
            countDownTimer.Stop();
        }
Esempio n. 15
0
        private string ResolveGameLevelSceneName(GameLevelInfo level)
        {
            if (!FortScene.IsNullOrEmpty(level.Scene))
            {
                return(level.Scene.Value.SceneName);
            }
            string categorySceneName = GetCategorySceneName(InfoResolver.Resolve <FortInfo>().GameLevel.LevelCategoriesParentMap[level.Id]);

            if (!string.IsNullOrEmpty(categorySceneName))
            {
                return(categorySceneName);
            }
            return(FortScene.IsNullOrEmpty(InfoResolver.Resolve <FortInfo>().GameLevel.DefaultScene)?null: InfoResolver.Resolve <FortInfo>().GameLevel.DefaultScene.Value.SceneName);
        }
    public override void StateUpdate()
    {
        if (Time.time >= NextTime) {
            gameLevelInfo = this.levelLoader.ReadLine ();

            if (gameLevelInfo != null) {

                LevelWeather ();
                LevelItem ();

                NextTime = gameLevelInfo.NextLoadTime + Time.time;
            }
        }
    }
Esempio n. 17
0
 public void LoadGameLevelAsync(GameLevelInfo level)
 {
     if (FortScene.IsNullOrEmpty(InfoResolver.Resolve <FortInfo>().GameLevel.LoaderScene.Value))
     {
         throw new Exception("No Loader Scene is defined in Game Level config");
     }
     _lastLoadGameAsync = level;
     ServiceLocator.Resolve <ISceneLoaderService>().Load(new SceneLoadParameters(InfoResolver.Resolve <FortInfo>().GameLevel.LoaderScene.Value.SceneName)
     {
         AddToSceneStack  = false,
         CaptureReturnKey = false,
         Context          = level,
         FlushSceneStack  = true
     });
 }
Esempio n. 18
0
    public GameLevelInfo RandomDSequenceElements(GameLevelInfo Info)
    {
        List <int> OriginalSequence = new List <int>(Info.ShuffledSequence);

        do
        {
            for (int i = 0; i < Info.ShuffledSequence.Count; i++)
            {
                int temp        = Info.ShuffledSequence[i];
                int randomIndex = Random.Range(0, Info.ShuffledSequence.Count - 1);
                Info.ShuffledSequence[i]           = Info.ShuffledSequence[randomIndex];
                Info.ShuffledSequence[randomIndex] = temp;
            }
        } while (OriginalSequence == Info.ShuffledSequence);
        return(Info);
    }
Esempio n. 19
0
    public override void StateStart()
    {
        this.gameLevelInfo = new GameLevelInfo ();
        this.levelLoader = GameObject.FindGameObjectWithTag ("LevelLoader").GetComponent<LevelLoader> ();

        GameModel.isFreeze = true;

        this.StartEffect = this.ResourceManagerInstance.InstantiateResourceWithName ("StartEffect");
        Transform Scale = this.StartEffect.transform;

        GameObject canvas = GameObject.Find ("GUICanvas");
        this.StartEffect.transform.SetParent (canvas.transform, false);

        gameLevelInfo = this.levelLoader.ReadLine ();
        LevelWeather ();
        LevelItem ();
    }
Esempio n. 20
0
        public void GameLevelFinished(LevelFinishParameters parameters)
        {
            _lastFinishStat = parameters.LevelFinishStat;
            GameLevelInfo level = GetLastLoadedLevel();

            ServiceLocator.Resolve <IAnalyticsService>().StatGameLevelFinished(level, parameters.LevelFinishStat);
            GameSavedData gameSavedData = ServiceLocator.Resolve <IStorageService>().ResolveData <GameSavedData>() ??
                                          new GameSavedData();

            gameSavedData.LastFinishedLevelId = level.Id;
            if (gameSavedData.LevelFinishStats.ContainsKey(level.Id))
            {
                if (gameSavedData.LevelFinishStats[level.Id].CompareTo(parameters.LevelFinishStat) == -1)
                {
                    gameSavedData.LevelFinishStats[level.Id] = parameters.LevelFinishStat;
                }
            }
            else
            {
                gameSavedData.LevelFinishStats[level.Id] = parameters.LevelFinishStat;
            }
            ServiceLocator.Resolve <IStorageService>().UpdateData(gameSavedData);
            switch (parameters.TransitionType)
            {
            case LevelFinishSceneTransitionType.Stay:
                break;

            case LevelFinishSceneTransitionType.MoveToScene:
                ServiceLocator.Resolve <ISceneLoaderService>().Load(new SceneLoadParameters(parameters.TransitionScene)
                {
                    AddToSceneStack  = true,
                    CaptureReturnKey = false,
                    Context          = GetLastLoadedLevel(),
                    FlushSceneStack  = true
                });
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
    /// <summary>
    /// ターゲットのRigidbodyのパラメータを設定.
    /// </summary>
    /// <returns>The rigidbody.</returns>
    /// <param name="targetGameObject">Target game object.</param>
    public Rigidbody InitRigidbodyAndGameLevel(GameObject targetGameObject)
    {
        //テキストからRigidbodyの情報を取得する.
        presentGameLevelInfo = GameData.SetLadGameLevelInfo(gameLevelInfoListMaster, gameClearCount);

        //制限時間を設定.
        this.PlayGameTimer = presentGameLevelInfo.MaxPlayGameTimeRimit;

        Debug.Log("<<init rigidbody!!>>");
        Rigidbody rigidbody = targetGameObject.GetComponent <Rigidbody>() as Rigidbody;

        if (rigidbody == null)
        {
            Debug.Log("rigidbody add");
            rigidbody = targetGameObject.AddComponent <Rigidbody>();
        }

        //Rigidbodyのステータスを設定.
        rigidbody.mass        = presentGameLevelInfo.Mass;
        rigidbody.drag        = presentGameLevelInfo.Drag;
        rigidbody.useGravity  = false;
        rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;

        //プレハブのモデルを設定.
        string     pathTarget      = string.Format("Prefab/{0}", presentGameLevelInfo.TargetGameObjectName);
        Object     objectCharacter = Resources.Load(pathTarget);
        GameObject cloneObj        = Instantiate(objectCharacter) as GameObject;

        if (cloneObj != null)
        {
            Debug.Log("game object setting...");
            cloneObj.transform.parent        = targetGameObject.transform;
            cloneObj.transform.localPosition = Vector3.zero;
        }
        else
        {
            Debug.LogError("not have prefab... please check text file." + pathTarget);
        }

        return(rigidbody);
    }
Esempio n. 22
0
        public void LoadGameLevel(GameLevelInfo level)
        {
            string gameLevelSceneName = ResolveGameLevelSceneName(level);

            if (string.IsNullOrEmpty(gameLevelSceneName))
            {
                throw new Exception(string.Format("Scene name of Level {0} cannot be resloved.", level.Name));
            }
            GameSavedData gameSavedData = ServiceLocator.Resolve <IStorageService>().ResolveData <GameSavedData>() ??
                                          new GameSavedData();

            gameSavedData.LastLoadedLevelId = level.Id;
            ServiceLocator.Resolve <IStorageService>().UpdateData(gameSavedData);
            ServiceLocator.Resolve <ISceneLoaderService>().Load(new SceneLoadParameters(gameLevelSceneName)
            {
                AddToSceneStack  = false,
                CaptureReturnKey = false,
                Context          = level,
                FlushSceneStack  = true
            });
        }
Esempio n. 23
0
        private void OnMaxPlayersReached(object sender, EventArgs e)
        {
            Console.WriteLine("max players reached");
            PlayerNames   packet2    = new PlayerNames();
            List <string> playerName = new List <string>();

            foreach (Player player in players.PlayersList)
            {
                playerName.Add(player.PlayerName);
            }
            packet2.Generate(playerName);
            ZeroGPacket mainPacket2 = PacketGenerator.Generate("PlayerNames", packet2);

            serverInst.SendToAll(mainPacket2, DeliveryMethod.ReliableOrdered);
            GameLevelInfo packet = new GameLevelInfo();

            packet.Generate(levelname, players.PlayersCount() - 1, 3, isReverse);
            ZeroGPacket fullPacket = PacketGenerator.Generate("LevelInfo", packet);

            serverInst.SendToAll(fullPacket, DeliveryMethod.ReliableOrdered);
            countDownTimer.Stop();
        }
Esempio n. 24
0
 public static GameLevelCategory GetCategory(this GameLevelInfo gameLevelInfo)
 {
     return(FortInfo.Instance.GameLevel.LevelCategoriesParentMap[gameLevelInfo.Id]);
 }
        public override bool HandleGameEditCommand(SkyPlayer player, GameLevel level, GameLevelInfo gameLevelInfo, params string[] args)
        {
            if (!(gameLevelInfo is MurderLevelInfo murderLevelInfo))
            {
                player.SendMessage("§cThe current levels game info is not in the correct format to be a Murder Level Info.");
                player.SendMessage("§cUpdating as MurderLevelInfo and saving with default options.");

                murderLevelInfo = new MurderLevelInfo(gameLevelInfo.LevelName, gameLevelInfo.WorldTime, gameLevelInfo.LobbyLocation,
                                                      new List <PlayerLocation>(), new List <PlayerLocation>());
            }

            if (args[0].Equals("add"))
            {
                if (args.Length < 2)
                {
                    player.SendMessage("§c/location add <spawn/gunpart>");
                    player.SendMessage("§cNot Enough Arguments.");
                    return(true);
                }

                List <PlayerLocation> locationList = null;
                if (args[1].Equals("spawn"))
                {
                    locationList = murderLevelInfo.PlayerSpawnLocations;
                }
                else if (args[1].Equals("gunpart"))
                {
                    locationList = murderLevelInfo.GunPartLocations;
                }

                if (locationList == null)
                {
                    player.SendMessage($"§cAction invalid. Must be 'spawn' or 'gunpart', but was '{args[1]}'");
                    return(true);
                }

                PlayerLocation addedLocation = (PlayerLocation)player.KnownPosition.Clone();
                addedLocation.X = (float)(Math.Floor(addedLocation.X) + 0.5f);
                addedLocation.Y = (float)Math.Floor(addedLocation.Y);
                addedLocation.Z = (float)(Math.Floor(addedLocation.Z) + 0.5f);

                addedLocation.HeadYaw = (float)Math.Floor(addedLocation.HeadYaw);
                addedLocation.HeadYaw = addedLocation.HeadYaw;
                addedLocation.Pitch   = (float)Math.Floor(addedLocation.Pitch);

                locationList.Add(addedLocation);

                string fileName =
                    $"C:\\Users\\Administrator\\Desktop\\worlds\\{RawName}\\{RawName}-{level.LevelName}.json";

                SkyUtil.log($"Saving as '{fileName}' -> {level.GameType} AND {level.LevelName}");

                File.WriteAllText(fileName, JsonConvert.SerializeObject(gameLevelInfo, Formatting.Indented));

                player.SendMessage($"§cUpdated {args[0]} location list ({locationList.Count}) with current location.");

                //Update current level info
                ((MurderLevel)player.Level).GameLevelInfo = gameLevelInfo;
            }
            else if (args[0].Equals("visualize"))
            {
                if (_currentVisualizationTasks.ContainsKey(player.Username))
                {
                    _currentVisualizationTasks[player.Username].Cancelled = true;

                    _currentVisualizationTasks.Remove(player.Username);

                    player.SendMessage("§eCancelling Visualization Task");
                }
                else
                {
                    player.SendMessage("§eVisualizing Gun Part and Player Spawn Locations...");

                    _currentVisualizationTasks.Add(player.Username, RunnableTask.RunTaskIndefinitely(() =>
                    {
                        foreach (PlayerLocation location in murderLevelInfo.GunPartLocations)
                        {
                            PlayerLocation displayLocation = (PlayerLocation)location.Clone();
                            displayLocation.Y += 0.5f;

                            Vector3 particleLocation = displayLocation.ToVector3();

                            new FlameParticle(player.Level)
                            {
                                Position = particleLocation
                            }.Spawn(new MiNET.Player[] { player });
                        }

                        foreach (PlayerLocation location in murderLevelInfo.PlayerSpawnLocations)
                        {
                            PlayerLocation displayLocation = (PlayerLocation)location.Clone();
                            displayLocation.Y += 0.5f;

                            Vector3 particleLocation = displayLocation.ToVector3();

                            new HeartParticle(player.Level)
                            {
                                Position = particleLocation
                            }.Spawn(new MiNET.Player[] { player });
                        }
                    }, 500));
                }
            }
            else if (args[0].Equals("tp"))
            {
                player.SendMessage("§eTeleporting to a random spawn location");
                player.Teleport(murderLevelInfo.PlayerSpawnLocations[Random.Next(murderLevelInfo.PlayerSpawnLocations.Count)]);
            }
            else
            {
                //Falls through, no specific handling
                return(false);
            }

            //One if-branch was used, this counts enough as usage
            return(true);
        }
Esempio n. 26
0
 public BuildBattleLevel(SkyCoreAPI plugin, string gameId, string levelPath, GameLevelInfo gameLevelInfo, List <BuildBattleTheme> themeList) :
     base(plugin, "build-battle", gameId, levelPath, gameLevelInfo, true)
 {
     ThemeList = themeList;
 }
Esempio n. 27
0
 public override bool HandleGameEditCommand(SkyPlayer player, GameLevel gameLevel, GameLevelInfo gameLevelInfo, params string[] args)
 {
     return(false);
 }
Esempio n. 28
0
 public static void Process(GameLevelInfo packet)
 {
     WriteLog.Verbose("Attempting to load game level " + packet.LevelName + " with players " + packet.PlayersLaps[0] + " and laps " + packet.PlayersLaps[1] + " and isReverse " + packet.isReverse);
     Main.opponents = packet.PlayersLaps[0];
     Main.LoadGame(packet.LevelName, packet.PlayersLaps[1], packet.PlayersLaps[0], packet.isReverse);
 }
Esempio n. 29
0
 public GameLevelInfo GetGameLevelInfo()
 {
     LevelInfo = RandomDSequenceElements(LevelInfo);
     return(LevelInfo);
 }
Esempio n. 30
0
        /*[Command(Name = "gameedit")]
         * [Authorize(Permission = CommandPermission.Normal)]
         * public void CommandGameEdit(MiNET.Player player, params string[] args)
         * {
         *      if (player.CommandPermission < CommandPermission.Admin)
         *      {
         *              player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
         *              return;
         *      }
         *
         *      if (!(player.Level is GameLevel level))
         *      {
         *              player.SendMessage($"§cYou must be in a {GameName} game to use this command!");
         *              return;
         *      }
         *
         *      if (!(level.GameLevelInfo is GameLevelInfo gameLevelInfo))
         *      {
         *              player.SendMessage("§cThe current level's information could not be loaded.");
         *              return;
         *      }
         *
         *      if (args[0].Equals("timeleft"))
         *      {
         *              if (args.Length < 2)
         *              {
         *                      player.SendMessage("§c/gameedit timeleft <time>");
         *                      return;
         *              }
         *
         *              if (!int.TryParse(args[1], out var timeRemaining))
         *              {
         *                      player.SendMessage($"§cInvalid time remaining ({args[1]})");
         *                      return;
         *              }
         *
         *              level.Tick = 0;
         *              ((RunningState)level.CurrentState).EndTick = timeRemaining * 2;
         *
         *              player.SendMessage($"§eReset in-game timer, and updated end-time to {timeRemaining} seconds");
         *      }
         *      else if (args[0].Equals("level"))
         *      {
         *              if (args.Length < 2)
         *              {
         *                      player.SendMessage("§c/gameedit level <levelname>");
         *                      return;
         *              }
         *
         *              string fullyQualifiedName = $"C:\\Users\\Administrator\\Desktop\\worlds\\{RawName}\\{args[1]}";
         *              GameLevel gameLevel;
         *              if (!LevelNames.Contains(fullyQualifiedName) || (gameLevel = InitializeNewGame(fullyQualifiedName)) == null)
         *              {
         *                      player.SendMessage($"§cInvalid level name ({args[1]})");
         *                      player.SendMessage($"§cBad Args: \n§c- {string.Join("\n§c- ", LevelNames.Select(x => _removeQualification(x.ToString())).ToArray())}");
         *                      return;
         *              }
         *
         *              foreach (SkyPlayer gamePlayer in level.GetAllPlayers())
         *              {
         *                      gameLevel.AddPlayer(gamePlayer);
         *              }
         *
         *              level.UpdateGameState(new VoidGameState()); //'Close' the game eventually
         *
         *              player.SendMessage($"§cUpdating game level to {args[1]}");
         *      }
         *      else if (args[0].Equals("nextstate"))
         *      {
         *              GameState nextState = level.CurrentState.GetNextGameState(level);
         *              if (nextState is VoidGameState)
         *              {
         *                      player.SendMessage("§cNo Next Available State Available.");
         *                      return;
         *              }
         *
         *              player.SendMessage($"§cProgressing to next state ({level.CurrentState.GetType()} -> {nextState.GetType()})");
         *              level.UpdateGameState(nextState);
         *      }
         *      else
         *      {
         *              if (!HandleGameEditCommand(player as SkyPlayer, level, gameLevelInfo, args))
         *              {
         *                      player.SendMessage("§c/gameedit timeleft");
         *                      player.SendMessage("§c/gameedit tp");
         *                      player.SendMessage("§c/gameedit nextstate");
         *                      player.SendMessage("§c/gameedit level <level-name>");
         *                      {
         *                              string subCommandHelp = GetGameEditCommandHelp(player as SkyPlayer);
         *                              if (subCommandHelp != null)
         *                              {
         *                                      player.SendMessage(subCommandHelp);
         *                              }
         *                      }
         *                      player.SendMessage($"§cBad Args: {string.Join(",", args.Select(x => x.ToString()).ToArray())}");
         *              }
         *      }
         * }*/

        public override bool HandleGameEditCommand(SkyPlayer player, GameLevel gameLevel, GameLevelInfo gameLevelInfo, params string[] args)
        {
            if (args[0].Equals("tp"))
            {
                if (!(gameLevel is BuildBattleLevel level))
                {
                    player.SendMessage("§eWorld is not BuildBattle world!");
                    return(false);
                }

                player.SendMessage("§eTeleporting to a random spawn location");
                player.Teleport(level.BuildTeams[Random.Next(level.BuildTeams.Count)].SpawnLocation);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Esempio n. 31
0
		/*
		 * Commands
		 */

	    public abstract bool HandleGameEditCommand(SkyPlayer player, GameLevel gameLevel, GameLevelInfo gameLevelInfo, params string[] args);
Esempio n. 32
0
	    public GameLevelInfo LoadGameLevelInfo(string levelName)
	    {
		    try
		    {
			    string shortLevelName;
			    {
				    string[] levelNameSplit = levelName.Split('\\');

				    shortLevelName = levelNameSplit[levelNameSplit.Length - 1];
			    }

			    string levelInfoFilename = GetGameLevelInfoLocation(RawName, shortLevelName);

			    GameLevelInfo gameLevelInfo;
				if (File.Exists(levelInfoFilename))
			    {
				    //SkyUtil.log($"Found '{levelInfoFilename}' for level. Loading...");

				    gameLevelInfo = (GameLevelInfo) JsonConvert.DeserializeObject(File.ReadAllText(levelInfoFilename),
					    GetGameLevelInfoType(), new GameLevelInfoJsonConverter());

					//Forcefully update/recalculate BlockCoordinates in-case the configuration was changed without modifying the Distance Property
					gameLevelInfo.LobbyMapLocation = new BlockCoordinates(gameLevelInfo.LobbyMapLocation.X, gameLevelInfo.LobbyMapLocation.Y, gameLevelInfo.LobbyMapLocation.Z);

					//Ensure all values are non-null
				    bool dirty = false;

				    if (string.IsNullOrEmpty(gameLevelInfo.GameType))
				    {
					    gameLevelInfo.GameType = RawName;
						dirty = true;
				    }
				    if (string.IsNullOrEmpty(gameLevelInfo.LevelName))
				    {
					    gameLevelInfo.LevelName = shortLevelName;
					    dirty = true;
				    }

				    if (dirty)
				    {
						File.WriteAllText(levelInfoFilename, JsonConvert.SerializeObject(gameLevelInfo, Formatting.Indented));

					    //SkyUtil.log($"Updating '{levelInfoFilename}' for level. Saving...");
					}
				}
				else
				{
					//SkyUtil.log($"Could not find '{levelInfoFilename} for level. Generating from base.");

					gameLevelInfo = new GameLevelInfo(RawName, levelName, 6000, new PlayerLocation(255.5, 15, 268.5, 180, 180));

					File.WriteAllText(levelInfoFilename, JsonConvert.SerializeObject(gameLevelInfo, Formatting.Indented));

					//SkyUtil.log($"Updating '{levelInfoFilename}' for level. Saving...");
				}

			    return gameLevelInfo;
			}
		    catch (Exception e)
		    {
				BugSnagUtil.ReportBug(e, this);
				return null;
		    }
	    }