Esempio n. 1
0
        /// <summary>
        /// </summary>
        /// Methods to do:
        /// Read Item
        /// Write Item
        /// Return Dynel Item (placing on the ground)
        /// <returns>
        /// </returns>
        public NanoFormula ShallowCopy()
        {
            NanoFormula nanoFormula = new NanoFormula();
            nanoFormula.ID = this.ID;

            foreach (KeyValuePair<int, int> nanoFormulaAttribute in this.Attack)
            {
                nanoFormula.Attack.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value);
            }

            foreach (KeyValuePair<int, int> nanoFormulaAttribute in this.Defend)
            {
                nanoFormula.Defend.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value);
            }

            foreach (KeyValuePair<int, int> nanoFormulaAttribute in this.Stats)
            {
                nanoFormula.Stats.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value);
            }

            foreach (Events aoEvents in this.Events)
            {
                Events newEvent = new Events();
                foreach (Functions aoFunctions in aoEvents.Functions)
                {
                    Functions newAOFunctions = new Functions();
                    foreach (Requirements aor in aoFunctions.Requirements)
                    {
                        Requirements newRequirement = new Requirements();
                        newRequirement.ChildOperator = aor.ChildOperator;
                        newRequirement.Operator = aor.Operator;
                        newRequirement.Statnumber = aor.Statnumber;
                        newRequirement.Target = aor.Target;
                        newRequirement.Value = aor.Value;
                        newAOFunctions.Requirements.Add(newRequirement);
                    }

                    foreach (object argument in aoFunctions.Arguments.Values)
                    {
                        if (argument.GetType() == typeof(string))
                        {
                            string z = (string)argument;
                            newAOFunctions.Arguments.Values.Add(z);
                        }

                        if (argument.GetType() == typeof(int))
                        {
                            int i = (int)argument;
                            newAOFunctions.Arguments.Values.Add(i);
                        }

                        if (argument.GetType() == typeof(Single))
                        {
                            float s = (Single)argument;
                            newAOFunctions.Arguments.Values.Add(s);
                        }
                    }

                    newAOFunctions.dolocalstats = aoFunctions.dolocalstats;
                    newAOFunctions.FunctionType = aoFunctions.FunctionType;
                    newAOFunctions.Target = aoFunctions.Target;
                    newAOFunctions.TickCount = aoFunctions.TickCount;
                    newAOFunctions.TickInterval = aoFunctions.TickInterval;
                    newEvent.Functions.Add(newAOFunctions);
                }

                newEvent.EventType = aoEvents.EventType;
                nanoFormula.Events.Add(newEvent);
            }

            nanoFormula.flags = this.flags;
            nanoFormula.Instance = this.Instance;
            nanoFormula.ItemType = this.ItemType;

            return nanoFormula;
        }
Esempio n. 2
0
        /// <summary>
        /// </summary>
        /// Methods to do:
        /// Read Item
        /// Write Item
        /// Return Dynel Item (placing on the ground)
        /// <returns>
        /// </returns>
        public NanoFormula ShallowCopy()
        {
            NanoFormula nanoFormula = new NanoFormula();

            nanoFormula.ID = this.ID;

            foreach (KeyValuePair <int, int> nanoFormulaAttribute in this.Attack)
            {
                nanoFormula.Attack.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value);
            }

            foreach (KeyValuePair <int, int> nanoFormulaAttribute in this.Defend)
            {
                nanoFormula.Defend.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value);
            }

            foreach (KeyValuePair <int, int> nanoFormulaAttribute in this.Stats)
            {
                nanoFormula.Stats.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value);
            }

            foreach (Events aoEvents in this.Events)
            {
                Events newEvent = new Events();
                foreach (Functions aoFunctions in aoEvents.Functions)
                {
                    Functions newAOFunctions = new Functions();
                    foreach (Requirements aor in aoFunctions.Requirements)
                    {
                        Requirements newRequirement = new Requirements();
                        newRequirement.ChildOperator = aor.ChildOperator;
                        newRequirement.Operator      = aor.Operator;
                        newRequirement.Statnumber    = aor.Statnumber;
                        newRequirement.Target        = aor.Target;
                        newRequirement.Value         = aor.Value;
                        newAOFunctions.Requirements.Add(newRequirement);
                    }

                    foreach (object argument in aoFunctions.Arguments.Values)
                    {
                        if (argument.GetType() == typeof(string))
                        {
                            string z = (string)argument;
                            newAOFunctions.Arguments.Values.Add(z);
                        }

                        if (argument.GetType() == typeof(int))
                        {
                            int i = (int)argument;
                            newAOFunctions.Arguments.Values.Add(i);
                        }

                        if (argument.GetType() == typeof(Single))
                        {
                            float s = (Single)argument;
                            newAOFunctions.Arguments.Values.Add(s);
                        }
                    }

                    newAOFunctions.dolocalstats = aoFunctions.dolocalstats;
                    newAOFunctions.FunctionType = aoFunctions.FunctionType;
                    newAOFunctions.Target       = aoFunctions.Target;
                    newAOFunctions.TickCount    = aoFunctions.TickCount;
                    newAOFunctions.TickInterval = aoFunctions.TickInterval;
                    newEvent.Functions.Add(newAOFunctions);
                }

                newEvent.EventType = aoEvents.EventType;
                nanoFormula.Events.Add(newEvent);
            }

            nanoFormula.flags    = this.flags;
            nanoFormula.Instance = this.Instance;
            nanoFormula.ItemType = this.ItemType;

            return(nanoFormula);
        }
Esempio n. 3
0
        /// <summary>
        /// The parse nano.
        /// </summary>
        /// <param name="rectype">
        /// The rectype.
        /// </param>
        /// <param name="recnum">
        /// The recnum.
        /// </param>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <param name="sqlFile">
        /// The sql file.
        /// </param>
        /// <returns>
        /// The <see cref="AONanos"/>.
        /// </returns>
        public NanoFormula ParseNano(int rectype, int recnum, byte[] data, string sqlFile)
        {
            this.br = new BufferedReader(rectype, recnum, data);
            NanoFormula aon = new NanoFormula();
            aon.ID = recnum;
            this.br.Skip(16);

            int numberOfAttributes = this.br.Read3F1() - 1;
            int counter = 0;

            while (true)
            {
                if (counter > numberOfAttributes)
                {
                    break;
                }

                int attrkey = this.br.ReadInt32();
                int attrval = this.br.ReadInt32();
                if (attrkey == 54)
                {
                    aon.Stats.Add(attrkey, attrval);
                }
                else
                {
                    aon.Stats.Add(attrkey, attrval);
                }

                counter++;
            }

            this.br.Skip(8);

            short nameLength = this.br.ReadInt16();
            short descriptionLength = this.br.ReadInt16();
            if (nameLength > 0)
            {
                this.br.ReadString(nameLength);
            }

            if (descriptionLength > 0)
            {
                this.br.ReadString(descriptionLength); // Read and discard Description
            }

            bool flag4 = true;
            checked
            {
                while (this.br.Ptr < this.br.Buffer.Length - 8 && flag4)
                {
                    switch (this.br.ReadInt32())
                    {
                        case 2:
                            this.ParseFunctionSet(aon.Events);
                            break;
                        case 3:
                        case 5:
                        case 7:
                        case 8:
                        case 9:
                        case 10:
                        case 11:
                        case 12:
                        case 13:
                        case 15:
                        case 16:
                        case 17:
                        case 18:
                        case 19:
                        case 21:
                            goto IL_4BF;
                        case 4:
                            this.ParseAtkDefSet(aon.Attack, aon.Defend);
                            break;
                        case 6:
                            {
                                this.br.Skip(4);
                                int count = this.br.Read3F1() * 8;
                                this.br.Skip(count);
                                break;
                            }

                        case 14:
                            this.ParseAnimSoundSet(1, null);
                            break;
                        case 20:
                            this.ParseAnimSoundSet(2, null);
                            break;
                        case 22:
                            this.ParseActionSet(aon.Actions);
                            break;
                        case 23:
                            this.ParseShopHash(aon.Events);
                            break;
                        default:
                            goto IL_4BF;
                    }

                    continue;
                IL_4BF:
                    flag4 = false;
                }
            }

            return aon;
        }