Exemplo n.º 1
0
    private void PopulateWindow()
    {
        _keyMapLetter = 'a';
        foreach (var slot in _playerEquipment.Keys)
        {
            if (slot == Entity.EquipmentSlot.Consumable)
            {
                continue;
            }

            if (slot == Entity.EquipmentSlot.LeftArmTwo || slot == Entity.EquipmentSlot.LeftHandTwo ||
                slot == Entity.EquipmentSlot.RightArmTwo || slot == Entity.EquipmentSlot.RightHandTwo)
            {
                if (!GameManager.Instance.Player.IsMultiArmed)
                {
                    continue;
                }
            }

            var bodyPartButton = Instantiate(BodyPartPrefab, new Vector3(0, 0), Quaternion.identity);
            _bodyPartButtons.Add(_keyMapLetter, bodyPartButton);
            bodyPartButton.transform.SetParent(_parent);

            var textFields = bodyPartButton.GetComponentsInChildren <TextMeshProUGUI>(true);

            var slotString = slot.ToString();

            if (!(Attribute.GetCustomAttribute(slot.GetType().GetField(slotString), typeof(DescriptionAttribute)) is DescriptionAttribute typeField))
            {
                textFields[0].text = "-  " + GlobalHelper.Capitalize(slotString);
            }
Exemplo n.º 2
0
    private void PopulateAbilityCategory(string categoryName, List <AbilityTemplate> abilities)
    {
        if (abilities.Count < 1)
        {
            return;
        }

        var categoryInstance = Instantiate(AbilityCategoryPrefab, AbilityCategoryPrefab.transform.position,
                                           Quaternion.identity);

        categoryInstance.transform.SetParent(AbilityCategoryParent);

        categoryInstance.GetComponentsInChildren <TextMeshProUGUI>()[1].text =
            $"{GlobalHelper.Capitalize(categoryName)}";

        var abilityParent = categoryInstance.GetComponentsInChildren <RectTransform>(true)[7];

        abilityParent.GetComponent <LayoutElement>().preferredHeight = 30 * abilities.Count;

        foreach (var ability in abilities)
        {
            if (ability.StartingAbility)
            {
                continue;
            }

            var instance = Instantiate(AvailableAbilityPrefab, StartingAbilityPrefab.transform.position,
                                       Quaternion.identity);

            instance.transform.SetParent(abilityParent);

            instance.transform.GetComponentsInChildren <TextMeshProUGUI>()[0].text =
                GlobalHelper.CapitalizeAllWords(ability.Name);
        }
    }
    private void PopulateDescendants()
    {
        _descendants = new Dictionary <Guid, Entity>();

        var numDescendants = Random.Range(MinDescendants, MaxDescendants + 1);

        for (var i = 0; i < numDescendants; i++)
        {
            var descendant = new Entity(GameManager.Instance.Player, null, true);

            descendant.GenerateStartingEquipment();

            _descendants.Add(descendant.Id, descendant);

            var descendantButton = Instantiate(DescendantPrefab, new Vector3(0, 0), Quaternion.identity);
            descendantButton.transform.SetParent(DescendantButtonParent.transform);

            if (i == 0)
            {
                descendantButton.GetComponent <Button>().Select();
            }

            var descendantTitle = descendantButton.GetComponentInChildren <TextMeshProUGUI>();
            descendantTitle.text = $"{descendant.Fluff.Name}, {GlobalHelper.Capitalize(descendant.Fluff.BackgroundType.Name)}";

            var id = descendantButton.GetComponentInChildren <Text>(true);
            id.text = descendant.Id.ToString();

            var playerSprite = descendantButton.GetComponentsInChildren <Image>()[1];
            playerSprite.sprite = descendant.GetSpritePrefab().GetComponent <SpriteRenderer>().sprite;
        }
    }
Exemplo n.º 4
0
        private void Show(Ability ability, int baseDamage)
        {
            _name.text = GlobalHelper.Capitalize(ability.Name);
            _abilityDescription.text = "Description not implemented yet"; //todo
            _apCost.text             = ability.ApCost.ToString();

            var eventMediator = FindObjectOfType <EventMediator>();
            var combatManager = FindObjectOfType <CombatManager>();

            //todo probably need bool for if ability damage is based on weapon
            if (ability.TargetType == TargetType.Hostile)
            {
                int damageMin;
                int damageMax;
                if (ability.IsRanged())
                {
                    (damageMin, damageMax) = combatManager.ActiveEntity.GetEquippedWeapon().GetRangedDamageRange();
                }
                else
                {
                    (damageMin, damageMax) = combatManager.ActiveEntity.GetEquippedWeapon().GetMeleeDamageRange();
                }

                _damageDescription.text = $"Deals {damageMin + baseDamage} - {damageMax + baseDamage} damage";
            }

            var position = Input.mousePosition;

            gameObject.transform.position = new Vector2(position.x + 180f, position.y + 160f);

            eventMediator.SubscribeToEvent(HidePopupEvent, this);

            gameObject.SetActive(true);
            GameManager.Instance.AddActiveWindow(gameObject);
        }
Exemplo n.º 5
0
    public void OnNextFromAbilitySelectPage()
    {
        SpeciesBox.GetComponent <TextMeshProUGUI>().text    = GlobalHelper.Capitalize(_player.EntityType);
        BackgroundBox.GetComponent <TextMeshProUGUI>().text = GlobalHelper.Capitalize(_selectedBackground.Name);

        SummaryStrengthBox.GetComponent <TextMeshProUGUI>().text     = _strength.ToString();
        SummaryAgilityBox.GetComponent <TextMeshProUGUI>().text      = _agility.ToString();
        SummaryIntelligenceBox.GetComponent <TextMeshProUGUI>().text = _intelligence.ToString();
        SummaryConstitutionBox.GetComponent <TextMeshProUGUI>().text = _constitution.ToString();

        EventMediator.Instance.UnsubscribeFromEvent(GlobalHelper.AbilitySelectedEventName, this);

        AbilitySelectPage.SetActive(false);

        SummaryPage.SetActive(true);
    }
    public void PopulateDescendantAbilities()
    {
        GlobalHelper.DestroyAllChildren(AbilitySummaryParent);

        if (_selectedDescendant == null)
        {
            return;
        }

        foreach (var ability in _selectedDescendant.Abilities.Values)
        {
            var abilitySummary = Instantiate(AbilitySummaryPrefab, new Vector3(0, 0), Quaternion.identity);
            abilitySummary.transform.SetParent(AbilitySummaryParent.transform);

            var abilityTitle = abilitySummary.GetComponentInChildren <TextMeshProUGUI>();
            abilityTitle.text = $"{GlobalHelper.Capitalize(ability.Name)}";
        }
    }
Exemplo n.º 7
0
    //todo sections should be melee, missile, armor -- correspond to slots. Could also offer group by option. Find by property.
    private void PopulateSectionDictionary()
    {
        _playerInventory = GameManager.Instance.Player.Inventory;
        _sortedItems     = new Dictionary <string, List <Item> >();

        foreach (var item in _playerInventory.Values)
        {
            string sectionName;

            var weapon = item as Weapon;

            if (item.ItemCategory.Equals("weapon", StringComparison.OrdinalIgnoreCase))
            {
                if (item.ItemType.IndexOf("grenade", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    sectionName = "Grenades";
                }
                else if (((Weapon)item).IsRanged)
                {
                    sectionName = "Ranged";
                }
                else
                {
                    sectionName = "Melee";
                }
            }
            else
            {
                sectionName = GlobalHelper.Capitalize(item.ItemCategory);
            }

            if (_sortedItems.ContainsKey(sectionName))
            {
                _sortedItems[sectionName].Add(item);
            }
            else
            {
                _sortedItems.Add(sectionName, new List <Item> {
                    item
                });
            }
        }
    }