public InitialPlayerSyncProcessor(IPacketSender packetSender, BuildThrottlingQueue buildEventQueue, Vehicles vehicles, ItemContainers itemContainers, EquipmentSlots equipment, PlayerManager remotePlayerManager, Entities entities)
 {
     this.packetSender        = packetSender;
     this.buildEventQueue     = buildEventQueue;
     this.vehicles            = vehicles;
     this.itemContainers      = itemContainers;
     this.equipment           = equipment;
     this.remotePlayerManager = remotePlayerManager;
     this.entities            = entities;
 }
Exemple #2
0
        public void Place()
        {
            foreach (Room room in Rooms)
            {
                if (rnd.Next(0, 6) > 1)
                {
                    ItemContainer itemContainer = new ItemContainer();
                    itemContainer.Position_x = room.Center_x;
                    itemContainer.Position_y = room.Center_y;
                    int i = rnd.Next(1, 101);
                    if (i > 0 && i <= 20)
                    {
                        itemContainer.Weapons.Add(new WoodenDagger());
                    }
                    if (i > 20 && i <= 35)
                    {
                        itemContainer.Weapons.Add(new IronSword());
                    }
                    if (i > 35 && i <= 45)
                    {
                        itemContainer.Weapons.Add(new GlassDagger());
                    }
                    if (i > 45 && i <= 50)
                    {
                        itemContainer.Weapons.Add(new SilverSpear());
                    }

                    i = rnd.Next(1, 101);

                    if (i > 0 && i <= 20)
                    {
                        itemContainer.Armors.Add(new LeatherArmor());
                    }
                    if (i > 20 && i <= 35)
                    {
                        itemContainer.Armors.Add(new IronArmor());
                    }
                    if (i > 35 && i <= 50)
                    {
                        itemContainer.Armors.Add(new GlassArmor());
                    }
                    if (i > 50 && i <= 60)
                    {
                        itemContainer.Armors.Add(new SteelArmor());
                    }
                    if (i > 60 && i <= 65)
                    {
                        itemContainer.Armors.Add(new SilverArmor());
                    }

                    ItemContainers.Add(itemContainer);
                    Objects.Add(itemContainer);
                }
            }
        }
        public InventoryItemsInitialSyncProcessor(IPacketSender packetSender, ItemContainers itemContainers)
        {
            this.packetSender   = packetSender;
            this.itemContainers = itemContainers;

            DependentProcessors.Add(typeof(GlobalRootInitialSyncProcessor));   // Global root items can have inventories like the floating locker.
            DependentProcessors.Add(typeof(BuildingInitialSyncProcessor));     // Buildings can have inventories like storage lockers.
            DependentProcessors.Add(typeof(PlayerInitialSyncProcessor));       // The player has their own inventory.
            DependentProcessors.Add(typeof(VehicleInitialSyncProcessor));      // Vehicle can have an inventory.
            DependentProcessors.Add(typeof(EquippedItemInitialSyncProcessor)); // Vehicles can have equipped items that spawns container
        }
Exemple #4
0
        public void OnFlagChanged(int index)
        {
            if (IsRevamp)
            {
                if (index == 2008) // CAMP_CABIN_FURNITURE_DRESSER
                {
                    UpdateDresser();
                    ItemContainers.Update();
                }
            }

            foreach (var prop in _allFlags[index].GameVMProperties)
            {
                OnPropertyChanged(prop);
            }
        }
Exemple #5
0
        /// <summary>
        /// Called when new containers are initialized by the <see cref="ItemContainerGenerator"/>.
        /// </summary>
        /// <param name="containers">The containers.</param>
        private void ContainersInitialized(ItemContainers containers)
        {
            var selectedIndex     = SelectedIndex;
            var selectedContainer = containers.Items.OfType <ISelectable>().FirstOrDefault(x => x.IsSelected);

            if (selectedContainer != null)
            {
                SelectedIndex = containers.Items.IndexOf((IControl)selectedContainer) + containers.StartingIndex;
            }
            else if (selectedIndex >= containers.StartingIndex &&
                     selectedIndex < containers.StartingIndex + containers.Items.Count)
            {
                var container = containers.Items[selectedIndex - containers.StartingIndex];
                MarkContainerSelected(container, true);
            }
        }
Exemple #6
0
        public void OnPerkAddedOrRemoved(string name, bool isOwned)
        {
            // Grants/removes the player the appropriate bonuses when a perk is added or removed.
            // We do not add stats however since the user can already change them easily.
            switch (name)
            {
            case "Feeder":
                _allStatuses.First(x => x.Name == name).IsOwned = isOwned;
                break;

            case "Misdirection":
                _allFlags[138].SetValue(isOwned ? 4 : 0);     // RAPHAEL_INTELLIGENCE_TRAINING
                break;

            case "Rapier Training":
                if (IsRevamp)
                {
                    FlagVM rapierTraining = _allFlags[137];     // RAPHAEL_RAPIER_TRANING
                    if (isOwned)
                    {
                        if (rapierTraining.AsInt() < 4)
                        {
                            rapierTraining.SetValue(4);
                        }
                    }
                    else
                    {
                        rapierTraining.SetValue(0);
                    }
                }
                break;

            case "Strong Back":
                GetObj("itemSlot4")["unlocked"] = isOwned;
                UpdateInventory();
                ItemContainers.Update();
                break;

            case "Strong Back 2: Strong Harder":
                GetObj("itemSlot5")["unlocked"] = isOwned;
                UpdateInventory();
                ItemContainers.Update();
                break;
            }
        }
Exemple #7
0
        public void UpdateItemSlots()
        {
            int maxItems     = IsXianxia ? 20 : 10;
            int startingSlot = IsXianxia ? 6 : 4;

            if (GetPerk("Strong Back").IsOwned)
            {
                GetObj("itemSlot" + startingSlot)["unlocked"] = true;
                startingSlot++;
            }
            if (GetPerk("Strong Back 2: Strong Harder").IsOwned)
            {
                GetObj("itemSlot" + startingSlot)["unlocked"] = true;
                startingSlot++;
            }
            if (IsRevampOrXianxia && GetPerk("Strong Back 3: Strong Hardest").IsOwned)
            {
                GetObj("itemSlot" + startingSlot)["unlocked"] = true;
                startingSlot++;
            }
            if (IsRevampOrXianxia && GetKeyItem("Backpack").IsOwned)
            {
                var backpack = _allKeyitems.First(x => x.Name == "Backpack");
                for (int i = startingSlot; i <= maxItems; i++)
                {
                    GetObj("itemSlot" + i)["unlocked"] = false;
                }
                if (backpack.IsOwned)
                {
                    int count = backpack.GetInt("value1");
                    if (count < 1 || count > maxItems)
                    {
                        count           = Math.Max(1, Math.Min(maxItems, count)); // clamp value to [1, maxItems], so CoC-Revamp/Xianxia doesn't assplode
                        backpack.Value1 = count;
                    }
                    for (int i = startingSlot; i < startingSlot + count; i++)
                    {
                        GetObj("itemSlot" + i)["unlocked"] = true;
                    }
                }
            }
            UpdateInventory();
            ItemContainers.Update();
        }
Exemple #8
0
        /// <summary>
        /// Moves keyboard focus the specified number of steps away from the currently focused item.
        /// </summary>
        /// <param name="step">The number of steps by which to move focus.</param>
        private void MoveItemFocus(Int32 step)
        {
            var selectedContainer = ItemsControlUtil.FindFocusedContainer <ComboBoxItem>(this);
            var selectedIndex     = (selectedContainer == null) ? -1 : ItemContainers.IndexOf(selectedContainer);

            var targetIndex = selectedIndex + step;

            if (targetIndex < 0 || targetIndex >= Items.Count)
            {
                return;
            }

            var targetContainer = ItemContainers[targetIndex] as UIElement;

            if (targetContainer == null)
            {
                return;
            }

            targetContainer.Focus();

            ItemsControlUtil.ScrollItemIntoView <ComboBoxItem>(this, PART_ScrollViewer, targetContainer);
        }
Exemple #9
0
 public ItemContainerAddProcessor(IPacketSender packetSender, ItemContainers itemContainer)
 {
     this.packetSender  = packetSender;
     this.itemContainer = itemContainer;
 }
Exemple #10
0
        public void Spawn(Player player)
        {
            List <LevelObject> floors = Objects.FindAll(x => x.Name == "floor");

            // Spawn Player:
            while (true)
            {
                int p = rnd.Next(0, floors.Count);
                if (ItemContainers.Any(i => i.Position_x == floors[p].Position_x && i.Position_y == floors[p].Position_y))
                {
                    continue;
                }
                else
                {
                    player.Position_x = floors[p].Position_x;
                    player.Position_y = floors[p].Position_y;
                    Player            = player;
                    Objects.Add(Player);
                    Creatures.Add(Player);
                    break;
                }
            }

            // Spawn Skeletons:
            for (int i = 0; i < 20;)
            {
                int s = rnd.Next(0, floors.Count);
                if (Creatures.Any(obj => obj.Position_x == floors[s].Position_x && obj.Position_y == floors[s].Position_y) || ItemContainers.Any(c => c.Position_x == floors[s].Position_x && c.Position_y == floors[s].Position_y))
                {
                    continue;
                }
                else
                {
                    Skeleton skeleton = new Skeleton(ID);
                    skeleton.Position_x       = floors[s].Position_x;
                    skeleton.Position_y       = floors[s].Position_y;
                    skeleton.Spawn_Position_x = skeleton.Position_x;
                    skeleton.Spawn_Position_y = skeleton.Position_y;
                    skeleton.Habitat_x_max    = skeleton.Position_x + 2;
                    skeleton.Habitat_x_min    = skeleton.Position_x - 2;
                    skeleton.Habitat_y_max    = skeleton.Position_y + 2;
                    skeleton.Habitat_y_min    = skeleton.Position_y - 2;
                    skeleton.Follow_x_max     = skeleton.Position_x + 6;
                    skeleton.Follow_x_min     = skeleton.Position_x - 6;
                    skeleton.Follow_y_max     = skeleton.Position_y + 6;
                    skeleton.Follow_y_min     = skeleton.Position_y - 6;

                    Objects.Add(skeleton);
                    Creatures.Add(skeleton);
                    i++;
                }
            }
            // Spawn Skeleton Warriors:
            for (int i = 0; i < 10;)
            {
                int z = rnd.Next(0, floors.Count);
                if (Creatures.Any(obj => obj.Position_x == floors[z].Position_x && obj.Position_y == floors[z].Position_y) || ItemContainers.Any(c => c.Position_x == floors[z].Position_x && c.Position_y == floors[z].Position_y) || Math.Abs(floors[z].Position_x - Player.Position_x) < 30 || Math.Abs(floors[z].Position_y - Player.Position_y) < 30)
                {
                    continue;
                }
                else
                {
                    SkeletonWarrior skeleton = new SkeletonWarrior();
                    skeleton.Position_x       = floors[z].Position_x;
                    skeleton.Position_y       = floors[z].Position_y;
                    skeleton.Spawn_Position_x = skeleton.Position_x;
                    skeleton.Spawn_Position_y = skeleton.Position_y;
                    skeleton.Habitat_x_max    = skeleton.Position_x + 2;
                    skeleton.Habitat_x_min    = skeleton.Position_x - 2;
                    skeleton.Habitat_y_max    = skeleton.Position_y + 2;
                    skeleton.Habitat_y_min    = skeleton.Position_y - 2;
                    skeleton.Follow_x_max     = skeleton.Position_x + 4;
                    skeleton.Follow_x_min     = skeleton.Position_x - 4;
                    skeleton.Follow_y_max     = skeleton.Position_y + 4;
                    skeleton.Follow_y_min     = skeleton.Position_y - 4;
                    Objects.Add(skeleton);
                    Creatures.Add(skeleton);
                    i++;
                }
            }
            // Spawn Guards:
            for (int i = 0; i < 9; i++)
            {
                Guard guard = new Guard();
                guard.Position_x       = Rooms[i].Center_x - 1;
                guard.Position_y       = Rooms[i].Center_y - 1;
                guard.Spawn_Position_x = guard.Position_x;
                guard.Spawn_Position_y = guard.Position_y;
                guard.Habitat_x_max    = (guard.Spawn_Position_x + 1) + (Rooms[i].Length) / 2 - 1;
                guard.Habitat_x_min    = (guard.Spawn_Position_x + 1) - (Rooms[i].Length) / 2 + 1;
                guard.Habitat_y_max    = (guard.Spawn_Position_y + 1) + (Rooms[i].Width) / 2 - 1;
                guard.Habitat_y_min    = (guard.Spawn_Position_y + 1) - (Rooms[i].Width) / 2 + 1;
                guard.Follow_x_max     = guard.Habitat_x_max;
                guard.Follow_y_max     = guard.Habitat_y_max;
                guard.Follow_x_min     = guard.Habitat_x_min;
                guard.Follow_y_min     = guard.Habitat_y_min;
                Objects.Add(guard);
                Creatures.Add(guard);
            }
        }
Exemple #11
0
        /// <summary>
        /// Selects the item which currently has keyboard focus.
        /// </summary>
        private void SelectFocusedItem()
        {
            var container = ItemsControlUtil.FindFocusedContainer <ComboBoxItem>(this);

            SelectedIndex = (container == null) ? -1 : ItemContainers.IndexOf(container);
        }
 public PlayerInitialSyncProcessor(ItemContainers itemContainers, IPacketSender packetSender)
 {
     this.itemContainers = itemContainers;
     this.packetSender   = packetSender;
 }
 public InventoryItemAdder(IPacketSender packetSender, ItemContainers itemContainers, List <ItemData> inventoryItems)
 {
     this.packetSender   = packetSender;
     this.itemContainers = itemContainers;
     this.inventoryItems = inventoryItems;
 }
 public ItemContainerAddProcessor(ItemContainers itemContainer)
 {
     this.itemContainer = itemContainer;
 }
Exemple #15
0
 public PlayerInitialSyncProcessor(ItemContainers itemContainers)
 {
     this.itemContainers = itemContainers;
 }
Exemple #16
0
 public ItemContainerRemoveProcessor(ItemContainers itemContainer)
 {
     this.itemContainer = itemContainer;
 }