Example #1
0
    public void AddToSelection(CharClasses type, List <GameObject> selection)
    {
        GameObject selectedUnit = null;

        foreach (GameObject unit in unitPrefabs)
        {
            if (unit.GetComponent <Unit>().unitClass == type)
            {
                selectedUnit = unit;
                break;
            }
        }
        if (selection == allySelection)
        {
            if (allySelection.Count < alliesCap)
            {
                selection.Add(selectedUnit);
            }
        }
        else
        {
            if (enemySelection.Count < enemiesCap)
            {
                selection.Add(selectedUnit);
            }
        }
    }
Example #2
0
        public void IsClassTest()
        {
            var testInstance = new CharClasses();

            testInstance.CharacterClasses.Add("Fighter");
            testInstance.CharacterClasses.Add("Wizard");
            testInstance.CharacterClasses.Add("Rogue");

            // expect to pass
            Assert.IsTrue(testInstance.DoesClassExist("Rogue"));
            // expect to fail
            Assert.IsFalse(testInstance.DoesClassExist("Sloth"));
        }
Example #3
0
    private void GetStats(CharClasses playerClass)
    {
        //set min stats based on class
        switch (playerClass)
        {
        case CharClasses.BigBoi:
            minStatVals[0] = 13; minStatVals[1] = 7; minStatVals[2] = 13; minStatVals[3] = 7; minStatVals[4] = 7; minStatVals[5] = 10;
            break;

        case CharClasses.Engineer:
            minStatVals[0] = 9; minStatVals[1] = 9; minStatVals[2] = 10; minStatVals[3] = 12; minStatVals[4] = 8; minStatVals[5] = 7;
            break;

        case CharClasses.GenericMarine:
            minStatVals[0] = 11; minStatVals[1] = 11; minStatVals[2] = 10; minStatVals[3] = 9; minStatVals[4] = 7; minStatVals[5] = 9;
            break;

        case CharClasses.Pilot:
            minStatVals[0] = 7; minStatVals[1] = 8; minStatVals[2] = 10; minStatVals[3] = 10; minStatVals[4] = 7; minStatVals[5] = 12;
            break;

        case CharClasses.SpaceWizard:
            minStatVals[0] = 6; minStatVals[1] = 8; minStatVals[2] = 8; minStatVals[3] = 12; minStatVals[4] = 12; minStatVals[5] = 9;
            break;

        case CharClasses.SpookyM8:
            minStatVals[0] = 8; minStatVals[1] = 8; minStatVals[2] = 8; minStatVals[3] = 9; minStatVals[4] = 10; minStatVals[5] = 2;
            break;
        }


        //set stat values to min stats
        for (int i = 0; i < minStatVals.Length; i++)
        {
            statVals[i] = minStatVals[i];
        }
        pointsToSpend = 10;
    }
Example #4
0
 public short GetReqLevelForClass(CharClasses charClass)
 {
     switch (charClass) {
         case CharClasses.Warrior:
             return this.WarriorReqLevel ?? 0;
         case CharClasses.Cleric:
             return this.ClericReqLevel ?? 0;
         case CharClasses.Paladin:
             return this.PaladinReqLevel ?? 0;
         case CharClasses.Ranger:
             return this.RangerReqLevel ?? 0;
         case CharClasses.ShadowKnight:
             return this.ShadowknightReqLevel ?? 0;
         case CharClasses.Druid:
             return this.DruidReqLevel ?? 0;
         case CharClasses.Monk:
             return this.MonkReqLevel ?? 0;
         case CharClasses.Bard:
             return this.BardReqLevel ?? 0;
         case CharClasses.Rogue:
             return this.RogueReqLevel ?? 0;
         case CharClasses.Shaman:
             return this.ShamanReqLevel ?? 0;
         case CharClasses.Necromancer:
             return this.NecromancerReqLevel ?? 0;
         case CharClasses.Wizard:
             return this.WizardReqLevel ?? 0;
         case CharClasses.Magician:
             return this.MagicianReqLevel ?? 0;
         case CharClasses.Enchanter:
             return this.EnchanterReqLevel ?? 0;
         case CharClasses.BeastLord:
             return this.BeastlordReqLevel ?? 0;
         case CharClasses.Berserker:
             return this.BeserkerReqLevel ?? 0;
         default:
             return 0;
     }
 }
Example #5
0
    private void OnGUI()
    {
        GUI.skin = customSkin;
        //get screen width and height fractions to space buttons
        float scrW = Screen.width / 16f;
        float scrH = Screen.height / 9f;
        //set up int to space customisation buttons downwards
        int buttonAdjust = 0;

        #region CustomizationButtons

        #region HeadButtons
        //if "-" button is pressed for head
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from headI
            headI--;
            //if headI is less than 0
            if (headI < 0)
            {
                //set headI to headMax - 1 to loop around
                headI = headMax - 1;
            }

            //Change the sprite with sprite at index headI in headList. String used here must match object in inspector
            SetSprite("Head", headI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Head: " + headI, customSkin.box);


        //if "+" button is pressed for head
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to headI
            headI++;
            //if headI is equal to or greater than headMax
            if (headI >= headMax)
            {
                //set headI to 0 to loop around
                headI = 0;
            }

            //Change the sprite with sprite at index headI in headList. String used here must match object in inspector
            SetSprite("Head", headI);
        }
        #endregion

        //add one to button adjust so the next row of buttons does not overlap the previous row
        buttonAdjust++;

        #region HairButtons
        //if "-" button is pressed for head
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from hairI
            hairI--;
            //if hairI is less than 0
            if (hairI < 0)
            {
                //set hairI to headMax - 1 to loop around
                hairI = hairMax - 1;
            }

            //Change the sprite with sprite at index hairI in hairList. String used here must match object in inspector
            SetSprite("Hair", hairI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Hair: " + hairI, customSkin.box);

        //if "+" button is pressed for hair
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to hair
            hairI++;
            //if hairI is equal to or greater than hairMax
            if (hairI >= hairMax)
            {
                //set hairI to 0 to loop around
                hairI = 0;
            }

            //Change the sprite with sprite at index headI in headList. String used here must match object in inspector
            SetSprite("Hair", hairI);
        }
        #endregion

        buttonAdjust++;

        #region EyesButtons
        //if "-" button is pressed for head
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from headI
            eyesI--;
            //if headI is less than 0
            if (eyesI < 0)
            {
                //set headI to headMax - 1 to loop around
                eyesI = eyesMax - 1;
            }

            //Change the sprite with sprite at index headI in headList. String used here must match object in inspector
            SetSprite("Eyes", eyesI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Eyes: " + eyesI, customSkin.box);

        //if "+" button is pressed for head
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to headI
            eyesI++;
            //if headI is equal to or greater than headMax
            if (eyesI >= eyesMax)
            {
                //set headI to 0 to loop around
                eyesI = 0;
            }

            //Change the sprite with sprite at index headI in headList. String used here must match object in inspector
            SetSprite("Eyes", eyesI);
        }
        #endregion

        buttonAdjust++;

        #region EyebrowButtons
        //if "-" button is pressed for head
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from headI
            eyebrowsI--;
            //if headI is less than 0
            if (eyebrowsI < 0)
            {
                //set headI to headMax - 1 to loop around
                eyebrowsI = eyebrowsMax - 1;
            }

            //Change the sprite with sprite at index headI in headList. String used here must match object in inspector
            SetSprite("Eyebrows", eyebrowsI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Eyebrows: " + eyebrowsI, customSkin.box);

        //if "+" button is pressed for head
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to headI
            eyebrowsI++;
            //if headI is equal to or greater than headMax
            if (eyebrowsI >= eyebrowsMax)
            {
                //set headI to 0 to loop around
                eyebrowsI = 0;
            }

            //Change the sprite with sprite at index headI in headList. String used here must match object in inspector
            SetSprite("Eyebrows", eyebrowsI);
        }
        #endregion

        buttonAdjust++;

        #region MouthButtons
        //if "-" button is pressed for mouth
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from mouthI
            mouthI--;
            //if mouthI is less than 0
            if (mouthI < 0)
            {
                //set mouthI to mouthMax - 1 to loop around
                mouthI = mouthMax - 1;
            }

            //Change the sprite with sprite at index mouthI in mouthList. String used here must match object in inspector
            SetSprite("Mouth", mouthI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Mouth: " + mouthI, customSkin.box);

        //if "+" button is pressed for mouth
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to mouth
            mouthI++;
            //if mouthI is equal to or greater than mouthMax
            if (mouthI >= mouthMax)
            {
                //set mouthI to 0 to loop around
                mouthI = 0;
            }

            //Change the sprite with sprite at index mouthI in mouthList. String used here must match object in inspector
            SetSprite("Mouth", mouthI);
        }
        #endregion

        buttonAdjust++;

        //for torso we will simultaniously change torso and pelvis using torsoI
        #region Torso
        //if "-" button is pressed for torso
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from torsoI
            torsoI--;
            //if torsoI is less than 0
            if (torsoI < 0)
            {
                //set torsoI to torsoMax - 1 to loop around
                torsoI = torsoMax - 1;
            }

            //Change the sprite with sprite at index torsoI in torsoList. String used here must match object in inspector
            SetSprite("Torso", torsoI);
            //Change the sprite with sprite at index torsoI in pelvisList. String used here must match object in inspector
            SetSprite("Pelvis", torsoI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Torso: " + torsoI, customSkin.box);

        //if "+" button is pressed for torso
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to torso
            torsoI++;
            //if torsoI is equal to or greater than torsoMax
            if (torsoI >= torsoMax)
            {
                //set torsoI to 0 to loop around
                torsoI = 0;
            }

            //Change the sprite with sprite at index torsoI in torsoList. String used here must match object in inspector
            SetSprite("Torso", torsoI);
            //Change the sprite with sprite at index torsoI in pelvisList. String used here must match object in inspector
            SetSprite("Pelvis", torsoI);
        }
        #endregion

        buttonAdjust++;

        //will change left and right legs and shins at the same time using legI
        #region Legs
        //if "-" button is pressed for legs
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from legI
            legI--;
            //if legI is less than 0
            if (legI < 0)
            {
                //set legI to legMax - 1 to loop around
                legI = legMax - 1;
            }

            //Change the sprite with sprite at index legI in shinRList and shinLList. String used here must match object in inspector
            SetSprite("ShinL", legI);
            SetSprite("ShinR", legI);
            //Change the sprite with sprite at index legI in legRList and legLList. String used here must match object in inspector
            SetSprite("LegL", legI);
            SetSprite("LegR", legI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Legs: " + legI, customSkin.box);

        //if "+" button is pressed for torso
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to leg
            legI++;
            //if legI is equal to or greater than legMax
            if (legI >= legMax)
            {
                //set legI to 0 to loop around
                legI = 0;
            }

            //Change the sprite with sprite at index legI in shinRList and shinLList. String used here must match object in inspector
            SetSprite("ShinL", legI);
            SetSprite("ShinR", legI);
            //Change the sprite with sprite at index legI in legRList and legLList. String used here must match object in inspector
            SetSprite("LegL", legI);
            SetSprite("LegR", legI);
        }
        #endregion

        buttonAdjust++;

        //will change left and right arms & forearms at the same time using armI
        #region Arms
        //if "-" button is pressed for arms
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from armI
            armI--;
            //if legI is less than 0
            if (armI < 0)
            {
                //set armI to armMax - 1 to loop around
                armI = armMax - 1;
            }

            //Change the sprite with sprite at index armI in armRList and armLList. String used here must match object in inspector
            SetSprite("ArmL", armI);
            SetSprite("ArmR", armI);
            //Change the sprite with sprite at index armI in forearmRList and forearmLList. String used here must match object in inspector
            SetSprite("ForearmL", armI);
            SetSprite("ForearmR", armI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Arms: " + armI, customSkin.box);

        //if "+" button is pressed for torso
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to arm
            armI++;
            //if armI is equal to or greater than armMax
            if (armI >= armMax)
            {
                //set armI to 0 to loop around
                armI = 0;
            }

            //Change the sprite with sprite at index armI in armRList and armLList. String used here must match object in inspector
            SetSprite("ArmL", armI);
            SetSprite("ArmR", armI);
            //Change the sprite with sprite at index armI in forearmRList and forearmLList. String used here must match object in inspector
            SetSprite("ForearmL", armI);
            SetSprite("ForearmR", armI);
        }
        #endregion

        buttonAdjust++;

        //set both left and right hands at the same time using handI
        #region Hands
        //if "-" button is pressed for hands
        if (GUI.Button(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[0]))
        {
            //take 1 from handI
            handI--;
            //if handI is less than 0
            if (handI < 0)
            {
                //set handI to handMax - 1 to loop around
                handI = handMax - 1;
            }

            //Change the sprite with sprite at index handI in handList. String used here must match object in inspector
            SetSprite("HandL", handI);
            SetSprite("HandR", handI);
        }

        GUI.Box(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2, scrH * 0.5f), "Hand: " + handI, customSkin.box);

        //if "+" button is pressed for hand
        if (GUI.Button(new Rect(scrW * 3f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "", customSkin.customStyles[1]))
        {
            //add 1 to hand
            handI++;
            //if handI is equal to or greater than handMax
            if (handI >= handMax)
            {
                //set handI to 0 to loop around
                handI = 0;
            }

            //Change the sprite with sprite at index handI in handRList and handLList. String used here must match object in inspector
            SetSprite("HandR", handI);
            SetSprite("HandL", handI);
        }
        #endregion

        #endregion

        buttonAdjust++;

        //make a toggle that opens and closes
        //showClasses = GUI.Toggle(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2f, scrH * 0.5f), showClasses, "Classes");
        if (GUI.Button(new Rect(scrW * 1f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 2f, scrH * 0.5f), playerClass.ToString(), customSkin.customStyles[2]))
        {
            showClasses = !showClasses;
        }


        buttonAdjust++;

        #region ClassScroll
        //if showClasses
        if (showClasses)
        {
            //begin the scroll window
            scrollPos = GUI.BeginScrollView(new Rect(scrW * 0.5f, scrH + buttonAdjust * (scrH * 0.5f), scrW * 3f, scrH * 2f), scrollPos, new Rect(0f, 0f, 0f, scrH * 2 + (classes.Length - 4) * scrH * 0.5f), false, true);

            //loop through the array of classes
            for (int i = 0; i < classes.Length; i++)
            {
                //if class button is pressed
                if (GUI.Button(new Rect(scrW * 0.5f, 0f + i * scrH * 0.5f, scrW * 2f, scrH * 0.5f), classes[i].ToString(), customSkin.button))
                {
                    playerClass = classes[i];
                    //run function to change default stats etc
                    GetStats(playerClass);
                }
            }

            //end the scroll window
            GUI.EndScrollView();
        }
        #endregion

        buttonAdjust = 0;

        #region StatButtons
        for (int i = 0; i < stats.Length; i++)
        {
            if (statVals[i] > minStatVals[i])
            {
                if (GUI.Button(new Rect(scrW * 12.5f, scrH + i * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "-"))
                {
                    //decrease the stat
                    statVals[i]--;
                    //increase points to spend
                    pointsToSpend++;
                }
            }

            GUI.Box(new Rect(scrW * 13f, scrH + i * (scrH * 0.5f), scrW * 2, scrH * 0.5f), stats[i] + ": " + statVals[i]);

            if (pointsToSpend > 0)
            {
                //if "+" button is pressed for hand
                if (GUI.Button(new Rect(scrW * 15f, scrH + i * (scrH * 0.5f), scrW * 0.5f, scrH * 0.5f), "+"))
                {
                    //up the stat being spent
                    statVals[i]++;
                    //deplete the points to spend
                    pointsToSpend--;
                }
            }
            buttonAdjust++;
        }
        #endregion

        playerName = GUI.TextField(new Rect(scrW * 5f, scrH * 7f, scrW * 6f, scrH * 0.75f), playerName, 16);

        if (pointsToSpend == 0 && playerName != "")
        {
            if (GUI.Button(new Rect(scrW * 7f, scrH * 8f, scrW * 2f, scrH * 0.5f), "Save and Play"))
            {
                SaveData();
                SceneManager.LoadScene(2);
            }
        }
    }
Example #6
0
 public IntArrayTest()
     : base("Int array")
 {
     data = CharClasses.Decompress8(compressedData);
 }