Exemple #1
0
    public void LoadMonsterToken(MonsterSaveToken m)
    {
        MonsterStatsSet();

        StatsCalc stats = new StatsCalc(gameObject.GetComponent <Monster>());

        GetStats(stats);
    }
Exemple #2
0
    //use this to get a monster's potential stats without saving them
    public void CheckStats(MonsterSaveToken m)
    {
        MonsterStatsSet();

        StatsCalc stats = new StatsCalc(gameObject.GetComponent <Monster>());

        info      = stats.Monster.info;
        tempStats = stats.Monster.tempStats;
    }
Exemple #3
0
    public void SaveMonsterToken()
    {
        MonsterToken token = new MonsterToken();

        token.CreateMonsterToken(this);
        saveToken = token.newToken;


        PlayerPrefs.SetString(saveToken.index.ToString(), JsonUtility.ToJson(saveToken));

        //change this monster's dictionary item in your monster list dictionary
        GameManager.Instance.GetComponent <YourMonsters>().MonsterList(info.index, this);


        //GameManager.Instance.GetComponent<YourMonsters>().GetYourMonsters();
        //GameManager.Instance.GetComponent<YourMonsters>().MonsterList(this);
    }
Exemple #4
0
    //use this when summoning a monster
    public void MonsterSummon(string name)
    {
        bool hasKey = PlayerPrefs.HasKey("MonsterCount");


        if (hasKey)
        {
            int monsterCount = GameManager.Instance.monsterCount + 1;

            var monsters = GameManager.Instance.monstersData.monstersAllDict;


            //get the monster's species dependent stats from the Game Manager
            if (monsters.ContainsKey(name))
            {
                MonsterToken token = new MonsterToken();

                info.name     = name;
                info.species  = name;
                info.level    = 1;
                info.totalExp = 0;
                info.AttackPotential.BaseValue    = Random.Range(0, 26);
                info.DefensePotential.BaseValue   = Random.Range(0, 26);
                info.SpeedPotential.BaseValue     = Random.Range(0, 26);
                info.PrecisionPotential.BaseValue = Random.Range(0, 26);
                info.HPPotential.BaseValue        = Random.Range(0, 26);
                info.index       = monsterCount;
                info.maxLevel    = monsters[name].maxLevel;
                info.levelConst  = monsters[name].levelConst;
                info.monsterRank = 1;

                int starChance = monsters[name].starChance;
                int randStar   = Random.Range(0, 500);

                if (randStar <= starChance)
                {
                    info.isStar = true;
                }



                PlayerPrefs.SetInt("MonsterCount", monsterCount);
                GameManager.Instance.monsterCount = monsterCount;

                //set the monster's first 2 base attacks
                int rand = Random.Range(0, monsters[name].baseAttacks.Length - 1);
                info.attack1Name = monsters[name].baseAttacks[rand];
                int rand2 = Random.Range(0, monsters[name].baseAttacks.Length - 1);
                info.attack2Name = monsters[name].baseAttacks[rand2];

                //set the monster's ability'
                if (monsters[name].abilities.Length > 1)
                {
                    int ab = Random.Range(0, monsters[name].abilities.Length - 1);
                    info.abilityName = monsters[name].abilities[ab];
                }
                else
                {
                    info.abilityName = monsters[name].abilities[0];
                }

                //set the monster's skill
                if (monsters[name].skills.Length > 1)
                {
                    int sk = Random.Range(0, monsters[name].skills.Length - 1);
                    info.skillName = monsters[name].skills[sk];
                }
                else
                {
                    info.skillName = monsters[name].skills[0];
                }

                info.equip1Name = "none";
                info.equip2Name = "none";


                token.CreateMonsterToken(this);
                saveToken = token.newToken;


                SaveMonsterToken();
                LoadMonsterToken(saveToken);
                GameManager.Instance.GetComponent <YourMonsters>().GetYourMonsters();
            }
        }
    }
    public void UpgradeMonster(GameObject hit)
    {
        var monstersDict = GameManager.Instance.monstersData.monstersAllDict;
        var monsters     = GameManager.Instance.GetComponent <YourMonsters>().yourMonstersDict;



        //monster1.GetComponent<Image>().sprite = monstersDict[activeMonster.info.species].iconSprite;
        //monster1.GetComponent<MonsterHomeIcon>().nameText.text = activeMonster.info.name;
        //monster1.GetComponent<MonsterHomeIcon>().levelText.text = activeMonster.info.level.ToString();
        //monster1.GetComponent<MonsterHomeIcon>().rankText.text = activeMonster.info.monsterRank.ToString();



        //monster1 = Instantiate(activeMonster.monsterIcon, monster1.transform.position, Quaternion.identity);
        var monster = Instantiate(activeMonster.monsterIcon, monster1.transform.position, Quaternion.identity);

        monster.GetComponentInChildren <MonsterIcon>().IconVisibility("Overlays");

        //var monster = monster1;
        monster.transform.SetParent(upgradePopMenu.transform, true);
        monster.tag = "Tower";


        //monster.GetComponent<Tower>().boneStructure.SetActive(false);
        //monster.GetComponent<Monster>().monsterIcon.SetActive(true);
        //monster.GetComponent<Monster>().monsterIcon.GetComponentInChildren<MonsterIcon>().DisplayMonster(activeMonster);



        hp1.text       = "HP: " + activeMonster.info.HP.Value.ToString();
        atk1.text      = "Atk: " + activeMonster.info.Attack.Value.ToString();
        def1.text      = "Def: " + activeMonster.info.Defense.Value.ToString();
        spe1.text      = "Spe: " + activeMonster.info.Speed.Value.ToString();
        prec1.text     = "Prec: " + activeMonster.info.Precision.Value.ToString();
        maxLevel1.text = "Max Level: " + activeMonster.info.maxLevel.ToString();
        rank1.text     = "Rank: " + activeMonster.info.monsterRank.ToString();



        //monster2.GetComponent<Image>().sprite = monstersDict[upgradeOptions[hit].species].iconSprite;
        //monster2.GetComponent<MonsterHomeIcon>().nameText.text = upgradeOptions[hit].name;
        //monster2.GetComponent<MonsterHomeIcon>().levelText.text = upgradeOptions[hit].level.ToString();
        //monster2.GetComponent<MonsterHomeIcon>().rankText.text = upgradeOptions[hit].rank.ToString();

        //create a temporary monster for the 2nd monster, to avoid having to spawn an entirely new monster
        if (monsters.ContainsKey(upgradeOptions[hit].index))
        {
            //monster2 = Instantiate(activeMonster.monsterIcon, monster2.transform.position, Quaternion.identity);
            var tempMonster2 = Instantiate(activeMonster.monsterIcon, monster2.transform.position, Quaternion.identity);
            tempMonster2.GetComponentInChildren <MonsterIcon>().IconVisibility("Overlays");
            tempMonster2.tag = "Tower";

            //var m = monster2;
            tempMonster2.transform.SetParent(upgradePopMenu.transform, true);


            string           monsterJson = monsters[upgradeOptions[hit].index];
            MonsterSaveToken info        = JsonUtility.FromJson <MonsterSaveToken>(monsterJson);
            string           species     = info.species;

            m2           = monstersDict[species].monsterPrefab.GetComponent <Monster>();
            m2.saveToken = info;
            m2.LoadMonsterToken(m2.saveToken);
            tempMonster2.GetComponentInChildren <MonsterIcon>().DisplayMonster(m2);


            hp2.text       = "HP: " + m2.info.HP.Value.ToString();
            atk2.text      = "Atk: " + m2.info.Attack.Value.ToString();
            def2.text      = "Def: " + m2.info.Defense.Value.ToString();
            spe2.text      = "Spe: " + m2.info.Speed.Value.ToString();
            prec2.text     = "Prec: " + m2.info.Precision.Value.ToString();
            maxLevel2.text = "Max Level: " + m2.info.maxLevel.ToString();
            rank2.text     = "Rank: " + m2.info.monsterRank.ToString();
        }

        //set the changes that will occur for the newly upgraded monster
        m3 = activeMonster;

        //monster3 = Instantiate(activeMonster.monsterIcon, monster3.transform.position, Quaternion.identity);
        var newMonster3 = Instantiate(activeMonster.monsterIcon, monster3.transform.position, Quaternion.identity);

        newMonster3.GetComponentInChildren <MonsterIcon>().IconVisibility("Overlays");
        newMonster3.tag = "Tower";

        //var m = monster3;
        newMonster3.transform.SetParent(upgradePopMenu.transform, true);

        m3.saveToken.rank     = activeMonster.saveToken.rank + 1;
        m3.saveToken.maxLevel = activeMonster.saveToken.maxLevel + (10 * (m3.saveToken.rank - 1));

        m3.CheckStats(m3.saveToken);

        hp3.text       = "HP: " + m3.info.HP.Value.ToString();
        atk3.text      = "Atk: " + m3.info.Attack.Value.ToString();
        def3.text      = "Def: " + m3.info.Defense.Value.ToString();
        spe3.text      = "Spe: " + m3.info.Speed.Value.ToString();
        prec3.text     = "Prec: " + m3.info.Precision.Value.ToString();
        maxLevel3.text = "Max Level: " + m3.info.maxLevel.ToString();
        rank3.text     = "Rank: " + m3.info.monsterRank.ToString();

        newMonster3.GetComponentInChildren <MonsterIcon>().DisplayMonster(m3);
        //monster3.GetComponent<Image>().sprite = monstersDict[activeMonster.info.species].iconSprite;
        //monster3.GetComponent<MonsterHomeIcon>().nameText.text = activeMonster.info.name;
        //monster3.GetComponent<MonsterHomeIcon>().levelText.text = activeMonster.info.level.ToString();
        //monster3.GetComponent<MonsterHomeIcon>().rankText.text = activeMonster.saveToken.rank.ToString();
    }