Exemplo n.º 1
0
 private void OnSlotClick(AllyInfo parent, int index, ThreadButtonGroup group)
 {
     selectedAlly = parent;
     if (index + 1 <= parent.capacity.Count)
     {
         RemoveThreadFromSlot(index, selectedAlly, group);
     }
 }
Exemplo n.º 2
0
    private void RefreshSlots(AllyInfo parent)
    {
        var slotButtons = parent.capacitySlots.Select(slot => slot.GetComponent <Button>()).ToList();

        slotButtons.ForEach(button => button.onClick.RemoveAllListeners());

        parent.capacity.Each((thread, i) => {
            var slot = parent.capacitySlots[i];
            thread.transform.position = slot.transform.position;
            var newThreadGroup        = threadButtonGroups.Find(x => x.prefabName == thread.GetComponent <Ethread>().effectName);
            slotButtons[i].onClick.AddListener(delegate { OnSlotClick(parent, i, newThreadGroup); });
        });
    }
Exemplo n.º 3
0
    private void RemoveThreadFromSlot(int index, AllyInfo parent, ThreadButtonGroup group)
    {
        var ethreadToRemove = parent.capacity[index];

        parent.capacity.Remove(ethreadToRemove);

        RefreshSlots(parent);

        partyInfoDict[parent].GetComponent <GridEntity>().equippedThreads.Remove(ethreadToRemove.GetComponent <Ethread>());
        Destroy(ethreadToRemove);

        group.quantity++;
    }
Exemplo n.º 4
0
    private void AddThreadToSlots(AllyInfo parent, ThreadButtonGroup group)
    {
        var newEthread = Instantiate(group.threadPrefab, new Vector2(0, 0), Quaternion.identity);

        newEthread.transform.SetParent(parent.threadCapacityGroup);
        parent.capacity.Add(newEthread);

        RefreshSlots(parent);

        partyInfoDict[parent].GetComponent <GridEntity>().equippedThreads.Add(newEthread.GetComponent <Ethread>());

        group.quantity--;
    }
Exemplo n.º 5
0
        public void UpdateDisplay(AllyInfo selectedAlly)
        {
            var threadDamageBonus = selectedAlly.capacity.Where(thread => thread.GetComponent <Ethread>().effectName == "RedThread").Count();
            var threadMoveBonus   = selectedAlly.capacity.Where(thread => thread.GetComponent <Ethread>().effectName == "BlueThread").Count();

            nameText.text    = selectedAlly.entity.entityName;
            subnameText.text = selectedAlly.entity.entitySubname;
            SetChips(damageChips, selectedAlly.entity.damage + threadDamageBonus);
            SetChips(moveRangeChips, selectedAlly.entity.maxMoves + threadMoveBonus);
            SetChips(atkRangeChips, selectedAlly.entity.range);

            var skills = SkillUtils.PopulateSkills(selectedAlly.entity.skillNames, new List <int> {
                1, 1, 1
            });

            skillNameTexts = skillElements.Select(element => {
                return(element.Find("SkillName").GetComponent <Text>());
            }).ToList();

            skillDescTexts = skillElements.Select(element => {
                return(element.Find("SkillDesc").GetComponent <Text>());
            }).ToList();

            skills.ForEach(skill => {
                var skillNameText = skillNameTexts[0];
                skillNameTexts.Remove(skillNameText);

                skillNameText.text = skill.name ?? "";

                var skillDescText = skillDescTexts[0];
                skillDescTexts.Remove(skillDescText);

                skillDescText.text = skill.desc ?? "";
            });

            var enablePrimarySkillText   = selectedAlly.capacity.Any(thread => thread.GetComponent <Ethread>().effectName == "PurpleThread");
            var enableSecondarySkillText = selectedAlly.capacity.Any(thread => thread.GetComponent <Ethread>().effectName == "YellowThread");
            var enableTertiarySkillText  = selectedAlly.capacity.Any(thread => thread.GetComponent <Ethread>().effectName == "PinkThread");

            ToggleSkillText(skillElements[0], enablePrimarySkillText);
            ToggleSkillText(skillElements[1], enableSecondarySkillText);
            ToggleSkillText(skillElements[2], enableTertiarySkillText);

            // resets any skill section that was previously populated, that the newly selected ally does not have
            // i.e swapping from ally with 3 skills to one with 2 will empty the third slot even though
            skillNameTexts.ForEach(text => text.text = "");
            skillDescTexts.ForEach(text => text.text = "");
        }
Exemplo n.º 6
0
 public void PopulateParty(List <GameObject> partyPrefabs)
 {
     if (!partyPrefabs.All(prefab => partyInfoDict.Values.Contains(prefab)))
     {
         for (var i = 0; i < partyPrefabs.Count; i++)
         {
             var group    = transform.Find("PartyMember" + i.ToString()).gameObject;
             var allyInfo = new AllyInfo(group);
             allyInfo.image.sprite = partyPrefabs[i].GetComponent <SpriteRenderer>().sprite;
             allyInfo.entity       = partyPrefabs[i].GetComponent <GridEntity>();
             allyInfo.selectionButton.onClick.AddListener(delegate { OnSelectionClick(allyInfo); });
             partyInfoDict.Add(allyInfo, partyPrefabs[i]);
         }
         selectedAlly = partyInfoDict.Keys.First();
         selectedAlly.selectionBox.enabled = true;
     }
 }
Exemplo n.º 7
0
 public void ShowHero(AllyInfo info)
 {
     /*nameUI_.text = info.GetName ();
      *
      * Stats stats = info.gameObject.GetComponent<Stats> ();
      * if (stats) {
      *      attackUI_.text = stats.GetAttack ().ToString ();
      *      defenseUI_.text = stats.GetDefense ().ToString ();
      *      speedUI_.text = stats.GetSpeed ().ToString ();
      * }
      *
      * Health health = info.gameObject.GetComponent<Health> ();
      * if (health) {
      *      healthUI_.text = health.GetHealth ().ToString () + "/" + health.GetMaxHealth ().ToString ();
      * }
      */
 }
Exemplo n.º 8
0
 private void OnSelectionClick(AllyInfo parent)
 {
     selectedAlly = parent;
 }