Example #1
0
        public static HUDObject LoadFromStorage(Storage.HUDObject storageHudObject, Storage.HUD storageHud)
        {
            // Build collisionboxes, hitboxes and events from storageCharacter
            // No worries with performance here, get a copy to everything
            HUDObject hudObj = new HUDObject();

            hudObj.name     = storageHudObject.name;
            hudObj.teamId   = storageHudObject.teamId;
            hudObj.playerId = storageHudObject.playerId;
            hudObj.attackAndGrabDelegation = storageHudObject.attackAndGrabDelegation;

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

            return(hudObj);
        }
        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);
        }
        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 ConditionalEvent Clone()
        {
            ConditionalEvent clone = new ConditionalEvent();

            clone.conditions = new List <GenericParameter>(conditions.Count);
            clone.events     = new List <GenericParameter>(events.Count);
            foreach (GenericParameter param in conditions)
            {
                clone.conditions.Add(param.Clone());
            }
            foreach (GenericParameter param in events)
            {
                clone.events.Add(param.Clone());
            }
            return(clone);
        }
        public static ConditionalEvent LoadFromStorage(Storage.GenericEvent storageEvent, Storage.HUD storageHud)
        {
            ConditionalEvent newEvent = new ConditionalEvent();

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

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

            return(newEvent);
        }