Esempio n. 1
0
        /// <summary>
        /// Begins the battle.
        /// </summary>
        public void Begin()
        {
            _dynamicMap = Collections.MapCollection.GetDynamicMap(700);
            _dynamicMap.Show();

            Task.Run(async() => await EndTimeOutAsync(90000, false));

            ArenaBattle.MatchStartTime = DateTime.UtcNow.AddMilliseconds(10000);
            ArenaBattle.Started        = true;

            var player1 = ArenaBattle.Player1.Player;
            var player2 = ArenaBattle.Player2.Player;

            player1.Revive(true);
            player2.Revive(true);

            player1.TransformModel = 0;
            player2.TransformModel = 0;

            player1.RemoveStatusFlag(Enums.StatusFlag.Ghost);
            player1.RemoveStatusFlag(Enums.StatusFlag.Dead);
            player1.RemoveStatusFlag(Enums.StatusFlag.Riding);

            player2.RemoveStatusFlag(Enums.StatusFlag.Ghost);
            player2.RemoveStatusFlag(Enums.StatusFlag.Dead);
            player2.RemoveStatusFlag(Enums.StatusFlag.Riding);

            player1.MapChangeEvents
            .Enqueue((p) =>
            {
                p.ClientSocket.Send(GetMatch());
                p.ClientSocket.Send(GetCountDown(player2, player1));
                p.ClientSocket.Send(GetPacket());
            });

            player2.MapChangeEvents
            .Enqueue((p) =>
            {
                p.ClientSocket.Send(GetMatch());
                p.ClientSocket.Send(GetCountDown(player1, player2));
                p.ClientSocket.Send(GetPacket());
            });

            foreach (var watcher in ArenaBattle.Watchers.Values)
            {
                watcher.MapChangeEvents
                .Enqueue((p) =>
                {
                    p.ClientSocket.Send(GetPacket());
                });
            }

            var player1Location = GenerateRandomLocation();

            player1.TeleportDynamic(_dynamicMap.Id, player1Location.X, player1Location.Y);

            var player2Location = GenerateRandomLocation();

            player2.TeleportDynamic(_dynamicMap.Id, player2Location.X, player2Location.Y);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a house.
        /// </summary>
        public void CreateHouse()
        {
            Guild.DbGuild.HasHouse = true;

            if (_house == null)
            {
                _house = Collections.MapCollection.GetDynamicMap(1099);

                _house.Show();

                Guild.Warehouse = new CandyConquer.WorldApi.Collections.GuildWarehouse(Guild);

                foreach (var dbOwnerItem in Database.Dal.Warehouses.GetGuildWarehouseItems(Guild.Id))
                {
                    var item = Collections.ItemCollection.CreateItemById((uint)dbOwnerItem.ItemId);
                    item.DbOwnerItem = dbOwnerItem;
                    if (!string.IsNullOrWhiteSpace(dbOwnerItem.Color))
                    {
                        item.Color = dbOwnerItem.Color.ToEnum <Enums.ItemColor>();
                    }
                    item.Gem1 = dbOwnerItem.Gem1.ToEnum <Enums.Gem>();
                    item.Gem2 = dbOwnerItem.Gem2.ToEnum <Enums.Gem>();

                    Guild.Warehouse.Add(item, null, true);
                }

                var dbNpc = new Database.Models.DbNpc
                {
                    Id     = 200000,
                    NpcId  = 200000,
                    Type   = "Normal",
                    Name   = "GuildWarehouse",
                    MapId  = _house.Id,
                    X      = 44,
                    Y      = 23,
                    Flag   = 2,
                    Mesh   = 5280,
                    Avatar = 0,
                    Server = Drivers.Settings.WorldSettings.Server
                };
                var npc = new Models.Entities.Npc(dbNpc);
                npc.TeleportDynamic(_house.Id, npc.X, npc.Y);
            }

            Guild.DbGuild.Update();
        }