Esempio n. 1
0
        public void FillChoiceOptions(ChoiceOption[] options)
        {
            OptionsTable.Items.Clear();
            char hotkey = char.MinValue;

            for (int i = 0; i < options.Count(); i++)
            {
                var option = options[i];

                if (i == 0)
                {
                    hotkey = HotkeyHelper.alphabet.First();
                }
                else
                {
                    hotkey = HotkeyHelper.GetNextKey(hotkey);
                }


                var tableItem = new TableItem(2);
                tableItem.Tag    = option;
                tableItem.Hotkey = hotkey;
                tableItem.Cells[0].Widgets.Add(new Label()
                {
                    Text = hotkey.ToString(), HorizontalAlignment = HorizontalAlignment.Center
                });
                tableItem.Cells[1].Widgets.Add(new Label()
                {
                    Text = option.Text,
                });
                OptionsTable.Items.Add(tableItem);
            }
        }
Esempio n. 2
0
        public void FillItems(NamelessGame game)
        {
            var selectedIndex = SelectedTable?.Items.IndexOf(SelectedItem);


            EquipmentBox.Items.Clear();
            ItemBox.Items.Clear();

            var playerEntity = game.PlayerEntity;

            var itemsHolder = playerEntity.GetComponentOfType <ItemsHolder>();
            var equipment   = playerEntity.GetComponentOfType <EquipmentSlots>();

            char hotkey = Char.MinValue;

            var headerEquipmentItem = new TableItem(3);

            headerEquipmentItem.Cells[0].Widgets.Add(new Label()
            {
                Text = "Hotkey", HorizontalAlignment = HorizontalAlignment.Center
            });
            headerEquipmentItem.Cells[1].Widgets.Add(new Label()
            {
                Text = "Slot",
            });
            headerEquipmentItem.Cells[2].Widgets.Add(new Label()
            {
                Text = "Name",
            });
            EquipmentBox.Items.Add(headerEquipmentItem);
            {
                int i = 0;
                foreach (var equipmentSlot in equipment.Slots)
                {
                    if (i == 0)
                    {
                        hotkey = HotkeyHelper.alphabet.First();
                    }
                    else
                    {
                        hotkey = HotkeyHelper.GetNextKey(hotkey);
                    }

                    var         eq   = equipmentSlot.Item2.Equipment;
                    Description desc = null;
                    if (eq != null)
                    {
                        var itemEntity = game.GetEntity(eq.ParentEntityId);
                        desc = itemEntity.GetComponentOfType <Description>();
                    }
                    var text = desc != null ? desc.Name : "Nothing";

                    var tableItem = new TableItem(3);
                    tableItem.Hotkey = hotkey;
                    tableItem.Tag    = equipmentSlot.Item1;
                    tableItem.Cells[0].Widgets.Add(new Label()
                    {
                        Text = hotkey.ToString(), HorizontalAlignment = HorizontalAlignment.Center
                    });
                    tableItem.Cells[1].Widgets.Add(new Label()
                    {
                        Text = equipmentSlot.Item1.ToString(),
                    });
                    tableItem.Cells[2].Widgets.Add(new Label()
                    {
                        Text = text
                    });
                    EquipmentBox.Items.Add(tableItem);
                    i++;
                }
            }

            var headerItem = new TableItem(6);

            headerItem.Cells[0].Widgets.Add(new Label()
            {
                Text = "Hotkey", HorizontalAlignment = HorizontalAlignment.Center
            });
            headerItem.Cells[1].Widgets.Add(new Label()
            {
                Text = "Name",
            });
            headerItem.Cells[2].Widgets.Add(new Label()
            {
                Text = "Quality",
            });
            headerItem.Cells[3].Widgets.Add(new Label()
            {
                Text = "Weight",
            });
            headerItem.Cells[4].Widgets.Add(new Label()
            {
                Text = "Type",
            });
            headerItem.Cells[5].Widgets.Add(new Label()
            {
                Text = "Amount",
            });
            ItemBox.Items.Add(headerItem);

            List <IEntity> list = itemsHolder.Items;

            for (int i = 0; i < list.Count; i++)
            {
                IEntity entity = list[i];

                hotkey = HotkeyHelper.GetNextKey(hotkey);

                Description desc = entity.GetComponentOfType <Description>();
                Item        item = entity.GetComponentOfType <Item>();

                var tableItem = new TableItem(6);
                tableItem.Tag    = entity;
                tableItem.Hotkey = hotkey;
                tableItem.Cells[0].Widgets.Add(new Label()
                {
                    Text = hotkey.ToString(), HorizontalAlignment = HorizontalAlignment.Center
                });
                tableItem.Cells[1].Widgets.Add(new Label()
                {
                    Text = desc.Name,
                });
                tableItem.Cells[2].Widgets.Add(new Label()
                {
                    Text = item.Quality.ToString(),
                });
                tableItem.Cells[3].Widgets.Add(new Label()
                {
                    Text = (item.Weight * item.Amount).ToString(),
                });
                tableItem.Cells[4].Widgets.Add(new Label()
                {
                    Text = item.Type.ToString(),
                });
                tableItem.Cells[5].Widgets.Add(new Label()
                {
                    Text = item.Amount.ToString(),
                });
                ItemBox.Items.Add(tableItem);
            }


            if (selectedIndex >= SelectedTable?.Items.Count)
            {
                if (SelectedTable != null)
                {
                    SelectedTable.SelectedIndex = 0;
                    SelectedItem = SelectedTable.SelectedItem;
                }
            }
            else
            {
                if (SelectedTable != null)
                {
                    SelectedTable.SelectedIndex = selectedIndex;
                    SelectedItem = SelectedTable.SelectedItem;
                }
            }
        }
Esempio n. 3
0
        public void FillItems(NamelessGame namelessGame)
        {
            var selectedIndex = SelectedTable?.Items.IndexOf(SelectedItem);

            ItemsTable.Items.Clear();

            var playerEntity = game.PlayerEntity;

            var itemsHolder = playerEntity.GetComponentOfType <ItemsHolder>();
            var equipment   = playerEntity.GetComponentOfType <EquipmentSlots>();

            char hotkey = Char.MinValue;

            var headerItem = new TableItem(4);

            headerItem.Cells[0].Widgets.Add(new Label()
            {
                Text = "Hotkey", HorizontalAlignment = HorizontalAlignment.Center
            });
            headerItem.Cells[1].Widgets.Add(new Label()
            {
                Text = "Name",
            });
            headerItem.Cells[2].Widgets.Add(new Label()
            {
                Text = "Weight",
            });
            headerItem.Cells[3].Widgets.Add(new Label()
            {
                Text = "Type",
            });
            ItemsTable.Items.Add(headerItem);


            IEntity        worldEntity   = namelessGame.TimelineEntity;
            IWorldProvider worldProvider = null;

            if (worldEntity != null)
            {
                worldProvider = worldEntity.GetComponentOfType <TimeLine>().CurrentTimelineLayer
                                .Chunks;
            }


            var position   = playerEntity.GetComponentOfType <Position>();
            var itemHolder = playerEntity.GetComponentOfType <ItemsHolder>();
            var tile       = worldProvider.GetTile(position.Point.X, position.Point.Y);

            List <IEntity> itemsToPickUp = new List <IEntity>();

            foreach (var entityOnTIle in tile.GetEntities())
            {
                var itemComponent = entityOnTIle.GetComponentOfType <Item>();
                if (itemComponent != null)
                {
                    itemsToPickUp.Add(entityOnTIle);
                }
            }



            List <IEntity> list = itemsToPickUp;

            for (int i = 0; i < list.Count; i++)
            {
                IEntity entity = list[i];

                if (i == 0)
                {
                    hotkey = HotkeyHelper.alphabet.First();
                }
                else
                {
                    hotkey = HotkeyHelper.GetNextKey(hotkey);
                }

                Description desc = entity.GetComponentOfType <Description>();
                Item        item = entity.GetComponentOfType <Item>();

                var tableItem = new TableItem(4);
                tableItem.Tag    = entity;
                tableItem.Hotkey = hotkey;
                tableItem.Cells[0].Widgets.Add(new Label()
                {
                    Text = hotkey.ToString(), HorizontalAlignment = HorizontalAlignment.Center
                });
                tableItem.Cells[1].Widgets.Add(new Label()
                {
                    Text = desc.Name,
                });
                tableItem.Cells[2].Widgets.Add(new Label()
                {
                    Text = item.Weight.ToString(),
                });
                tableItem.Cells[3].Widgets.Add(new Label()
                {
                    Text = item.Type.ToString(),
                });
                ItemsTable.Items.Add(tableItem);
            }


            if (selectedIndex > SelectedTable?.Items.Count)
            {
                if (SelectedTable != null)
                {
                    SelectedTable.SelectedIndex = 0;
                    SelectedItem = SelectedTable.SelectedItem;
                }
            }
            else
            {
                if (SelectedTable != null)
                {
                    SelectedTable.SelectedIndex = selectedIndex;
                    SelectedItem = SelectedTable.SelectedItem;
                }
            }
        }