Beispiel #1
0
    void Update()
    {
        if (myTarget == null)
        {
            return;
        }
        if (myTarget != null && !myTarget.gameObject.activeSelf)
        {
            NullTarget();
            return;
        }
        if (Vector2.Distance(myTarget.transform.position, this.transform.position) > firearm.getCurrentRange())
        {
            //	Debug.Log("Laser out of range\n");
            NullTarget();
            return;
        }

        TIME += Time.deltaTime;

        if (TIME >= next_ammo_time)
        {
            firearm.UseAmmo();
            next_ammo_time += ammo_frequency;
        }

        if (TIME >= next_damage_time)
        {
            targetBody.DoTheThing(this.firearm, statsum);
            if (firearm.isSparkles)
            {
                firearm.sparkles.AskSparkles(targetBody.my_hitme);
            }
            next_damage_time += damage_frequency;
        }
    }
Beispiel #2
0
    void GetVictims()
    {
        if (monsters == null)
        {
            monsters = Peripheral.Instance.targets;
        }

        HitMe closest_target   = null;
        float closest_distance = 999f;

        bool previous_status = halo_active;

        List <HitMe> targets = new List <HitMe>();

        //  Debug.Log("Potential targets " + monsters.Count + " range is " + range + " tilesize " + tileSize + "\n");
        for (int i = 0; i < monsters.max_count; i++)
        {
            HitMe enemy = monsters.array[i];
            if (enemy == null || enemy.amDying() || !enemy.gameObject.activeSelf)
            {
                continue;
            }

            float distance = Vector2.Distance(enemy.transform.position, transform.position);
            if (distance < closest_distance)
            {
                closest_target   = enemy;
                closest_distance = distance;
            }
            if (distance < my_firearm.getCurrentRange() * tileSize)
            {
                targets.Add(enemy);
                halo_active = true;
            }
        }
        //  Debug.Log("Got " + targets.Count + " victims, previous status is " + previous_status + "\n");
        if (targets.Count > 0)
        {
            type = my_firearm.toy.rune.GetStats(false);


            if (previous_status == false)
            {
                if (my_calamity != null)
                {
                    StatBit bit = type.GetStatBit(EffectType.Calamity);
                    if (bit != null)
                    {
                        my_calamity.Init(bit, closest_target, my_firearm, EffectType.Calamity);
                    }
                }

                if (my_foil != null)
                {
                    StatBit bit = type.GetStatBit(EffectType.Foil);
                    if (bit != null)
                    {
                        my_foil.Init(bit, closest_target, my_firearm, EffectType.Foil);
                    }
                }

                if (my_swarm != null)
                {
                    StatBit bit = type.GetStatBit(EffectType.Swarm);
                    if (bit != null)
                    {
                        my_swarm.Init(bit, transform, my_firearm, EffectType.Swarm);
                    }
                }
            }
        }
        //    Debug.Log("Gonna hurt " + targets.Count + " victims\n");
        for (int i = 0; i < targets.Count; i++)
        {
            targets[i].HurtMe(type, my_firearm, EffectType.Null);

            if (my_wish_catcher != null)
            {
                StatBit bit = type.GetStatBit(EffectType.WishCatcher);
                if (bit != null)
                {
                    my_wish_catcher.Init(targets[i], bit.getStats());
                }
            }
        }

        if (!previous_status && halo_active)
        {
            ShowHalo(true);
            if (!previous_status)
            {
                my_firearm.UseAmmo();
            }
            if (previous_status == false)
            {
            }
        }
    }