Ejemplo n.º 1
0
        public static CollisionBox LoadFromStorage(Storage.CollisionBox storageBox, Storage.Character storageCharacter)
        {
            CollisionBox newBox = new CollisionBox();

            int[] boxIds = storageBox.boxIds;
            if (boxIds != null && boxIds.Length > 0)
            {
                // Populate boxes
                newBox.boxesPerFrame = new List <Box>(boxIds.Length);
                newBox.enabledFrames = new List <bool>(boxIds.Length);
                foreach (int boxId in storageBox.boxIds)
                {
                    if (boxId == Box.invalidBoxId)
                    {
                        newBox.enabledFrames.Add(false);
                        newBox.boxesPerFrame.Add(new Box());
                    }
                    else
                    {
                        newBox.enabledFrames.Add(true);
                        newBox.boxesPerFrame.Add(Box.LoadFromStorage(storageCharacter.boxes[boxId]));
                    }
                }
            }

            return(newBox);
        }
Ejemplo n.º 2
0
        public static HitBox LoadFromStorage(Storage.HitBox storageBox, Storage.Character storageCharacter)
        {
            HitBox newBox = new HitBox();

            // Populate boxes
            newBox.boxesPerFrame = new List <Box>(storageBox.boxIds.Length);
            newBox.enabledFrames = new List <bool>(storageBox.boxIds.Length);
            foreach (int boxId in storageBox.boxIds)
            {
                if (boxId == Box.invalidBoxId)
                {
                    newBox.enabledFrames.Add(false);
                    newBox.boxesPerFrame.Add(new Box());
                }
                else
                {
                    newBox.enabledFrames.Add(true);
                    newBox.boxesPerFrame.Add(Box.LoadFromStorage(storageCharacter.boxes[boxId]));
                }
            }

            newBox.param = GenericParameter.LoadFromStorage(storageCharacter.genericParameters[storageBox.paramId]);

            return(newBox);
        }
Ejemplo n.º 3
0
        public static Character LoadFromStorage(Storage.Character storageCharacter)
        {
            // Basic data
            Character character = new Character(storageCharacter.name);

            character.shadowName = storageCharacter.shadowName;
            if (storageCharacter.viewAnchors != null)
            {
                character.viewAnchors = new List <string>(storageCharacter.viewAnchors);
            }
            else
            {
                character.viewAnchors = new List <string>();
            }
            if (storageCharacter.viewModels != null)
            {
                character.viewModels = new List <string>(storageCharacter.viewModels);
            }
            else
            {
                character.viewModels = new List <string>();
            }
            if (storageCharacter.portraits != null)
            {
                character.viewPortraits = new List <string>(storageCharacter.portraits);
            }
            else
            {
                character.viewPortraits = new List <string>();
                for (int i = 0; i < character.viewModels.Count; ++i)
                {
                    character.viewPortraits.Add("");
                }
            }
            // Populate animations
            if (storageCharacter.animations != null)
            {
                character.animations = new List <CharacterAnimation>(storageCharacter.animations.Length);
                foreach (Storage.CharacterAnimation storageAnimation in storageCharacter.animations)
                {
                    character.animations.Add(CharacterAnimation.LoadFromStorage(storageAnimation, storageCharacter));
                }
            }
            else
            {
                character.animations = new List <CharacterAnimation>();
            }

            return(character);
        }
        public static ConditionalEvent LoadFromStorage(Storage.GenericEvent storageEvent, Storage.Character storageCharacter)
        {
            ConditionalEvent newEvent = new ConditionalEvent();

            // Populate subjects
            if (storageEvent.subjectIds != null)
            {
                newEvent.subjects = new List <GenericParameter>(storageEvent.subjectIds.Length);
                foreach (int subjectId in storageEvent.subjectIds)
                {
                    newEvent.subjects.Add(GenericParameter.LoadFromStorage(storageCharacter.genericParameters[subjectId]));
                }
            }
            else
            {
                newEvent.subjects = new List <GenericParameter>();
            }

            // Populate conditions
            if (storageEvent.conditionIds != null)
            {
                newEvent.conditions = new List <GenericParameter>(storageEvent.conditionIds.Length);
                foreach (int conditionId in storageEvent.conditionIds)
                {
                    newEvent.conditions.Add(GenericParameter.LoadFromStorage(storageCharacter.genericParameters[conditionId]));
                }
            }
            else
            {
                newEvent.conditions = new List <GenericParameter>();
            }

            // Populate events
            if (storageEvent.eventIds != null)
            {
                newEvent.events = new List <GenericParameter>(storageEvent.eventIds.Length);
                foreach (int eventId in storageEvent.eventIds)
                {
                    newEvent.events.Add(GenericParameter.LoadFromStorage(storageCharacter.genericParameters[eventId]));
                }
            }
            else
            {
                newEvent.events = new List <GenericParameter>();
            }

            return(newEvent);
        }
        public static CharacterAnimation LoadFromStorage(Storage.CharacterAnimation storageAnimation, Storage.Character storageCharacter)
        {
            // Build collisionboxes, hitboxes and events from storageCharacter
            // No worries with performance here, get a copy to everything
            CharacterAnimation anim = new CharacterAnimation(storageAnimation.name, storageAnimation.numFrames);

            // Populate collision boxes
            if (storageAnimation.collisionBoxes != null)
            {
                anim.collisionBoxes = new List <CollisionBox>(storageAnimation.collisionBoxes.Length);
                foreach (Storage.CollisionBox box in storageAnimation.collisionBoxes)
                {
                    anim.collisionBoxes.Add(CollisionBox.LoadFromStorage(box, storageCharacter));
                }
            }
            else
            {
                anim.collisionBoxes = new List <CollisionBox>();
            }

            // Populate hit boxes
            if (storageAnimation.hitBoxes != null)
            {
                anim.hitBoxes = new List <HitBox>(storageAnimation.hitBoxes.Length);
                foreach (Storage.HitBox box in storageAnimation.hitBoxes)
                {
                    anim.hitBoxes.Add(HitBox.LoadFromStorage(box, storageCharacter));
                }
            }
            else
            {
                anim.hitBoxes = new List <HitBox>();
            }

            // Populate events
            if (storageAnimation.events != null)
            {
                anim.events = new List <ConditionalEvent>(storageAnimation.events.Length);
                foreach (Storage.GenericEvent e in storageAnimation.events)
                {
                    anim.events.Add(ConditionalEvent.LoadFromStorage(e, storageCharacter));
                }
            }
            else
            {
                anim.events = new List <ConditionalEvent>();
            }

            return(anim);
        }
Ejemplo n.º 6
0
        public Storage.Character SaveToStorage()
        {
            // Basic data
            Storage.Character storageCharacter = new Storage.Character(name);
            storageCharacter.shadowName = shadowName;
            if (viewAnchors != null)
            {
                storageCharacter.viewAnchors = viewAnchors.ToArray();
            }
            if (viewModels != null)
            {
                storageCharacter.viewModels = viewModels.ToArray();
            }
            if (viewPortraits != null)
            {
                storageCharacter.portraits = viewPortraits.ToArray();
            }

            // Generate boxes, generic parameters, and imediately construct the rest of the data
            // Tricky step
            List <Box> boxes = new List <Box>();
            List <GenericParameter> genericParams = new List <GenericParameter>();

            if (animations != null)
            {
                foreach (CharacterAnimation anim in animations)
                {
                    anim.BuildStorage(boxes, genericParams);
                }
            }

            // Populate boxes and generic params
            if (boxes != null)
            {
                storageCharacter.boxes = new Storage.Box[boxes.Count];
                for (int i = 0; i < boxes.Count; ++i)
                {
                    storageCharacter.boxes[i] = boxes[i].SaveToStorage();
                }
            }
            if (genericParams != null)
            {
                storageCharacter.genericParameters = new Storage.GenericParameter[genericParams.Count];
                for (int i = 0; i < genericParams.Count; ++i)
                {
                    storageCharacter.genericParameters[i] = genericParams[i].SaveToStorage();
                }
            }

            // Populate animations
            if (animations != null)
            {
                storageCharacter.animations = new Storage.CharacterAnimation[animations.Count];
                for (int i = 0; i < animations.Count; ++i)
                {
                    storageCharacter.animations[i] = animations[i].SaveToStorage();
                }
            }

            return(storageCharacter);
        }