Ejemplo n.º 1
0
    public override void Die(Projectile p_projectile)
    {
        if (Random.Range(0f, 100f) <= m_chanceToExplode && !p_projectile.m_shooter.m_entity.m_isDead)
        {
            ShotPattern pattern = ShotPattern.Get(m_explosionPattern, false);

            pattern.m_spawnLocation = p_projectile.transform.position;
            p_projectile.m_shooter.Shoot(pattern);
        }
    }
Ejemplo n.º 2
0
    public override void Use(Entity p_entity, int p_trainingLevel)
    {
        ShotPattern pattern = ShotPattern.Get(m_shotPatterns.Find(s => s.TrainingLevel == p_trainingLevel).Pattern, false);

        if (m_aimAtCursor)
        {
            pattern.m_forcedTarget = Camera.main.ScreenToWorldPoint((p_entity as Player).m_mouse.GetPosition());
        }

        pattern.m_manaPerStep = 0;

        p_entity.m_shooter.Shoot(pattern);
    }
Ejemplo n.º 3
0
    private void Shoot(StateController p_controller)
    {
        ShotPattern        pattern  = ShotPattern.Get(m_patternToShoot, false);
        List <ShotPattern> patterns = new List <ShotPattern>();

        if (p_controller.m_shotPatterns.ContainsKey(this))
        {
            p_controller.m_shotPatterns.TryGetValue(this, out patterns);
        }

        patterns.Add(pattern);
        p_controller.m_shotPatterns[this] = patterns;

        if (m_forceTarget)
        {
            pattern.m_forcedTarget = p_controller.m_target.transform.position;
        }

        p_controller.m_entity.m_shooter.Shoot(pattern);
    }
Ejemplo n.º 4
0
    public override string GetDescription(int p_trainingLevel, bool p_translate)
    {
        ShotPattern pattern     = ShotPattern.Get(m_shotPatterns.Find(s => s.TrainingLevel == p_trainingLevel).Pattern, true);
        string      description = m_descriptions.Find(d => d.TrainingLevel == p_trainingLevel).Description;

        if (p_translate)
        {
            description = Game.m_languages.GetLine(description);
        }

        return(description.Replace("{damage}", pattern.m_projectileInfo.m_damage.ToString())
               .Replace("{manaPerStep}", pattern.m_manaPerStep.ToString())
               .Replace("{manaCost}", m_manaCosts.Find(m => m.TrainingLevel == p_trainingLevel).Value.ToString())
               .Replace("{cooldown}", m_cooldowns.Find(m => m.TrainingLevel == p_trainingLevel).Value.ToString())
               .Replace("{shots}", pattern.m_shots.ToString())
               .Replace("{statApplied}", pattern.m_projectileInfo.m_statApplied.ToString())
               .Replace("{range}", pattern.m_projectileInfo.m_range.ToString())
               .Replace("{speed}", pattern.m_projectileInfo.m_speed.ToString())
               .Replace("{newLine}", "\n"));
    }
Ejemplo n.º 5
0
    public override void Use(Entity p_entity, string[] p_args)
    {
        if (p_args.Length == 0)
        {
            return;
        }

        bool        useLeft = p_args[0].ToLower() == "true";  // left or right, case insensitive
        ShotPattern pattern = ShotPattern.Get(useLeft ? m_leftClickPattern : m_rightClickPattern, false);

        if (pattern != null)
        {
            if (p_args.Length >= 2)
            {
                if (p_args[1].ToLower() == "true" && p_entity is Player)
                {
                    pattern.m_forcedTarget = Camera.main.ScreenToWorldPoint(((Player)p_entity).m_mouse.GetPosition());
                }
            }

            p_entity.m_shooter.Shoot(pattern);
        }
    }
Ejemplo n.º 6
0
    public void SetItem(Item p_item)
    {
        Entity holder = p_item.m_holder ? p_item.m_holder : p_item.m_inventory.m_interactor;

        if (m_modifiableInfo.Count == 0)
        {
            FillModifiableInfo();
        }

        foreach (TooltipInfo info in m_modifiableInfo)
        {
            info.m_info.SetActive(false);
        }

        m_panelHeight       = m_tooltipBorderSize * 2 + 12;
        m_tooltipInfoOffset = -(m_panelHeight / 2);
        BaseItem item = p_item.m_item;

        Show(m_panelHeight, true); // activating the tooltip (out of sight) to allow preferred heights to be fetched

        TextMeshProUGUI name = m_modifiableInfo.Find(ti => ti.m_name == "Item Name Text").Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        name.text  = Get(item.GetDisplayName());
        name.color = item.m_nameColor.Value;

        if (item is Armor || item is Weapon)
        {
            TextMeshProUGUI type     = m_modifiableInfo.Find(ti => ti.m_name == "Item Type Text").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset);
            string          itemType = "";

            if (item is Armor)
            {
                itemType = (item as Armor).GetArmorType().ToString();
            }
            if (item is Weapon)
            {
                itemType = (item as Weapon).GetWeaponType().ToString();
            }

            type.text = Get(itemType);
        }

        TextMeshProUGUI slot = m_modifiableInfo.Find(ti => ti.m_name == "Slot Info Text").Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        slot.text = Get(item.GetSlotInfoText());

        ShowSeparator(1);

        bool leftShotPattern  = false;
        bool rightShotPattern = false;

        if (item is Weapon)
        {
            Weapon weapon = item as Weapon;

            leftShotPattern = !String.IsNullOrEmpty(weapon.m_leftClickPattern) && ShotPattern.Get(weapon.m_leftClickPattern, true) != null;

            if (leftShotPattern)
            {
                ShowShotPattern(1, ShotPattern.Get(weapon.m_leftClickPattern, true), ref m_panelHeight);
                ShowSeparator(2);

                rightShotPattern = !String.IsNullOrEmpty(weapon.m_rightClickPattern) && ShotPattern.Get(weapon.m_rightClickPattern, true) != null;

                if (rightShotPattern)
                {
                    ShowShotPattern(2, ShotPattern.Get(weapon.m_rightClickPattern, true), ref m_panelHeight);
                    ShowSeparator(3);
                }
            }
        }

        if (item is Weapon || item is Armor)
        {
            int[] statGains = item is Weapon ? (item as Weapon).m_statGainValues : (item as Armor).m_statGainValues;

            if (statGains.Length == UnitStats.STAT_AMOUNT)
            {
                TextMeshProUGUI statGainText          = m_modifiableInfo.Find(ti => ti.m_name == "Stat Gain Text").Get <TextMeshProUGUI>();
                TextMeshProUGUI statComparisonOneText = m_modifiableInfo.Find(ti => ti.m_name == "Stat Comparison 1").Get <TextMeshProUGUI>();
                TextMeshProUGUI statComparisonTwoText = m_modifiableInfo.Find(ti => ti.m_name == "Stat Comparison 2").Get <TextMeshProUGUI>();
                int[]           comparisonOne         = item.m_equipmentSlots.Count >= 1 ?
                                                        BaseItem.GetStatGainDifferences(item, holder.m_equipment, item.m_equipmentSlots[0]) : new int[UnitStats.STAT_AMOUNT];
                int[] comparisonTwo = item.m_equipmentSlots.Count == 2 ?
                                      BaseItem.GetStatGainDifferences(item, holder.m_equipment, item.m_equipmentSlots[1]) : new int[UnitStats.STAT_AMOUNT];

                if (p_item.m_inventory == holder.m_equipment)
                {
                    comparisonOne = new int[UnitStats.STAT_AMOUNT];
                    comparisonTwo = new int[UnitStats.STAT_AMOUNT];
                }

                for (int i = 0; i < statGains.Length; ++i)
                {
                    if (statGains[i] == 0 && comparisonOne[i] == 0 && comparisonTwo[i] == 0)
                    {
                        continue;
                    }
                    if (!m_modifiableInfo.Exists(ti => ti.m_name == ((Stats)i).ToString() + " Gain Text"))
                    {
                        InstantiateStatText(((Stats)i).ToString() + " Gain Text", statGainText, transform);
                    }

                    TextMeshProUGUI statGain = m_modifiableInfo.Find(ti => ti.m_name == ((Stats)i).ToString() + " Gain Text")
                                               .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
                    if (!m_modifiableInfo.Exists(ti => ti.m_name == ((Stats)i).ToString() + " Comparison 1"))
                    {
                        InstantiateStatText(((Stats)i).ToString() + " Comparison 1", statComparisonOneText, statGain.transform);
                    }
                    if (!m_modifiableInfo.Exists(ti => ti.m_name == ((Stats)i).ToString() + " Comparison 2"))
                    {
                        InstantiateStatText(((Stats)i).ToString() + " Comparison 2", statComparisonTwoText, statGain.transform);
                    }

                    TextMeshProUGUI statComparisonOne = m_modifiableInfo.Find(ti => ti.m_name == ((Stats)i).ToString() + " Comparison 1")
                                                        .Get <TextMeshProUGUI>();
                    TextMeshProUGUI statComparisonTwo = m_modifiableInfo.Find(ti => ti.m_name == ((Stats)i).ToString() + " Comparison 2")
                                                        .Get <TextMeshProUGUI>();

                    statGain.color = statGains[i] > 0 ? Constants.GREEN : (statGains[i] == 0 ? Constants.YELLOW : Constants.RED);
                    statGain.text  = (statGains[i] > 0 ? "+" : "") + statGains[i] + " " + ((Stats)i).ToString();

                    if (comparisonOne[i] != 0)
                    {
                        statComparisonOne.color = comparisonOne[i] > 0 ? Constants.GREEN : Constants.RED;
                        statComparisonOne.text  = "(" + (comparisonOne[i] > 0 ? "+" : "") + comparisonOne[i] + ")";
                    }
                    else
                    {
                        statComparisonOne.text = "";
                    }

                    if (comparisonTwo[i] != 0)
                    {
                        statComparisonTwo.color = comparisonTwo[i] > 0 ? Constants.GREEN : Constants.RED;
                        statComparisonTwo.text  = "(" + (comparisonTwo[i] > 0 ? "+" : "") + comparisonTwo[i] + ")";
                    }
                    else
                    {
                        statComparisonTwo.text = "";
                    }
                }
            }
        }

        string prefixColorTag = "<color=#" + ColorUtility.ToHtmlStringRGBA(Constants.YELLOW) + ">";
        string suffixColorTag = "</color>";

        if (item is Weapon || item is Armor)
        {
            TextMeshProUGUI durability = m_modifiableInfo.Find(ti => ti.m_name == "Durability")
                                         .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            durability.text  = Game.m_languages.FormatTexts(Get("Durability: {0}%"), prefixColorTag + p_item.m_durability + suffixColorTag);
            durability.color = Constants.WHITE;
        }

        TextMeshProUGUI sellPrice = m_modifiableInfo.Find(ti => ti.m_name == "Sell Price")
                                    .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        sellPrice.text  = Game.m_languages.FormatTexts(Get("Sell Price: {0}g"), prefixColorTag + item.m_sellPrice + suffixColorTag);
        sellPrice.color = Constants.WHITE;

        TooltipInfo     descInfo    = m_modifiableInfo.Find(ti => ti.m_name == "Item Description Text");
        TextMeshProUGUI description = descInfo.Get <TextMeshProUGUI>();

        description.text = "";

        float basePrefHeight = LayoutUtility.GetPreferredHeight(description.rectTransform);

        description.text     = Get(item.m_description);
        description.color    = Constants.YELLOW;
        m_tooltipInfoOffset += description.rectTransform.rect.y;

        float descPrefHeight = LayoutUtility.GetPreferredHeight(description.rectTransform);

        if (basePrefHeight != descPrefHeight)  // multiline
        {
            m_tooltipInfoOffset += descPrefHeight / 2f;

            description = descInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset, descPrefHeight);
        }
        else
        {
            description    = descInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            m_panelHeight += basePrefHeight;
        }

        if (leftShotPattern)
        {
            PositionDamageType(1);
        }
        if (rightShotPattern)
        {
            PositionDamageType(2);
        }

        Show(m_panelHeight, false);         // resizing the panel again to fit and actually showing it
    }
	public override void Init(Projectile p_projectile) {
		m_pattern = ShotPattern.Get(m_shotPattern, false);
		m_started = false;
		m_initTime = Time.time;
	}