Пример #1
0
 public override void Activate(GameObject actor, GameObject target)
 {
     base.Activate(actor, target);
     if (target.GetComponent <BuffReceiver>())
     {
         BuffReceiver receiver = target.GetComponent <BuffReceiver>();
         if (receiver.buffs.Any(item => item.buffType == buff.buffType) == true)
         {
             //BaseBuff temp = receiver.buffs.First(item => item.buffType == buff.buffType);
             foreach (var item in receiver.buffs.ToArray())
             {
                 if (item.buffType == buff.buffType)
                 {
                     item.Activate(receiver);
                     receiver.RemoveBuff(item);
                 }
             }
             //temp.Activate(receiver);
         }
         if (receiver.buffs.Any(item => item.ID == buff.ID) == false)
         {
             receiver.AddBuff(buff);
         }
     }
 }
Пример #2
0
 void LateUpdate()
 {
     if (isActivated == false)
     {
         return;
     }
     foreach (var item in players)
     {
         if (item == null)
         {
             continue;
         }
         BuffReceiver receiver = item.GetComponent <BuffReceiver>();
         if (receiver.gameObject == null)
         {
             return;
         }
         if (receiver.buffs.Any(p => p.buffType == buff.buffType) == true)
         {
             if (receiver.gameObject == null)
             {
                 return;
             }
             return;
         }
         if (receiver.buffs.Any(p => p.ID == buff.ID) == false)
         {
             receiver.AddBuff(buff);
         }
     }
 }
Пример #3
0
 public IEnumerator OvertimeEffect(BuffReceiver receiver)
 {
     while (true)
     {
         receiver.GetComponent <Health>().AddHp(heal);
         yield return(new WaitForSeconds(effectInterval));
     }
 }
Пример #4
0
    public IEnumerator Duration(BuffReceiver receiver)
    {
        yield return(new WaitForSeconds(duration));

        StopCoroutine(OvertimeEffect(receiver));
        Deactivate(receiver);
        receiver.RemoveBuff(this);
    }
Пример #5
0
 public virtual void Activate(BuffReceiver receiver)
 {
     isActivated = !isActivated;
     if (particle != null)
     {
         tempParticle = Instantiate(particle.gameObject, receiver.transform);
         tempParticle.transform.localPosition = Vector3.zero;
     }
     EventOnActivated.Invoke();
 }
Пример #6
0
    public virtual void OnTriggerEnter2D(Collider2D col)
    {
        BuffReceiver receiver = col.GetComponent <BuffReceiver>();

        if (receiver == null)
        {
            return;
        }
        players.Add(receiver.GetComponent <PlayerController>());
    }
 public IEnumerator OvertimeEffect(BuffReceiver receiver)
 {
     while (true)
     {
         if (receiver.GetComponent <Health>().fireModifier > 0)
         {
             receiver.GetComponent <Health>().DeductHpWhileInvulnerable(damage);
         }
         yield return(new WaitForSeconds(effectInterval));
     }
 }
Пример #8
0
    public virtual void OnTriggerExit2D(Collider2D col)
    {
        BuffReceiver receiver = col.GetComponent <BuffReceiver>();

        if (receiver == null)
        {
            return;
        }
        if (col.gameObject.tag == "Player" && players.Any(player => player.ID == col.gameObject.GetComponent <PlayerController>().ID))
        {
            players.Remove(col.gameObject.GetComponent <PlayerController>());
        }
        if (players.Count == 0 && autoDeactivate)
        {
            EventDeactivate.Invoke();
        }
    }
Пример #9
0
    public override void Activate(BuffReceiver receiver)
    {
        PlayerController player = receiver.GetComponent <PlayerController>();

        base.Activate(receiver);
        if (isActivated == true)
        {
            StartCoroutine(OvertimeEffect(receiver));
            StartCoroutine(Duration(receiver));
            Debug.Log("Do" + this.name);
        }
        if (isActivated == false)
        {
            StopCoroutine(OvertimeEffect(receiver));
            StopCoroutine(Duration(receiver));
            receiver.RemoveBuff(this);
            Debug.Log("Undo" + this.name);
        }
    }
Пример #10
0
    public void OnTriggerStay2D(Collider2D col)
    {
        if (buff == null)
        {
            return;
        }
        BuffReceiver receiver = col.gameObject.GetComponent <BuffReceiver>();

        if (receiver == null)
        {
            return;
        }
        if (receiver.GetComponent <PlayerController>().ID == 5)
        {
            return;
        }
        if (receiver.buffs.Any(p => p.ID == buff.ID) == false)
        {
            receiver.AddBuff(buff);
        }
    }
Пример #11
0
    public override void Activate(BuffReceiver receiver)
    {
        base.Activate(receiver);
        receiver.GetComponent <SpriteRenderer>().color = color;
        ArcherCombat combat = receiver.GetComponent <ArcherCombat>();

        if (isActivated == true)
        {
            if (!receiver.GetComponent <ArcherCombat>())
            {
                return;
            }
            temp             = combat.objPrefab;
            combat.objPrefab = sapphireArrow;
            Debug.Log("Do" + this.name);
        }
        if (isActivated == false)
        {
            combat.objPrefab = temp;
            temp             = null;
            Debug.Log("Undo" + this.name);
        }
    }
Пример #12
0
    public override void Activate(BuffReceiver receiver)
    {
        PlayerController player = receiver.GetComponent <PlayerController>();

        base.Activate(receiver);
        receiver.GetComponent <SpriteRenderer>().color = color;
        if (isActivated == true)
        {
            speed              = player.playerSpeed;
            tempSpeed          = player.playerSpeed * slowModifier;
            player.playerSpeed = tempSpeed;

            tempModifier = player.GetComponent <Health>().fireModifier;
            player.GetComponent <Health>().fireModifier = damageModifier;
            Debug.Log("Do" + this.name);
        }
        if (isActivated == false)
        {
            player.playerSpeed = speed;
            tempSpeed          = 0;
            player.GetComponent <Health>().fireModifier += tempModifier;
            Debug.Log("Undo" + this.name);
        }
    }
Пример #13
0
    public override void Activate(BuffReceiver receiver)
    {
        PlayerController player = receiver.GetComponent <PlayerController>();

        base.Activate(receiver);
        receiver.GetComponent <SpriteRenderer>().color = color;
        if (isActivated == true)
        {
            Vector3 playerPos = player.transform.position;
            if (rubyLight != null)
            {
                tempLight = Instantiate(rubyLight, new Vector3(playerPos.x, playerPos.y, rubyLight.transform.position.z), rubyLight.transform.rotation, player.transform);
                //tempModifier = player.GetComponent<PlayerStats>().globalModifier;
                //player.GetComponent<PlayerStats>().globalModifier = damageModifier;
            }
            Debug.Log("Do" + this.name);
        }
        if (isActivated == false)
        {
            Destroy(tempLight);
            //player.GetComponent<PlayerStats>().globalModifier = tempModifier;
            Debug.Log("Undo" + this.name);
        }
    }
Пример #14
0
 public virtual void Start()
 {
     receiver = GetComponent <BuffReceiver>();
 }
Пример #15
0
 public override void Activate(BuffReceiver receiver)
 {
     base.Activate(receiver);
     receiver.GetComponent <SpriteRenderer>().color = color;
 }
Пример #16
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }
Пример #17
0
 public virtual void Deactivate(BuffReceiver receiver)
 {
     isActivated = false;
     Destroy(tempParticle, 1);
     EventOnDeactivated.Invoke();
 }