// Set the type of battle item
 public void setBattleType(battleType b)
 {
     if (this.iTypeMain == itemType.BATTLE || this.iTypeSub == itemType.BATTLE)
     {
         this.bType = b;
     }
     return;
 }
Beispiel #2
0
 public void setSupport(battleType supportType, status statusMod, stat statBoost, int scalar, bool selfTarget, bool targetAlly)
 {
     this.supprtType = supportType;
     this.statusMod  = statusMod;
     this.statBoost  = statBoost;
     this.scalar     = scalar;
     this.selfTarget = selfTarget;
     this.targetAlly = targetAlly;
     return;
 }
    private Ally makeAlly(jankFile input, character duck)
    {
        List <string>          sheetP        = new List <string>();
        List <Sprite[]>        sheets        = new List <Sprite[]>();
        List <SpriteAnimation> RPGanims      = new List <SpriteAnimation>();
        List <Skill>           skillList     = new List <Skill>();
        List <FighterSkill>    fighterSkills = new List <FighterSkill>();

        bool hasBack;

        int[] battlestats = new int[7];
        // Determine number of spritesheets
        string s = input.ReadLine();

        string[] split = s.Split(' ');
        int      paths = 0;

        int.TryParse(split[split.Length - 1], out paths);
        // Read paths for spritesheets
        for (int i = 0; i < paths; i++)
        {
            string   sheetPath = input.ReadLine();
            Sprite[] sheet     = Resources.LoadAll <Sprite>(@sheetPath);
            sheets.Add(sheet);
            sheetP.Add(sheetPath);
        }
        input.ReadLine();

        // Check if the character as a back set of animations
        s     = input.ReadLine();
        split = s.Split(' ');
        bool.TryParse(split[split.Length - 1], out hasBack);

        // Read in stats of character
        s     = input.ReadLine();
        split = s.Split(' ');
        for (int i = 1; i < split.Length; i++)
        {
            int.TryParse(split[i], out battlestats[i - 1]);
        }
        input.ReadLine();

        // Read in RPG animations
        for (int i = 0; i < 7; i++)
        {
            input.ReadLine();
            float fps;
            int   spriteAmt;

            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out fps);
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out spriteAmt);

            Sprite[] anim  = new Sprite[spriteAmt];
            string[] pathS = new string[spriteAmt];
            string[] nameS = new string[spriteAmt];
            for (int j = 0; j < spriteAmt; j++)
            {
                int sheetNum;
                s     = input.ReadLine();
                split = s.Split('-');
                int.TryParse(split[0], out sheetNum);
                pathS[j] = sheetP[sheetNum];
                nameS[j] = split[split.Length - 1];

                anim[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
            }

            SpriteAnimation entry = new SpriteAnimation(anim, new int[0], fps, true);
            entry.saveSprites(pathS, nameS);
            RPGanims.Add(entry);
            input.ReadLine();
        }

        input.ReadLine();
        int skillAmt;

        s     = input.ReadLine();
        split = s.Split(' ');
        int.TryParse(split[split.Length - 1], out skillAmt);
        input.ReadLine();

        // Read in RPG skills
        for (int i = 0; i < skillAmt; i++)
        {
            skillType       skill;
            string          atkName, des;
            element         atkEle;
            int             basePower, mpCost, range, effectChance;
            bool            isMagical, animLoop;
            float           start, end, fps;
            SpriteAnimation anim;

            battleType support    = battleType.NULL;
            status     statusMod  = status.NULL;
            int        scalar     = 0;
            stat       statBoost  = stat.NULL;
            bool       selfTarget = false;
            bool       targetAlly = false;
            string     skillSFX;

            atkName = input.ReadLine();
            des     = input.ReadLine();

            s     = input.ReadLine();
            split = s.Split(' ');
            if (split[split.Length - 1].CompareTo("Offensive") == 0)
            {
                skill = skillType.OFFENSIVE;

                // Attack element
                s      = input.ReadLine();
                split  = s.Split(' ');
                atkEle = decideEle(split[split.Length - 1]);

                // base power
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out basePower);

                // mp cost
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out mpCost);

                // is magical
                s     = input.ReadLine();
                split = s.Split(' ');
                bool.TryParse(split[split.Length - 1], out isMagical);

                // effect chance
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out effectChance);
                if (effectChance > 0)
                {
                    // status variables
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    support   = decideSupport(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    statusMod = decideStatus(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    statBoost = decideStat(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out scalar);
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    bool.TryParse(split[split.Length - 1], out selfTarget);
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    bool.TryParse(split[split.Length - 1], out targetAlly);
                }

                // range
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out range);

                // positions
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out start);
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out end);

                // FPS
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out fps);

                // Sprite animation
                int spriteAmt;
                s     = input.ReadLine();
                split = s.Split(' ');
                if (split.Length > 2)
                {
                    int.TryParse(split[split.Length - 2], out spriteAmt);
                    animLoop = true;
                }
                else
                {
                    int.TryParse(split[split.Length - 1], out spriteAmt);
                    animLoop = false;
                }
                Sprite[] sprites = new Sprite[spriteAmt];
                string[] pathS   = new string[spriteAmt];
                string[] nameS   = new string[spriteAmt];
                for (int j = 0; j < spriteAmt; j++)
                {
                    int sheetNum;
                    s     = input.ReadLine();
                    split = s.Split('-');
                    int.TryParse(split[0], out sheetNum);

                    pathS[j] = sheetP[sheetNum];
                    nameS[j] = split[split.Length - 1];

                    sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
                }
                anim = new SpriteAnimation(sprites, new int[0], fps, animLoop);
                anim.saveSprites(pathS, nameS);
            }
            else
            {
                skill        = skillType.SUPPORT;
                basePower    = 0;
                effectChance = 0;
                isMagical    = true;

                // Attack element
                s      = input.ReadLine();
                split  = s.Split(' ');
                atkEle = decideEle(split[split.Length - 1]);

                // mp cost
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out mpCost);

                // range
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out range);

                // positions
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out start);
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out end);

                // status variables
                s         = input.ReadLine();
                split     = s.Split(' ');
                support   = decideSupport(split[split.Length - 1]);
                s         = input.ReadLine();
                split     = s.Split(' ');
                statusMod = decideStatus(split[split.Length - 1]);
                s         = input.ReadLine();
                split     = s.Split(' ');
                statBoost = decideStat(split[split.Length - 1]);
                s         = input.ReadLine();
                split     = s.Split(' ');
                int.TryParse(split[split.Length - 1], out scalar);
                s     = input.ReadLine();
                split = s.Split(' ');
                bool.TryParse(split[split.Length - 1], out selfTarget);
                s     = input.ReadLine();
                split = s.Split(' ');
                bool.TryParse(split[split.Length - 1], out targetAlly);

                // FPS
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out fps);

                // Sprite animation
                int spriteAmt;
                s     = input.ReadLine();
                split = s.Split(' ');
                if (split.Length > 2)
                {
                    int.TryParse(split[split.Length - 2], out spriteAmt);
                    animLoop = true;
                }
                else
                {
                    int.TryParse(split[split.Length - 1], out spriteAmt);
                    animLoop = false;
                }
                Sprite[] sprites = new Sprite[spriteAmt];
                string[] pathS   = new string[spriteAmt];
                string[] nameS   = new string[spriteAmt];
                for (int j = 0; j < spriteAmt; j++)
                {
                    int sheetNum;
                    s     = input.ReadLine();
                    split = s.Split('-');
                    int.TryParse(split[0], out sheetNum);

                    pathS[j] = sheetP[sheetNum];
                    nameS[j] = split[split.Length - 1];

                    sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
                }
                anim = new SpriteAnimation(sprites, new int[0], fps, animLoop);
                anim.saveSprites(pathS, nameS);
            }
            // Get SFX path
            input.ReadLine();
            skillSFX = input.ReadLine();
            input.ReadLine();

            Skill entry = new Skill(skill, atkName, des, atkEle, mpCost, range, start, end, anim, skillSFX);
            entry.setAttack(basePower, isMagical, effectChance);
            if (skill == skillType.SUPPORT || effectChance > 0)
            {
                entry.setSupport(support, statusMod, statBoost, scalar, selfTarget, targetAlly);
            }
            skillList.Add(entry);
        }

        input.ReadLine();
        s     = input.ReadLine();
        split = s.Split(' ');
        int.TryParse(split[split.Length - 1], out skillAmt);
        input.ReadLine();

        // Read fighter skills
        for (int i = 0; i < skillAmt; i++)
        {
            bool            hasProj;
            string          projPath = "";
            string          atkName = input.ReadLine();
            int             hitstun, basePower, faf, fps, rehit;
            float           xPow, yPow, xShift, yShift;
            bool            jc, sc, animLoop;
            SpriteAnimation anim, animB;
            string          skillSFX;

            // Projectile
            s     = input.ReadLine();
            split = s.Split(' ');
            bool.TryParse(split[split.Length - 1], out hasProj);
            if (hasProj)
            {
                projPath = input.ReadLine();
            }

            // Command Input
            int inputAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out inputAmt);
            KeyCode[] command = new KeyCode[inputAmt];
            s     = input.ReadLine();
            split = s.Split(' ');
            for (int j = 0; j < inputAmt; j++)
            {
                command[j] = decideKeyCode(split[j]);
            }

            // Hitstun
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out hitstun);

            // Base Power
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out basePower);

            // First Active Frame
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out faf);

            // Rehit
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out rehit);

            // Power and shift
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out xPow);
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out yPow);
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out xShift);
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out yShift);

            // Cancels
            s     = input.ReadLine();
            split = s.Split(' ');
            bool.TryParse(split[split.Length - 1], out jc);
            s     = input.ReadLine();
            split = s.Split(' ');
            bool.TryParse(split[split.Length - 1], out sc);

            // Hitbox Frames
            int frameAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out frameAmt);
            int[] hitFrames = new int[frameAmt];
            s = input.ReadLine();
            if (frameAmt == 1)
            {
                int.TryParse(s, out hitFrames[0]);
            }
            else if (frameAmt > 1)
            {
                split = s.Split('-');
                int min, max;
                int.TryParse(split[0], out min);
                int.TryParse(split[split.Length - 1], out max);
                for (int j = 0; j < hitFrames.Length; j++)
                {
                    hitFrames[j] = j + min;
                }
            }

            // Sprites
            int spriteAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            if (split.Length > 2)
            {
                int.TryParse(split[split.Length - 2], out spriteAmt);
                animLoop = true;
            }
            else
            {
                int.TryParse(split[split.Length - 1], out spriteAmt);
                animLoop = false;
            }
            Sprite[] sprites = new Sprite[spriteAmt];
            string[] pathS   = new string[spriteAmt];
            string[] nameS   = new string[spriteAmt];
            for (int j = 0; j < spriteAmt; j++)
            {
                int sheetNum;
                s     = input.ReadLine();
                split = s.Split('-');
                int.TryParse(split[0], out sheetNum);

                pathS[j] = sheetP[sheetNum];
                nameS[j] = split[split.Length - 1];

                sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
            }

            // Sprites back
            Sprite[] spritesB = new Sprite[spriteAmt];
            string[] pathSB   = new string[spriteAmt];
            string[] nameSB   = new string[spriteAmt];
            if (hasBack)
            {
                for (int j = 0; j < spriteAmt; j++)
                {
                    int sheetNum;
                    s     = input.ReadLine();
                    split = s.Split('-');
                    int.TryParse(split[0], out sheetNum);

                    pathSB[j] = sheetP[sheetNum];
                    nameSB[j] = split[split.Length - 1];

                    spritesB[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
                }
            }

            // Hitboxes
            int hitboxAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out hitboxAmt);
            HitBox[] boxes = new HitBox[hitboxAmt];
            for (int j = 0; j < hitboxAmt; j++)
            {
                s     = input.ReadLine();
                split = s.Split(' ');
                float x, y, xs, ys;
                float.TryParse(split[0], out x);
                float.TryParse(split[1], out y);
                float.TryParse(split[2], out xs);
                float.TryParse(split[3], out ys);

                boxes[j] = new HitBox((x / 2) + xs, (y / 2) + ys, (-x / 2) + xs, (-y / 2) + ys);
            }

            // FPS
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out fps);
            anim = new SpriteAnimation(sprites, hitFrames, fps, animLoop);
            anim.saveSprites(pathS, nameS);
            animB = new SpriteAnimation(spritesB, hitFrames, fps, animLoop);
            animB.saveSprites(pathSB, nameSB);

            // Get SFX path
            input.ReadLine();
            skillSFX = input.ReadLine();

            FighterSkill entry = new FighterSkill(atkName, hitstun, basePower, faf, xPow, yPow, xShift, yShift, jc, sc, command, boxes, rehit, hitFrames, skillSFX);
            entry.setAnimation(anim);
            if (hasBack)
            {
                entry.setAnimationBack(animB);
            }
            if (hasProj)
            {
                entry.setProjectile(projPath, false);
            }
            fighterSkills.Add(entry);

            input.ReadLine();
        }
        float walkSpd, dashSpd, glideSpd, gravity;
        int   maxJumps;

        // Read in fighter variables
        s     = input.ReadLine();
        split = s.Split(' ');
        float.TryParse(split[split.Length - 1], out walkSpd);
        s     = input.ReadLine();
        split = s.Split(' ');
        float.TryParse(split[split.Length - 1], out dashSpd);
        s     = input.ReadLine();
        split = s.Split(' ');
        float.TryParse(split[split.Length - 1], out glideSpd);
        s     = input.ReadLine();
        split = s.Split(' ');
        float.TryParse(split[split.Length - 1], out gravity);
        s     = input.ReadLine();
        split = s.Split(' ');
        int.TryParse(split[split.Length - 1], out maxJumps);
        input.ReadLine();

        List <SpriteAnimation> fightAnims  = new List <SpriteAnimation>();
        List <SpriteAnimation> fightAnimsB = new List <SpriteAnimation>();

        for (int i = 0; i < 9; i++)
        {
            input.ReadLine();
            float fps;
            int   spriteCount;
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out fps);
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out spriteCount);

            Sprite[] sprites = new Sprite[spriteCount];
            string[] pathS   = new string[spriteCount];
            string[] nameS   = new string[spriteCount];
            for (int j = 0; j < spriteCount; j++)
            {
                int sheetNum;
                s     = input.ReadLine();
                split = s.Split('-');
                int.TryParse(split[0], out sheetNum);
                pathS[j]   = sheetP[sheetNum];
                nameS[j]   = split[split.Length - 1];
                sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
            }
            SpriteAnimation entry = new SpriteAnimation(sprites, new int[0], fps, true);
            entry.saveSprites(pathS, nameS);
            fightAnims.Add(entry);

            if (hasBack)
            {
                pathS = new string[spriteCount];
                nameS = new string[spriteCount];
                for (int j = 0; j < spriteCount; j++)
                {
                    int sheetNum;
                    s     = input.ReadLine();
                    split = s.Split('-');
                    int.TryParse(split[0], out sheetNum);
                    pathS[j]   = sheetP[sheetNum];
                    nameS[j]   = split[split.Length - 1];
                    sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
                }
                entry = new SpriteAnimation(sprites, new int[0], fps, true);
                entry.saveSprites(pathS, nameS);
                fightAnimsB.Add(entry);
            }

            input.ReadLine();
        }

        // Read in icons
        input.ReadLine();
        Sprite[] icons = new Sprite[4];
        string[] pathF = new string[3];
        string[] nameF = new string[3];
        string   pathW = "", nameW = "";

        for (int i = 0; i < icons.Length; i++)
        {
            int sheetNum;
            s     = input.ReadLine();
            split = s.Split('-');
            int.TryParse(split[0], out sheetNum);
            if (i < 3)
            {
                pathF[i] = sheetP[sheetNum];
                nameF[i] = split[split.Length - 1];
            }
            else
            {
                pathW = sheetP[sheetNum];
                nameW = split[split.Length - 1];
            }
            icons[i] = getSprite(sheets[sheetNum], split[split.Length - 1]);
        }

        Fighter streetDuck = new Fighter(walkSpd, dashSpd, glideSpd, gravity, maxJumps);

        streetDuck.setAnimations(fightAnims[0], fightAnims[1], fightAnims[2], fightAnims[3], fightAnims[4], fightAnims[5], fightAnims[6], fightAnims[7], fightAnims[8]);
        if (hasBack)
        {
            streetDuck.setBackAnimations(fightAnimsB[0], fightAnimsB[1], fightAnimsB[2], fightAnimsB[3], fightAnimsB[4], fightAnimsB[5], fightAnimsB[6], fightAnimsB[7], fightAnimsB[8]);
        }

        streetDuck.setNormals(fighterSkills[0], fighterSkills[1], fighterSkills[2]);
        streetDuck.setCrouches(fighterSkills[3], fighterSkills[4], fighterSkills[5]);
        streetDuck.setJumps(fighterSkills[6], fighterSkills[7], fighterSkills[8]);
        for (int i = 9; i < fighterSkills.Count; i++)
        {
            streetDuck.addSkill(fighterSkills[i]);
        }

        Ally ducky = new Ally(duck, streetDuck, battlestats);

        for (int j = 0; j < skillList.Count; j++)
        {
            ducky.addSkill(skillList[j]);
        }
        ducky.setAnimations(RPGanims[0], RPGanims[1], RPGanims[2], RPGanims[3], RPGanims[4], RPGanims[5], RPGanims[6]);
        ducky.setIcons(icons[0], icons[1], icons[2], icons[3]);
        ducky.saveIcons(pathF, nameF, pathW, nameW);
        return(ducky);
    }
    // Fills out hash table for items
    private void fillItemList()
    {
        this.itemList = new Hashtable();
        jankFile        itemTxt = new jankFile(Resources.Load <TextAsset>(@"ItemList"));
        List <string>   sheetP  = new List <string>();
        List <Sprite[]> sheets  = new List <Sprite[]>();

        // Determine number of spritesheets
        string s = itemTxt.ReadLine();

        string[] split = s.Split(' ');
        int      paths = 0;

        int.TryParse(split[split.Length - 1], out paths);
        // Read paths for spritesheets
        for (int i = 0; i < paths; i++)
        {
            string   sheetPath = itemTxt.ReadLine();
            Sprite[] sheet     = Resources.LoadAll <Sprite>(@sheetPath);
            sheets.Add(sheet);
            sheetP.Add(sheetPath);
        }
        itemTxt.ReadLine();

        // Count the number of items to read
        s     = itemTxt.ReadLine();
        split = s.Split(' ');
        int itemAmt = 0;

        int.TryParse(split[split.Length - 1], out itemAmt);

        // Read in each item and place in hash
        itemTxt.ReadLine();
        for (int i = 0; i < itemAmt; i++)
        {
            string   name = "", path = "", des = "";
            Sprite   icon;
            itemType main, sub;

            // Name
            s     = itemTxt.ReadLine();
            split = s.Split(' ');
            for (int j = 1; j < split.Length; j++)
            {
                name += split[j];
                if (j != split.Length - 1)
                {
                    name += " ";
                }
            }
            // Description
            s     = itemTxt.ReadLine();
            split = s.Split(' ');
            for (int j = 1; j < split.Length; j++)
            {
                des += split[j];
                if (j != split.Length - 1)
                {
                    des += " ";
                }
            }

            // Path
            s     = itemTxt.ReadLine();
            split = s.Split(' ');
            int pathNum = 0;
            int.TryParse(split[split.Length - 1], out pathNum);
            path = sheetP[pathNum];
            icon = getSprite(sheets[pathNum], name);

            // Price
            s     = itemTxt.ReadLine();
            split = s.Split(' ');
            int price = 0;
            int.TryParse(split[split.Length - 1], out price);

            // Types
            s     = itemTxt.ReadLine();
            split = s.Split(' ');
            main  = (itemType)System.Enum.Parse(typeof(itemType), split[split.Length - 1]);
            s     = itemTxt.ReadLine();
            split = s.Split(' ');
            sub   = (itemType)System.Enum.Parse(typeof(itemType), split[split.Length - 1]);

            // Make item so far
            Item entry = new Item(main, sub, icon, path, name, des, i, price, 1);

            // Read in main type first
            switch (main)
            {
            case itemType.ARMOR:
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                armorType a = (armorType)System.Enum.Parse(typeof(armorType), split[split.Length - 1]);
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                int[] stats = new int[7];
                for (int k = 0; k < stats.Length; k++)
                {
                    int.TryParse(split[k + 1], out stats[k]);
                }
                entry.setArmorType(a);
                entry.setStats(stats);
                break;

            case itemType.WEAPON:
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                weaponType w = (weaponType)System.Enum.Parse(typeof(weaponType), split[split.Length - 1]);
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                stats = new int[7];
                for (int k = 0; k < stats.Length; k++)
                {
                    int.TryParse(split[k + 1], out stats[k]);
                }
                entry.setWeaponType(w);
                entry.setStats(stats);
                entry.setSubType(itemType.ARMOR);
                entry.setArmorType(armorType.WEAPON);
                break;

            case itemType.FIELD:
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                fieldType f = (fieldType)System.Enum.Parse(typeof(fieldType), split[split.Length - 1]);
                entry.setFieldType(f);
                break;

            case itemType.BATTLE:
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                battleType b = (battleType)System.Enum.Parse(typeof(battleType), split[split.Length - 1]);
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                status statusMod = (status)System.Enum.Parse(typeof(status), split[split.Length - 1]);
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                int range = 0;
                int.TryParse(split[split.Length - 1], out range);
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                stat st = (stat)System.Enum.Parse(typeof(stat), split[split.Length - 1]);
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                int scalar = 0;
                int.TryParse(split[split.Length - 1], out scalar);
                s     = itemTxt.ReadLine();
                split = s.Split(' ');
                bool tAlly = true;
                bool.TryParse(split[split.Length - 1], out tAlly);
                entry.setBattleType(b);
                entry.setStatus(statusMod);
                entry.setModifiers(range, st, scalar, tAlly);
                break;

            default:     // Nothing happens if it's a key item
                break;
            }
            this.itemList.Add(i, entry);
            itemTxt.ReadLine();
        }
    }
Beispiel #5
0
    public List <Foe> readFoes(GameProgress.jankFile input)
    {
        // Determine number of unique foes
        string s = input.ReadLine();

        string[] split  = s.Split(' ');
        int      foeAmt = 0;

        int.TryParse(split[split.Length - 1], out foeAmt);

        // Read in each foe in the ecosystem
        Foe[] community = new Foe[foeAmt];
        for (int i = 0; i < foeAmt; i++)
        {
            input.ReadLine();
            input.ReadLine();
            string       foeName   = "";
            string       path      = "";
            int[]        stats     = new int[7];
            List <Skill> skillList = new List <Skill>();

            // Read in name
            s     = input.ReadLine();
            split = s.Split(' ');
            for (int j = 1; j < split.Length; j++)
            {
                foeName += split[j];
                if (j != split.Length - 1)
                {
                    foeName += " ";
                }
            }
            // Read in path
            path = input.ReadLine();
            // Read in stats
            s     = input.ReadLine();
            split = s.Split(' ');
            for (int j = 1; j < split.Length; j++)
            {
                int.TryParse(split[j], out stats[j - 1]);
            }
            // Open up the sprites in the path file
            Sprite[] source = Resources.LoadAll <Sprite>(@path);

            // Read in items
            int itemAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out itemAmt);
            Item[] drops    = new Item[itemAmt];
            int[]  dropRate = new int[itemAmt];

            for (int j = 0; j < itemAmt; j++)
            {
                int itemID, itemCount, itemOdds;
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[0], out itemID);
                int.TryParse(split[1], out itemCount);
                int.TryParse(split[2], out itemOdds);

                Item theDrop = (Item)TitleManager.curFile.getItemList()[itemID];
                drops[j]    = theDrop.copy(itemCount);
                dropRate[j] = itemOdds;
            }

            // Read in skills
            int skillAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out skillAmt);

            int[]    skillOdds = new int[skillAmt];
            AItype[] ai        = new AItype[skillAmt];
            for (int j = 0; j < skillAmt; j++)
            {
                skillType       skill;
                string          atkName, des, skillSFX;
                element         atkEle;
                int             basePower, mpCost, range, effectChance;
                bool            isMagical, animLoop;
                float           start, end, fps;
                SpriteAnimation anim;

                battleType support    = battleType.NULL;
                status     statusMod  = status.NULL;
                int        scalar     = 0;
                stat       statBoost  = stat.NULL;
                bool       selfTarget = false;
                bool       targetAlly = false;

                s       = input.ReadLine();
                split   = s.Split('-');
                atkName = split[1];
                des     = input.ReadLine();

                // Read in odds then ai type
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out skillOdds[j]);
                s     = input.ReadLine();
                split = s.Split(' ');
                ai[j] = decideAI(split[split.Length - 1]);

                s     = input.ReadLine();
                split = s.Split(' ');
                if (split[split.Length - 1].CompareTo("Offensive") == 0)
                {
                    skill = skillType.OFFENSIVE;

                    // Attack element
                    s      = input.ReadLine();
                    split  = s.Split(' ');
                    atkEle = decideEle(split[split.Length - 1]);

                    // base power
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out basePower);

                    // mp cost
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out mpCost);

                    // is magical
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    bool.TryParse(split[split.Length - 1], out isMagical);

                    // effect chance
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out effectChance);
                    if (effectChance > 0)
                    {
                        /*
                         * implement me eventually
                         */
                    }

                    // range
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out range);

                    // positions
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    float.TryParse(split[split.Length - 1], out start);
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    float.TryParse(split[split.Length - 1], out end);

                    // FPS
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    float.TryParse(split[split.Length - 1], out fps);

                    // Sprite animation
                    int spriteAmt;
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    if (split.Length > 2)
                    {
                        int.TryParse(split[split.Length - 2], out spriteAmt);
                        animLoop = true;
                    }
                    else
                    {
                        int.TryParse(split[split.Length - 1], out spriteAmt);
                        animLoop = false;
                    }
                    Sprite[] sprites = new Sprite[spriteAmt];
                    for (int k = 0; k < spriteAmt; k++)
                    {
                        s          = input.ReadLine();
                        sprites[k] = getSprite(source, s);
                    }
                    anim = new SpriteAnimation(sprites, new int[0], fps, animLoop);
                }
                else
                {
                    skill        = skillType.SUPPORT;
                    basePower    = 0;
                    effectChance = 0;
                    isMagical    = true;

                    // Attack element
                    s      = input.ReadLine();
                    split  = s.Split(' ');
                    atkEle = decideEle(split[split.Length - 1]);

                    // mp cost
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out mpCost);

                    // range
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out range);

                    // positions
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    float.TryParse(split[split.Length - 1], out start);
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    float.TryParse(split[split.Length - 1], out end);

                    // status variables
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    support   = decideSupport(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    statusMod = decideStatus(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    statBoost = decideStat(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out scalar);
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    bool.TryParse(split[split.Length - 1], out selfTarget);
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    bool.TryParse(split[split.Length - 1], out targetAlly);

                    // FPS
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    float.TryParse(split[split.Length - 1], out fps);

                    // Sprite animation
                    int spriteAmt;
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    if (split.Length > 2)
                    {
                        int.TryParse(split[split.Length - 2], out spriteAmt);
                        animLoop = true;
                    }
                    else
                    {
                        int.TryParse(split[split.Length - 1], out spriteAmt);
                        animLoop = false;
                    }
                    Sprite[] sprites = new Sprite[spriteAmt];
                    for (int k = 0; k < spriteAmt; k++)
                    {
                        s          = input.ReadLine();
                        sprites[k] = getSprite(source, s);
                    }
                    anim = new SpriteAnimation(sprites, new int[0], fps, animLoop);
                }
                // Get SFX path
                input.ReadLine();
                skillSFX = input.ReadLine();

                Skill move = new Skill(skill, atkName, des, atkEle, mpCost, range, start, end, anim, skillSFX);
                move.setAttack(basePower, isMagical, effectChance);
                if (skill == skillType.SUPPORT)
                {
                    move.setSupport(support, statusMod, statBoost, scalar, selfTarget, targetAlly);
                }
                skillList.Add(move);
            }
            // Hitboxes
            int hitboxAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out hitboxAmt);
            HitBox[] boxes = new HitBox[hitboxAmt];
            for (int j = 0; j < hitboxAmt; j++)
            {
                s     = input.ReadLine();
                split = s.Split(' ');
                float x, y, xs, ys;
                float.TryParse(split[0], out x);
                float.TryParse(split[1], out y);
                float.TryParse(split[2], out xs);
                float.TryParse(split[3], out ys);

                boxes[j] = new HitBox((x / 2) + xs, (y / 2) + ys, (-x / 2) + xs, (-y / 2) + ys);
            }
            // Gravity
            float gravity;
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out gravity);

            // Read in standard animations
            input.ReadLine();
            input.ReadLine();
            string facePath = input.ReadLine();
            Sprite face     = getSprite(Resources.LoadAll <Sprite>(@facePath), input.ReadLine());
            List <SpriteAnimation> anims = new List <SpriteAnimation>();
            for (int j = 0; j < 5; j++)
            {
                input.ReadLine();
                // FPS
                float fps;
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out fps);

                // Sprite animation
                int spriteAmt;
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out spriteAmt);

                Sprite[] sprites = new Sprite[spriteAmt];
                for (int k = 0; k < spriteAmt; k++)
                {
                    s          = input.ReadLine();
                    sprites[k] = getSprite(source, s);
                }
                SpriteAnimation anim = new SpriteAnimation(sprites, new int[0], fps, true);
                anims.Add(anim);
            }

            Foe inhabitant = new Foe(foeName, stats, skillList, skillOdds, ai, drops, dropRate, boxes, gravity);
            inhabitant.setAnimations(face, anims[0], anims[1], anims[2], anims[3], anims[4]);
            community[i] = inhabitant;
        }

        // Create an empty foe set so you don't have to use NULL
        int[] nothing = { 0, 0, 0, 0, 0, 0, 0 };
        Foe   empty   = new Foe("", nothing, new List <Skill>(), new int[0], new AItype[0], new Item[0], new int[0], new HitBox[0], 0);

        // Read in sets of enemies
        input.ReadLine();
        int setAmt;

        s     = input.ReadLine();
        split = s.Split(' ');
        int.TryParse(split[split.Length - 1], out setAmt);
        List <Foe> foeList = new List <Foe>();

        for (int j = 0; j < 1; j++)
        {
            input.ReadLine();
            // Read in rate
            s = input.ReadLine();
            // Read in foes
            int foeCount;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out foeCount);
            for (int k = 0; k < 5; k++)
            {
                if (k < foeCount)
                {
                    int foeNum;
                    s = input.ReadLine();
                    int.TryParse(s, out foeNum);
                    foeList.Add(community[foeNum]);
                }
                else
                {
                    foeList.Add(empty);
                }
            }
        }
        return(foeList);
    }