예제 #1
0
        protected override void RemoveExisting(Drop <ContainerDestination> drop)
        {
            var existingPosition = Drops.FirstOrDefault(x => x.Bay == drop.Bay && x.Row == drop.Row);

            if (existingPosition != null)
            {
                Drops.Remove(existingPosition);

                if (existingPosition.Data.Container.Size == ContainerSize.FortyFoot)
                {
                    string rowNumber      = existingPosition.Row;
                    string rightBayNumber = (int.Parse(existingPosition.Bay) + 1).ToString();
                    string leftBayNumber  = (int.Parse(existingPosition.Bay) - 1).ToString();

                    existingPosition = Drops.FirstOrDefault(x => x.Bay == rightBayNumber && x.Row == rowNumber);
                    if (existingPosition == null)
                    {
                        existingPosition = Drops.FirstOrDefault(x => x.Bay == leftBayNumber && x.Row == rowNumber);
                    }

                    Drops.Remove(existingPosition);
                }
            }

            foreach (var objectDrop in Drops.Where(x => x.Data.GetHashCode() == drop.Data.GetHashCode()).ToArray())
            {
                Drops.Remove(objectDrop);
            }
        }
예제 #2
0
        public async Task <bool> DeleteDrop(Guid?dropId)
        {
            if (dropId.HasValue)
            {
                var resp = await _dropClient.DeleteDrop(dropId.Value, _deviceService.DeviceId);

                if (resp.IsSuccessStatusCode)
                {
                    //remove drop from cache of all drops
                    var dropToDelete = Drops.FirstOrDefault(x => x.Id == dropId);
                    if (dropToDelete != null)
                    {
                        Drops.Remove(dropToDelete);
                    }

                    //remove drop from cache of own drops
                    dropToDelete = OwnDrops.FirstOrDefault(x => x.Id == dropId);
                    if (dropToDelete != null)
                    {
                        OwnDrops.Remove(dropToDelete);
                    }
                }
                return(resp.IsSuccessStatusCode);
            }
            return(false);
        }
예제 #3
0
        public void Update(GameTime gameTime)
        {
            // Update drops
            for (int i = Drops.Count - 1; i >= 0; i--)
            {
                Drop drop = Drops[i];

                // Use map to detect collisions
                drop.DetectCollisions(this);

                // Calc dist from drop tp player
                float distToPlayer = Vector2.Distance(drop.Position, Main.Player.Bounds.Center.ToVector2());

                if (distToPlayer < 2 * Tile.Size)
                {
                    // Pick up
                    Drops.Remove(drop);
                    Main.inventory.AddItems(drop.Type, 1);
                }
                else if (distToPlayer < Player.PickupRange * Tile.Size)
                {
                    // Move drop towards player
                    drop.MoveToPlayer(Main.Player);
                }

                // Will move it
                drop.Update(gameTime);
            }
        }
예제 #4
0
 public void RemoveDrop(Drop drop)
 {
     if (Drops.Remove(drop.ID))
     {
         using (var removedrop = Handler6.RemoveDrop(drop))
         {
             Broadcast(removedrop);
         }
     }
 }
예제 #5
0
        public void Update()
        {
            map.UpDate();
            MEvent Event;

            while ((Event = map.NextEvent()) != null)
            {
                if (Event.Type == MEvents.PlayerArrow)
                {
                    int TagArrow  = ((MEventArrowHit)Event).TagArrow;
                    int TagPlayer = ((MEventArrowHit)Event).TagPlayer;
                    players[TagPlayer].recieveDamage(Arrows[TagArrow].dmg);
                    if (players[TagPlayer].isDead())
                    {
                        if (ArenaPlayer.ContainsKey(Arrows[TagArrow].creater))
                        {
                            ArenaPlayer[Arrows[TagArrow].creater].AddKill();
                        }
                        ArenaPlayer[TagPlayer].AddDeath();
                        if (players[TagPlayer].rightHand != 1)
                        {
                            int NewTag = Utily.GetTag();
                            Drops.Add(NewTag, new ADrop(1, players[TagPlayer].rightHand));
                            map.SpawnDrops(NewTag, map.players[TagPlayer].x, map.players[TagPlayer].y);
                        }
                        map.SpawnPlayer(TagPlayer);
                        players[TagPlayer].respawn();
                    }
                    Arrows.Remove(TagArrow);
                }
                if (Event.Type == MEvents.PlayerDrop)
                {
                    var drop = Drops[((MEventDrop)Event).TagDrop];
                    players[((MEventDrop)Event).TagPlayer].pickedUpItem(drop.id, drop.Count);
                    Drops.Remove(((MEventDrop)Event).TagDrop);
                    if (((MEventDrop)Event).BySpawner)
                    {
                        DropForRespawn.Enqueue(Utily.MakePair <long, int>(timer.ElapsedMilliseconds, ((MEventDrop)Event).NumSpawner));
                    }
                }
                if (Event.Type == MEvents.DestroyArrow)
                {
                    Arrows.Remove(((MEventDestroyArrow)Event).TagArrow);
                }
            }
            while (DropForRespawn.Count > 0 && DropForRespawn.Peek().Item1 + WaitRespawnDrop < timer.ElapsedMilliseconds)
            {
                int num = DropForRespawn.Dequeue().Item2;
                int tag = Utily.GetTag();
                map.SpawnDrops(num, tag);
                Drops.Add(tag, new ADrop(map.dropSpawners[num].count, map.dropSpawners[num].id));
            }
        }
예제 #6
0
        protected virtual void RemoveExisting(Drop <T> drop)
        {
            var existingDrop     = Drops.FirstOrDefault(x => x.Data.GetHashCode() == drop.Data.GetHashCode());
            var existingPosition = Drops.FirstOrDefault(x => x.Bay == drop.Bay && x.Row == drop.Row);

            if (existingPosition != null)
            {
                Drops.Remove(existingPosition);
            }
            if (existingDrop != null)
            {
                Drops.Remove(existingDrop);
            }
        }
예제 #7
0
        private bool RemoveEyeOfFire(bool bRemove)
        {
            int dwDropIdToRemove = 0;

            foreach (var drop in Drops)
            {
                if (drop.Item?.nItemID == EYE_OF_FIRE && DropRect.PointInRect(drop.Position.CurrentXY))
                {
                    if (bRemove && drop.OwnerCharId == 69)
                    {
                        dwDropIdToRemove = drop.dwId;
                        break;
                    }
                    else
                    {
                        drop.nLeaveType  = DropLeaveType.TimeOut;
                        drop.DropOwnType = DropOwnType.UserOwn;
                        drop.OwnerCharId = 69;
                        return(true);
                    }
                }
            }
            return(Drops.Remove(dwDropIdToRemove));
        }
예제 #8
0
 public void RemoveDrop(Drop drop)
 {
     Drops.Remove(drop.ID);
     drop = null;
 }
예제 #9
0
        public override bool TryDropPickup(Character pUser, CDrop pDrop)
        {
            if (!aTeams.ContainsKey(pUser.dwId))
            {
                return(false);
            }

            var bUserIsWolf = aTeams[pUser.dwId] == BattlefieldData.BattlefieldTeams.Wolves;

            var bKeepItem = true;

            switch ((BattlefieldData.BattleItems)pDrop.Item.nItemID)
            {
            // let sheep pick these up
            case BattlefieldData.BattleItems.CryOfLamb:
            case BattlefieldData.BattleItems.LambSurpriseAttack:
            case BattlefieldData.BattleItems.SoundOfSheepBells:
            {
                bKeepItem = !bUserIsWolf;
            }
            break;

            case BattlefieldData.BattleItems.GreatConfusion:
            case BattlefieldData.BattleItems.WoundOfWolfBells:
            case BattlefieldData.BattleItems.WolfThreat:
            {
                bKeepItem = bUserIsWolf;
            }
            break;

            case BattlefieldData.BattleItems.FineWool:
            {
                if (!bUserIsWolf)
                {
                    bKeepItem = false;

                    var user = Convert.ToInt32(pDrop.QR);

                    if (aTeams.ContainsKey(user))
                    {
                        ChangePlayerTeam(user, BattlefieldData.BattlefieldTeams.Sheep);

                        aSheepPoints[user] += 1;

                        if (aSheepPoints[user] > POINTS_PER_SHEEP)
                        {
                            aSheepPoints[user] = POINTS_PER_SHEEP;
                        }
                    }
                }
                else
                {
                    // player keeps item, score is reduced if player is still in
                    if (aTeams.ContainsKey(Convert.ToInt32(pDrop.QR)))
                    {
                        UpdateScore(BattlefieldData.BattlefieldTeams.Sheep, -1);
                    }
                }
            }
            break;

            case BattlefieldData.BattleItems.ShepherdBoysLunch:
            {
                if (bUserIsWolf)
                {
                    bKeepItem = false;
                }
                else
                {
                    // else player keeps item, score is reduced
                    UpdateScore(BattlefieldData.BattlefieldTeams.Wolves, -1);
                }
            }
            break;
            }

            if (bKeepItem)
            {
                if (InventoryManipulator.InsertInto(pUser, pDrop.Item) <= 0)
                {
                    return(false);
                }
            }
            else
            {
                Drops.Remove(pDrop);
                return(false);
            }

            return(true);
        }
예제 #10
0
 public void OnDropRemoved(object source, GameplayDropEventArgs args)
 {
     Drops.Remove(args.Id);
 }
예제 #11
0
        public void TakeString(string Arrow, string Drop, string Player)
        {
            var           arr    = Arrow.Split(',');
            HashSet <int> IsUsed = new HashSet <int>();

            for (int i = 0; i < arr.Length; i++)
            {
                var small = arr[i].Split(' ');
                int tag   = Utily.Parse(small[0]);
                int dmg   = Utily.Parse(small[1]);
                int id    = Utily.Parse(small[2]);
                if (Arrows.ContainsKey(tag))
                {
                    Arrows[tag].dmg = dmg;
                    Arrows[tag].id  = id;
                }
                else
                {
                    Arrows.Add(tag, new AArrow(dmg, id));
                    ArrowEvent.Enqueue(tag);
                }
                IsUsed.Add(tag);
            }
            List <int> ForRemove = new List <int>();

            foreach (var i in Arrows)
            {
                if (!IsUsed.Contains(i.Key))
                {
                    ForRemove.Add(i.Key);
                    ArrowEvent.Enqueue(-i.Key);
                }
            }
            foreach (var i in ForRemove)
            {
                Arrows.Remove(i);
            }

            var dro = Drop.Split(',');

            IsUsed.Clear();
            for (int i = 0; i < arr.Length; i++)
            {
                var small = dro[i].Split(' ');
                int tag   = Utily.Parse(small[0]);
                int cnt   = Utily.Parse(small[1]);
                int id    = Utily.Parse(small[2]);
                if (Drops.ContainsKey(tag))
                {
                    Drops[tag].Count = cnt;
                    Drops[tag].id    = id;
                }
                else
                {
                    Drops.Add(tag, new ADrop(cnt, id));
                    DropEvent.Enqueue(tag);
                }
                IsUsed.Add(tag);
            }
            ForRemove.Clear();
            foreach (var i in Drops)
            {
                if (!IsUsed.Contains(i.Key))
                {
                    ForRemove.Add(i.Key);
                    DropEvent.Enqueue(-i.Key);
                }
            }
            foreach (var i in ForRemove)
            {
                Drops.Remove(i);
            }

            var pla = Player.Split(',');

            IsUsed.Clear();
            for (int i = 0; i < arr.Length; i++)
            {
                var small = pla[i].Split(' ');
                int tag   = Utily.Parse(small[0]);
                int kill  = Utily.Parse(small[1]);
                int death = Utily.Parse(small[2]);
                if (ArenaPlayer.ContainsKey(tag))
                {
                    ArenaPlayer[tag].RealName = small[3];
                    IsUsed.Add(tag);
                }
                else
                {
                    ArenaPlayer.Add(tag, new APlayer(small[3]));
                }
                ArenaPlayer[tag].Kill  = kill;
                ArenaPlayer[tag].Death = death;
            }
            ForRemove.Clear();
            foreach (var i in ArenaPlayer)
            {
                if (!IsUsed.Contains(i.Key))
                {
                    ForRemove.Add(i.Key);
                }
            }
            foreach (var i in ForRemove)
            {
                ArenaPlayer.Remove(i);
            }
        }