Inheritance: InputItem
Exemplo n.º 1
0
        /**creates a timeline object from a string serialization and assumes the following
         * formats (specified by the respective Serialize methods)
         *
         * WaitFrameItem: ITEMTYPE#PLAYSOUND#NUMFRAMES
         * InputItem:     ITEMTYPE#PLAYSOUND#NUMIMPUTS#INPUT1#INPUT2...
         */
        public static TimeLineItem Deserialize(String obj)
        {
            String[] tokens = obj.Split('#');

            if (tokens[0].Equals(WaitFrameItem.itemType))
            {
                WaitFrameItem item = new WaitFrameItem(int.Parse(tokens[2]));
                item.PlaySound = Boolean.Parse(tokens[1]);
                return(item);
            }
            else if (tokens[0].Equals(PressItem.itemType))
            {
                int     numInputs = int.Parse(tokens[2]);
                Input[] inputs    = new Input[numInputs];
                for (int i = 0; i < numInputs; i++)
                {
                    inputs[i] = ParseInput(tokens[3 + i]);
                }
                PressItem item = new PressItem(inputs);
                item.PlaySound = Boolean.Parse(tokens[1]);
                return(item);
            }
            else if (tokens[0].Equals(HoldItem.itemType))
            {
                int     numInputs = int.Parse(tokens[2]);
                Input[] inputs    = new Input[numInputs];
                for (int i = 0; i < numInputs; i++)
                {
                    inputs[i] = ParseInput(tokens[3 + i]);
                }
                HoldItem item = new HoldItem(inputs);
                item.PlaySound = Boolean.Parse(tokens[1]);
                return(item);
            }
            else if (tokens[0].Equals(ReleaseItem.itemType))
            {
                int     numInputs = int.Parse(tokens[2]);
                Input[] inputs    = new Input[numInputs];
                for (int i = 0; i < numInputs; i++)
                {
                    inputs[i] = ParseInput(tokens[3 + i]);
                }
                ReleaseItem item = new ReleaseItem(inputs);
                item.PlaySound = Boolean.Parse(tokens[1]);
                return(item);
            }

            throw new FormatException("Failed to deserialize TimelineItem, wrong string format: " + obj);
        }
Exemplo n.º 2
0
        /**creates a timeline object from a string serialization and assumes the following
         * formats (specified by the respective Serialize methods)
         *
         * WaitFrameItem: ITEMTYPE#PLAYSOUND#NUMFRAMES
         * InputItem:     ITEMTYPE#PLAYSOUND#NUMIMPUTS#INPUT1#INPUT2...
         */
        public static TimeLineItem Deserialize(String obj)
        {
            String[] tokens = obj.Split('#');

            if (tokens[0].Equals(WaitFrameItem.itemType))
            {
                WaitFrameItem item = new WaitFrameItem(int.Parse(tokens[2]));
                item.PlaySound = Boolean.Parse(tokens[1]);
                return item;
            }
            else if (tokens[0].Equals(PressItem.itemType))
            {
                int numInputs = int.Parse(tokens[2]);
                Input[] inputs = new Input[numInputs];
                for (int i = 0; i < numInputs; i++)
                {
                    inputs[i] = ParseInput(tokens[3 + i]);
                }
                PressItem item= new PressItem(inputs);
                item.PlaySound = Boolean.Parse(tokens[1]);
                return item;
            }
            else if (tokens[0].Equals(HoldItem.itemType))
            {
                int numInputs = int.Parse(tokens[2]);
                Input[] inputs = new Input[numInputs];
                for (int i = 0; i < numInputs; i++)
                {
                    inputs[i] = ParseInput(tokens[3 + i]);
                }
                HoldItem item = new HoldItem(inputs);
                item.PlaySound = Boolean.Parse(tokens[1]);
                return item;
            }
            else if (tokens[0].Equals(ReleaseItem.itemType))
            {
                int numInputs = int.Parse(tokens[2]);
                Input[] inputs = new Input[numInputs];
                for (int i = 0; i < numInputs; i++)
                {
                    inputs[i] = ParseInput(tokens[3 + i]);
                }
                ReleaseItem item = new ReleaseItem(inputs);
                item.PlaySound = Boolean.Parse(tokens[1]);
                return item;
            }

            throw new FormatException("Failed to deserialize TimelineItem, wrong string format: " + obj);
        }