public void Init(ref HeroActionField actionField)
 {
     ActionCommon.CreateActionField(ref actionField.ints, 1, 0);
 }
Exemple #2
0
 public void Init(ref HeroActionField actionField)
 {
     ActionCommon.CreateActionField(ref actionField.colors, 1, new Color(0, 0, 0));
 }
Exemple #3
0
 public void Init(ref HeroActionField actionField)
 {
     ActionCommon.CreateActionField(ref actionField.ints, 6, 0);
     ActionCommon.CreateActionField(ref actionField.heroObjects, 1, null);
     ActionCommon.CreateActionField(ref actionField.strings, 2, "");
 }
Exemple #4
0
        // --------------------------------------------------------------
        // Action Fields
        // --------------------------------------------------------------

        /// <summary>
        /// Get a value from a string field.
        /// This is for a field that contains Value, Variable, Property, Global.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionField">Action field.</param>
        /// <param name="titleToLeft">Show the title on the left?</param>
        public static void BuildFieldA(string title, HeroActionParams actionParams, HeroActionField actionField, bool titleToLeft = false, bool useTextField = false, int rightOffset = 0)
        {
            // create the fields
            StringFieldData data = CreateFieldData(title, actionField, actionParams.heroObject);

            //-----------------------------------------
            // Display this title above the field
            //-----------------------------------------
            if (data.title != "" && !titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }
            SimpleLayout.BeginHorizontal();
            if (data.title != "" && titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }

            //-----------------------------------------
            // Get the type of field you want to work with.
            //-----------------------------------------
            data.fieldType = new HeroField.ValueTypeField().SetValues(data.fieldType, 0);

            //-----------------------------------------
            // Get the type of game object we are working with
            // Option 1: This game object (game object that this hero object is attached to)
            // Option 2: Another game object (another game object in the scene that has a hero object attached to it)
            //-----------------------------------------
            if (data.fieldType == 2 || data.fieldType == 3)
            {
                data = ActionCommon.GetTargetHeroObject(data);
            }

            //-----------------------------------------
            // Get the integer list you want to work with.
            // The integer list is in hero object editor > Variables
            //-----------------------------------------

            // if this is a field, draw field (1=value)
            if (data.fieldType == 1)
            {
                if (useTextField)
                {
                    data.fieldValue = SimpleLayout.TextArea(data.fieldValue, HeroKitCommon.GetWidthForField(133) + rightOffset);
                }
                else
                {
                    data.fieldValue = SimpleLayout.TextField(data.fieldValue, HeroKitCommon.GetWidthForField(133) + rightOffset); //test
                }
            }

            // if this is a list, draw ints (2=variables, 3=properties)
            if (data.fieldType != 1)
            {
                data = SetPropertyID(data, -1);
                List <StringField> items = GetItemsFromList(data, -1);
                data = BuildItemFieldList(data, items);
            }

            //-----------------------------------------
            // assign values back to hero object fields
            //-----------------------------------------
            actionField.ints[0]        = data.objectType;
            actionField.ints[1]        = data.objectID;
            actionField.ints[2]        = data.fieldID;
            actionField.ints[3]        = data.fieldType;
            actionField.ints[4]        = data.heroGUID;
            actionField.ints[5]        = data.propertyID;
            actionField.heroObjects[0] = data.targetHeroObject;
            actionField.strings[0]     = data.objectName;
            actionField.strings[1]     = data.fieldValue;

            //-----------------------------------------
            // Visual stuff
            //-----------------------------------------
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();
        }
Exemple #5
0
        /// <summary>
        /// Get a value from a string field.
        /// This is for a field that contains Variable, Property, Global.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionField">Action field.</param>
        /// <param name="titleToLeft">Show the title on the left?</param>
        public static void BuildFieldB(string title, HeroActionParams actionParams, HeroActionField actionField, bool titleToLeft = false)
        {
            // create the fields
            StringFieldData data = CreateFieldData(title, actionField, actionParams.heroObject);

            //-----------------------------------------
            // Display this title above the field
            //-----------------------------------------
            if (data.title != "" && !titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }
            SimpleLayout.BeginHorizontal();
            if (data.title != "" && titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }

            //-----------------------------------------
            // Get the type of field you want to work with.
            //-----------------------------------------
            data.fieldType = new HeroField.ValueTypeFieldB().SetValues(data.fieldType, 0);

            //-----------------------------------------
            // Get the type of game object we are working with
            // Option 1: This game object (game object that this hero object is attached to)
            // Option 2: Another game object (another game object in the scene that has a hero object attached to it)
            //-----------------------------------------
            if (data.fieldType == 1 || data.fieldType == 2)
            {
                data = ActionCommon.GetTargetHeroObject(data);
            }

            //-----------------------------------------
            // Get the string list you want to work with.
            // The string list is in hero object editor > Variables
            //-----------------------------------------
            data = SetPropertyID(data);
            List <StringField> items = GetItemsFromList(data);

            data = BuildItemFieldList(data, items);

            //-----------------------------------------
            // assign values back to hero object fields
            //-----------------------------------------
            actionField.ints[0]        = data.objectType;
            actionField.ints[1]        = data.objectID;
            actionField.ints[2]        = data.fieldID;
            actionField.ints[3]        = data.fieldType;
            actionField.ints[4]        = data.heroGUID;
            actionField.ints[5]        = data.propertyID;
            actionField.heroObjects[0] = data.targetHeroObject;
            actionField.strings[0]     = data.objectName;
            actionField.strings[1]     = data.fieldValue;

            //-----------------------------------------
            // Visual stuff
            //-----------------------------------------
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();
        }
Exemple #6
0
        /// <summary>
        /// Compiles script into subaction byte code
        /// </summary>
        public static void Compile(string script)
        {
            if (scriptToBinary.ContainsKey(script) || scriptToReference.ContainsKey(script))
            {
                return;
            }

            HSDStruct main = null;

            var stream = Regex.Replace(script, @"\s+", string.Empty);

            if (script.StartsWith("ref:"))
            {
                var name = stream.Split(':')[1];
                scriptToReference.Add(script, name);
                return;
            }

            var functions = Regex.Matches(stream, @"([^\{])*\{([^\}]*)\}");

            foreach (Match g in functions)
            {
                var name = Regex.Match(g.Value, @".+?(?={)").Value;
                var code = Regex.Match(g.Value, @"(?<=\{).+?(?=\})").Value.Split(';');

                if (nameToFunction.ContainsKey(name))
                {
                    continue;
                }

                HSDStruct s = new HSDStruct();
                nameToFunction.Add(name, s);
                structToOffsetToFunction.Add(s, new Dictionary <int, string>());

                if (main == null)
                {
                    main = s;
                }

                List <byte> output   = new List <byte>();
                bool        returned = false;
                foreach (var c in code)
                {
                    var cname       = Regex.Match(c, @".+?(?=\()").Value;
                    var cparameters = Regex.Match(c, @"(?<=\().+?(?=\))").Value.Split(',');

                    if (cname == "Return")
                    {
                        returned = true;
                    }

                    byte flag = ActionCommon.GetMeleeCMDAction(cname).Command;

                    if (flag == 0x5 || flag == 0x7) //goto and subroutine
                    {
                        structToOffsetToFunction[s].Add(output.Count + 4, cparameters[0]);
                        output.AddRange(new byte[] { (byte)(flag << 2), 0, 0, 0, 0, 0, 0, 0 });
                    }
                    else
                    {
                        output.AddRange(CompileCommand(cname, cparameters));
                    }

                    // padd
                    if (output.Count % 4 != 0)
                    {
                        output.AddRange(new byte[4 - (output.Count % 4)]);
                    }
                }
                if (true)
                {
                    output.Add(0);
                    if (output.Count % 4 != 0)
                    {
                        output.AddRange(new byte[4 - (output.Count % 4)]);
                    }
                }
                s.SetData(output.ToArray());
            }

            if (main == null)
            {
                main = new HSDStruct(4);
            }

            scriptToBinary.Add(script, main);
        }
Exemple #7
0
 public void Init(ref HeroActionField actionField)
 {
     ActionCommon.CreateActionField(ref actionField.bools, 1, false);
 }