Пример #1
0
        protected override void OnActivateScene(object parameter)
        {
            leader = parameter as Character;
            group  = leader.GetGroup();

            BurntimeClassic classic = app as BurntimeClassic;

            inventory.SetGroup(leader);

            if (classic.InventoryBackground == -1)
            {
                Background = "hint2.pac";
            }
            else
            {
                Background = "raum_" + classic.InventoryBackground.ToString() + ".pac";
            }
            Size = new Vector2(320, 200);

            if (grid != null)
            {
                Windows -= grid;
                grid     = null;
            }

            if (classic.InventoryRoom != null)
            {
                Music = classic.InventoryRoom.IsWaterSource ? "22_MUS 22_HSC.ogg" : "04_MUS 04_HSC.ogg";

                grid = new ItemGridWindow(app);
                grid.LockPositions = true;
                grid.DoubleLayered = !classic.InventoryRoom.IsWaterSource;
                grid.Position      = new Vector2(160, classic.InventoryRoom.IsWaterSource ? 128 : 20);
                grid.Spacing       = new Vector2(4, 4);
                grid.Grid          = new Vector2(4, classic.InventoryRoom.IsWaterSource ? 2 : 5);
                grid.Layer++;
                grid.LeftClickItemEvent  += OnLeftClickItemRoom;
                grid.RightClickItemEvent += OnRightClickItemRoom;
                Windows += grid;

                grid.Add(classic.InventoryRoom.Items);

                // group drinks water
                if (classic.InventoryRoom.IsWaterSource)
                {
                    int r = group.Drink(leader, classic.Game.World.ActiveLocationObj.Source.Reserve);
                    classic.Game.World.ActiveLocationObj.Source.Reserve = r;
                }
            }
            else if (classic.PickItems != null)
            {
                Music = "04_MUS 04_HSC.ogg";

                grid          = new ItemGridWindow(app);
                grid.Position = new Vector2(170, 10);
                grid.Spacing  = new Vector2(2, 2);
                grid.Grid     = new Vector2(4, 5);
                grid.Layer++;
                grid.LeftClickItemEvent  += OnLeftClickItemRoom;
                grid.RightClickItemEvent += OnRightClickItemRoom;
                Windows += grid;

                grid.Add(classic.PickItems);
            }
            else
            {
                Music = "04_MUS 04_HSC.ogg";
            }
        }
Пример #2
0
        void OnRightClickItemInventory(Framework.States.StateObject state)
        {
            BurntimeClassic classic = app as BurntimeClassic;

            Item item = state as Item;

            // eat
            if (item.FoodValue != 0)
            {
                int left = group.Eat(leader, item.FoodValue);

                // remove item only if somebody actually ate
                if (left < item.FoodValue)
                {
                    if (item.Type.Empty != null)
                    {
                        item.MakeEmpty();
                        inventory.Grid.Update(item);
                    }
                    else
                    {
                        inventory.ActiveCharacter.Items.Remove(item);
                        inventory.Grid.Remove(item);
                    }
                }
            }
            // drink
            else if (item.WaterValue != 0)
            {
                int left = group.Drink(leader, item.WaterValue);

                // remove item only if somebody actually drank
                if (left < item.WaterValue)
                {
                    if (item.Type.Empty != null)
                    {
                        item.MakeEmpty();
                        inventory.Grid.Update(item);
                    }
                    else
                    {
                        inventory.ActiveCharacter.Items.Remove(item);
                        inventory.Grid.Remove(item);
                    }
                }
            }
            else if (item.Type.Full != null)
            {
                // fill up empty bottles
                if (classic.InventoryRoom != null && classic.InventoryRoom.IsWaterSource)
                {
                    if (item.Type.Full != null && item.Type.Full.WaterValue != 0)
                    {
                        if (classic.Game.World.ActiveLocationObj.Source.Reserve >= item.Type.Full.WaterValue)
                        {
                            classic.Game.World.ActiveLocationObj.Source.Reserve -= item.Type.Full.WaterValue;
                            item.MakeFull();

                            // refresh item
                            inventory.Grid.Remove(item);
                            inventory.Grid.Add(item);
                        }
                    }
                }
            }
            else if (item.IsSelectable)
            {
                inventory.ActiveCharacter.SelectItem(item);
                inventory.Grid.Selection.Clear();
                if (inventory.ActiveCharacter.Weapon != null)
                {
                    inventory.Grid.Selection.Add(inventory.ActiveCharacter.Weapon);
                }
                if (inventory.ActiveCharacter.Protection != null)
                {
                    inventory.Grid.Selection.Add(inventory.ActiveCharacter.Protection);
                }
            }
            else //if (inventory.ActiveCharacter.Class == CharClass.Technician)
            {
                IItemCollection right = (classic.InventoryRoom == null) ? (IItemCollection)classic.PickItems : classic.InventoryRoom.Items;
                construction = classic.Game.Constructions.GetConstruction(inventory.ActiveCharacter, right, item);
                this.item    = item;
                dialog.SetCharacter(inventory.ActiveCharacter, construction.Dialog);
                dialog.Show();
            }
        }
Пример #3
0
        public virtual void Turn()
        {
            if (IsDead)
            {
                return;
            }

            if (Player == null)
            {
                TurnNonPlayer();
                return;
            }

            // npc is with boss
            if (IsWithBoss)
            {
                Group group = Player.Group;

                if (Food == 0)
                {
                    IItemCollection owner;
                    Item            item = group.FindFood(out owner);
                    if (item != null)
                    {
                        group.Eat(null, item.FoodValue);
                        owner.Remove(item);
                    }
                }

                if (Water == 0)
                {
                    Item item = group.FindWater();
                    if (item != null)
                    {
                        group.Drink(null, item.WaterValue);
                        item.Type = item.Type.Empty;
                    }
                }
            }
            else // npc is stationed
            {
                ICharacterCollection group = GetGroup();

                if (Location.NPCFoodProduction > 0)
                {
                    Location.NPCFoodProduction--;
                    Food++;
                }
                else if (Food == 0)
                {
                    IItemCollection owner;
                    // search for food in rooms
                    Item item = Location.FindFood(out owner);
                    // if not available then try the inventory
                    if (item == null)
                    {
                        item = group.FindFood(out owner);
                    }
                    if (item != null)
                    {
                        group.Eat(null, item.FoodValue);
                        owner.Remove(item);
                    }
                }

                Location.Source.Reserve = group.Drink(null, Location.Source.Reserve);
                if (Water == 0)
                {
                    // search for stored water in rooms
                    Item item = Location.FindWater();
                    // if not available then try the inventory
                    if (item == null)
                    {
                        item = group.FindWater();
                    }
                    if (item != null)
                    {
                        group.Drink(null, item.WaterValue);
                        item.Type = item.Type.Empty;
                    }
                }
            }

            if (Food == 0)
            {
                health -= 25;
            }
            if (Water == 0)
            {
                health -= 25;
            }

            bool doctorAvailable = false;

            if (Player != null && location == null)
            {
                for (int i = 0; i < Player.Group.Count; i++)
                {
                    doctorAvailable |= (Player.Group[i].Class == CharClass.Doctor);
                }
            }

            if (doctorAvailable)
            {
                if (health >= 50)
                {
                    health += 4;
                }
            }
            else
            {
                if (health >= 70)
                {
                    health += 2;
                }
            }

            if (health > 100)
            {
                health = 100;
            }

            if (health <= 0)
            {
                Die();
                return;
            }

            Food--;
            if (Food < 0)
            {
                Food = 0;
            }
            Water--;
            if (Water < 0)
            {
                Water = 0;
            }

            //Dialog.Turn();
        }