public bool UserDetected(int[] boxIds, byte jobId)
        {
            Job job = (Job)jobId;
            List <IFieldObject <Player> > players = Field.State.Players.Values.ToList();

            if (job != Job.None)
            {
                players = players.Where(x => x.Value.Job == job).ToList();
            }
            foreach (int boxId in boxIds)
            {
                MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);
                if (box == null)
                {
                    return(false);
                }

                foreach (IFieldObject <Player> player in players)
                {
                    if (FieldManager.IsPlayerInBox(box, player))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        public void MiniGameGiveReward(int winnerBoxId, string contentType, MiniGame type)
        {
            MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, winnerBoxId);
            List <IFieldObject <Player> > players = new List <IFieldObject <Player> >();

            foreach (IFieldObject <Player> player in Field.State.Players.Values)
            {
                if (FieldManager.IsPlayerInBox(box, player))
                {
                    players.Add(player);
                }
            }
            foreach (IFieldObject <Player> player in players)
            {
                if (contentType == "miniGame")
                {
                    List <Item> items = RewardContentMetadataStorage.GetRewardItems(3, player.Value.Levels.Level);
                    foreach (Item item in items)
                    {
                        InventoryController.Add(player.Value.Session, item, true);
                    }
                }
                else if (contentType == "UserOpenMiniGameExtraReward")
                {
                }
            }
        }
Example #3
0
    public void SetAchievement(int boxId, string type, string trophySet)
    {
        List <IFieldActor <Player> > players = Field.State.Players.Values.ToList();

        if (boxId != 0)
        {
            MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);
            List <IFieldActor <Player> > boxedPlayers = new();
            foreach (IFieldActor <Player> player in players)
            {
                if (FieldManager.IsPlayerInBox(box, player))
                {
                    boxedPlayers.Add(player);
                }
            }

            players = boxedPlayers;
        }

        foreach (IFieldObject <Player> player in players)
        {
            if (type == "trigger")
            {
                TrophyManager.OnTrigger(player.Value, trophySet);
            }
        }
    }
        public void SetAchievement(int boxId, string type, string trophySet)
        {
            List <IFieldObject <Player> > players = Field.State.Players.Values.ToList();

            if (boxId != 0)
            {
                MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);
                List <IFieldObject <Player> > boxedPlayers = new List <IFieldObject <Player> >();
                foreach (IFieldObject <Player> player in players)
                {
                    if (FieldManager.IsPlayerInBox(box, player))
                    {
                        boxedPlayers.Add(player);
                    }
                }
                players = boxedPlayers;
            }

            foreach (IFieldObject <Player> player in players)
            {
                if (type == "trigger")
                {
                    switch (trophySet)
                    {
                    case "oxquiz_start":
                        player.Value.TrophyUpdate(23400009, 1);
                        break;

                    case "oxquiz_correct":
                        player.Value.TrophyUpdate(23400010, 1);
                        break;

                    case "oxquiz_win":
                        player.Value.TrophyUpdate(23400011, 1);
                        break;

                    case "trapmaster_start":
                        player.Value.TrophyUpdate(23400001, 1);
                        break;

                    case "trapmaster_win":
                        player.Value.TrophyUpdate(23400002, 1);
                        break;

                    case "finalsurvivor_start":
                        player.Value.TrophyUpdate(23400003, 1);
                        break;

                    case "finalsurvivor_win":
                        player.Value.TrophyUpdate(23400004, 1);
                        break;

                    default:
                        Logger.Warn($"Unhandled trophy set: {trophySet}");
                        break;
                    }
                }
            }
        }
        public void EndMiniGameRound(int winnerBoxId, float expRate, bool isOnlyWinner, bool isGainLoserBonus, bool meso, MiniGame type)
        {
            MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, winnerBoxId);

            foreach (IFieldObject <Player> player in Field.State.Players.Values)
            {
                if (FieldManager.IsPlayerInBox(box, player))
                {
                    // TODO: calculate correct amount of exp;
                    player.Value.Levels.GainExp(10000);
                }
            }
        }
        public void MiniGameCameraDirection(int boxId, int cameraId)
        {
            MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);
            List <IFieldObject <Player> > boxPlayers = new List <IFieldObject <Player> >();

            foreach (IFieldObject <Player> player in Field.State.Players.Values)
            {
                if (FieldManager.IsPlayerInBox(box, player))
                {
                    boxPlayers.Add(player);
                }
            }

            Random random = RandomProvider.Get();
            int    index  = random.Next(boxPlayers.Count);
            IFieldObject <Player> randomPlayer = boxPlayers[index];

            Field.BroadcastPacket(LocalCameraPacket.Camera(cameraId, 1, randomPlayer.ObjectId));
        }
Example #7
0
        public int GetUserCount(int boxId, int userTagId)
        {
            if (boxId != 0)
            {
                List <IFieldObject <Player> > players = Field.State.Players.Values.ToList();
                MapTriggerBox box       = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);
                int           userCount = 0;

                foreach (IFieldObject <Player> player in players)
                {
                    if (FieldManager.IsPlayerInBox(box, player))
                    {
                        userCount++;
                    }
                }
                return(userCount);
            }
            return(Field.State.Players.Values.Count);
        }
Example #8
0
    public void PlaySystemSoundInBox(int[] boxIds, string sound)
    {
        if (boxIds != null)
        {
            foreach (int boxId in boxIds)
            {
                MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);

                foreach (IFieldObject <Player> player in Field.State.Players.Values)
                {
                    if (FieldManager.IsPlayerInBox(box, player))
                    {
                        player.Value.Session.Send(SystemSoundPacket.Play(sound));
                    }
                }
            }
            return;
        }
        Field.BroadcastPacket(SystemSoundPacket.Play(sound));
    }
        public void EndMiniGame(int winnerBoxId, MiniGame type, bool isOnlyWinner)
        {
            MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, winnerBoxId);
            List <IFieldObject <Player> > players = new List <IFieldObject <Player> >();

            foreach (IFieldObject <Player> player in Field.State.Players.Values)
            {
                if (FieldManager.IsPlayerInBox(box, player))
                {
                    if (type == MiniGame.LudibriumEscape)
                    {
                        PlayerTrigger trigger = player.Value.Triggers.FirstOrDefault(x => x.Key == "gameStart");
                        player.Value.Triggers.Remove(trigger);
                        player.Value.Session.Send(ResultsPacket.Rounds(1, 1));
                    }
                    else if (type == MiniGame.OXQuiz)
                    {
                        player.Value.Session.Send(ResultsPacket.Rounds(10, 10));
                    }
                }
            }
        }
    public bool QuestUserDetected(int[] boxes, int[] questIds, byte[] modes, byte arg4)
    {
        QuestState mode = (QuestState) modes[0];
        foreach (int boxId in boxes)
        {
            MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);
            List<IFieldActor<Player>> players = Field.State.Players.Values.ToList();

            foreach (IFieldObject<Player> player in players)
            {
                if (!FieldManager.IsPlayerInBox(box, player))
                {
                    continue;
                }

                foreach (int questId in questIds)
                {
                    if (!player.Value.QuestData.TryGetValue(questId, out QuestStatus quest))
                    {
                        return false;
                    }

                    switch (mode)
                    {
                        case QuestState.Started:
                            return quest.State is QuestState.Started;
                        case QuestState.ConditionCompleted:
                            return quest.Condition.All(condition => condition.Completed);
                        case QuestState.Finished:
                            return quest.State is QuestState.Finished;
                    }
                }
            }
        }

        return false;
    }
        public void MoveUser(int mapId, int triggerId, int boxId)
        {
            List <IFieldObject <Player> > players = Field.State.Players.Values.ToList();

            if (boxId != 0)
            {
                MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);
                List <IFieldObject <Player> > boxedPlayers = new List <IFieldObject <Player> >();
                foreach (IFieldObject <Player> player in players)
                {
                    if (FieldManager.IsPlayerInBox(box, player))
                    {
                        boxedPlayers.Add(player);
                    }
                }
                players = boxedPlayers;
            }

            // move player back to return map
            if (mapId == 0 && triggerId == 0)
            {
                foreach (IFieldObject <Player> player in players)
                {
                    player.Value.Warp(player.Value.ReturnMapId, player.Value.ReturnCoord);
                }
                return;
            }

            if (mapId == Field.MapId)
            {
                IFieldObject <Portal> portal = Field.State.Portals.Values.First(p => p.Value.Id == triggerId);
                foreach (IFieldObject <Player> player in players)
                {
                    player.Coord    = portal.Coord;
                    player.Rotation = portal.Rotation;
                    player.Value.Session.Send(UserMoveByPortalPacket.Move(player, portal.Coord, portal.Rotation));
                }
                return;
            }

            CoordF    moveCoord;
            CoordF    moveRotation;
            MapPortal dstPortal = MapEntityStorage.GetPortals(mapId).FirstOrDefault(portal => portal.Id == triggerId);

            if (dstPortal == null)
            {
                MapPlayerSpawn spawn = MapEntityStorage.GetRandomPlayerSpawn(mapId);
                moveCoord    = spawn.Coord.ToFloat();
                moveRotation = spawn.Rotation.ToFloat();
            }
            else
            {
                moveCoord    = dstPortal.Coord.ToFloat();
                moveRotation = dstPortal.Rotation.ToFloat();
            }

            foreach (IFieldObject <Player> player in players)
            {
                player.Value.Warp(mapId, moveCoord, moveRotation);
            }
        }