示例#1
0
            public void RunEvent(MapInstance map)
            {
                SummonNpc(Map);
                map.Broadcast("msg 0 The battle begin in 5 seconds.");
                map.SendInMapAfter(1, "msg 0 The battle begin in 4 seconds.");
                map.SendInMapAfter(2, "msg 0 The battle begin in 3 seconds.");
                map.SendInMapAfter(3, "msg 0 The battle begin in 2 seconds.");
                map.SendInMapAfter(4, "msg 0 The battle begin in 1 seconds.");
                map.SendInMapAfter(5, "msg 0 Fight !");

                Observable.Timer(TimeSpan.FromSeconds(5)).Subscribe(o =>
                {
                    CreateGroup(Map.Sessions);
                    GenerateBattleRainbowPacket(RainbowTeamBattleType.Blue);
                    GenerateBattleRainbowPacket(RainbowTeamBattleType.Red);
                    map.IsPVP = true;

                    // Observable Disposed → EndEvent()
                    RainbowBattleManager.ObservableFlag = Observable.Interval(TimeSpan.FromSeconds(7)).Subscribe(s =>
                    {
                        RainbowBattleManager.GenerateScoreForAll();
                    });
                });

                Observable.Timer(TimeSpan.FromSeconds(605)).Subscribe(o =>
                {
                    RainbowBattleManager.EndEvent(map);
                });
            }
示例#2
0
            public void CreateGroup(IEnumerable <ClientSession> session)
            {
                int team1 = 0;
                int team2 = 0;
                var group = new Group
                {
                    GroupType = GroupType.RainbowBattleBlue
                };

                ServerManager.Instance.AddGroup(group);
                var group2 = new Group
                {
                    GroupType = GroupType.RainbowBattleRed
                };

                ServerManager.Instance.AddGroup(group2);
                ConcurrentBag <ClientSession> firstTeam  = new ConcurrentBag <ClientSession>();
                ConcurrentBag <ClientSession> secondTeam = new ConcurrentBag <ClientSession>();

                foreach (ClientSession ses in session)
                {
                    if (RainbowBattleManager.AreNotInMap(ses))
                    {
                        continue;
                    }

                    ses.Character.Group?.LeaveGroup(ses);

                    var value = team1 - team2;

                    if (value == 0)
                    {
                        team1++;
                        firstTeam.Add(ses);
                        group.JoinGroup(ses);
                    }
                    else
                    {
                        team2++;
                        secondTeam.Add(ses);
                        group2.JoinGroup(ses);
                    }

                    ServerManager.Instance.UpdateGroup(ses.Character.CharacterId);
                }

                ServerManager.Instance.RainbowBattleMembers = new ConcurrentBag <RainbowBattleTeam>
                {
                    new RainbowBattleTeam(firstTeam, RainbowTeamBattleType.Blue),
                    new RainbowBattleTeam(secondTeam, RainbowTeamBattleType.Red)
                };
            }
示例#3
0
            public void GenerateBattleRainbowPacket(RainbowTeamBattleType value)
            {
                string rndm        = string.Empty;
                string rndm2       = string.Empty;
                var    RainbowTeam = ServerManager.Instance.RainbowBattleMembers.First(s => s.TeamEntity == value);

                if (RainbowTeam == null)
                {
                    return;
                }

                foreach (var bb in RainbowTeam.Session)
                {
                    if (RainbowBattleManager.AreNotInMap(bb))
                    {
                        continue;
                    }

                    rndm  += $"{bb.Character.CharacterId} ";
                    rndm2 +=
                        $"{bb.Character.Level}." +
                        $"{bb.Character.Morph}." +
                        $"{(byte)bb.Character.Class}." +
                        $"0." +
                        $"{bb.Character.Name}." +
                        $"{(byte)bb.Character.Gender}." +
                        $"{bb.Character.CharacterId}." +
                        $"{bb.Character.HeroLevel} ";
                }

                foreach (var bb in RainbowTeam.Session)
                {
                    if (RainbowBattleManager.AreNotInMap(bb))
                    {
                        continue;
                    }

                    bb.SendPacket("fbt 0 1");
                    bb.SendPacket($"fbt 1 {rndm}");
                    bb.SendPacket($"fblst {rndm2}");
                    bb.SendPacket($"fbt 5 1 600");
                    bb.SendPacket($"msg 0 you are the {value} team");
                    bb.SendPacket($"fbs {(byte)value} {RainbowTeam.Session.Count()} 0 0 0 0 0 {value}");
                }
                //fbs <Type> <TeamCount> <RedPts> <BluePts> <flag1> <flag2> <flag3> <TEAM>
            }
示例#4
0
            public void SummonNpc(MapInstance map)
            {
                List <MapNpc> npc = new List <MapNpc>
                {
                    new MapNpc
                    {
                        NpcVNum   = 922,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 59,
                        MapY      = 40,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 5
                    },
                    new MapNpc
                    {
                        NpcVNum   = 923,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 74,
                        MapY      = 53,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 2
                    },
                    new MapNpc
                    {
                        NpcVNum   = 923,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 32,
                        MapY      = 75,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 2
                    },
                    new MapNpc
                    {
                        NpcVNum   = 923,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 85,
                        MapY      = 4,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 2
                    },
                    new MapNpc
                    {
                        NpcVNum   = 923,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 43,
                        MapY      = 26,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 2
                    },
                    new MapNpc
                    {
                        NpcVNum   = 924,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 15,
                        MapY      = 40,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 1
                    },
                    new MapNpc
                    {
                        NpcVNum   = 924,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 999,
                        MapId     = map.Map.MapId,
                        MapX      = 102,
                        MapY      = 39,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 1
                    },
                };

                foreach (var Stone in npc)
                {
                    Stone.Dialog = 999;
                    Stone.Initialize(map);
                    map.AddNPC(Stone);
                    map.Broadcast(Stone.GenerateIn());
                    IEnumerable <ClientSession> sess = ServerManager.Instance.Sessions.Where(s => s.Character?.CharacterId == null);
                    foreach (ClientSession ses in sess)
                    {
                        if (Stone.Dialog == 999)
                        {
                            ses.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 1, $"#guri^711^{Stone.MapNpcId}"));
                            Stone.Score++;
                            RainbowBattleManager.SendFbs();
                        }
                    }
                }
            }