Ejemplo n.º 1
0
    void onButtonClick(string _name)
    {
        Button       tempButton   = Translate(_name);
        SkillButtons skillButtons = tempButton.GetComponent <SkillButtons>();

        if (skillButtons.skillPointCost <= PersistantGameManager.Instance.playerStats.playerSkillPoints)
        {
            PersistantGameManager.Instance.skillLevels[_name]++;
            PersistantGameManager.Instance.playerStats.playerSkillPoints -= skillButtons.skillPointCost;
        }
        PersistantGameManager.Instance.CheckSkills();
        FindObjectOfType <skillDescription>().transform.Find("Lvl").GetComponent <Text>().text = "Level: " + PersistantGameManager.Instance.skillLevels[_name] + "/" + Translate(_name).GetComponent <SkillButtons>().maxLevel + ".";
        CheckButtons();
    }
    //create attack buttons
    void createAttackButtons()
    {
        GameObject      attackButton     = Instantiate(actionButton) as GameObject;
        TextMeshProUGUI attackbuttonText = attackButton.transform.Find("Text").gameObject.GetComponent <TextMeshProUGUI>();

        attackbuttonText.text = "Attack";
        attackButton.GetComponent <Button>().onClick.AddListener(() => input1());
        attackButton.transform.SetParent(actionSpacer, false);
        attackButtons.Add(attackButton);

        GameObject      skillButton     = Instantiate(actionButton) as GameObject;
        TextMeshProUGUI skillbuttonText = skillButton.transform.Find("Text").gameObject.GetComponent <TextMeshProUGUI>();

        skillbuttonText.text = "Skill";
        skillButton.GetComponent <Button>().onClick.AddListener(() => input3());
        skillButton.transform.SetParent(actionSpacer, false);
        attackButtons.Add(skillButton);

        if (PlayerCharacters[0].GetComponent <PlayerStateMachine>().hero.skillList.Count > 0)
        {
            foreach (BaseAttack skillAttack in PlayerCharacters[0].GetComponent <PlayerStateMachine>().hero.skillList)
            {
                GameObject      skills    = Instantiate(skillsButton) as GameObject;
                TextMeshProUGUI skillText = skills.transform.Find("Text").gameObject.GetComponent <TextMeshProUGUI>();
                skillText.text = skillAttack.attackName;
                SkillButtons skillB = skills.GetComponent <SkillButtons>();
                skillB.skillAttackToPerform = skillAttack;

                skillB.transform.SetParent(skillSpacer, false);
                attackButtons.Add(skills);
            }
        }
        else
        {
            skillButton.GetComponent <Button>().interactable = false;
        }
    }
Ejemplo n.º 3
0
    //Updates all buttons and sets all buttons to their correct state.
    void CheckButtons()
    {
        foreach (Button b in buttons)
        {
            if ((b.gameObject.name == "IKB" && !(InstantKillB.GetComponent <SkillButtons>().nessesaryXPLevel <= PersistantGameManager.Instance.playerStats.playerLevel)) || (b.gameObject.name == "WDVB" && !(WeaponDropValueB.GetComponent <SkillButtons>().nessesaryXPLevel <= PersistantGameManager.Instance.playerStats.playerLevel)))
            {
                InstantKillB.interactable      = false;
                b.GetComponent <Image>().color = turnedOffColor;
                SkillButtons requirements = b.GetComponent <SkillButtons>();
                b.transform.Find("Text").GetComponent <Text>().text = requirements.text + "\n(" + requirements.skillPointCost + " S.P)   (" + PersistantGameManager.Instance.skillLevels[requirements._name] + "/" + requirements.maxLevel + ")";
            }
            else
            {
                bool         shouldUnlock = false;
                int          index        = 0;
                SkillButtons requirements = b.GetComponent <SkillButtons>();
                foreach (string s in requirements.toBeUnlocked)
                {
                    if (requirements.unlocked)
                    {
                        shouldUnlock = true;
                    }
                    if (PersistantGameManager.Instance.skillLevels[s] > requirements.levelToUnlock - 1)
                    {
                        shouldUnlock = true;
                    }
                    index++;
                }
                if (requirements.toBeUnlocked.Length == 0)
                {
                    shouldUnlock = true;
                }
                if (PersistantGameManager.Instance.skillLevels[requirements._name] > 0 && shouldUnlock)
                {
                    b.interactable = true;
                    b.GetComponent <Image>().color = unlockedColor;

                    if (PersistantGameManager.Instance.skillLevels[requirements._name] >= requirements.maxLevel)
                    {
                        b.GetComponent <Image>().color = maxedColor;
                        b.interactable = false;
                    }
                }
                else if (shouldUnlock || requirements.unlocked)
                {
                    b.interactable                 = true;
                    requirements.unlocked          = true;
                    b.GetComponent <Image>().color = normalColor;
                }
                else
                {
                    b.interactable = false;
                    b.GetComponent <Image>().color = turnedOffColor;
                }

                if (requirements.maxLevel > 1)
                {
                    b.transform.Find("Text").GetComponent <Text>().text = requirements.text + "\n(" + requirements.skillPointCost + " S.P)   (" + PersistantGameManager.Instance.skillLevels[requirements._name] + "/" + requirements.maxLevel + ")";
                }
                else
                {
                    b.transform.Find("Text").GetComponent <Text>().text = requirements.text + "\n(" + requirements.skillPointCost + " S.P)";
                }
            }
        }
        //Sets Locks to correct number
        //Health Regen To Turtle
        int HR2TuV = TurtleB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["HealthBonus"];

        if (HR2TuV < 1 || TurtleB.GetComponent <SkillButtons>().unlocked)
        {
            HR2Tu.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            HR2Tu.text = HR2TuV.ToString();
        }
        //Health Regen To Damage On Movement
        int HR2DaMV = MoveDefenceB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["HealthBonus"];

        if (HR2DaMV < 1 || MoveDefenceB.GetComponent <SkillButtons>().unlocked)
        {
            HR2DaM.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            HR2DaM.text = HR2DaMV.ToString();
        }

        //Health Regen to Weapon Drop Value
        //int HR2WDVV = WeaponDropValueB.GetComponent<SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["HealthBonus"];
        //if (HR2WDVV < 1 || WeaponDropValueB.GetComponent<SkillButtons>().unlocked) {}


        //Health Regen to Life Steal
        int HR2LSV = LifeStealB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["HealthBonus"];

        if (HR2LSV < 1 || LifeStealB.GetComponent <SkillButtons>().unlocked)
        {
            HR2WLS.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            HR2WLS.text = HR2LSV.ToString();
        }
        //Move Speed to Damage On Movement
        int MS2DaMV = MoveDefenceB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["MoveSpeed"];

        if (MS2DaMV < 1 || MoveDefenceB.GetComponent <SkillButtons>().unlocked)
        {
            MS2DaM.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            MS2DaM.text = MS2DaMV.ToString();
        }
        //Move Speed to triple Jump
        int MS2TJV = TripleJumpB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["MoveSpeed"];

        if (MS2TJV < 1 || TripleJumpB.GetComponent <SkillButtons>().unlocked)
        {
            MS2TJ.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            MS2TJ.text = MS2TJV.ToString();
        }
        //Move Speed to Air Attack
        int MS2AAV = AirAttackB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["MoveSpeed"];

        if (MS2AAV < 1 || AirAttackB.GetComponent <SkillButtons>().unlocked)
        {
            MS2AA.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            MS2AA.text = MS2AAV.ToString();
        }
        //Attack Speed to Air Attack
        int AS2AAV = AirAttackB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["AttackSpeed"];

        if (AS2AAV < 1 || AirAttackB.GetComponent <SkillButtons>().unlocked)
        {
            AS2AA.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            AS2AA.text = AS2AAV.ToString();
        }
        //Attack Speed to Life Steal
        int AS2WLSV = LifeStealB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["AttackSpeed"];

        if (AS2WLSV < 1 || LifeStealB.GetComponent <SkillButtons>().unlocked)
        {
            AS2LS.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            AS2LS.text = AS2WLSV.ToString();
        }
        //Attack Speed to Smite
        int AS2SMV = SmiteB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["AttackSpeed"];

        if (AS2SMV < 1 || SmiteB.GetComponent <SkillButtons>().unlocked)
        {
            AS2SM.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            AS2SM.text = AS2SMV.ToString();
        }
        //Smite to Smite Damage
        int SM2SMDaV = SmiteDamageB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["Smite"];

        if (SM2SMDaV < 1 || SmiteDamageB.GetComponent <SkillButtons>().unlocked)
        {
            SM2SMDa.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            SM2SMDa.text = SM2SMDaV.ToString();
        }
        //Smite to Smite Duration

        int SM2SMDuV = SmiteDurationB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["Smite"];

        if (SM2SMDuV < 1 || SmiteDurationB.GetComponent <SkillButtons>().unlocked)
        {
            SM2SMDu.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            SM2SMDu.text = SM2SMDuV.ToString();
        }
        //Turtle to Turtle Defense

        int Tu2TuDeV = TurtleDefenseB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["Turtle"];

        if (Tu2TuDeV < 1 || TurtleDefenseB.GetComponent <SkillButtons>().unlocked)
        {
            Tu2TuDe.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            Tu2TuDe.text = Tu2TuDeV.ToString();
        }
        //Turtle to Turtle Duration

        int Tu2TuDuV = TurtleDurationB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["Turtle"];

        if (Tu2TuDuV < 1 || TurtleDurationB.GetComponent <SkillButtons>().unlocked)
        {
            Tu2TuDu.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            Tu2TuDu.text = Tu2TuDuV.ToString();
        }
        //Triple Jump to Grip Walls

        int TJ2GWV = GripWallsB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["TripleJump"];

        if (TJ2GWV < 1 || GripWallsB.GetComponent <SkillButtons>().unlocked)
        {
            TJ2GW.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            TJ2GW.text = TJ2GWV.ToString();
        }
        //Triple Jump to Jump height

        int TJ2JHV = JumpHeightB.GetComponent <SkillButtons>().levelToUnlock - PersistantGameManager.Instance.skillLevels["TripleJump"];

        if (TJ2JHV < 1 || JumpHeightB.GetComponent <SkillButtons>().unlocked)
        {
            TJ2JH.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            TJ2JH.text = TJ2JHV.ToString();
        }
        //Instant Kill

        int SKV = InstantKillB.GetComponent <SkillButtons>().nessesaryXPLevel - PersistantGameManager.Instance.playerStats.playerLevel;

        if (SKV < 1)
        {
            IK.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            IK.text = SKV.ToString();
        }
        //Weapon Drop Value

        int LSV = WeaponDropValueB.GetComponent <SkillButtons>().nessesaryXPLevel - PersistantGameManager.Instance.playerStats.playerLevel;

        if (LSV < 1)
        {
            WDV.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            WDV.text = LSV.ToString();
        }
    }