Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        mutatorManager      = GetComponent <AbilityMutatorManager>();
        myAlignmentManager  = GetComponent <AlignmentManager>();
        myTaggedStatsHolder = GetComponent <TaggedStatsHolder>();

        myCreationReferences = GetComponent <CreationReferences>();
        myHitDetector        = GetComponent <HitDetector>();
    }
Ejemplo n.º 2
0
    public static AbilityMutatorManager GetOrAdd(GameObject _gameObject)
    {
        AbilityMutatorManager ret = _gameObject.GetComponent <AbilityMutatorManager>();

        if (ret)
        {
            return(ret);
        }
        return(_gameObject.AddComponent <AbilityMutatorManager>());
    }
Ejemplo n.º 3
0
 protected virtual void Awake()
 {
     // get a reference to the mutator manager
     mutatorManager = GetComponent <AbilityMutatorManager>();
     if (mutatorManager == null)
     {
         mutatorManager = gameObject.AddComponent <AbilityMutatorManager>();
     }
     // add to list
     mutatorManager.mutators.Add(this);
     // add to dictionary
     if (ability != null)
     {
         mutatorManager.addMutator(this);
     }
 }
Ejemplo n.º 4
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);
    }