Example #1
0
 public Character(string name, Stats stats, Inventory inventory, Equipment equipment, AbilityList abilities)
 {
     this.name      = name;
     this.stats     = stats;
     this.inventory = inventory;
     this.equipment = equipment;
     this.abilities = abilities;
 }
Example #2
0
    // Update is called once per frame
    void Update()        //TODO make this only trigger when the ability is changed
    {
        if (!player)
        {
            return;
        }

        AbilityList abilityList = player.GetComponent <AbilityList>();

        if (abilityList.abilities.Count < abilityNumber)
        {
            return;
        }

        if (ability != abilityList.abilities[abilityNumber - 1])
        {
            // update the ability
            ability = abilityList.abilities[abilityNumber - 1];
            // update the tooltip
            tooltipAbility.SetAbility(abilityList.abilities[abilityNumber - 1]);
            // update the icon
            icon.sprite = abilityList.abilities[abilityNumber - 1].abilitySprite;
            // activate or deactivate the cooldown bar
            //activateCooldownBarIfNecessary();
            // update the number of charges in the charge display
            //chargeDisplay.updateMaxCharges((int) playerCharges.maxCharges[abilityNumber - 1]);
            // inform the skill saving manager
            save();
        }

        if (!playerMana.hasEnoughManaToUse(ability))
        {
            if (!outOfMana.gameObject.activeSelf)
            {
                outOfMana.gameObject.SetActive(true);
            }
        }
        else
        {
            outOfMana.gameObject.SetActive(false);
        }

        //if (cooldownBar.gameObject.activeSelf)
        //{
        //    cooldownBar.currentFill = 1 - playerCharges.getChargesFloat(ability);
        //    if (cooldownBar.currentFill < 0) { cooldownBar.currentFill = 0; }
        //}

        if (cooldownBarActive && cooldownBar && !cooldownBar.gameObject.activeSelf)
        {
            cooldownBar.gameObject.SetActive(true);
        }

        if (!cooldownBarActive && cooldownBar && cooldownBar.gameObject.activeSelf)
        {
            cooldownBar.gameObject.SetActive(false);
        }
    }
Example #3
0
        /// <summary>
        /// Check if the provided ability is ready to use.
        /// </summary>
        /// <param name="ability"></param>
        /// <returns></returns>
        public bool Ready(AbilityList ability)
        {
            if (_fface.Timer.GetAbilityRecast(ability) == 0)// && fface.Player.HasAbility(ability))
            {
                return(true);
            }

            return(false);
        }
Example #4
0
        public bool Ready(AbilityList ability)
        {
            if (fface.Timer.GetAbilityRecast(ability) == 0)
            {
                return(true);
            }

            return(false);
        }
Example #5
0
        public void Activate(object param)
        {
            int abilityId = 0;

            if (param != null && Int32.TryParse(param.ToString(), out abilityId))
            {
                _cachedAbilityId = abilityId;
                AbilityList.SelectItem(abilityId);
            }
        }
Example #6
0
        public static Ability GetAbilityFromOffset(UInt16 value)
        {
            Ability i = AbilityList.Find(
                delegate(Ability j)
            {
                return(j.Value == value);
            });

            return(i);
        }
Example #7
0
 public Ability getAbility(AbilityList ability)
 {
     foreach (Ability a in abilities)
     {
         if (a.ability == ability)
         {
             return(a);
         }
     }
     return(null);
 }
Example #8
0
            } // @ public TimeSpan GetSpellRecast(eSpellList spell)

            /// <summary>
            /// Gets the time left in seconds before being able to reuse an ability (use sparingly)
            /// </summary>
            /// <param name="abil">Ability List</param>
            /// <returns>-1 if Ability is not "equipped", Recast of the ability otherwise</returns>
            public int GetAbilityRecast(AbilityList abil)
            {
                for (byte i = 0; i < MAX_ABILITY_INDEX; i++)
                {
                    if (GetAbilityID(i) == abil)
                    {
                        return((int)Math.Ceiling((decimal)(FFACE.GetAbilityRecast(_InstanceID, i) / 60)));
                    }
                }
                // not found.
                return(-1);
            }
Example #9
0
    private List<List<Item>> LoadJSONItems(string fileName, LoadType loadType)
    {
        string json = GetJSONFromFile(fileName);

        //load abilities
        AbilityList jsonAbilitiesLoad = JsonUtility.FromJson<AbilityList>(json);

        List<List<Item>> itemsLoad = new List<List<Item>>();

        //add 4 lists for common, uncommon, rare, special
        itemsLoad.Add(new List<Item>()); //common
        itemsLoad.Add(new List<Item>()); //uncommon
        itemsLoad.Add(new List<Item>()); //rare
        itemsLoad.Add(new List<Item>()); //special

        foreach (Abilities item in jsonAbilitiesLoad.Abilities)
        {
            Item itemDescription = new Item();

            itemDescription.ability = null;
            itemDescription.modifier = null;
            itemDescription.item = null;
            itemDescription.cost = 0;

            if (loadType == LoadType.ability)
            {
                itemDescription.ability = (Ability)System.Activator.CreateInstance(System.Type.GetType(item.className));
            }
            else if (loadType == LoadType.modifier)
            {
                itemDescription.modifier = (Modifier)System.Activator.CreateInstance(System.Type.GetType(item.className));
                itemDescription.cost = (int)Random.Range(((item.poolType + 1) * 40) * item.cost, (((item.poolType + 1) * 40) * 4) * item.cost);
            }
            else if (loadType == LoadType.item)
            {
                itemDescription.item = (ItemPickup)System.Activator.CreateInstance(System.Type.GetType(item.className));
                itemDescription.cost = (int)Random.Range((30 * item.cost), (70 * item.cost));
            }

            itemDescription.name = item.name;
            itemDescription.obj = Resources.Load<GameObject>(item.asset);
            if (itemDescription.obj == null)
            {
                Debug.LogError("Failed to load object for item name: " + item.name);
            }
            itemDescription.description = item.description;
            itemDescription.costMultiplier = item.cost;
            itemDescription.tier = item.poolType;
            itemsLoad[item.poolType].Add(itemDescription);
        }

        return itemsLoad;
    }
Example #10
0
    /// <summary>
    /// Initialize the descriptor for the nexus abilities
    /// </summary>
    /// <param name="nexusAbilities">The AbilityList for the nexus</param>
    private void InitializeDescriptor(AbilityList nexusAbilities)
    {
        //modify the descriptor tooltip, making it show the human buffs
        DescriptorTooltip descriptorTT = (DescriptorTooltip)nexusAbilities[0].Tooltip;

        descriptorTT.Title = GetRaceFaction() + " - " + Human.HUMAN_RACE;
        descriptorTT.GetSection(DescriptorTooltip.UNIT_HEADER).Body       = "+5% attack rate";
        descriptorTT.GetSection(DescriptorTooltip.BUILDING_HEADER).Body   = "+1 armor";
        descriptorTT.GetSection(DescriptorTooltip.UPGRADE_HEADER).Body    = "+3Lv unit armor";
        descriptorTT.GetSection(DescriptorTooltip.TRAIT_HEADER).Body      = "\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\"";
        descriptorTT.GetSection(DescriptorTooltip.DIFFICULTY_HEADER).Body = "Beginner";
    }
Example #11
0
 private void Awake()
 {
     instance = this;
     for (int i = 0; i < actionList.Length; i++)
     {
         actionList[i].id = i;
     }
     for (int i = 0; i < traitList.Length; i++)
     {
         traitList[i].id = i;
     }
 }
Example #12
0
    void Start()
    {
        _motor         = _bodyIdentity.gameObject.GetComponent <BaseMotor>();
        _abilities     = _bodyIdentity.gameObject.GetComponent <AbilityList>();
        _animationSync = _bodyIdentity.gameObject.GetComponent <AnimationSync>();


        if (isServer)
        {
            _abilities.GrantAbility(new AbilityJump(_motor, _animationSync), AbilitySlot.Jump);
            _abilities.GrantAbility(new AbilityBasicAttack(_motor, _animationSync), AbilitySlot.Attack1);
        }
    }
Example #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            var abilities = new AbilityList();

            abilities.Update();

            listBox1.Items.Add(String.Format("Count: {0}", abilities.Count()));

            foreach (var ability in abilities)
            {
                listBox1.Items.Add(String.Format("Name: {0}, UsableAt: {1}, CooldownLength: {2}", ability.AbilityName, ability.AvailableAtTick, ability.CooldownLength));
            }
        }
Example #14
0
 // Use this for initialization
 void Awake()
 {
     abilityList = GetComponent <AbilityList>();
     abilities.Clear();
     abilities.AddRange(abilityList.abilities);
     for (int i = 0; i < abilityList.abilities.Count; i++)
     {
         // initialise other lists
         charges.Add(0);
         chargeRegen.Add(0);
         maxCharges.Add(0);
     }
     for (int i = 0; i < abilityList.abilities.Count; i++)
     {
         updateChargeInfo(i);
     }
 }
Example #15
0
    public void GenerateEvolution(int minValue = 80, int maxValue = 100)
    {
        minValue = 60 + (GameEngine.instance.numGenerations * 5);
        maxValue = 70 + (GameEngine.instance.numGenerations * 10);
        int generatedValue = 9999;

        while (generatedValue > maxValue || generatedValue < minValue)
        {
            hp  = Random.Range(hpRange.first, hpRange.second + 1) * 5;
            sp  = Random.Range(spRange.first, spRange.second + 1) * 5;
            str = Random.Range(strRange.first, strRange.second + 1);
            agi = Random.Range(agiRange.first, agiRange.second + 1);

            action = null; //Random.value > .5f ? AbilityList.GetRandomAction() : null;
            trait  = AbilityList.GetRandomTrait();

            generatedValue = GetValue();
        }
    }
    public static void loadAbilityBar()
    {
        CharacterDataTracker tracker        = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>();
        AbilityList          abilityList    = PlayerFinder.getPlayer().GetComponent <AbilityList>();
        List <string>        savedAbilities = tracker.charData.abilityBar;

        for (int i = 0; i < savedAbilities.Count; i++)
        {
            Ability ability = AbilityIDList.getPlayerAbility(savedAbilities[i]);
            if (ability == null)
            {
                abilityList.abilities[i] = AbilityIDList.getAbility(AbilityID.nullAbility);
            }
            else
            {
                abilityList.abilities[i] = ability;
            }
        }
    }
Example #17
0
    //private GenericItem item;

    // Use this for initialization
    void Start()
    {
        int shopCounter = 0;

        management      = GameObject.FindGameObjectWithTag("Management").GetComponent <Management>();
        gameDataManager = GameObject.FindGameObjectWithTag("GameData").GetComponent <GameDataManager>();
        enemyDatabase   = JsonUtility.FromJson <EnemyList>(File.ReadAllText(Application.dataPath + "/StreamingAssets/enemies.json"));
        abilityDatabase = JsonUtility.FromJson <AbilityList>(File.ReadAllText(Application.dataPath + "/StreamingAssets/abilities.json"));


        if (!gameDataManager.hasSavedGame)
        {
            itemDatabase = JsonUtility.FromJson <ItemList>(File.ReadAllText(Application.dataPath + "/StreamingAssets/items.json"));//JsonHelper.FromJson<ItemList>(File.ReadAllText(Application.dataPath + "/StreamingAssets/Items.json"));
            shopPool     = new List <GenericItem>();

            for (int i = 0; i < itemDatabase.itemList.Count && shopCounter < 8; i++)
            {
                if (management.randomBoolean(0.8f))
                {
                    shopPool.Add(itemDatabase.itemList[i]);
                    itemDatabase.itemList.RemoveAt(i);
                    shopCounter++;
                    i--;
                }

                if (i == itemDatabase.itemList.Count - 1)
                {
                    i = 0;
                }
            }
        }
        else
        {
            var save = gameDataManager.LoadGame();
            itemDatabase = save.items.database;
            shopPool     = save.items.shopPool;
        }
        //item = JsonUtility.FromJson<GenericItem>(File.ReadAllText(Application.dataPath + "/StreamingAssets/item.json"));
        //Debug.Log(File.ReadAllText(Application.dataPath + "/StreamingAssets/Items.json"));
    }
Example #18
0
 /// <summary>
 /// Set the ability panes for the currently selected object
 /// </summary>
 /// <param name="list">The list of abilities associated with the object</param>
 public void SetAbilityPanes(AbilityList list)
 {
     AbilityPanelManager.GetInstance().SetPanes(list);
 }
Example #19
0
    public virtual GameObject adapt(GameObject entity)
    {
        // attach extra abilities if necessary
        if (extraAbilities.Count > 0)
        {
            AbilityList           list           = entity.GetComponent <AbilityList>();
            AbilityRangeList      rangeList      = entity.GetComponent <AbilityRangeList>();
            AbilityMutatorManager mutatorManager = null;
            bool addChargeManager = false;

            // check that there is an ability list and ability range list
            if (list && rangeList)
            {
                // add each ability in order
                foreach (ExtraAbility extra in extraAbilities)
                {
                    // add the new ability
                    if (extra.lowPriority)
                    {
                        list.abilities.Add(extra.ability);
                    }
                    else
                    {
                        list.AddAbilityToStart(extra.ability);
                    }

                    // add the ranges to use the ability at
                    AbilityRangeList.AbilityRanges abilityRanges = new AbilityRangeList.AbilityRanges();
                    abilityRanges.minRange     = extra.minRange;
                    abilityRanges.engageRange  = extra.engageRange;
                    abilityRanges.maxRange     = extra.maxRange;
                    abilityRanges.persuitRange = extra.persuitRange;
                    if (extra.lowPriority)
                    {
                        rangeList.ranges.Add(abilityRanges);
                    }
                    else
                    {
                        rangeList.addRangeToStart(abilityRanges);
                    }

                    // if the ability has a cooldown add a mutator for it unless one already exists, in which case change the cooldown on it
                    if (extra.addedCharges + extra.ability.maxCharges != 0)
                    {
                        addChargeManager = true;

                        if (!mutatorManager)
                        {
                            mutatorManager = entity.GetComponent <AbilityMutatorManager>();
                        }
                        if (!mutatorManager)
                        {
                            mutatorManager = entity.AddComponent <AbilityMutatorManager>();
                        }

                        // get a reference to, or add, a mutator
                        AbilityMutator        myMutator = null;
                        List <AbilityMutator> mutators  = mutatorManager.getMutators(extra.ability);
                        if (mutators != null && mutators.Count > 0)
                        {
                            myMutator = mutators[0];
                        }
                        else
                        {
                            myMutator = entity.AddComponent <GenericMutator>();
                            myMutator.changeAbility(extra.ability);
                        }

                        // replace the cooldown on the mutator
                        myMutator.addedCharges     = extra.addedCharges;
                        myMutator.addedChargeRegen = extra.addedChargeRegen;
                    }
                }
            }

            if (addChargeManager)
            {
                if (!entity.GetComponent <ChargeManager>())
                {
                    entity.AddComponent <ChargeManager>();
                }

                //check if a null ability needs to be added
                bool needsNull = false;
                foreach (ExtraAbility extra in extraAbilities)
                {
                    if (extra.lowPriority)
                    {
                        if (extra.addedCharges + extra.ability.maxCharges != 0)
                        {
                            needsNull = true;
                        }
                        else
                        {
                            needsNull = false;
                        }
                    }
                }
                if (needsNull && !list.abilities.Contains(AbilityIDList.getAbility(AbilityID.nullAbility)))
                {
                    list.abilities.Add(AbilityIDList.getAbility(AbilityID.nullAbility));
                    float highestRange = 0f;
                    foreach (AbilityRangeList.AbilityRanges range in rangeList.ranges)
                    {
                        if (range.persuitRange > highestRange)
                        {
                            highestRange = range.persuitRange;
                        }
                    }
                    AbilityRangeList.AbilityRanges ranges = new AbilityRangeList.AbilityRanges(highestRange, 1f, 0.5f, 0f);
                    rangeList.ranges.Add(ranges);
                }
            }
        }


        // add retaliators if necessary
        if (retaliators.Count > 0)
        {
            foreach (Retaliator retal in retaliators)
            {
                GameObject retalObj = new GameObject();
                retalObj.transform.parent        = entity.transform;
                retalObj.transform.localPosition = Vector3.zero;

                RetaliateWhenParentHit retalComponent = retalObj.AddComponent <RetaliateWhenParentHit>();
                retalComponent.ability                 = retal.ability;
                retalComponent.sourceOfAbility         = RetaliateWhenParentHit.SourceOfAbilityObjectConstructor.Parent;
                retalComponent.damageTakenTrigger      = retal.threshold;
                retalComponent.damageTakenSinceTrigger = retal.startingDamage;
            }
        }

        return(entity);
    }
Example #20
0
 // Use this for initialization
 void Start()
 {
     invAnim = transform.parent.GetComponent <Animator>();
     list    = transform.parent.GetChild(1).GetChild(0).GetChild(0).GetComponent <AbilityList> ();
 }
Example #21
0
 public void AddAbility(BaseAbilityClass ability)
 {
     AbilityList.Add(ability);
     ability.Active = (AbilityList.Count <= 3);
 }
Example #22
0
            } // @ public TimeSpan GetSpellRecast(eSpellList spell)

            /// <summary>
            /// Gets the time left in seconds before being able to reuse an ability (use sparingly)
            /// </summary>
            /// <param name="abil">Ability List</param>
            /// <returns>-1 if Ability is not "equipped", Recast of the ability otherwise</returns>
            public int GetAbilityRecast (AbilityList abil)
            {
                for (byte i = 0; i < MAX_ABILITY_INDEX; i++)
                    if (GetAbilityID(i) == abil)
                        return (int) Math.Ceiling((decimal) (FFACE.GetAbilityRecast(_InstanceID, i) / 60));
                // not found.
                return -1;
            }
Example #23
0
 /// <summary>
 /// Gets the time left in seconds before being able to reuse an ability (use sparingly)
 /// </summary>
 /// <param name="abil">Ability List</param>
 /// <returns>-1 if Ability is not "equipped", Recast of the ability otherwise</returns>
 public int GetAbilityRecast(AbilityList abil)
 {
     for (byte i = 0; i < MAX_ABILITY_INDEX; i++)
         if (GetAbilityID(i) == abil)
             return FFACE.GetAbilityRecast(_InstanceID, i) / 60;
     // not found.
     return -1;
 }
Example #24
0
            /// <summary>
            /// Will get the name of the passed ability ID
            /// </summary>
            /// <param name="abil">AbilityList enum indicating the Ability to get the name of.</param>
            /// <returns>In-game name of the ability passed, String.Empty on error</returns>
            public static String GetAbilityName(AbilityList abil)
            {
                if (Instance == null)
                    return String.Empty;

                int key = (int)abil | (int)ResourceBit.Abils;
                String result;

                if (Instance.ResourcesCache.TryGetValue(key, out result))
                    return result;
                return String.Empty;
            }
Example #25
0
 /// <summary>
 /// Set the Ability List for this building
 /// </summary>
 /// <param name="list">The initial AbilityList for this building</param>
 public void SetAbilityList(AbilityList list)
 {
     abilities = list;
 }
Example #26
0
 /// <summary>
 /// Checks that you have access to a given ability
 /// </summary>
 /// <param name="ability"></param>
 /// <returns></returns>
 public bool HasAbility(AbilityList ability)
 {
     return GetAbilityAvailable(_InstanceID, (uint)ability);
 }
Example #27
0
 /// <summary>
 /// Uses an ability list that belongs to a group of abilities; such as a Pet ability, DNC Step, or DNC Waltz.
 /// </summary>
 /// <example>
 ///     UseAbility("Predator Claws", AbilityList.Pet_commands, 3, true);
 /// </example>
 /// <param name="ability">The ability to use</param>
 /// <param name="abilityGroup">The ability group to use from AbilityList</param>
 /// <param name="Delay">How long does it take to use this ability? (Consider lockout after use)</param>
 /// <param name="Offensive">Is this ability used on me, or my target?</param>
 public bool UseAbility(string ability, AbilityList abilityGroup, int Delay = 2, bool Offensive = false)
 {
     return(SendCommand("/ja \"" + ability.ToString().Replace('_', ' ') + "\" " + (Offensive ? "<t>" : "<me>"), Delay));
 }
Example #28
0
 /// <summary>
 /// Checks that you have access to a given ability
 /// </summary>
 /// <param name="ability"></param>
 /// <returns></returns>
 public bool HasAbility(AbilityList ability)
 {
     return(GetAbilityAvailable(_InstanceID, (uint)ability));
 }