Exemplo n.º 1
0
        private static IEnumerator <float> CheckLast()
        {
            yield return(Timing.WaitForSeconds(1.5f));

            if (scriptData.lastRan)
            {
                yield break;
            }

            foreach (var role in scriptData.last)
            {
                if (Player.List.Count(p => p.GetRole().Equals(role)) < 2)
                {
                    scriptData.lastRan = true;

                    foreach (var player in Player.List.Where(p => !p.GetRole().Equals(role)))
                    {
                        player.SetRole(RoleType.Spectator);
                        CustomRoles.ChangeRole(player, null);
                    }

                    foreach (var player in Player.List.Where(p => p.GetRole().Equals(role)))
                    {
                        player.SetRole(RoleType.Tutorial);
                        CustomRoles.ChangeRole(player, null);
                    }

                    break;
                }
            }
        }
Exemplo n.º 2
0
        public static RoleInfo GetRole(this Player p)
        {
            if (CustomRoles.users.ContainsKey(p.UserId))
            {
                var role = CustomRoles.GetRole(p);
                return(new RoleInfo(role.id, role.classId));
            }

            return(new RoleInfo(null, (int)p.Role));
        }
Exemplo n.º 3
0
        private static void SetRoles(ScriptActionsStore dataObj)
        {
            var players = Player.List.ToList();

            players.Shuffle();

            var playersTemp = players.Clone();

            foreach (var data in dataObj.classIds)
            {
                var num = 0;

                for (var i = 0; i < playersTemp.Count; i++)
                {
                    if (random.Next(0, 101) > data.chance && num > data.min)
                    {
                        continue;
                    }

                    playersTemp[i].SetRole(data.role.GetRole());
                    CustomRoles.ChangeRole(playersTemp[i], data.role.GetCustomRole());
                    players.RemoveAll(player => player.Id == playersTemp[i].Id);
                    num++;
                }

                players.Shuffle();
                playersTemp = players.Clone();
            }

            playersTemp = players.Clone();

            var spawnData = dataObj.classIds.Where(data => data.chance == 100).ToList();

            if (spawnData.Count > 0)
            {
                for (var i = 0; i < playersTemp.Count; i++)
                {
                    playersTemp[i].SetRole(spawnData[0].role.GetRole());
                    CustomRoles.ChangeRole(playersTemp[i], spawnData[0].role.GetCustomRole());
                    players.RemoveAll(player => player.Id == playersTemp[i].Id);
                }
            }

            if (dataObj.finalClass != null && players.Count > 0 && dataObj.finalClass.classId != -1)
            {
                var role       = dataObj.finalClass.GetRole();
                var customRole = dataObj.finalClass.GetCustomRole();

                foreach (var player in players)
                {
                    player.SetRole(role);
                    CustomRoles.ChangeRole(player, customRole);
                }
            }
        }
Exemplo n.º 4
0
        private static IEnumerator <float> LastEscape(EscapingEventArgs ev)
        {
            RoleInfo r = ev.Player.GetRole();

            yield return(Timing.WaitForSeconds(1f));

            foreach (var role in scriptData.escape)
            {
                if (role.Equals(r))
                {
                    scriptData.lastRan = true;

                    foreach (var player in Player.List.Where(p => p.Id != ev.Player.Id))
                    {
                        player.SetRole(RoleType.Spectator);
                        CustomRoles.ChangeRole(player, null);
                    }

                    ev.Player.SetRole(RoleType.Tutorial);
                    CustomRoles.ChangeRole(ev.Player, null);
                }
            }
        }
Exemplo n.º 5
0
        private static IEnumerator <float> Infect(DiedEventArgs ev)
        {
            if (DisallowedDamage.Contains(ev.HitInformations.GetDamageType()))
            {
                yield break;
            }

            var role = ev.Target.GetRole();

            DebugLog("Infect waiting");
            yield return(Timing.WaitForSeconds(2f));

            DebugLog("Infect done waiting");

            if (scriptData.lastRan)
            {
                DebugLog("");
                yield break;
            }

            var ran = false;

            DebugLog("Infect running checks");

            foreach (var data in scriptData.infectData)
            {
                if (!data.oldRole.Equals(role))
                {
                    DebugLog("Role " + data.oldRole.classId + "," + data.oldRole.roleID + " is not equal to " + role.classId + "," + role.roleID + ".");
                    continue;
                }

                DebugLog("Role " + data.oldRole.classId + "," + data.oldRole.roleID + " is equal to " + role.classId + "," + role.roleID + ".");

                ran = true;

                Vector3 oldPos = ev.Target.Position;

                ev.Target.SetRole(data.newRole.GetRole());

                CustomRoles.ChangeRole(ev.Target, data.newRole.GetCustomRole());

                DebugLog("Done setting roles");

                yield return(Timing.WaitForSeconds(1f));

                if (data.soft)
                {
                    ev.Target.Position = oldPos;
                }
                else
                {
                    foreach (var teleportdata in scriptData.teleportIds)
                    {
                        if (!teleportdata.role.Equals(data.newRole))
                        {
                            continue;
                        }

                        ev.Target.Position = teleportdata.pos;
                    }
                }

                foreach (var clearItemsData in scriptData.clearItems)
                {
                    if (!clearItemsData.Equals(data.newRole))
                    {
                        continue;
                    }

                    ev.Target.ClearInventory();
                }

                foreach (var itemData in scriptData.giveData)
                {
                    if (!itemData.role.Equals(data.newRole))
                    {
                        continue;
                    }

                    ev.Target.Inventory.AddNewItem(itemData.item);
                }

                foreach (var sizedata in scriptData.sizeData)
                {
                    if (!sizedata.role.Equals(data.newRole))
                    {
                        continue;
                    }

                    ev.Target.Scale = sizedata.scale;
                }

                foreach (var healthData in scriptData.hpData)
                {
                    if (!healthData.role.Equals(data.newRole))
                    {
                        continue;
                    }

                    ev.Target.Health = healthData.amount;
                }

                foreach (var broadcastData in scriptData.broadcast)
                {
                    if (!broadcastData.role.Equals(data.newRole) || broadcastData.role.roleID == "all")
                    {
                        continue;
                    }

                    ev.Target.Broadcast((ushort)broadcastData.duration, broadcastData.message);
                }

                foreach (var hintData in scriptData.hint)
                {
                    if (!hintData.role.Equals(data.newRole) || hintData.role.roleID == "all")
                    {
                        continue;
                    }

                    ev.Target.ShowHint(hintData.message, hintData.duration);
                }

                DebugLog("Infect done.");
            }

            if (!ran)
            {
                DebugLog("Infect not ran. Resetting player.");
                CustomRoles.ChangeRole(ev.Target, null);
            }
        }