public void Initialize(BuffConfiguration newConfiguration, ElementType[] newAffinity, BattleNPC newCaster = null)
 {
     m_Configuration    = newConfiguration;
     m_BuffActiveObject = _createBuffActive(newConfiguration);
     m_SkillAffinity    = newAffinity;
     m_Caster           = newCaster;
 }
Esempio n. 2
0
 public BuffByte(BuffByteConfig newConfiguration, BuffActive newController, BattleNPC caster)
 {
     Configuration = newConfiguration;
     Controller    = newController;
     BuffCaster    = caster;
     BuffDiff      = 0;
 }
Esempio n. 3
0
 public override void OnSkillByteHit(BattleNPC collisionNPC, float damageMultiplier = 1.0f)
 {
     base.OnSkillByteHit(collisionNPC, damageMultiplier);
     ParentSkill.SkillOwner.FlipBattleNPCSpriteX();
     ParentSkill.SkillSpriteRenderer.enabled = false;
     ParentSkill.AdvanceToNextByte();
 }
Esempio n. 4
0
    /*
     * Check if this skill is configured to hit this BattleNPC
     * @param: b - BattleNPC beam says it hit
     * @returns: bool - true if configured to hit b, false if not configured to hit b
     */
    private bool _checkValidDamage(BattleNPC hitNPC)
    {
        bool heroTeam = BattleGlobals.IsHeroTeamTag(hitNPC.tag);

        return(otherTeamValidTargets || (Target == TargetType.AnyTarget) ||
               ((Target == TargetType.AlliedTargets) && heroTeam) ||
               ((Target == TargetType.EnemyTargets) && !heroTeam));
    }
Esempio n. 5
0
 private void Update()
 {
     if (!changedToAlly && isAlly)
     {
         changedToAlly = true;
         me            = new BattleNPC(myBaseDamage, myBaseDefense, myStrength, myWeakness, true);
         me.SetName(myName);
     }
 }
    protected float ChannelingOnSkillHit(BattleNPC hitNPC, float timeToCheck)
    {
        bool intervalTime = _channelInterval(timeToCheck);

        if (intervalTime)
        {
            OnSkillByteHit(hitNPC);
            return(Time.fixedTime);
        }
        return(-1.0f);
    }
Esempio n. 7
0
 /*
  * Because TargetSignature affords more than one target, need to check more than one index now
  */
 public override int CheckValidTarget(BattleNPC checkNPC)
 {
     for (int index = 0; index < NPCTargets.Length; index++)
     {
         if (NPCTargets[index].Focus == checkNPC)
         {
             return(index);
         }
     }
     return(-1);
 }
Esempio n. 8
0
    private void _createBuffBytes(List <BuffByteConfig> configArray, BattleNPC caster)
    {
        List <BuffByte> temporaryList = new List <BuffByte>();

        foreach (BuffByteConfig config in configArray)
        {
            BuffByte buff = config.GenerateBuffByteFromByteType(this, caster);
            buff.Configuration.CustomFloat = m_Configuration.CustomFloat;
            temporaryList.Add(buff);
        }
        m_ManagedBuffs = temporaryList.ToArray();
    }
Esempio n. 9
0
    /*
     * This function checks our damage pulse time per target
     * (e.g. Target 2 can be hit by damage even if the pulse time on Target1 isn't up)
     * @param: BattleNPC - BattleNPC that intercepted the beam
     */
    private void _checkConditionsOnSkillHit(BattleNPC hitNPC)
    {
        bool canHit = _checkValidDamage(hitNPC);

        if (canHit)
        {
            int prevTimeIndex = _hitBattleNPCbefore(hitNPC);

            float temp = ChannelingOnSkillHit(hitNPC, m_PreviousTargetTime[prevTimeIndex]);
            m_PreviousTargetTime[prevTimeIndex] = (temp > 0) ? temp : m_PreviousTargetTime[prevTimeIndex];
        }
    }
Esempio n. 10
0
    /*
     * Gets the PrevTargetHit entry for BattleNPC, b
     * or creates one based on the time
     * param: b - BattleNPC to check and see if we've hit before
     * returns: int - index of prevTargetTime for the battleNPC (even if it's a new battleNPC)
     */
    private int _hitBattleNPCbefore(BattleNPC hitNPC)
    {
        int i = m_PreviousTarget.IndexOf(hitNPC);

        if (i == -1)
        {
            m_PreviousTarget.Add(hitNPC);
            m_PreviousTargetTime.Add(Time.fixedTime - DamageInterval);
            i = (m_PreviousTargetTime.Count - 1);
        }
        return(i);
    }
Esempio n. 11
0
 /*
  * When a skill hits it's target, apply OnHit buffs
  * @param: target - if (de)buffs are to be applied to target, this is the target
  * @param: dmg    - the damage the skill did, if the buff relies on dmg dealt
  */
 protected virtual void ApplyOnHitBuffs(BattleNPC target, int damage)
 {
     if (OnHitBuffs.Count > 0)
     {
         foreach (BuffApplicator tempBuffController in OnHitBuffs)
         {
             BattleNPC buffTarget = (tempBuffController.CheckTargetType(BuffConfiguration.TargetType.Self)) ?
                                    ParentSkill.SkillOwner : target;
             tempBuffController.OnSkillHit(buffTarget, damage);
         }
     }
 }
    private void _applyBuffWhenPassesChance(BattleNPC targetNPC)
    {
        bool passedChanceToHit = GameGlobals.CheckPercentHitChance(m_Configuration.ChanceToApply);

        if (passedChanceToHit)
        {
            BuffActive newActive = Instantiate(m_BuffActiveObject, targetNPC.transform);
            newActive.gameObject.SetActive(true);
            targetNPC.RegisterBuff(newActive);
            newActive.Initialize(m_Configuration, m_SkillAffinity, m_Caster);
            newActive.StartBuffs(targetNPC);
        }
    }
Esempio n. 13
0
 // Use this for initialization
 void Awake()
 {
     m_Rigid2d         = GameGlobals.AttachCheckComponent <Rigidbody2D>(this.gameObject);
     m_ParentSkillByte = GameGlobals.AttachCheckComponentParent <ProjectileAttackByte>(this.gameObject);
     m_SpriteRenderer  = GameGlobals.AttachCheckComponent <SpriteRenderer>(this.gameObject);
     this.tag          = (BattleGlobals.IsHeroTeamTag(m_ParentSkillByte.ParentSkill.SkillOwner.tag)) ?
                         BattleGlobals.TAG_FOR_HERO_PROJ : BattleGlobals.TAG_FOR_ENEMY_PROJ;
     this.name = GameGlobals.TrimCloneFromName(this.name) +
                 "(" + m_ParentSkillByte.ParentSkill.SkillOwner + ")";
     // If the object is homing, this does not matter
     m_ProjDirection = (this.gameObject.CompareTag(BattleGlobals.TAG_FOR_HERO_PROJ)) ?
                       Vector2.left : Vector2.right;
     m_mainTarget = null;
 }
Esempio n. 14
0
 /*
  * This is called separately because in multi-target spells it's better the skill set the target,
  * than the projectile query the skill for a target
  */
 public void SetTargetAndDamage(BattleNPC target, float damageMultiplier)
 {
     m_mainTarget = target;
     m_ProjectileDamageMultiplier = damageMultiplier;
     if (m_ProjectileDamageMultiplier == 0)
     {
         m_ParentSkillByte.DeRegisterProjectile(this);
     }
     else
     {
         m_Rigid2d.transform.rotation = BattleGlobals.LookAt(this.gameObject,
                                                             target.StartPuck.transform.position, this.tag);
     }
 }
Esempio n. 15
0
 public virtual void OnSkillByteHit(BattleNPC collisionNPC, float damageMultiplier = 1.0f)
 {
     // Hit *a* target
     if (collisionNPC != null)
     {
         int damage = (m_Damage != null) ? _applyDamageToBattleNPC(collisionNPC, damageMultiplier) : 0;
         SetSkillHitStatus(damage, collisionNPC.Alive);
         ApplyOnHitBuffs(collisionNPC, damage);
         ParentSkill.RegisterCumulative(damage);
     }
     else // Missed Target
     {
         SetSkillHitStatus(0, true);
     }
 }
Esempio n. 16
0
    public override void DoByte()
    {
        AnimateOwner(BattleGlobals.ANIMATE_NPC_ATTACK);

        ApplyOnCastBuffs();

        // Check if byte should end
        bool interrupted = CheckInterruptedByDamage();
        bool channelOver = CheckChannelTime();

        if (interrupted || !channelOver)
        {
            ParentSkill.SkillSpriteRenderer.enabled = false;
            ParentSkill.AdvanceToNextByte();
            return;
        }

        if (Homing)
        {
            m_TargetPosition = NPCTargets[BEAM_PRIMARY_TARGET].Focus.transform.position;
        }

        RaycastHit2D[] hit         = Physics2D.LinecastAll(m_BeamStart.transform.position, m_TargetPosition, m_TargetMask);
        Vector3        endPosition = m_TargetPosition;

        foreach (RaycastHit2D r in hit)
        {
            if (r.collider != null)
            {
                BattleNPC b = GameGlobals.AttachCheckComponentChildren <BattleNPC>(r.collider.gameObject);
                if ((b != null) && b.Alive)
                {
                    endPosition = r.point;
                    _checkConditionsOnSkillHit(b);
                    break;
                }
            }
        }
        GameGlobals.Stretch(m_BeamMiddle.gameObject, m_BeamStart.transform.position,
                            endPosition, m_PositiveDirection);
        m_BeamEnd.transform.position = endPosition;

        if (Homing)
        {
            _updateRotation();
        }
    }
Esempio n. 17
0
    private void SelectAlly()
    {
        allySelectionEffectController.SelectingOneTarget(indexOfAllyList[indexOfAlly]);

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            if (indexOfAlly == 0)
            {
                indexOfAlly = 0; // currentAllyList.Count-1;
            }
            else
            {
                indexOfAlly -= 1;
            }
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            if (indexOfAlly == currentAllyList.Count - 1)
            {
                indexOfAlly = currentAllyList.Count - 1; // 0;
            }
            else
            {
                indexOfAlly += 1;
            }
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            // store selected ally from the index
            selectedAlly = currentAllyList[indexOfAlly];
            // remove selected ally from allyList
            currentAllyList.RemoveAt(indexOfAlly);
            // add selected and stored ally into selectedAllyList for further function or add action respectively
            selectedAllyList.Add(selectedAlly);
            currentState = SelectionState.ACTION;

            indexOfAllyList.RemoveAt(indexOfAlly);
            indexOfAlly = 0;

            // off indicator
            allySelectionEffectController.SelectingOneTarget(-1);

            // debug
            Debug.Log("Selected Ally: " + selectedAlly.GetName());
        }
    }
Esempio n. 18
0
 public override void Behavior()
 {
     base.Behavior();
     for (int i = 0; i < myTargetList.Count; i++)
     {
         BattleNPC temp       = myTargetList[i];
         Monster   tempTarget = (Monster)temp;
         float     hp         = tempTarget.GetMyHP();
         float     damage     = thisNPC.GetBaseDamage() + thisNPC.GetDamage();
         float     defense    = tempTarget.GetBaseDefense() + tempTarget.GetDefense();
         if (damage > defense)
         {
             damage = damage - defense;
             hp    -= damage;
         }
         tempTarget.SetMyHP(hp);
     }
 }
Esempio n. 19
0
    public override void Behavior()
    {
        base.Behavior();

        for (int i = 0; i < myTargetList.Count; i++)
        {
            BattleNPC temp       = myTargetList[i];
            Monster   tempTarget = (Monster)temp;
            float     hp         = tempTarget.GetMyHP();
            float     damage     = GirlController.Instance.GetEQ() + thisKnowledge.GetValue();
            float     defense    = tempTarget.GetBaseDefense() + tempTarget.GetDefense();
            if (damage > defense)
            {
                damage = damage - defense;
                hp    -= damage;
            }
            tempTarget.SetMyHP(hp);
        }
    }
Esempio n. 20
0
    private int _applyDamageToBattleNPC(BattleNPC target, float damageMultiplier)
    {
        int damage = 0;

        for (int index = 0; index < m_Damage.NumberOfHits; index++)
        {
            int baseDamage = Convert.ToInt32(damageMultiplier *
                                             m_Damage.GetSkillDamage(m_StartFlightTime, ParentSkill.CumulativeDamage));
            target.DeltaHitPointsList.Add(
                new SkillDamagePacket()
            {
                Affinity       = ParentSkill.AffinityTypes,
                Caster         = ParentSkill.SkillOwner,
                BaseSkillDelta = baseDamage
            });
            damage += baseDamage;
        }
        return(damage);
    }
Esempio n. 21
0
    protected override void OnEnable()
    {
        base.OnEnable();

        m_PreviousTarget     = new List <BattleNPC>();
        m_PreviousTargetTime = new List <float>();
        m_BeamStart.flipX    = m_DefaultStartFlipX;
        m_BeamEnd.flipX      = m_DefaultEndFlipX;

        Vector3 beamStartPos = BEAM_START_OFFSET;

        if (ParentSkill.SkillOwner.CompareTag(BattleGlobals.TAG_FOR_ENEMIES))
        {
            ParentSkill.ToggleSpriteFlipX();
            beamStartPos = -1 * beamStartPos;
        }
        beamStartPos += this.gameObject.transform.position;

        beamStart.tag                  = BattleGlobals.TAG_FOR_ENEMY_PROJ;
        m_PositiveDirection            = true;
        m_BeamStart.transform.position = beamStartPos;

        if ((NPCTargets != null))
        {
            BattleNPC primary = NPCTargets[BEAM_PRIMARY_TARGET].Focus;
            if (beamStartPos.x > primary.transform.position.x)
            {
                m_BeamStart.flipX   = !m_DefaultStartFlipX;
                m_BeamEnd.flipX     = !m_DefaultEndFlipX;
                m_PositiveDirection = false;
                m_BeamStart.tag     = BattleGlobals.TAG_FOR_HERO_PROJ;
            }
            m_TargetPosition = primary.StartPuck.transform.position;
        }

        _updateRotation();

        m_BeamStart.enabled  = true;
        m_BeamMiddle.enabled = true;
        m_BeamEnd.enabled    = true;
    }
Esempio n. 22
0
    // controllable action constructor
    public Action(BattleNPC me)
    {
        thisNPC = me;

        if (myTargetList != null)
        {
            // clear target list in case myTargetList is the previous list
            myTargetList.Clear();
        }
        else
        {
            // initiate
            myTargetList = new List <BattleNPC>();
        }
        //reset defense point
        if (thisNPC.GetDefendBool() == true)
        {
            thisNPC.SetDefense(thisNPC.GetDefense() + 10);
            thisNPC.SetDefendBool(false);
        }
    }
Esempio n. 23
0
    // This handles the logic for the projectile "connecting" with it's target
    public void OnTriggerEnter2D(Collider2D collision)
    {
        BattleNPC colNPC = collision.gameObject.GetComponentInChildren <BattleNPC>();

        if (colNPC != null)
        {
            if (!m_ParentSkillByte.Blockable)
            {
                if ((m_mainTarget != null) && (m_mainTarget == colNPC))
                {
                    if (m_ProjectileDamageMultiplier != 0)
                    {
                        m_ParentSkillByte.OnSkillByteHit(colNPC, m_ProjectileDamageMultiplier);
                    }
                    m_ParentSkillByte.DeRegisterProjectile(this);
                }
            }
            else
            {
                SkillByte.TargetType targetType = m_ParentSkillByte.Target;
                bool isValidTarget = (targetType == SkillByte.TargetType.AnyTarget)
                                     ||
                                     ((targetType == SkillByte.TargetType.AlliedTargets) &&
                                      !BattleGlobals.IsHostileToTag(this.tag, colNPC.tag))
                                     ||
                                     ((targetType == SkillByte.TargetType.EnemyTargets) &&
                                      BattleGlobals.IsHostileToTag(this.tag, colNPC.tag));
                if (colNPC.Alive && isValidTarget)
                {
                    if (m_ProjectileDamageMultiplier != 0)
                    {
                        m_ParentSkillByte.OnSkillByteHit(colNPC, m_ProjectileDamageMultiplier);
                    }
                    m_ParentSkillByte.DeRegisterProjectile(this);
                }
            }
        }
    }
Esempio n. 24
0
    public virtual void OnTriggerEnter2D(Collider2D collision)
    {
        BattleNPC colNPC = collision.gameObject.GetComponentInChildren <BattleNPC>();

        if (colNPC != null)
        {
            if (!Blockable)
            {
                int targetIndex = CheckValidTarget(colNPC);
                if ((targetIndex != -1))
                {
                    OnSkillByteHit(NPCTargets[targetIndex].Focus, NPCTargets[targetIndex].Multiplier);
                }
            }
            else
            {
                if (colNPC.Alive && BattleGlobals.IsHostileToTag(ParentSkill.SkillOwner.tag, colNPC.tag))
                {
                    OnSkillByteHit(colNPC);
                }
            }
        }
    }
Esempio n. 25
0
 public void StartBuffs(BattleNPC target)
 {
     BuffTarget = target;
     foreach (BuffByte temporaryByte in m_ManagedBuffs)
     {
         temporaryByte.ApplyBuff(temporaryByte.Configuration.BuffAmount);
         if (m_Configuration.DurationMeasure == BuffConfiguration.DurationType.Permanent)
         {
             m_CompletedBuffBytes++;
         }
         else
         {
             m_SpriteRenderer.enabled = true;
             float interval = (m_Configuration.DegradeSecondsInterval < m_Configuration.DurationSeconds) ?
                              m_Configuration.DegradeSecondsInterval : m_Configuration.DurationSeconds;
             secondsTimer = new TimerSeconds(m_Configuration.DurationSeconds, interval);
             int currentSkills = (m_Configuration.DurationMeasure == BuffConfiguration.DurationType.SkillDamage) ?
                                 BuffTarget.SkillsHitByThisBattle : BuffTarget.SkillsDoneThisBattle;
             skillTimer = new TimerSkillCount(currentSkills, currentSkills + m_Configuration.DurationSkills,
                                              BuffTarget, m_Configuration.DurationMeasure);
             m_Active = true;
         }
     }
 }
 public CurrentHealthBuffByte(BuffByteConfig newConfiguration, BuffActive newController, BattleNPC caster) :
     base(newConfiguration, newController, caster)
 {
 }
Esempio n. 27
0
 public ReadinessBuffByte(BuffByteConfig newConfiguration, BuffActive newController, BattleNPC caster) :
     base(newConfiguration, newController, caster)
 {
 }
 public SkillDropBuffByte(BuffByteConfig newConfiguration, BuffActive newController, BattleNPC caster) :
     base(newConfiguration, newController, caster)
 {
 }
Esempio n. 29
0
 /*
  * returns -1 if NPC isn't a valid target
  */
 public virtual int CheckValidTarget(BattleNPC checkNPC)
 {
     return((NPCTargets[PRIMARY_SKILL_BYTE_TARGET_INDEX].Focus == checkNPC) ? PRIMARY_SKILL_BYTE_TARGET_INDEX : -1);
 }
Esempio n. 30
0
    public BuffByte GenerateBuffByteFromByteType(BuffActive newController, BattleNPC caster)
    {
        BuffByte returnObject = null;

        switch (ByteType)
        {
        case BuffByteType.Cleanse:
            returnObject = new CleanseBuffByte(this, newController, caster);
            break;

        case BuffByteType.Current_Health:
            returnObject = new CurrentHealthBuffByte(this, newController, caster);
            break;

        case BuffByteType.Delayed_Revive:
            returnObject = new DelayedReviveBuffByte(this, newController, caster);
            break;

        case BuffByteType.Experience:
            returnObject = new ExperienceBuffByte(this, newController, caster);
            break;

        case BuffByteType.Flat_Resistance:
            returnObject = new FlatResistanceBuffByte(this, newController, caster);
            break;

        case BuffByteType.Martyr:
            returnObject = new MartyrBuffByte(this, newController, caster);
            break;

        case BuffByteType.Maximum_Health:
            returnObject = new MaxHealthBuffByte(this, newController, caster);
            break;

        case BuffByteType.Move_Speed:
            returnObject = new MoveSpeedBuffByte(this, newController, caster);
            break;

        case BuffByteType.Readiness:
            returnObject = new ReadinessBuffByte(this, newController, caster);
            break;

        case BuffByteType.Resistance:
            returnObject = new ResistanceBuffByte(this, newController, caster);
            break;

        case BuffByteType.Retaliate:
            returnObject = new RetaliateBuffByte(this, newController, caster);
            break;

        case BuffByteType.Skill_Drop:
            returnObject = new SkillDropBuffByte(this, newController, caster);
            break;

        case BuffByteType.Skill_Level:
            returnObject = new SkillLevelBuffByte(this, newController, caster);
            break;

        case BuffByteType.Stun:
            returnObject = new StunDebuffByte(this, newController, caster);
            break;

        case BuffByteType.Taunt:
            returnObject = new TauntDebuffByte(this, newController, caster);
            break;

        default:
            break;
        }
        return(returnObject);
    }