Exemple #1
0
    //Function that loads the unit party
    public void loadParty()
    {
        //Create instance of FileIOS object
        FileIOS File = new FileIOS();
        //Create an instance of a new Party object
        Party Team = new Party();

        //If count of the ulBattleReadyParty is greater than or equal to 1
        if (ulBattleReadyParty.Count >= 1)
        {//Remove all elements of the current ulBattleReadyParty list
            ulBattleReadyParty.RemoveRange(0, ulBattleReadyParty.Count);
        }

        //string victoryParty = EditorUtility.OpenFilePanel("Open File", Application.dataPath + "/GameData/VictoryParty", "xml");
        //Store file path into the string variable
        string victoryParty = Application.dataPath + "/GameData/VictoryParty/WinningParty.xml";
        //Deserialize the the object in the path and store into party variable
        Team = File.Deserialize<Party>(victoryParty);

        //Set proper text variables to proper values
        ifP1Name.text = Team.ulUnits[0].sName;
        ifP1Name.text = Team.ulUnits[0].sName;
        ifP1Health.text = Team.ulUnits[0].iHealth.ToString();
        ifP1Strength.text = Team.ulUnits[0].iStrength.ToString();
        ifP1Defense.text = Team.ulUnits[0].iDefense.ToString();
        ifP1Speed.text = Team.ulUnits[0].iSpeed.ToString();
        ifP1Level.text = Team.ulUnits[0].iLevel.ToString();

        //Add unit to list
        ulBattleReadyParty.Add(Team.ulUnits[0]);

        //Set proper text variables to proper values
        ifP2Name.text = Team.ulUnits[1].sName;
        ifP2Name.text = Team.ulUnits[1].sName;
        ifP2Health.text = Team.ulUnits[1].iHealth.ToString();
        ifP2Strength.text = Team.ulUnits[1].iStrength.ToString();
        ifP2Defense.text = Team.ulUnits[1].iDefense.ToString();
        ifP2Speed.text = Team.ulUnits[1].iSpeed.ToString();
        ifP2Level.text = Team.ulUnits[1].iLevel.ToString();

        //Add unit to list
        ulBattleReadyParty.Add(Team.ulUnits[1]);

        //Set proper text variables to proper values
        ifP3Name.text = Team.ulUnits[2].sName;
        ifP3Name.text = Team.ulUnits[2].sName;
        ifP3Health.text = Team.ulUnits[2].iHealth.ToString();
        ifP3Strength.text = Team.ulUnits[2].iStrength.ToString();
        ifP3Defense.text = Team.ulUnits[2].iDefense.ToString();
        ifP3Speed.text = Team.ulUnits[2].iSpeed.ToString();
        ifP3Level.text = Team.ulUnits[2].iLevel.ToString();

        //Add unit to list
        ulBattleReadyParty.Add(Team.ulUnits[2]);

        //Set images to passed in list
        setImages(ulBattleReadyParty);

        //Create objects
        Unit TwoFaced = new Unit("2Faced", 100, 20, 15, 5, 25, "Enemy");
        Unit AncientDragon = new Unit("Ancient Dragon", 200, 30, 12, 4, 100, "Enemy");
        Unit Ghost = new Unit("Ghost", 80, 20, 15, 5, 30, "Enemy");
        Unit IceGolem = new Unit("Ice Golem", 150, 25, 15, 5, 35, "Enemy");
        Unit Zuu = new Unit("Zuu", 120, 15, 10, 5, 20, "Enemy");
        Unit ToxicFrog = new Unit("Toxic Frog", 180, 22, 12, 5, 30, "Enemy");
        Unit DeathClaw = new Unit("Death Claw", 140, 25, 18, 7, 50, "Enemy");
        Unit MasterTonberry = new Unit("Master Tonberry", 170, 20, 15, 5, 50, "Enemy");
        Unit Behemoth = new Unit("Behemoth", 200, 35, 14, 4, 100, "Enemy");

        //Create a new list
        List<Unit> ulE = new List<Unit>();

        //Add the Enemy Types to the list
        ulE.Add(TwoFaced);
        ulE.Add(AncientDragon);
        ulE.Add(Ghost);
        ulE.Add(IceGolem);
        ulE.Add(Zuu);
        ulE.Add(ToxicFrog);
        ulE.Add(DeathClaw);
        ulE.Add(MasterTonberry);
        ulE.Add(Behemoth);

        //Creat an instance of Random class
        System.Random a = new System.Random();

        //call Next() 3 times giving random selection for enemy party members
        int e1 = a.Next(0, ulE.Count - 1);
        int e2 = a.Next(0, ulE.Count - 1);
        int e3 = a.Next(0, ulE.Count - 1);

        //while e1 is equal to ee2
        while (e1 == e2)
        {//Randomize e2
            e2 = a.Next(0, ulE.Count - 1);
        }
        //while e2 is equal to e3
        while (e2 == e3)
        {//Randomize e3
            e3 = a.Next(0, ulE.Count - 1);
        }
        //while e3 is equal to e1
        while (e3 == e1)
        {//Randomize e1
            e1 = a.Next(0, ulE.Count - 1);
            //while e1 is equal to e2
            while (e1 == e2)
            {//Randomize e1
                e1 = a.Next(0, ulE.Count - 1);
            }
        }
        //Add unit to list
        ulBattleReadyParty.Add(ulE[e1]);
        //Add unit to list
        ulBattleReadyParty.Add(ulE[e2]);
        //Add unit to list
        ulBattleReadyParty.Add(ulE[e3]);
        //Enable play button
        bPlayButton.enabled = true;
    }
Exemple #2
0
    //Function that loads the unit party
    public void loadParty()
    {//Create instance of FileIOS object
        FileIOS File = new FileIOS();
        //Create an instance of a new Party object
        Party Team = new Party();

        //If count of the ulBattleReadyParty is greater than or equal to 1
        if (ulBattleReadyParty.Count >= 1)
        {//Remove all elements of the current ulBattleReadyParty list
            ulBattleReadyParty.RemoveRange(0, ulBattleReadyParty.Count);
        }

        //string victoryParty = EditorUtility.OpenFilePanel("Open File", Application.dataPath + "/GameData/VictoryParty", "xml");
        //Store file path into the string variable
        string victoryParty = Application.dataPath + "/GameData/VictoryParty/WinningParty.xml";

        //Deserialize the the object in the path and store into party variable
        Team = File.Deserialize <Party>(victoryParty);

        //Set proper text variables to proper values
        ifP1Name.text     = Team.ulUnits[0].sName;
        ifP1Name.text     = Team.ulUnits[0].sName;
        ifP1Health.text   = Team.ulUnits[0].iHealth.ToString();
        ifP1Strength.text = Team.ulUnits[0].iStrength.ToString();
        ifP1Defense.text  = Team.ulUnits[0].iDefense.ToString();
        ifP1Speed.text    = Team.ulUnits[0].iSpeed.ToString();
        ifP1Level.text    = Team.ulUnits[0].iLevel.ToString();

        //Add unit to list
        ulBattleReadyParty.Add(Team.ulUnits[0]);

        //Set proper text variables to proper values
        ifP2Name.text     = Team.ulUnits[1].sName;
        ifP2Name.text     = Team.ulUnits[1].sName;
        ifP2Health.text   = Team.ulUnits[1].iHealth.ToString();
        ifP2Strength.text = Team.ulUnits[1].iStrength.ToString();
        ifP2Defense.text  = Team.ulUnits[1].iDefense.ToString();
        ifP2Speed.text    = Team.ulUnits[1].iSpeed.ToString();
        ifP2Level.text    = Team.ulUnits[1].iLevel.ToString();

        //Add unit to list
        ulBattleReadyParty.Add(Team.ulUnits[1]);

        //Set proper text variables to proper values
        ifP3Name.text     = Team.ulUnits[2].sName;
        ifP3Name.text     = Team.ulUnits[2].sName;
        ifP3Health.text   = Team.ulUnits[2].iHealth.ToString();
        ifP3Strength.text = Team.ulUnits[2].iStrength.ToString();
        ifP3Defense.text  = Team.ulUnits[2].iDefense.ToString();
        ifP3Speed.text    = Team.ulUnits[2].iSpeed.ToString();
        ifP3Level.text    = Team.ulUnits[2].iLevel.ToString();

        //Add unit to list
        ulBattleReadyParty.Add(Team.ulUnits[2]);

        //Set images to passed in list
        setImages(ulBattleReadyParty);

        //Create objects
        Unit TwoFaced       = new Unit("2Faced", 100, 20, 15, 5, 25, "Enemy");
        Unit AncientDragon  = new Unit("Ancient Dragon", 200, 30, 12, 4, 100, "Enemy");
        Unit Ghost          = new Unit("Ghost", 80, 20, 15, 5, 30, "Enemy");
        Unit IceGolem       = new Unit("Ice Golem", 150, 25, 15, 5, 35, "Enemy");
        Unit Zuu            = new Unit("Zuu", 120, 15, 10, 5, 20, "Enemy");
        Unit ToxicFrog      = new Unit("Toxic Frog", 180, 22, 12, 5, 30, "Enemy");
        Unit DeathClaw      = new Unit("Death Claw", 140, 25, 18, 7, 50, "Enemy");
        Unit MasterTonberry = new Unit("Master Tonberry", 170, 20, 15, 5, 50, "Enemy");
        Unit Behemoth       = new Unit("Behemoth", 200, 35, 14, 4, 100, "Enemy");

        //Create a new list
        List <Unit> ulE = new List <Unit>();

        //Add the Enemy Types to the list
        ulE.Add(TwoFaced);
        ulE.Add(AncientDragon);
        ulE.Add(Ghost);
        ulE.Add(IceGolem);
        ulE.Add(Zuu);
        ulE.Add(ToxicFrog);
        ulE.Add(DeathClaw);
        ulE.Add(MasterTonberry);
        ulE.Add(Behemoth);

        //Creat an instance of Random class
        System.Random a = new System.Random();

        //call Next() 3 times giving random selection for enemy party members
        int e1 = a.Next(0, ulE.Count - 1);
        int e2 = a.Next(0, ulE.Count - 1);
        int e3 = a.Next(0, ulE.Count - 1);

        //while e1 is equal to ee2
        while (e1 == e2)
        {//Randomize e2
            e2 = a.Next(0, ulE.Count - 1);
        }
        //while e2 is equal to e3
        while (e2 == e3)
        {//Randomize e3
            e3 = a.Next(0, ulE.Count - 1);
        }
        //while e3 is equal to e1
        while (e3 == e1)
        {//Randomize e1
            e1 = a.Next(0, ulE.Count - 1);
            //while e1 is equal to e2
            while (e1 == e2)
            {//Randomize e1
                e1 = a.Next(0, ulE.Count - 1);
            }
        }
        //Add unit to list
        ulBattleReadyParty.Add(ulE[e1]);
        //Add unit to list
        ulBattleReadyParty.Add(ulE[e2]);
        //Add unit to list
        ulBattleReadyParty.Add(ulE[e3]);
        //Enable play button
        bPlayButton.enabled = true;
    }