Example #1
0
    public override void UseAbility(AbilityTarget target)
    {
        if (suspended)
        {
            return;
        }

        if (keepTargetRemaining > 0)         // We have a target
        {
            if (!offCooldown)
            {
                return;
            }

            if (stacks < 1)
            {
                return;
            }

            //if (InRange(targetUnit.transform))
            //{
            base.UseAbility(target);

            //Boom();
            DropBombs();

            stacks--;
            DisplayStacks();
            //}
        }

        // While a missile is already active, a new target for the current missile can be selected
    }
Example #2
0
        public static PartyMember[] GetAllTargetsForAbilityStep(PartyMember source, PartyMember primaryTarget, AbilityTarget abilityTarget, AbilityStep abilityStep)
        {
            var menu = MenuModel.Instance;

            var targets = new List<PartyMember> { primaryTarget };

            if (abilityTarget == AbilityTarget.AllFriendly)
            {
                //apply to all party members
                targets.AddRange(new[]
                {
                    GameModel.Instance.PartyMember1,
                    GameModel.Instance.PartyMember2,
                    GameModel.Instance.PartyMember3,
                    GameModel.Instance.PartyMember4
                });
            }
            else if (abilityTarget == AbilityTarget.AnySingleDefaultFriendlyWithSecondaryTargets ||
                     abilityTarget == AbilityTarget.AnySingleDefaultHostileWithSecondaryTargets ||
                     abilityTarget == AbilityTarget.SingleFriendlyWithSecondaryTargets)
            {
                targets.AddRange(abilityStep
                    .GetSecondaryTargets(source, primaryTarget, null)
                    .Select(x => x as PartyMember));
            }

            return targets.Where(x => x != null).Distinct().ToArray();
        }
Example #3
0
    public void Stop()
    {
        hGoalCur     = transform.position;
        reachedHGoal = true;

        manualRotationGoal = null;
    }
Example #4
0
    public override void UseAbility(AbilityTarget target)
    {
        //if (suspended)
        //	return;

        if (!offCooldown)
        {
            return;
        }

        base.UseAbility(target);

        if (swarmController.HasUsed())
        {
            if (target.unit != targetUnit && target.unit != swarmController.GetTargetUnit())
            {
                //targetUnit = target.unit; // swarmController will set this property for us
                swarmController.MoveSwarm(target.unit);
            }
            else             // Unit is already targeted
            {
                ResetCooldown();
            }
        }
        else         // No swarms to control
        {
            ResetCooldown();
        }
    }
Example #5
0
    public void SetHGoal(Vector3 newHGoal, bool group)
    {
        if (suspended)
        {
            return;
        }

        if (abilityGoal != null)         // Can't move while an ability is rotating us
        {
            return;
        }

        float selCircleRadius = parentUnit.GetSelCircleSize() * 1.85f;         // Approximation of visual area inside selection circle graphic

        if (Vector3.SqrMagnitude(new Vector3(newHGoal.x - transform.position.x, newHGoal.z - transform.position.z)) > selCircleRadius * selCircleRadius)
        {
            PathRequestHandler.RequestPath(new PathRequest(transform.position, newHGoal, OnPathFound));

            manualRotationGoal = null; // Clear any current rotation goal
        }
        else                           // Not grouped or clicked outside of selection circle
        {
            if (!reachedHGoal)         // Only able to rotate while stationary
            {
                Stop();
            }
            if (!group)
            {
                manualRotationGoal = new AbilityTarget(newHGoal);
            }
        }
        // else to do if rotation order but grouped
    }
Example #6
0
    public override void UseAbility(AbilityTarget target)
    {
        if (suspended)
        {
            return;
        }

        if (!offCooldown)
        {
            return;
        }

        if (state == 0)
        {
            base.UseAbility(target);
            ResetCooldown();             // Cooldown is applied later

            startTargetTime = Time.time;
            BeginTargeting(target.unit);
        }
        else if (state == 1)
        {
            if (Time.time > startTargetTime + gameRules.ABLY_superlaserCancelTime)
            {
                base.UseAbility(target);
                Reset();
                SetCooldown(gameRules.ABLY_superlaserCancelCDMult);                 // Reduced cooldown
            }
        }
    }
Example #7
0
    }         //UseAbility()

    public void UseCommandWheel(int index)
    {
        if (!HasSelection())
        {
            return;
        }

        foreach (Entity e in selection)
        {
            if (IsUnit(e))
            {
                Unit unit = (Unit)e;

                RaycastHit hit = RaycastFromCursor(1);
                if (hit.collider)
                {
                    AbilityTarget targ = new AbilityTarget(hit.point);
                    unit.OrderCommandWheel(index, targ);
                }
                else
                {
                    unit.OrderCommandWheel(index, null);
                }
            }
        }
    }
Example #8
0
    public Ability(AbilityTemplate template, Entity owner)
    {
        Name                   = template.Name;
        Attribute              = template.Attribute;
        AttributePrereq        = template.AttributePrereq;
        RequiresBackground     = template.RequiresBackground;
        Description            = template.Description;
        RequiresBodyPart       = template.RequiresBodyPart;
        RequiresProperty       = template.RequiresProperty.Trim();
        Dice                   = template.Dice;
        Cooldown               = template.Cooldown;
        Effect                 = template.Effect;
        Range                  = template.Range;
        StartingAbility        = template.StartingAbility;
        RemainingCooldownTurns = 0;
        Owner                  = owner;

        TargetType = (AbilityTarget)Enum.Parse(typeof(AbilityTarget), template.Target.Replace(" ", ""), true);

        if (!string.IsNullOrEmpty(RequiresProperty) && Owner.IsPlayer())
        {
            EventMediator.Instance.SubscribeToEvent(GlobalHelper.ItemEquippedEventName, this);
            EventMediator.Instance.SubscribeToEvent(GlobalHelper.ItemUnequippedEventName, this);
        }
    }
Example #9
0
 public TargeterResolver(AbilityUtil_Targeter targeter, AbilityTarget target, ActorData caster, Ability ability)
 {
     m_targeter        = targeter;
     m_targeterVanilla = targeter;
     m_target          = target;
     m_caster          = caster;
     m_ability         = ability;
 }
    private void HighlightAttackArea(Unit unit)
    {
        AbilityTarget aTarget = unit.GetComponentInChildren <AbilityTarget>();

        foreach (Tile abilityTile in owner.rangeManager.AbilityRangeAndOrigin.Keys)
        {
            HighlightTile(abilityTile, SetColorIntensity(attackColor, lowIntensity));
        }
    }
 //constructor with overload
 public AbilityBase(AbilityEffect _abil_effect, AbilityTarget _abil_target, AbilityAOE _abil_aoe, int _str, int _duration, int _delay)
 {
     Ability_effect = _abil_effect;
     Ability_target = _abil_target;
     Ability_aoe    = _abil_aoe;
     strength       = _str;
     duration       = _duration;
     delay          = _delay;
 }
Example #12
0
    public override void UseAbility(AbilityTarget target)
    {
        if (!offCooldown)
        {
            return;
        }

        base.UseAbility(target);

        ApplyChain(target.unit);
    }
Example #13
0
 /// <summary>
 /// The constructor for an ability setting default values.
 /// </summary>
 /// <param name="cost">by default 2</param>
 /// <param name="intensity">by default 1</param>
 /// <param name="duration">by default 0</param>
 /// <param name="cooldown">by default 5</param>
 /// <param name="target"></param>
 /// <param name="element"></param>
 /// <param name="name"></param>
 /// <param name="description"></param>
 public Ability( int cost = 2, int intensity = 1, int duration = 0, int cooldown = 5, AbilityTarget target = AbilityTarget.None, AbilityElement element = AbilityElement.None, string name = "", string description = "")
 {
     _cost = cost;
     _intensity = intensity;
     _duration = duration;
     _cooldown = cooldown;
     _target = target;
     _element = element;
     if (name != "")
         _name = name;
     else
         GenerateName();
     _description = description;
     GetIcon();
 }
Example #14
0
    public override void UseAbility(AbilityTarget target)
    {
        if (suspended)
        {
            return;
        }

        if (state == 0)         // Standby
        {
            if (!offCooldown)
            {
                return;
            }

            if (stacks < 1)
            {
                return;
            }

            if (InRange(target.unit.transform))
            {
                base.UseAbility(target);
                ResetCooldown();                 // Cooldown is applied later

                startTargetTime = Time.time;
                BeginTargeting(target.unit);
                attemptShotWhen = Time.frameCount + 1;                 // We should start aim checking in 1 frame from now
            }
        }
        else if (state == 1)         // Targeting
        {
            if (Time.time + gameRules.ABLY_ionMissileCancelTime > startTargetTime)
            {
                base.UseAbility(target);
                ResetCooldown();
                Reset();
            }
        }
        else if (state == 2)
        {
            if (InRange(target.unit.transform))
            {
                SwitchTargets(target.unit);
            }
        }

        // While a missile is already active, a new target for the current missile can be selected
    }
Example #15
0
    //private CardAbilityData ability;

    public Player GetPlayerByAbilitiTarget(AbilityTarget target)
    {
        if (target == AbilityTarget.Me)
        {
            return(myPlayer);
        }
        else if (target == AbilityTarget.You)
        {
            return(youPlayer);
        }
        else
        {
            Debug.LogError("アビリティターゲットで想定されていない値");
            return(null);
        }
    }
Example #16
0
    public override void UseAbility(AbilityTarget target)
    {
        if (suspended)
        {
            return;
        }

        if (!offCooldown)
        {
            return;
        }

        base.UseAbility(target);

        ToggleActive();
    }
Example #17
0
    public override void UseAbility(AbilityTarget target)
    {
        if (suspended)
        {
            return;
        }

        if (!offCooldown)
        {
            return;
        }

        base.UseAbility(target);

        ProjectShield(target.unit);
    }
Example #18
0
        public Ability(AbilityTrigger triggerRef, AbilityTarget targetRef, bool stackRef, string nameRef, string internalNameRef, string descriptionRef,
                       int priorityRef, int counterRef, int magnitudeRef, int manaCost)
        {
            m_AbilityTrigger  = triggerRef;
            m_Target          = targetRef;
            m_Stacking        = stackRef;
            m_Name            = nameRef;
            m_InternalName    = internalNameRef;
            m_Description     = descriptionRef;
            m_ReadyForRemoval = false;
            m_Counter         = counterRef;
            m_Magnitude       = magnitudeRef;
            m_Priority        = priorityRef;

            m_ManaCost = manaCost;
        }
Example #19
0
    public override void UseAbility(AbilityTarget target)
    {
        if (suspended)
        {
            return;
        }

        if (target.unit.Team == team)
        {
            return;
        }

        // TODO: TEST ALL POSSIBLE COOLDOWN RESETS
        //if (target.unit.team == team)
        //{
        //	ResetCooldown();
        //	return;
        //}

        // While a missile is already active, a new target for the current missile can be selected
        if (missileActive)
        {
            if (InRange(target.unit.transform))
            {
                targetUnit = target.unit;
            }
        }
        else         // New missile
        {
            if (!offCooldown)
            {
                return;
            }

            base.UseAbility(target);

            if (InRange(target.unit.transform))
            {
                targetUnit = target.unit;
                SpawnMissile();
            }
            else
            {
                ResetCooldown();
            }
        }
    }
Example #20
0
    public override void UseAbility(AbilityTarget target)
    {
        if (suspended)
        {
            return;
        }

        if (!offCooldown)
        {
            return;
        }

        base.UseAbility(target);
        otherMode._StartCooldown();

        SetActive(!isActive);
    }
Example #21
0
    public void fireAbility(AbilityTarget abilityTarget)
    {
        Attackable target = abilityTarget.getAttackableTarget();

        if (target.dead)
        {
            return;
        }
        GameObject gun  = transform.FindChild("Gun").gameObject;
        Shot       shot = Instantiate(bulletObj).GetComponent <Shot>();

        shot.attacker = this;
        float r = 0.25f;

        shot.transform.position = gun.transform.position + new Vector3(Random.Range(-r, r), Random.Range(-r, r), 0);
        Vector2 offset = target.transform.position - gun.transform.position;
        float   angle  = Mathf.Rad2Deg * Mathf.Atan2(offset.y, offset.x);

        shot.transform.localEulerAngles = new Vector3(0, 0, angle);
        //shot.transform.rotation = gun.transform.rotation;
        shot.GetComponent <Rigidbody2D>().velocity = 20 * shot.transform.right;
        shot.setTarget(target);
    }
Example #22
0
    public override void UseAbility(AbilityTarget target)
    {
        if (suspended)
        {
            return;
        }

        if (!offCooldown)
        {
            return;
        }

        base.UseAbility(target);

        //if (SpawnSwarm()) // If spawn cast succeeds, also cast move
        //	MoveSwarm(parentUnit, true);
        //else // If cast fails, reset cooldown
        //	ResetCooldown();

        if (!SpawnSwarm())         // If spawn cast fails, reset cooldown
        {
            ResetCooldown();
        }
    }
Example #23
0
        public static BattleEntityInBattle[] GetAllTargetsForAbilityStep(BattleEntityInBattle source, BattleEntityInBattle primaryTarget, AbilityTarget abilityTarget, AbilityStep step)
        {
            switch (abilityTarget)
            {
                case AbilityTarget.AnySingleDefaultFriendly:
                case AbilityTarget.AnySingleDefaultHostile:
                case AbilityTarget.SingleFriendlyOnly:
                case AbilityTarget.SingleHostileOnly:
                    //no additional targets, just return the primary target
                    return new[] { primaryTarget };
                case AbilityTarget.AnySingleDefaultFriendlyWithSecondaryTargets:
                case AbilityTarget.AnySingleDefaultHostileWithSecondaryTargets:
                case AbilityTarget.SingleFriendlyWithSecondaryTargets:
                case AbilityTarget.SingleHostileWithSecondaryTargets:
                    //add additional targets
                    var allTargetsWithPrimary = new List<BattleEntityInBattle> { primaryTarget };
                    allTargetsWithPrimary.AddRange(step.GetSecondaryTargets(source.BattleEntity, primaryTarget.BattleEntity, BattleModel.Instance.BattleData)
                        .Select(GetBattleEntityInBattleByBattleEntity));
                    return allTargetsWithPrimary.Distinct().ToArray();
                case AbilityTarget.AllFriendly:
                    //there is no 'primary' target, just return all alive friendly targets
                    return GetAllAliveFriendlyTargets(source);
                case AbilityTarget.AllHostile:
                    //there is no 'primary' target, just return all alive hostile targets
                    return GetAllAliveHostileTargets(source);
                case AbilityTarget.All:
                    //everything is a target!
                    var allTargets = new List<BattleEntityInBattle>();
                    allTargets.AddRange(GetAllAliveFriendlyTargets(source));
                    allTargets.AddRange(GetAllAliveHostileTargets(source));
                    return allTargets.Distinct().ToArray(); //just incase something is added twice
            }

            //should never reach this
            return new[] { primaryTarget };
        }
Example #24
0
 public override void Deserialize(NetworkReader reader)
 {
     ActorIndex = reader.ReadInt32();
     ActionType = (AbilityData.ActionType)reader.ReadInt32();
     Targets    = AbilityTarget.DeSerializeAbilityTargetList(reader);
 }
Example #25
0
 public override void Serialize(NetworkWriter writer)
 {
     writer.Write(ActorIndex);
     writer.Write((int)ActionType);
     AbilityTarget.SerializeAbilityTargetList(Targets, writer);
 }
Example #26
0
    void UseAbility(int index)
    {
        //return;

        if (!HasSelection())
        {
            return;
        }

        // If we are dealing with a mixed group of units, don't use abilities
        EntityType type = EntityType.Default;

        foreach (Entity e in selection)
        {
            // TODO: Check by abilities rather than types
            if (type == EntityType.Default)
            {
                type = e.Type;
            }
            else if (e.Type != type)
            {
                return;
            }

            /*
             * if (IsUnit(e))
             * {
             *      Unit unit = (Unit)e;
             *      if (type == EntityType.Default)
             *              type = unit.type;
             *      else if (unit.type != type)
             *              return;
             * }
             */
        }

        foreach (Entity e in selection)
        {
            if (IsUnit(e))
            {
                Unit unit = (Unit)e;

                // Don't have that many abilities
                if (unit.abilities.Count < index + 1)
                {
                    return;
                }

                //AbilityOld current = unit.abilities[index];
                Ability current = unit.abilities[index];

                if (AbilityUtils.GetTargetRequirement(current.GetAbilityType()) == 0)                 // Targets nothing
                {
                    unit.OrderAbility(index, null);
                }
                else if (AbilityUtils.GetTargetRequirement(current.GetAbilityType()) == 1)                 // Targets a unit
                {
                    Entity ent = GetEntityFromHit(RaycastFromCursor(0));
                    // Treat invisible entities as if they don't exist
                    // TODO: Is it visible ON THE SERVER?
                    if (ent)
                    {
                        ent = ent.VisibleBy(team) ? ent : null;
                    }
                    if (ent && IsUnit(ent))
                    {
                        AbilityTarget targ = new AbilityTarget((Unit)ent);
                        unit.OrderAbility(index, targ);
                    }
                }
                else if (AbilityUtils.GetTargetRequirement(current.GetAbilityType()) == 2)                 // Targets a position
                {
                    RaycastHit hit = RaycastFromCursor(1);
                    if (hit.collider)
                    {
                        AbilityTarget targ = new AbilityTarget(hit.point);
                        unit.OrderAbility(index, targ);
                    }
                }
            } //if IsUnit
        }     //foreach
    }         //UseAbility()
 public TargeterResolver_BounceLaser(AbilityUtil_Targeter targeter, AbilityTarget target, ActorData caster, Ability ability, int targeterIndex)
     : base(targeter, target, caster, ability)
 {
     OverrideTargeter(new Targeter_BounceLaser(targeter as AbilityUtil_Targeter_BounceLaser, ability), targeterIndex);
 }
Example #28
0
    // runs debuff & buffs
    IEnumerator RunAbilityEffects(AbilityEffects effects, Piece source, Piece target, AbilityTarget abilityTarget)
    {
        //stat boosting
        if (effects.Boosts != null)
        {
            if (abilityTarget == AbilityTarget.Self)
            {
                source.ApplyBoost(effects.Boosts);
            }
            else
            {
                target.ApplyBoost(effects.Boosts);
            }
        }

        // cheecks to see what type of status condtion effect
        if (effects.Status != ConditionID.none)
        {
            target.SetStatus(effects.Status);
        }

        // cheecks to see what type of volatile status condtion effect
        if (effects.VolatileStatus != ConditionID.none)
        {
            target.SetVolatileStatus(effects.VolatileStatus);
        }

        //calls function to show after applying stat
        yield return(ShowStatusChanges(source));

        yield return(ShowStatusChanges(target));
    }
        //cost

        //used for generating a random ability
        public AbilityBase GenerateAbility(string seed)
        {
            AbilityBase ability = new AbilityBase();

            //make sure that it is all uppercase
            seed = seed.ToLower();

            //seeds consist of 7 letters
            //effect; damage, heal
            if (seed.Length > 0)
            {
                for (int ability_number = 0; ability_number < seed.Length; ability_number++)
                {
                    //convert letter to int
                    int integer = ConvertAlphabetToInteger(seed[ability_number].ToString());

                    //loop for going through the alphabet
                    for (int number = 0; number < 27; number++)
                    {
                        if (integer == number)
                        {
                            switch (ability_number)
                            {
                            case 0:     //ability effect
                                Ability_effect = (AbilityEffect)number;
                                break;

                            case 1:     //ability target
                                Ability_target = (AbilityTarget)number;
                                break;

                            case 2:     //ability aoe
                                Ability_aoe = (AbilityAOE)number;
                                break;

                            case 3:     //strength
                                strength = number;
                                break;

                            case 4:     //duration
                                duration = number;
                                break;

                            case 5:     //delay
                                delay = number;
                                break;
                            }

                            //break out of loop
                            break;
                        }
                    }
                }

                ability = new AbilityBase(
                    Ability_effect,
                    Ability_target,
                    Ability_aoe,
                    strength,
                    duration,
                    delay
                    );

                /* Debug.Log(
                 * "Effect: " + ability.Ability_effect + "\n" +
                 * "Target: " + ability.Ability_target + "\n" +
                 * "AoE: " + ability.Ability_aoe + "\n" +
                 * "Strength: " + ability.strength + "\n" +
                 * "Duration: " + ability.duration + "\n" +
                 * "Delay: " + ability.delay
                 * );
                 */
            }

            return(ability);
        }
Example #30
0
 protected override TargeterResolver MakeTargeterResolver(Ability ability, int index, AbilityUtil_Targeter targeter, AbilityTarget target, ActorData caster)
 {
     return(new TargeterResolver_BounceLaser(targeter, target, caster, ability, index));
 }
Example #31
0
 /// <summary>
 /// Loading method
 /// </summary>
 /// <param name="reader"></param>
 public void Load(XmlReader reader)
 {
     _name = reader.GetAttribute("name");
     _icon = new ImageData(
         reader.GetAttribute("iconfile"),
         new Rectangle(Convert.ToInt32(reader.GetAttribute("clipRectX")),
         Convert.ToInt32(reader.GetAttribute("clipRectY")),
         Convert.ToInt32(reader.GetAttribute("clipRectW")),
         Convert.ToInt32(reader.GetAttribute("clipRectH"))),
         new Coords(Convert.ToInt32(reader.GetAttribute("iconoffsetX")),
         Convert.ToInt32(reader.GetAttribute("iconoffsetY"))),
         new Coords(Convert.ToInt32(reader.GetAttribute("iconcropX")),
         Convert.ToInt32(reader.GetAttribute("iconcropY"))));
     _description = reader.GetAttribute("description");
     _cost = Convert.ToInt32(reader.GetAttribute("cost"));
     _intensity = Convert.ToInt32(reader.GetAttribute("intensity"));
     _duration = Convert.ToInt32(reader.GetAttribute("duration"));
     _cooldown = Convert.ToInt32(reader.GetAttribute("cooldown"));
     _currentCool = Convert.ToInt32(reader.GetAttribute("currentCool"));
     if (reader.GetAttribute("target") != null)
         _target = (AbilityTarget)Enum.Parse(typeof(AbilityTarget), reader.GetAttribute("target"));
     if (reader.GetAttribute("element") != null)
         _element = (AbilityElement)Enum.Parse(typeof(AbilityElement), reader.GetAttribute("element"));
 }
Example #32
0
 public virtual void UseAbility(AbilityTarget targ)
 {
     //target = targ;
     StartCooldown();
 }
Example #33
0
 // based on AbilityUtil_Targeter_Grid
 private static BoardSquare GetGameplayRefSquare(AbilityTarget currentTarget, ActorData targetingActor)
 {
     return(Board.Get().GetSquare(currentTarget.GridPos));
 }
Example #34
0
        // copied from AbilityUtil_Targeter_Grid
        private static Vector3 GetHighlightGoalPos(AbilityUtil_Targeter_Grid targeter, AbilityTarget currentTarget, ActorData targetingActor)
        {
            BoardSquare gameplayRefSquare = GetGameplayRefSquare(currentTarget, targetingActor);

            if (gameplayRefSquare != null)
            {
                Vector3 centerOfGridPattern            = AreaEffectUtils.GetCenterOfGridPattern(targeter.m_pattern, currentTarget.FreePos, gameplayRefSquare);
                Vector3 travelBoardSquareWorldPosition = targetingActor.GetTravelBoardSquareWorldPosition();
                centerOfGridPattern.y = travelBoardSquareWorldPosition.y + 0.1f;
                return(centerOfGridPattern);
            }
            return(Vector3.zero);
        }