Esempio n. 1
0
 AbilityBook Cast(AbilityBook ability)
 {
     /*Instantiates the passed ability projectile
     pass it the target, rutrns the cooldown time*/
     foreach(GameObject enemy in ability.target){
         GameObject shot = Graveyard.graveyard.CheckTombstone(ability.projectile.name);
         //Debug.Log(shot+" : "+ability.projectile.name);
         if (shot != null){
             shot.GetComponent<Missile>().Recycle(transform.position);
         } else {
             shot = (GameObject)Instantiate (ability.projectile, transform.position, ability.projectile.transform.rotation);
         }
         shot.transform.parent = LayerProjectileScript.projLayer.transform;
         Missile shotMissile = shot.GetComponent<Missile>();
         shotMissile.target = enemy;
         Debug.Log("Missile target: "+shotMissile.target);
         //add ability modifiers
         shotMissile.damage += ability.damagePlus;
         //Debug.Log(enemy+" : "+shotMissile.target);
         shot.SetActive(true);
     }
     ability.target = new GameObject[ability.maxTargets];
     OnCooldown(globalCooldown);
     //Debug.Log(ability.projectile);
     ability.cooldown = ability.projectile.GetComponent<Missile>().cooldown + ability.cooldownPlus;
     return null;
 }
    public void UseAbility(int slot)
    {
        if (abilityInfo[slot].CD > 0 || GCD > 0)
        {
            return;
        }

        Ability ab = AbilityBook.FindAbility(abilityInfo[slot].ID);

        switch (ab.abilityCostType)
        {
        case Enumeration.AbilityCost.AC_HEALTH:
            break;

        case Enumeration.AbilityCost.AC_MANA:
            break;

        case Enumeration.AbilityCost.AC_NONE:
            break;
        }

        GCD = resetGCD;
        abilityInfo[slot].CD = ab.cooldownTime;
        ab.UseAbility(this);
    }
Esempio n. 3
0
 void GameUpdate()
 {
     if(globalCooldownTimer > 0){
             globalCooldownTimer -= GameHandler.handler.GetDelta();
     }
     if (globalCooldownTimer < 0){
         globalCooldownTimer = 0;
     }
     foreach(AbilityBook ability in abilityBook){
         if(ability.cooldown > 0){
             ability.cooldown -= GameHandler.handler.GetDelta();
         }
         if(ability.cooldown < 0){
             ability.cooldown = 0;
         }
     }
     if (casting == null){
         //check for ready abilities, find targets, cast()
         if (globalCooldownTimer <= 0){
             //Debug.Log(gameObject.name+": "+globalCooldownTimer);
             foreach(AbilityBook ability in abilityBook){
                 if (ability.cooldown <= 0 && ability.isActive){
                     ability.target = CommonClasses.common.FindTargets(gameObject, ability.target, transform.position, ability.range + ability.rangePlus, team, ability.projectile.GetComponent<Missile>().targetAI);
                     if(ability.target[0] != null){
                         casting = ability;
                         if(ability.castTime > 0){
                             castTime = ability.castTime + ability.castTimePlus;
                         }
                     }
                 }
             }
         }
     } else {
         if (castTime > 0){
             castTime -= GameHandler.handler.GetDelta();
         } else {
             casting = Cast(casting);
         }
     }
 }
Esempio n. 4
0
    private void LoadAllAbilities(string str)
    {
        string current = "";
        int    j       = 0;

        //Initilize the basic information for the abilities
        AbilityInfo info;

        info.classType       = System.Type.GetType("Leap");
        info.abilityName     = "";
        info.id              = 0;
        info.resourceCost    = 0;
        info.cooldownTime    = 0;
        info.castTime        = 0;
        info.abilityCostType = Enumeration.AbilityCost.AC_MANA;
        info.abilityTypes    = new List <Enumeration.AbilityType>();
        CurrentRead currentRead = CurrentRead.CR_CLASS;

        // Start reading in the abilities
        for (int i = 0; i < str.Length; i++)
        {
            //Debug.Log(str.Length);

            if (str[i] == '-')
            {
                switch (currentRead)
                {
                case CurrentRead.CR_CLASS:
                    info.classType = System.Type.GetType(current);
                    break;

                case CurrentRead.CR_NAME:
                    info.abilityName = current;
                    break;

                case CurrentRead.CR_ID:
                    info.id = int.Parse(current);
                    break;

                case CurrentRead.CR_COST:
                    info.resourceCost = int.Parse(current);
                    break;

                case CurrentRead.CR_CD:
                    info.cooldownTime = float.Parse(current);
                    break;

                case CurrentRead.CR_CASTTIME:
                    info.castTime = float.Parse(current);
                    break;

                case CurrentRead.CR_TYPES:
                    info.abilityTypes.Add(GetType(current));
                    break;

                case CurrentRead.CR_COSTTYPE:
                    info.abilityCostType = GetCostType(current);
                    break;

                default:
                    break;
                }

                //Debug.Log(current);
                current = "";
                currentRead++;
                if (currentRead == CurrentRead.CR_COUNT)
                {
                    //Create and store the ability into the abilitybook
                    object[] arguments = { info.abilityName, info.id, info.resourceCost, info.cooldownTime, info.castTime, info.abilityTypes.ToArray(), info.abilityCostType };
                    object   myObj     = System.Activator.CreateInstance(info.classType, arguments);
                    AbilityBook.AddAbility((Ability)myObj);
                    info.abilityTypes.Clear();
                    currentRead = CurrentRead.CR_CLASS;
                    i++;
                }
            }
            else if (str[i] == '*')
            {
                break;
            }
            else if (str[i] == '\n')
            {
                continue;
            }
            else
            {
                current += str[i].ToString();
            }
        }
    }