예제 #1
0
    //Function called externally from SaveLoadManager.cs to get object references based on their IDTag component
    public GameObject GetPrefabFromID(IDTag tagToGet_)
    {
        //Switch statement for the type of objet to get based on the ID enum
        switch (tagToGet_.objType)
        {
        case IDTag.ObjectType.Perk:
            return(this.perkList.GetPerkByIDNum(tagToGet_.numberID));

        case IDTag.ObjectType.ItemWeapon:
            return(this.weaponList.GetWeaponByIDNum(tagToGet_.numberID));

        case IDTag.ObjectType.ItemArmor:
            return(this.armorList.GetArmorByIDNum(tagToGet_.numberID));

        case IDTag.ObjectType.ItemQuest:
            return(this.questItemList.GetQuestItemByIDNum(tagToGet_.numberID));

        case IDTag.ObjectType.ItemConsumable:
            return(this.foodList.GetFoodByIDNum(tagToGet_.numberID));

        case IDTag.ObjectType.ItemMisc:
            return(this.itemList.GetItemByIDNum(tagToGet_.numberID));

        case IDTag.ObjectType.Location:
            return(this.locationList.GetLocationByIDNum(tagToGet_.numberID));

        case IDTag.ObjectType.Action:
            return(this.actionList.GetActionByIDNum(tagToGet_.numberID));

        default:
            //If for some reason the enum has no match, we return null and let the SaveLoadManager deal with it
            return(null);
        }
    }
예제 #2
0
 //Constructor for this class
 public InventoryItemStackData(int inventoryIndex_, IDTag objIDTag_, uint stackSize_)
 {
     this.itemStackIndex       = inventoryIndex_;
     this.objType              = objIDTag_.objType;
     this.iDNumber             = objIDTag_.numberID;
     this.numberOfItemsInStack = stackSize_ - 1; //Removing one because the first one is already saved in the index position
 }
예제 #3
0
    //Constructor function for this class
    public PartySaveData(PartyGroup groupToSave_)
    {
        this.combatDist = groupToSave_.combatDistance;

        TileColRow tileLocation = TileMapManager.globalReference.GetTileCoords(groupToSave_.GetComponent <WASDOverworldMovement>().currentTile);

        this.tileCol = tileLocation.col;
        this.tileRow = tileLocation.row;

        //Looping through all of the characters in the given party and getting their save data
        this.partyCharacters = new List <global::CharacterSaveData>();
        for (int c = 0; c < groupToSave_.charactersInParty.Count; ++c)
        {
            //If the current character isn't null, we save it's data
            if (groupToSave_.charactersInParty[c] != null)
            {
                CharacterSaveData charData = new CharacterSaveData(groupToSave_.charactersInParty[c]);
                this.partyCharacters.Add(charData);
            }
            //If the current character slot is null, we add the empty slot
            else
            {
                this.partyCharacters.Add(null);
            }
        }

        //Looping through all of the party inventory items to save their object references
        this.inventorySlots = new List <string>();
        this.stackedItems   = new List <string>();
        for (int i = 0; i < groupToSave_.inventory.itemSlots.Count; ++i)
        {
            //Making sure the current inventory object isn't null
            if (groupToSave_.inventory.itemSlots[i] != null)
            {
                //Reference to the item's IDTag component
                IDTag itemTag = groupToSave_.inventory.itemSlots[i].GetComponent <IDTag>();

                //Saving the IDTag info
                this.inventorySlots.Add(JsonUtility.ToJson(new PrefabIDTagData(itemTag)));

                //If the current item is a stack
                if (groupToSave_.inventory.itemSlots[i].currentStackSize > 1)
                {
                    //Creating a new InventoryItemStackData class to store the item stack
                    InventoryItemStackData stack = new InventoryItemStackData(i, itemTag, groupToSave_.inventory.itemSlots[i].currentStackSize);
                    //Adding a serialized version of the stack data to our list of stacked items
                    this.stackedItems.Add(JsonUtility.ToJson(stack));
                }
            }
            //If the current item is null, we set a null slot to keep the empty space
            else
            {
                this.inventorySlots.Add("");
            }
        }
    }
예제 #4
0
파일: Program.cs 프로젝트: ekicyou/mmflex
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("第一引数にvmdファイルへのファイルパス,第二引数に出力先のファイルパスを指定してください。");
                return;
            }
            String filePath = args[0];
            String fileDest = args[1];

            if (!File.Exists(filePath))
            {
                Console.WriteLine("指定されたvmdファイルは存在しません。");
                return;
            }
            using (FileStream source = File.OpenRead(filePath))
            {
                MotionData data = MotionData.getMotion(source);
                //ヘッダー情報の生製
                Console.WriteLine("ヘッダー情報の生成");
                VocaloidMotionEvolved vme = new VocaloidMotionEvolved();
                vme.header             = new Header();
                vme.header.versionInfo = "Vocaloid Motion Evolved";
                vme.header.modelInfo.Add(data.header.ModelName);
                //ボーンフレームのインデックス処理
                Console.WriteLine("VME用ボーンインデックスの生成");
                HashSet <String> boneNames = new HashSet <string>();
                foreach (var frameData in data.boneFrameList.boneFrameDatas)
                {
                    boneNames.Add(frameData.BoneName);
                }
                Dictionary <string, ulong> boneIdtable = new Dictionary <string, ulong>();
                ulong id = 0;
                foreach (var boneName in boneNames)
                {
                    boneIdtable.Add(boneName, id);
                    IDTag tag = new IDTag();
                    tag.id   = id;
                    tag.name = boneName;
                    vme.boneIDTable.Add(tag);
                    id++;
                }
                //ボーンフレームの書き出し処理
                Console.WriteLine("ボーンフレーム情報の生成");
                foreach (var boneName in boneNames)
                {
                    Console.WriteLine("ボーンフレームテーブル生成:{0}", boneName);
                    BoneFrameTable frameTable = new BoneFrameTable();
                    frameTable.id = boneIdtable[boneName];
                    foreach (var frameData in data.boneFrameList.boneFrameDatas)
                    {
                        if (frameData.BoneName.Equals(boneName))
                        {
                            BoneFrame frame = new BoneFrame();
                            frame.frameNumber        = frameData.FrameNumber;
                            frame.position           = frameData.BonePosition.ToData();
                            frame.rotation           = frameData.BoneRotatingQuaternion.ToData();
                            frame.interpolParameters = new BezInterpolParams();
                            BezInterpolParams interpol = frame.interpolParameters;
                            interpol.X1 = new bvec2()
                            {
                                x = frameData.Interpolation[0][0][0],
                                y = frameData.Interpolation[0][1][0]
                            };
                            interpol.X2 = new bvec2()
                            {
                                x = frameData.Interpolation[0][2][0],
                                y = frameData.Interpolation[0][3][0]
                            };
                            interpol.Y1 = new bvec2()
                            {
                                x = frameData.Interpolation[0][0][1],
                                y = frameData.Interpolation[0][1][1]
                            };
                            interpol.Y2 = new bvec2()
                            {
                                x = frameData.Interpolation[0][2][1],
                                y = frameData.Interpolation[0][3][1]
                            };
                            interpol.Z1 = new bvec2()
                            {
                                x = frameData.Interpolation[0][0][2],
                                y = frameData.Interpolation[0][1][2]
                            };
                            interpol.Z2 = new bvec2()
                            {
                                x = frameData.Interpolation[0][2][2],
                                y = frameData.Interpolation[0][3][2]
                            };
                            interpol.R1 = new bvec2()
                            {
                                x = frameData.Interpolation[0][0][3],
                                y = frameData.Interpolation[0][1][3]
                            };
                            interpol.R2 = new bvec2()
                            {
                                x = frameData.Interpolation[0][2][3],
                                y = frameData.Interpolation[0][3][3]
                            };
                            frameTable.frames.Add(frame);
                        }
                    }
                    frameTable.frames.Sort(new FrameComparator());
                    vme.boneFrameTables.Add(frameTable);
                }
                Console.WriteLine("ボーンフレームリスト生成完了");
                Console.WriteLine("モーフ用フレームリスト生成");
                HashSet <String> faceNames = new HashSet <string>();
                foreach (var frameData in data.morphFrameList.morphFrameDatas)
                {
                    faceNames.Add(frameData.Name);
                }
                Dictionary <string, ulong> faceIdtable = new Dictionary <string, ulong>();
                id = 0;
                foreach (var faceName in faceNames)
                {
                    faceIdtable.Add(faceName, id);
                    IDTag tag = new IDTag();
                    tag.id   = id;
                    tag.name = faceName;
                    vme.morphIDTable.Add(tag);
                    id++;
                }
                foreach (var morphName in faceNames)
                {
                    Console.WriteLine("モーフフレームテーブル生成:{0}", morphName);
                    MorphFrameTable frameTable = new MorphFrameTable();
                    frameTable.id = faceIdtable[morphName];
                    foreach (var frameData in data.morphFrameList.morphFrameDatas)
                    {
                        if (frameData.Name.Equals(morphName))
                        {
                            MorphFrame frame = new MorphFrame();
                            frame.frameNumber = frameData.FrameNumber;
                            frame.value       = frameData.MorphValue;
                            frameTable.frames.Add(frame);
                        }
                    }
                    frameTable.frames.Sort(new FrameComparator());
                    vme.morphFrameTables.Add(frameTable);
                }
                Console.WriteLine("モーフフレーム生成完了");
                if (data.CameraFrames.CameraFrameCount > 0)
                {
                    Console.WriteLine("カメラ用フレームリスト生成");
                    IDTag camTag = new IDTag();
                    camTag.id   = 0;
                    camTag.name = "Default";
                    vme.cameraIDTable.Add(camTag);
                    CameraFrameTable table = new CameraFrameTable();
                    table.id = camTag.id;
                    foreach (var cameraFrame in data.CameraFrames.CameraFrames)
                    {
                        CameraFrame frame = new CameraFrame();
                        frame.frameNumber        = cameraFrame.FrameNumber;
                        frame.position           = cameraFrame.CameraPosition.ToData();
                        frame.rotation           = cameraFrame.CameraRotation.ToData();
                        frame.viewAngle          = cameraFrame.ViewAngle;
                        frame.perspective        = cameraFrame.Perspective;
                        frame.distance           = cameraFrame.Distance;
                        frame.interpolParameters = new BezInterpolParams();
                        BezInterpolParams interpol = frame.interpolParameters;
                        interpol.X1 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[0][0],
                            y = cameraFrame.Interpolation[1][0]
                        };
                        interpol.X2 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[2][0],
                            y = cameraFrame.Interpolation[3][0]
                        };
                        interpol.Y1 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[0][1],
                            y = cameraFrame.Interpolation[1][1]
                        };
                        interpol.Y2 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[2][1],
                            y = cameraFrame.Interpolation[3][1]
                        };
                        interpol.Z1 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[0][2],
                            y = cameraFrame.Interpolation[1][2]
                        };
                        interpol.Z2 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[2][2],
                            y = cameraFrame.Interpolation[3][2]
                        };
                        interpol.R1 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[0][3],
                            y = cameraFrame.Interpolation[1][3]
                        };
                        interpol.R2 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[2][3],
                            y = cameraFrame.Interpolation[3][3]
                        };
                        CameraExtraBezParams camInterpol = frame.cameraInterpolParams = new CameraExtraBezParams();
                        camInterpol.L1 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[0][4],
                            y = cameraFrame.Interpolation[1][4]
                        };
                        camInterpol.L2 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[2][4],
                            y = cameraFrame.Interpolation[3][4]
                        };
                        camInterpol.V1 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[0][5],
                            y = cameraFrame.Interpolation[1][5]
                        };
                        camInterpol.V2 = new bvec2()
                        {
                            x = cameraFrame.Interpolation[2][5],
                            y = cameraFrame.Interpolation[3][5]
                        };

                        table.frames.Add(frame);
                    }
                }
                if (data.LightFrames.LightCount > 0)
                {
                    Console.WriteLine("ライト用フレームリストの生成");
                    IDTag lightTag = new IDTag();
                    lightTag.id   = 0;
                    lightTag.name = "Default";
                    vme.lightIDTable.Add(lightTag);
                    LightFrameTable table = new LightFrameTable();
                    table.id = lightTag.id;
                    foreach (var lightFrame in data.LightFrames.LightFrames)
                    {
                        LightFrame frame = new LightFrame();
                        frame.frameNumber = lightFrame.FrameNumber;
                        frame.position    = lightFrame.LightPosition.ToData();
                        frame.color       = lightFrame.LightColor.ToData();
                        table.frames.Add(frame);
                    }
                }
                if (File.Exists(fileDest))
                {
                    File.Delete(fileDest);
                }
                using (FileStream fs = File.OpenWrite(fileDest))
                {
                    Serializer.Serialize(fs, vme);
                }
            }
        }
예제 #5
0
 //Constructor for this class
 public PrefabIDTagData(IDTag objIDTag_)
 {
     this.objType  = objIDTag_.objType;
     this.iDNumber = objIDTag_.numberID;
 }
예제 #6
0
    //Constructor for this class
    public CharacterSaveData(Character characterToSave_)
    {
        //Setting variables from Character.cs
        this.firstName = characterToSave_.firstName;
        this.lastName  = characterToSave_.lastName;
        this.sex       = characterToSave_.sex;

        //Setting variables from RaceTypes.cs
        this.race        = characterToSave_.charRaceTypes.race;
        this.subtypeList = characterToSave_.charRaceTypes.subtypeList;

        //Setting variables from Skills.cs
        this.unarmed       = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Unarmed);
        this.daggers       = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Daggers);
        this.swords        = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Swords);
        this.mauls         = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Mauls);
        this.poles         = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Poles);
        this.bows          = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Bows);
        this.shields       = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Shields);
        this.arcaneMagic   = characterToSave_.charSkills.GetSkillLevelValue(SkillList.ArcaneMagic);
        this.holyMagic     = characterToSave_.charSkills.GetSkillLevelValue(SkillList.HolyMagic);
        this.darkMagic     = characterToSave_.charSkills.GetSkillLevelValue(SkillList.DarkMagic);
        this.fireMagic     = characterToSave_.charSkills.GetSkillLevelValue(SkillList.FireMagic);
        this.waterMagic    = characterToSave_.charSkills.GetSkillLevelValue(SkillList.WaterMagic);
        this.windMagic     = characterToSave_.charSkills.GetSkillLevelValue(SkillList.WindMagic);
        this.electricMagic = characterToSave_.charSkills.GetSkillLevelValue(SkillList.ElectricMagic);
        this.stoneMagic    = characterToSave_.charSkills.GetSkillLevelValue(SkillList.StoneMagic);
        this.survivalist   = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Survivalist);
        this.social        = characterToSave_.charSkills.GetSkillLevelValue(SkillList.Social);

        //Setting variables from PhysicalState.cs
        this.maxHP               = characterToSave_.charPhysState.maxHealth;
        this.currentHP           = characterToSave_.charPhysState.currentHealth;
        this.maxFood             = characterToSave_.charPhysState.maxFood;
        this.currentFood         = characterToSave_.charPhysState.currentFood;
        this.maxWater            = characterToSave_.charPhysState.maxWater;
        this.currentWater        = characterToSave_.charPhysState.currentWater;
        this.maxSleep            = characterToSave_.charPhysState.maxSleep;
        this.currentSleep        = characterToSave_.charPhysState.currentSleep;
        this.requireFood         = characterToSave_.charPhysState.requiresFood;
        this.requireWater        = characterToSave_.charPhysState.requiresWater;
        this.requireSleep        = characterToSave_.charPhysState.requiresSleep;
        this.startingHealthCurve = characterToSave_.charPhysState.startingHealthCurve;
        this.healthCurveLevels   = characterToSave_.charPhysState.healthCurveLevels;

        this.highestHealthPercent = characterToSave_.charPhysState.highestHealthPercent;
        this.highestFoodPercent   = characterToSave_.charPhysState.highestFoodPercent;
        this.highestWaterPercent  = characterToSave_.charPhysState.highestWaterPercent;
        this.highestSleepPercent  = characterToSave_.charPhysState.highestSleepPercent;

        this.trackingHealthPercents = characterToSave_.charPhysState.trackingHealthPercents;
        this.trackingFoodPercents   = characterToSave_.charPhysState.trackingFoodPercents;
        this.trackingWaterPercents  = characterToSave_.charPhysState.trackingWaterPercents;
        this.trackingSleepPercents  = characterToSave_.charPhysState.trackingSleepPercents;

        //Setting variables from CombatStats.cs
        this.currentInitiativeSpeed = characterToSave_.charCombatStats.currentInitiativeSpeed;
        this.startingCol            = characterToSave_.charCombatStats.startingPositionCol;
        this.startingRow            = characterToSave_.charCombatStats.startingPositionRow;
        this.accuracy = characterToSave_.charCombatStats.accuracy;
        this.evasion  = characterToSave_.charCombatStats.evasion;

        this.combatEffects = new List <string>();
        for (int ce = 0; ce < characterToSave_.charCombatStats.combatEffects.Count; ++ce)
        {
            this.combatEffects.Add(JsonUtility.ToJson(characterToSave_.charCombatStats.combatEffects[ce]));
        }

        //Setting variables from ActionList.cs
        this.defaultActions = new List <string>();
        for (int da = 0; da < characterToSave_.charActionList.defaultActions.Count; ++da)
        {
            PrefabIDTagData actionIDData = new PrefabIDTagData(characterToSave_.charActionList.defaultActions[da].GetComponent <IDTag>());
            this.defaultActions.Add(JsonUtility.ToJson(actionIDData));
        }

        this.rechargingSpells = new List <string>();
        for (int rs = 0; rs < characterToSave_.charActionList.rechargingSpells.Count; ++rs)
        {
            this.rechargingSpells.Add(JsonUtility.ToJson(characterToSave_.charActionList.rechargingSpells[rs]));
        }

        //Setting variables from CharacterSprites.cs
        this.ourSprites = characterToSave_.charSprites.allSprites;

        //Setting all of the equipped object references
        if (characterToSave_.charInventory.helm != null)
        {
            this.helmObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.helm.GetComponent <IDTag>()));
        }
        if (characterToSave_.charInventory.chestPiece != null)
        {
            this.chestObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.chestPiece.GetComponent <IDTag>()));
        }
        if (characterToSave_.charInventory.leggings != null)
        {
            this.legObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.leggings.GetComponent <IDTag>()));
        }
        if (characterToSave_.charInventory.gloves != null)
        {
            this.gloveObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.gloves.GetComponent <IDTag>()));
        }
        if (characterToSave_.charInventory.shoes != null)
        {
            this.shoeObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.shoes.GetComponent <IDTag>()));
        }
        if (characterToSave_.charInventory.cloak != null)
        {
            this.cloakObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.cloak.GetComponent <IDTag>()));
        }
        if (characterToSave_.charInventory.necklace != null)
        {
            this.necklaceObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.necklace.GetComponent <IDTag>()));
        }
        if (characterToSave_.charInventory.ring != null)
        {
            this.ringObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.ring.GetComponent <IDTag>()));
        }

        if (characterToSave_.charInventory.leftHand != null)
        {
            this.leftHandObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.leftHand.GetComponent <IDTag>()));
        }
        if (characterToSave_.charInventory.rightHand != null)
        {
            this.rightHandObj = JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charInventory.rightHand.GetComponent <IDTag>()));
        }

        //Looping through all of the character inventory items to save their object references
        this.inventorySlots = new List <string>();
        this.stackedItems   = new List <string>();
        for (int i = 0; i < characterToSave_.charInventory.itemSlots.Count; ++i)
        {
            //Making sure the current inventory object isn't null
            if (characterToSave_.charInventory.itemSlots[i] != null)
            {
                //Reference to the item's IDTag component
                IDTag itemTag = characterToSave_.charInventory.itemSlots[i].GetComponent <IDTag>();

                //Saving the IDTag info
                this.inventorySlots.Add(JsonUtility.ToJson(new PrefabIDTagData(itemTag)));

                //If the current item is a stack
                if (characterToSave_.charInventory.itemSlots[i].currentStackSize > 1)
                {
                    //Creating a new InventoryItemStackData class to store the item stack
                    InventoryItemStackData stack = new InventoryItemStackData(i, itemTag, characterToSave_.charInventory.itemSlots[i].currentStackSize);
                    //Adding a serialized version of the stack data to our list of stacked items
                    this.stackedItems.Add(JsonUtility.ToJson(stack));
                }
            }
            //If the current item is null, we set a null slot to keep the empty space
            else
            {
                this.inventorySlots.Add("");
            }
        }

        //Looping through all of the character perks to save their object references
        this.perkNames = new List <string>();
        for (int p = 0; p < characterToSave_.charPerks.allPerks.Count; ++p)
        {
            //Making sure the current perk isn't null
            if (characterToSave_.charPerks.allPerks[p] != null)
            {
                //Saving this perk's ID tag info
                this.perkNames.Add(JsonUtility.ToJson(new PrefabIDTagData(characterToSave_.charPerks.allPerks[p].GetComponent <IDTag>())));
            }
        }
    }