Esempio n. 1
0
    public void ShowSkillInfo(string charName, GameObject[] skills)
    {
        /*if(skillList.Length != skills.Length){
         *      print("number of character skills is not relevant to number of skill slots in skill panel");
         *      return;
         * }*/
        //if(!skills[0]){

        //}
        skillsOfPassingInChar = skills;
        skillUsingCharName    = charName;
        //switch(type){
        //case SkillSlot.SkillType.SKILL_SHOOT:
        for (int i = 0; i < skills.Length; i++)
        {
            Sprite shotSprt        = null;
            string shotName        = "";
            string shotDetail      = "";
            int    skillPower      = 0;
            float  skillReUseSpeed = 0f;

            if (skills[i].GetComponent <CharacterSkillShot>())
            {
                CharacterSkillShot thisSkillShot = skills[i].GetComponent <CharacterSkillShot>();
                shotSprt        = thisSkillShot.GetShotSprtIcon();
                shotName        = thisSkillShot.GetShotSkillName();
                shotDetail      = thisSkillShot.GetShotDetail();
                skillPower      = thisSkillShot.GetShotPower();
                skillReUseSpeed = thisSkillShot.GetShotCoolDownSpeed();
            }
            else if (skills[i].GetComponent <SupportSkillShot>())
            {
                SupportSkillShot thisSpSkillShot = skills[i].GetComponent <SupportSkillShot>();
                shotSprt        = thisSpSkillShot.GetShotSprtIcon();
                shotName        = thisSpSkillShot.GetShotSkillName();
                shotDetail      = thisSpSkillShot.GetShotDetail();
                skillPower      = thisSpSkillShot.GetShotPower();
                skillReUseSpeed = thisSpSkillShot.GetShotCoolDownSpeed();
            }

            Transform shotSlotToSetSprt = shotListPanel.transform.GetChild(i);

            //Check if this skill is available to be used or not
            //if is available, turn interactability of the shot and set sprite onto the slot
            if (IsSkillUnlocked(charName, shotName) == true)
            {
                shotSlotToSetSprt.GetChild(0).GetComponent <Button>().interactable = true;
                shotSlotToSetSprt.GetChild(0).GetComponent <Image>().sprite        = shotSprt;

                //if this shot is latest used shot, set it on selection and show all info of the shot
                if (IsLastestUsedSkill(charName, shotName) == true)
                {
                    shotSlotToSetSprt.GetComponent <Image>().sprite = IsSelectingSprite;
                    SetSkillNameToDisplay(shotName);
                    SetSkillDetailToDisplay(shotDetail);

                    SetPowerPropertyToDisplay(skillPower);
                    SetCoolDownSpeedPropertyToDisplay(skillReUseSpeed);

                    SelectingSkill = skills[i];

                    //if this shot is not latest used shot, set the sprite indicating the shot being selecting to null
                    //TODO set it to a transparent image sprite instead of null
                }
                else
                {
                    shotSlotToSetSprt.GetComponent <Image>().sprite = nonSelectingSprite;
                }

                //if is unavailable to use, hide it out by setting a "lock" sprite, also hide "selecting" sprite and
                //turn off the button interactability
            }
            else
            {
                shotSlotToSetSprt.GetChild(0).GetComponent <Image>().sprite        = lockedSkillSprite;
                shotSlotToSetSprt.GetChild(0).GetComponent <Button>().interactable = false;
                shotSlotToSetSprt.GetComponent <Image>().sprite = nonSelectingSprite;
                //shotSlotToSetSprt.GetChild(0).gameObject.SetActive(false);
            }
        }

        //break;

        //default: break;
    }
Esempio n. 2
0
    //This is done in accordance with the assuming that the order of the skill list in shooting skill script
    // is the same as order of skills in Common data
    // NOTE: Comparison method based on sprite comparison
    private void ShowSelectedSkillInfo(int selectingSkillIndex)
    {
        print("button " + selectingSkillIndex);
        //Get Selecting skill avar index


        for (int i = 0; i < shotListPanel.transform.childCount; i++)
        {
            shotListPanel.transform.GetChild(i).GetComponent <Image>().sprite = nonSelectingSprite;

            //Set selecting effect on the skill which is equal to the button index
            if (selectingSkillIndex == i)
            {
                shotListPanel.transform.GetChild(i).GetComponent <Image>().sprite = IsSelectingSprite;
            }
        }
        GameObject skillToShowInfo = skillsOfPassingInChar[selectingSkillIndex];

        //Set skill name to display
        //If the skill is shooting skill
        if (skillToShowInfo.GetComponent <CharacterSkillShot>())
        {
            SelectingSkill = skillToShowInfo;
            CharacterSkillShot skillShot = skillToShowInfo.GetComponent <CharacterSkillShot>();

            string skillNameToDisplay = skillShot.GetShotSkillName();
            SetSkillNameToDisplay(skillNameToDisplay);

            string skillDetail = skillShot.GetShotDetail();
            SetSkillDetailToDisplay(skillDetail);

            //Set equivalent property to display
            //Power Property
            int skillPower = skillShot.GetShotPower();
            SetPowerPropertyToDisplay(skillPower);
            //Cooldown Speed Property
            float skillReUseSpeed = skillShot.GetShotCoolDownSpeed();
            SetCoolDownSpeedPropertyToDisplay(skillReUseSpeed);

            //If the skill is supporting skill
        }
        else if (skillToShowInfo.GetComponent <SupportSkillShot>())
        {
            SelectingSkill = skillToShowInfo;
            SupportSkillShot skillShot = skillToShowInfo.GetComponent <SupportSkillShot>();

            string skillNameToDisplay = skillShot.GetShotSkillName();
            SetSkillNameToDisplay(skillNameToDisplay);

            string skillDetail = skillShot.GetShotDetail();
            SetSkillDetailToDisplay(skillDetail);

            //Set equivalent property to display
            //Power Property
            int skillPower = skillShot.GetShotPower();
            SetPowerPropertyToDisplay(skillPower);
            //Cooldown Speed Property
            float skillReUseSpeed = skillShot.GetShotCoolDownSpeed();
            SetCoolDownSpeedPropertyToDisplay(skillReUseSpeed);
        }
    }