Пример #1
0
        // --------------------------------------------------------------
        // Methods (General)
        // --------------------------------------------------------------

        /// <summary>
        /// Block to display on the canvas.
        /// </summary>
        /// <param name="heroKitAction">Hero kit action to display in the block.</param>
        /// <param name="indexProperty">ID of the property.</param>
        public static void Block(HeroObject heroKitObject, int indexProperty)
        {
            // exit early if object is null
            if (heroKitObject == null)
            {
                return;
            }

            // exit early if property no longer exists
            if (heroKitObject.propertiesList.properties == null || heroKitObject.propertiesList.properties.Count - 1 < indexProperty)
            {
                return;
            }

            // assign hero object to this class
            heroObject = heroKitObject;

            // save the id of the property that this event belongs in
            itemIndex     = indexProperty;
            propertyBlock = heroObject.propertiesList.properties[itemIndex];

            // save the fields
            stringFields = propertyBlock.itemProperties.strings.items;
            intFields    = propertyBlock.itemProperties.ints.items;
            floatFields  = propertyBlock.itemProperties.floats.items;
            boolFields   = propertyBlock.itemProperties.bools.items;
            uoFields     = propertyBlock.itemProperties.unityObjects.items;

            // draw components
            DrawBlock();
        }
Пример #2
0
        /// <summary>
        /// Clone the hero properties, remove references.
        /// </summary>
        /// <param name="field">The hero properties to clone.</param>
        /// <returns>The cloned hero properties.</returns>
        public HeroProperties Clone(HeroProperties field)
        {
            HeroProperties temp = new HeroProperties();

            temp.propertyTemplate = field.propertyTemplate;
            temp.itemProperties   = field.itemProperties.Clone(field.itemProperties);
            return(temp);
        }
Пример #3
0
 public void attack(HeroProperties hero, float damage, string sentenses = null)
 {
     //daño
     hero.getDamage(damage);
     //frase que dice cuando ataca
     if (sentenses != null)
     {
         FindObjectOfType <LevelInformationPanel>().showDialogs(sentenses, false);
     }
 }
Пример #4
0
    // evitar que ataque siempre a un solo heroe
    public HeroProperties heroWithMoreLife(HeroProperties possibleHero)
    {
        if (Characters.Count > 0)
        {
            foreach (HeroProperties hero in Characters)
            {
                if (possibleHero.Life < hero.Life)
                {
                    return(hero);
                }
            }
        }

        return(possibleHero);
    }
Пример #5
0
        // update HeroKit to 1.2
        public static void UpdateHeroKit1_2()
        {
            HeroObject[] heroObjects = Resources.LoadAll <HeroObject>("");
            for (int i = 0; i < heroObjects.Length; i++)
            {
                HeroProperties hp = heroObjects[i].properties;
                if (heroObjects[i].propertiesList.properties.Count == 0 && hp != null)
                {
                    // move properties to list
                    heroObjects[i].propertiesList.properties.Add(hp);
                    heroObjects[i].properties = null;

                    Debug.Log("Properties updated for: " + heroObjects[i].name);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Move item down.
        /// </summary>
        /// <param name="obj">Item to move down.</param>
        private static void moveItemDown(object obj)
        {
            int index = (int)obj;

            HeroKitCommon.deselectField();
            int indexA = index;
            int indexB = index + 1;

            if (indexB < itemsContextMenu.Count)
            {
                HeroProperties fieldA = itemsContextMenu[indexA];
                HeroProperties fieldB = itemsContextMenu[indexB];
                itemsContextMenu[indexA] = fieldB;
                itemsContextMenu[indexB] = fieldA;
            }
        }
Пример #7
0
        /// <summary>
        /// Store a deleted item for future restoration.
        /// </summary>
        /// <param name="stateID">ID of the state.</param>
        private static void saveDeletedItem(int stateID)
        {
            // add to deleted item to front of the stack
            HeroProperties t = new HeroProperties();

            t = t.Clone(itemsContextMenu[stateID]);

            deletedFields.AddFirst(t);
            deletedFieldsIndex.AddFirst(stateID);

            // if there are too many items in the stack, pop the last item in the stack
            if (deletedFields.Count > 10)
            {
                deletedFields.RemoveLast();
                deletedFieldsIndex.RemoveLast();
            }
        }
Пример #8
0
    public virtual void selecAttack()
    {
        int random = Random.Range(1, 101);

        if (!_weak)
        {
            // fijo
            if (random <= 70)
            {
                random = Random.Range(0, Characters.Count);
                //visual del daño
                _lastHeroToHarm = heroWithMoreLife(Characters[random]);
                Instantiate(_visualDamageOthers, _lastHeroToHarm.transform);
                _lastHeroToHarm.GetComponent <Animator>().Play(Animator.StringToHash("Damage"));
                //recibe el daño
                attack(_lastHeroToHarm, 1, "Ataque directo");
            }
            else
            {
                // en area
                foreach (HeroProperties hero in Characters)
                {
                    Instantiate(_visualDamageOthers, hero.transform);
                    hero.GetComponent <Animator>().Play(Animator.StringToHash("Damage"));
                    attack(hero, 1);
                }
                FindObjectOfType <LevelInformationPanel>().showDialogs("Daño en área", false);
            }
        }
        else
        {
            // aca deberia ser mas mortal
            random = Random.Range(0, Characters.Count - 1);
            //visual del daño
            Instantiate(_visualDamageOthers, Characters[random].transform);
            Instantiate(_visualDamageOthers, Characters[random].transform);
            Characters[random].GetComponent <Animator>().Play(Animator.StringToHash("Damage"));
            //recibe el daño
            attack(Characters[random], 2, "Ataque cargado  ");
        }

        //siguiente personaje en atacar
        _shifts.CurrentHero = _shifts.newChallenge();
        //revisa si mato a alguien
        removeHeroe();
    }
Пример #9
0
        /// <summary>
        /// Restor the last item that was deleted from the list.
        /// </summary>
        private static void restoreItem(object obj)
        {
            if (deletedFieldsIndex.Count > 0)
            {
                HeroKitCommon.deselectField();
                int            index = deletedFieldsIndex.First();
                HeroProperties field = deletedFields.First();

                // get state that contains the list of events
                List <HeroProperties> list = heroObject.propertiesList.properties;

                // insert this event in the list
                list.Insert(index, field);

                // delete fields
                deletedFields.RemoveFirst();
                deletedFieldsIndex.RemoveFirst();
            }
        }
Пример #10
0
        // --------------------------------------------------------------
        // Methods (General)
        // --------------------------------------------------------------

        /// <summary>
        /// Block to display on the canvas.
        /// </summary>
        /// <param name="heroKitAction">Hero kit action to display in the block.</param>
        /// <param name="indexProperty">ID of the property.</param>
        public static void Block(HeroObject heroKitObject, int indexProperty)
        {
            // exit early if object is null
            if (heroKitObject == null)
            {
                return;
            }

            // exit early if property no longer exists
            if (heroKitObject.propertiesList.properties == null || heroKitObject.propertiesList.properties.Count - 1 < indexProperty)
            {
                return;
            }

            // assign hero object to this class
            heroObject = heroKitObject;

            // save the id of the property that this event belongs in
            propertyIndex = indexProperty;
            propertyBlock = heroObject.propertiesList.properties[propertyIndex];

            // draw components
            DrawBlock();
        }
Пример #11
0
        /// <summary>
        /// Convert a variable into a string.
        /// </summary>
        /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param>
        /// <param name="subString">The code for the variable (ex. [V-I-0]).</param>
        /// <param name="codeType">The type of variable to parse.</param>
        /// <returns>Parsed string.</returns>
        private static string GetValueForCode(HeroKitObject heroKitObject, string subString, CodeType codeType, bool isProperty = false)
        {
            string code       = "";
            int    propertyID = 0;

            // convert the code into an integer.  ex: [V-I-0] = 99
            string slotValue = "";
            int    slotID    = 0;

            if (!isProperty)
            {
                // get the code. ex: 0
                int codeStartIndex = 5;
                int codeWidth      = subString.Length - codeStartIndex - 1;
                code = subString.Substring(codeStartIndex, codeWidth);
            }

            // [P-2-I-5]
            if (isProperty)
            {
                // [p-
                int propertyStartIndex = 3;

                // 2-I (i = -)
                int propertyIdLength = subString.IndexOf("-", propertyStartIndex) - propertyStartIndex;

                // 2
                string pID    = subString.Substring(propertyStartIndex, propertyIdLength);
                bool   parsed = Int32.TryParse(pID, out propertyID);
                if (!parsed)
                {
                    return("???");
                }

                // get last value in sequence (5)
                int codeStartIndex = propertyStartIndex + propertyIdLength + 3;
                int codeWidth      = subString.Length - codeStartIndex - 1;
                code = subString.Substring(codeStartIndex, codeWidth);
            }

            // --------------------------------------------------------------
            // Variables
            // --------------------------------------------------------------

            if (Int32.TryParse(code, out slotID))
            {
                if (codeType == CodeType.IntegerVariable)
                {
                    // get the value from the variable list
                    if (heroKitObject.heroList.ints.items != null &&
                        heroKitObject.heroList.ints.items.Count != 0 &&
                        heroKitObject.heroList.ints.items.Count > slotID)
                    {
                        slotValue = heroKitObject.heroList.ints.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Variable Integer Slot does not exist!");
                    }
                }

                else if (codeType == CodeType.BoolVariable)
                {
                    // get the value from the variable list
                    if (heroKitObject.heroList.bools.items != null &&
                        heroKitObject.heroList.bools.items.Count != 0 &&
                        heroKitObject.heroList.bools.items.Count > slotID)
                    {
                        slotValue = heroKitObject.heroList.bools.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Variable Bool Slot does not exist!");
                    }
                }

                else if (codeType == CodeType.StringVariable)
                {
                    // get the value from the variable list
                    if (heroKitObject.heroList.strings.items != null &&
                        heroKitObject.heroList.strings.items.Count != 0 &&
                        heroKitObject.heroList.strings.items.Count > slotID)
                    {
                        slotValue = heroKitObject.heroList.strings.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Variable String Slot does not exist!");
                    }
                }

                // --------------------------------------------------------------
                // Properties
                // --------------------------------------------------------------

                if (codeType == CodeType.IntegerProperty)
                {
                    // get the hero property attached to hero object
                    HeroProperties heroProperties = (heroKitObject.heroProperties.Length > propertyID) ? heroKitObject.heroProperties[propertyID] : null;

                    // get the value from the variable list
                    if (heroProperties != null &&
                        heroProperties.itemProperties.ints.items != null &&
                        heroProperties.itemProperties.ints.items.Count != 0 &&
                        heroProperties.itemProperties.ints.items.Count > slotID)
                    {
                        slotValue = heroProperties.itemProperties.ints.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Property Integer Slot does not exist!");
                    }
                }

                else if (codeType == CodeType.BoolProperty)
                {
                    // get the hero property attached to hero object
                    HeroProperties heroProperties = heroKitObject.heroProperties[propertyID];

                    // get the value from the variable list
                    if (heroProperties != null &&
                        heroProperties.itemProperties.bools.items != null &&
                        heroProperties.itemProperties.bools.items.Count != 0 &&
                        heroProperties.itemProperties.bools.items.Count > slotID)
                    {
                        slotValue = heroProperties.itemProperties.bools.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Property Bool Slot does not exist!");
                    }
                }

                else if (codeType == CodeType.StringProperty)
                {
                    // get the hero property attached to hero object
                    HeroProperties heroProperties = heroKitObject.heroProperties[propertyID];

                    // get the value from the variable list
                    if (heroProperties != null &&
                        heroProperties.itemProperties.strings.items != null &&
                        heroProperties.itemProperties.strings.items.Count != 0 &&
                        heroProperties.itemProperties.strings.items.Count > slotID)
                    {
                        slotValue = heroProperties.itemProperties.strings.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Property String Slot does not exist!");
                    }
                }

                // --------------------------------------------------------------
                // Globals
                // --------------------------------------------------------------

                if (codeType == CodeType.IntegerGlobal)
                {
                    // get the value from the variable list
                    if (HeroKitDatabase.GetGlobals().ints.items != null &&
                        HeroKitDatabase.GetGlobals().ints.items.Count != 0 &&
                        HeroKitDatabase.GetGlobals().ints.items.Count > slotID)
                    {
                        slotValue = HeroKitDatabase.GetGlobals().ints.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Global Integer Slot does not exist!");
                    }
                }

                else if (codeType == CodeType.BoolGlobal)
                {
                    // get the value from the variable list
                    if (HeroKitDatabase.GetGlobals().bools.items != null &&
                        HeroKitDatabase.GetGlobals().bools.items.Count != 0 &&
                        HeroKitDatabase.GetGlobals().bools.items.Count > slotID)
                    {
                        slotValue = HeroKitDatabase.GetGlobals().bools.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Global Bool Slot does not exist!");
                    }
                }

                else if (codeType == CodeType.StringGlobal)
                {
                    // get the value from the variable list
                    if (HeroKitDatabase.GetGlobals().strings.items != null &&
                        HeroKitDatabase.GetGlobals().strings.items.Count != 0 &&
                        HeroKitDatabase.GetGlobals().strings.items.Count > slotID)
                    {
                        slotValue = HeroKitDatabase.GetGlobals().strings.items[slotID].value.ToString();
                    }
                    else
                    if (heroKitObject.debugHeroObject)
                    {
                        Debug.LogError("Global String Slot does not exist!");
                    }
                }
            }

            return(slotValue);
        }
Пример #12
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="list">The hero property to construct.</param>
 public HeroProperties(HeroProperties field)
 {
     propertyTemplate = field.propertyTemplate;
     itemProperties   = field.itemProperties.Clone(field.itemProperties);
 }
Пример #13
0
 public void prepareAttack(List <VoiceAttacks> listAttacks, HeroProperties hero)
 {
     _listAttacks = listAttacks;
     _hero        = hero;
 }
Пример #14
0
 public virtual void addCharacter(HeroProperties hero)
 {
     Characters.Add(hero);
 }