Exemplo n.º 1
0
    void Update()
    {
        var target = iAttackTarget.GetTarget();

        AimAt(target);

        iAttack.Attack(Time.deltaTime, target);

        iBuff.Apply(iBuffTarget.GetTargets());
    }
Exemplo n.º 2
0
        public void Buff(IBuff buff)
        {
            if (_activeBuff != null)
            {
                _activeBuff.Undo(this);
                _buffTimer = 4000;
            }

            _activeBuff = buff;
            _activeBuff.Apply(this);
        }
Exemplo n.º 3
0
 public override void SetCharacter(Character character)
 {
     if (current != null)
     {
         current.Remove();
         current = null;
     }
     base.SetCharacter(character);
     if (character != null)
     {
         current = passive_buff.GetInstance();
         current.Apply(character, character);
     }
 }
        public override GameCommandStatus FixedStep()
        {
            if (finalTick == -1)
            {
                if (_iBuff.Validate(_buffData))                     //if it is valid then the effect will be applied
                {
                    _iBuff.Apply(_buffData);
                    Debug.Log("applied armor buff");                      //actually working but why so infrequently
                }
                else
                {
                    return(GameCommandStatus.Complete);                    //don't do the buff
                }
                finalTick = _tick.currentTick + _buffData.duration;
            }
            else
            {
                if (_tick.currentTick > finalTick)
                {
                    _iBuff.Clear(_buffData);
                    return(GameCommandStatus.Complete);
                }
            }
            return(GameCommandStatus.InProgress);            //if it has not passed the final tick then keep the buff going.


            //_unitReceiver.UnitData.hpAdded = _unitReceiver.UnitData.hpAdded + _hpAddedValue;
            //Debug.Log("received buff");

            //Logs this buff in the event list. Maybe this could be done in the command processor itself?
            //EventObj newEvent = new EventObj(Time.time, 2, currentBuffObj.buffType, currentBuffObj.buffSender, currentBuffObj.buffDuration, currentBuffObj.buffStrength);
            //_receivingUnit.UnitData.eventList.Add(newEvent);

            //first time it is called, when it is first called take the current tick and figure out the final tick: wait and send in progress, check the current tick. After
            //the current tick == more than the finaltick call clear and return complete.

            //multiple conditions for the buff clearing: one of the conditions is the tick = final tick. Is this unit still alive: clear.
        }
Exemplo n.º 5
0
    IEnumerator Cyclone()
    {
        character.animator.SetTrigger(anim_trigger_windup);

        IBuff buff = null;

        if (speed_buff)
        {
            buff = speed_buff.GetInstance();
        }

        is_using_ability = true;
        is_winding_up    = true;
        // Wait for anim to finish windup
        while (is_winding_up)
        {
            yield return(null);
        }

        buff?.Apply(character, character);
        attack.Enable();

        float timer = duration;

        while (timer > 0)
        {
            yield return(new WaitForFixedUpdate());

            timer -= GameManager.GetDeltaTime(character.team);
        }

        attack.Disable();
        buff?.Remove();

        character.animator.SetTrigger(anim_trigger_end_spin);
        is_using_ability = false;
    }
Exemplo n.º 6
0
    protected IEnumerator AIRoutine()
    {
        yield return(new WaitForFixedUpdate());

        has_energy_buff_instance.Apply(enemy, enemy);
        List <Func <IEnumerator> > round_1_attacks = new List <Func <IEnumerator> >()
        {
            Rockets, Electric, SpikeAttack
        };
        List <Func <IEnumerator> > wall_attacks = new List <Func <IEnumerator> >()
        {
            SpikeAttack, Rockets
        };
        List <Func <IEnumerator> > vertical_attacks = new List <Func <IEnumerator> >()
        {
            LaserAttack, Electric
        };
        List <Func <IEnumerator> > round_3_attacks = new List <Func <IEnumerator> >()
        {
            LaserAttack, Electric, SpikeAttack
        };

        while (active)
        {
            // 1 Trap
            sub_cycle_count = 0;
            round_1_attacks.Shuffle();
            StartCoroutine(round_1_attacks[0]());
            enemy.animator.SetTrigger("Blink");
            while (attacks_occuring > 0)
            {
                yield return(new WaitForFixedUpdate());
            }
            enemy.animator.SetTrigger("Spend");
            // 2 trap
            sub_cycle_count = 1;
            wall_attacks.Shuffle();
            vertical_attacks.Shuffle();
            StartCoroutine(wall_attacks[0]());
            StartCoroutine(vertical_attacks[0]());
            enemy.animator.SetTrigger("Blink");
            while (attacks_occuring > 0)
            {
                yield return(new WaitForFixedUpdate());
            }
            enemy.animator.SetTrigger("Spend");
            // 3 trap
            round_3_attacks.Shuffle();
            List <Func <IEnumerator> > attacks = new List <Func <IEnumerator> >()
            {
                Rockets, round_3_attacks[0], round_3_attacks[1]
            };
            sub_cycle_count = 2;
            attacks.Shuffle();
            StartCoroutine(attacks[0]());
            StartCoroutine(attacks[1]());
            StartCoroutine(attacks[2]());
            enemy.animator.SetTrigger("Blink");
            while (attacks_occuring > 0)
            {
                yield return(new WaitForFixedUpdate());
            }
            enemy.animator.SetTrigger("Spend");
            cycle_count++;
            // fall
            float original_height = transform.position.y;
            float fallen_distance = 0;
            while (fall_distance > fallen_distance)
            {
                float to_fall = fall_speed * GameManager.GetFixedDeltaTime(enemy.team);
                if (fall_distance < fallen_distance + to_fall)
                {
                    to_fall = fall_distance - fallen_distance;
                }
                fallen_distance          += to_fall;
                enemy.transform.position += Vector3.down * to_fall;
                yield return(new WaitForFixedUpdate());
            }
            has_energy_buff_instance.Remove();
            no_energy_buff_instance.Apply(enemy, enemy);
            enemy.animator.SetBool("Rest", true);

            yield return(null);

            yield return(null);

            yield return(null);

            while (enemy.health.current / enemy.health > (1f - (float)cycle_count / max_cycles))
            {
                yield return(new WaitForFixedUpdate());
            }
            // raise
            lever_pulled = false;
            enemy.animator.SetTrigger("Refill");
            enemy.animator.SetBool("Rest", false);
            no_energy_buff_instance.Remove();
            has_energy_buff_instance.Apply(enemy, enemy);

            while (!lever_pulled)
            {
                yield return(new WaitForFixedUpdate());
            }

            while (fallen_distance > 0)
            {
                float to_raise = raise_speed * GameManager.GetFixedDeltaTime(enemy.team);
                if (0 > fallen_distance - to_raise)
                {
                    to_raise = fallen_distance;
                }
                fallen_distance          -= to_raise;
                enemy.transform.position += Vector3.up * to_raise;
                yield return(new WaitForFixedUpdate());
            }
            transform.position = new Vector3(transform.position.x, original_height, transform.position.z);

            yield return(new WaitForSeconds(2f));
        }
    }