Beispiel #1
0
    private static IEnumerator Tremor(Gun gun, BulletScript script)
    {
        script.coroutines_running++;
        while (!script.has_collided && !script.Target)//Wait for collision and check target validity
        {
            yield return(new WaitForEndOfFrame());
        }
        string layer = "";

        if (gun.client_user)
        {
            layer = LayerMask.LayerToName(
                gun.client_user.gameObject.layer);
        }
        else
        {
            layer = LayerMask.LayerToName(
                gun.GetComponentInParent <HealthDefence>()
                .gameObject.layer);
        }
        Collider[] target_colliders = Physics.OverlapSphere(script.gameObject.transform.position, 7,
                                                            LayerMask.GetMask(layer), QueryTriggerInteraction.Collide);
        foreach (Collider col in target_colliders)
        {
            UnitHealthDefence HP = col.GetComponent <UnitHealthDefence>();
            if (HP && script.Target.netId != HP.netId)
            {
                HP.DetermineStun(1);
            }
        }
        script.coroutines_running--;
    }
    /*Code for actually syncing health bar values to the actual health of the player,
     * as well as setting up mod text to be displayed*/
    void InitializePlayerInterface()
    {
        UnitHealthDefence HP = GetComponent <UnitHealthDefence>();

        HP.health_bar_show = player_interface_show.GetComponentsInChildren <Slider>()[1].gameObject as GameObject;
        HP.hp_string       = HP.health_bar_show.GetComponentInChildren <Text>();
        HP.hp_string.text  = "<b>" + HP.HP + "</b>";
        HP.hp_bar          = HP.health_bar_show.GetComponentInChildren <Slider>().GetComponent <RectTransform
                                                                                                >();
        HP.maxWidth = HP.hp_bar.rect.width;
        mod_text    = player_interface_show.GetComponentInChildren <Text>();
    }
Beispiel #3
0
 /*Applies experience to whomever shot the damaging bullet*/
 void ApplyExperience(int damage, UnitHealthDefence Target)
 {
     if (Target && gun_reference.client_user)
     {                                                                                        //
         if (damage >= Target.HP)
         {
             gun_reference.experience += (int)(Target.HP * Target.exp_rate);
         }
         else
         {
             gun_reference.experience += (int)(damage * Target.exp_rate);
         }
     }
 }
Beispiel #4
0
    private static IEnumerator Gunslinger(Gun gun, BulletScript script)
    {
        script.coroutines_running++;
        while (!script.has_collided && !script.Target)//Wait for collision and check target validity
        {
            yield return(new WaitForEndOfFrame());
        }
        UnitHealthDefence tgt = script.Target as UnitHealthDefence;

        if (tgt)
        {
            const int STUN_TIME = 2;
            tgt.DetermineStun(STUN_TIME);
        }
        script.coroutines_running--;
    }
Beispiel #5
0
    private static IEnumerator Debilitate(Gun gun, BulletScript script)
    {
        script.coroutines_running++;
        while (script.has_collided == false)
        {
            yield return(new WaitForEndOfFrame());
        }
        List <uint> IDs    = new List <uint>();
        double      chill  = 0;
        double      burn   = 0;
        double      mez    = 0;
        double      sunder = 0;

        script.coroutines_running--;
        while (script)
        {
            if (script.Target && !IDs.Contains(script.Target.netId.Value))
            {
                script.chill_strength     -= chill;
                script.chill_strength     -= burn;
                script.mezmerize_strength -= mez;
                script.sunder_strength    -= sunder;

                UnitHealthDefence tgt = script.Target as UnitHealthDefence;

                burn   = script.Target.burn_resistance /= 2;
                sunder = tgt.sunder_resistance /= 2;
                if (tgt)
                {
                    chill = tgt.chill_resistance /= 2;
                    mez   = tgt.mezmerize_resistance /= 2;
                }

                script.chill_strength  += burn;
                script.sunder_strength += sunder;
                if (tgt)
                {
                    script.chill_strength     += chill;
                    script.mezmerize_strength += mez;
                }
                IDs.Add(script.Target.netId.Value);
            }
            yield return(new WaitForEndOfFrame());
        }
    }
Beispiel #6
0
    private static IEnumerator Destroyer(Gun gun, BulletScript script)
    {
        script.coroutines_running++;
        while (!script.Target)
        {
            yield return(new WaitForEndOfFrame());
        }
        float multiplier = 1;

        if (script.Target.burning)
        {
            multiplier += .3f;
        }
        if (script.Target.sundered)
        {
            multiplier += .3f;
        }
        UnitHealthDefence tgt = script.Target as UnitHealthDefence;

        if (tgt)
        {
            if (tgt.chilling)
            {
                multiplier += .3f;
            }
            if (tgt.mezmerized)
            {
                multiplier += .3f;
            }
            if (tgt.stunned)
            {
                multiplier += .3f;
            }
        }
        float upper = script.upper_bound_damage;
        float lower = script.lower_bound_damage;

        upper *= multiplier;
        lower *= multiplier;
        script.upper_bound_damage = (int)upper;
        script.lower_bound_damage = (int)lower;
        script.coroutines_running--;
    }
Beispiel #7
0
 /*Applies aggro to whoever damage the AIController.Assumes that
  * the target is a cpu.*/
 void ApplyAggro(int damage, UnitHealthDefence Target)
 {
     /*This distinction is made,for players' guns aren't children for the sake
      * of manual position syncing in multiplayer.*/
     if (Target)
     {
         AIController AI = Target.GetComponentInChildren <AIController>();
         if (AI)
         {
             NetworkInstanceId ID;
             if (gun_reference.client_user)
             {
                 ID = gun_reference.client_user.netId;
             }
             else
             {
                 NetworkBehaviour pnb = gun_reference.transform.parent.GetComponent <NetworkBehaviour>();
                 ID = pnb.netId;
                 AIController aAI = pnb.GetComponentInChildren <AIController>();
             }
             AI.UpdateAggro(damage, ID);
         }
     }
 }
Beispiel #8
0
    private static IEnumerator Epidemic(Gun gun, BulletScript script)
    {
        bool         chill  = false;
        bool         stun   = false;
        bool         burn   = false;
        bool         mez    = false;
        bool         sunder = false;
        const double num    = .05;

        while (script)
        {
            while (!script.Target)
            {
                yield return(new WaitForEndOfFrame());
            }
            if (burn)
            {
                int damage = script.lower_bound_damage
                             + (script.upper_bound_damage - script.lower_bound_damage) / 2
                             - script.Target.defence;
                script.Target.StartCoroutine(script.Target.DetermineBurn(num, damage));
            }
            if (sunder)
            {
                int damage = script.lower_bound_damage
                             + (script.upper_bound_damage - script.lower_bound_damage) / 2
                             - script.Target.defence;
                script.Target.StartCoroutine(script.Target.DetermineSunder(num, damage));
            }
            UnitHealthDefence tgt = script.Target as UnitHealthDefence;
            if (tgt)
            {
                if (chill)
                {
                    tgt.StartCoroutine(tgt.DetermineChill(num));
                }
                if (stun)
                {
                    tgt.DetermineStun(1);
                }
                if (mez)
                {
                    tgt.StartCoroutine(tgt.DetermineMezmerize(num));
                }
            }
            if (script.Target.sundered)
            {
                sunder = true;
            }
            if (script.Target.burning)
            {
                burn = true;
            }
            if (tgt)
            {
                if (tgt.chilling)
                {
                    chill = true;
                }
                if (tgt.mezmerized)
                {
                    mez = true;
                }
                if (tgt.stunned)
                {
                    stun = true;
                }
            }
            yield return(new WaitForEndOfFrame());
        }
    }