예제 #1
0
        public EffectBase DeserializeEffect(byte[] buffer, ref int index)
        {
            if (buffer.Length < index)
            {
                throw new System.Exception("buffer too small to contain an Effect");
            }
            byte       b = buffer[index];
            EffectBase effectBase;

            switch (b)
            {
            case 1:
                effectBase = new EffectBase();
                break;

            case 2:
                effectBase = new EffectCreature();
                break;

            case 3:
                effectBase = new EffectDate();
                break;

            case 4:
                effectBase = new EffectDice();
                break;

            case 5:
                effectBase = new EffectDuration();
                break;

            case 6:
                effectBase = new EffectInteger();
                break;

            case 7:
                effectBase = new EffectLadder();
                break;

            case 8:
                effectBase = new EffectMinMax();
                break;

            case 9:
                effectBase = new EffectMount();
                break;

            case 10:
                effectBase = new EffectString();
                break;

            default:
                throw new System.Exception(string.Format("Incorrect identifier : {0}", b));
            }
            index++;
            effectBase.DeSerialize(buffer, ref index);
            return(effectBase);
        }
예제 #2
0
        public EffectBase ConvertExportedEffect(EffectInstance effect)
        {
            EffectBase result;

            if (effect is EffectInstanceLadder)
            {
                result = new EffectLadder(effect as EffectInstanceLadder);
            }
            else
            {
                if (effect is EffectInstanceCreature)
                {
                    result = new EffectCreature(effect as EffectInstanceCreature);
                }
                else
                {
                    if (effect is EffectInstanceDate)
                    {
                        result = new EffectDate(effect as EffectInstanceDate);
                    }
                    else
                    {
                        if (effect is EffectInstanceDice)
                        {
                            result = new EffectDice(effect as EffectInstanceDice);
                        }
                        else
                        {
                            if (effect is EffectInstanceDuration)
                            {
                                result = new EffectDuration(effect as EffectInstanceDuration);
                            }
                            else
                            {
                                if (effect is EffectInstanceMinMax)
                                {
                                    result = new EffectMinMax(effect as EffectInstanceMinMax);
                                }
                                else
                                {
                                    if (effect is EffectInstanceMount)
                                    {
                                        result = new EffectMount(effect as EffectInstanceMount);
                                    }
                                    else
                                    {
                                        if (effect is EffectInstanceString)
                                        {
                                            result = new EffectString(effect as EffectInstanceString);
                                        }
                                        else
                                        {
                                            if (effect is EffectInstanceInteger)
                                            {
                                                result = new EffectInteger(effect as EffectInstanceInteger);
                                            }
                                            else
                                            {
                                                result = new EffectBase(effect);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }