예제 #1
0
    static public bool TestModTypes(out int infractions, out int totalCases)
    {
        infractions = 0;
        totalCases  = System.Enum.GetNames(typeof(ProjModType)).Length;

        for (int i = 1; i < totalCases; i++)
        {
            ProjMod projMod = GetProjModFromType((ProjModType)i);
            if (projMod == null)
            {
                Debug.LogWarning($"Infraction {++infractions}:\nUnsupported case '{(ProjModType)i}'");
            }
            else if (projMod.Clone().GetType() != projMod.GetType())
            {
                Debug.LogWarning($"Infraction {++infractions}:\nMissing Clone constructor for '{(ProjModType)i}'");
            }
            //else if ("Your mom is gay"!="true")
            //Debug.LogComeback("No u");
        }

        if (infractions > 0)
        {
            return(false);
        }
        return(true);
    }
예제 #2
0
    void RunDataTests()
    {
        Debug.Log("===================\nStarting Tests!");
        System.DateTime startTime = System.DateTime.Now;

        System.DateTime equipmentTime = System.DateTime.Now;
        if (!EquipmentManager.TestAllWeapons(out int infractions, out int totalCases))
        {
            Debug.LogError($"Weapons Set-up: Failed {infractions}/{totalCases} cases\nTimeElapsed: {System.DateTime.Now.Subtract(equipmentTime).TotalMilliseconds}ms");
        }
        else
        {
            Debug.Log($"Weapons Set-up: Passed {totalCases} cases\nTimeElapsed: {System.DateTime.Now.Subtract(equipmentTime).TotalMilliseconds}ms");
        }

        System.DateTime projModTime = System.DateTime.Now;
        if (!ProjMod.TestModTypes(out infractions, out totalCases))
        {
            Debug.LogError($"ProjMod Set-up: Failed {infractions}/{totalCases} cases\nTimeElapsed: {System.DateTime.Now.Subtract(projModTime).TotalMilliseconds} ms");
        }
        else
        {
            Debug.Log($"ProjMod Set-up: Passed {totalCases} cases\nTimeElapsed: {System.DateTime.Now.Subtract(projModTime).TotalMilliseconds}ms");
        }

        double elapsedTime = System.DateTime.Now.Subtract(startTime).TotalMilliseconds;

        Debug.Log("Tests complete! Elapsed time: " + elapsedTime + "ms\n===================");
    }
예제 #3
0
 public bool RemoveProjMod(ProjMod mod)
 {
     foreach (ProjMod pm in mods)
     {
         if (pm.GetType() == mod.GetType())
         {
             mods.Remove(pm);
             return(true);
         }
     }
     return(false);
 }
예제 #4
0
 public void Detonate()
 {
     if (Detonated)
     {
         return;
     }
     projectile.scale   *= 4;
     projectile.damage  *= 2;
     this.Detonated      = true;
     projectile.velocity = Vector2.Zero;
     Frame = 9;
     projectile.timeLeft = 180;
     if (ProjMod.IsGuardianProjectile(projectile.whoAmI))
     {
         TerraGuardian tg             = ProjMod.GuardianProj[projectile.whoAmI];
         Rectangle     ExplosionRange = new Rectangle((int)projectile.position.X - (int)(48 * projectile.scale), (int)projectile.position.Y - (int)(48 * projectile.scale)
                                                      , (int)(96 * projectile.scale), (int)(96 * projectile.scale));
         for (int t = 0; t < 255; t++)
         {
             if (Main.player[t].active && tg.IsPlayerHostile(Main.player[t]) && Main.player[t].getRect().Intersects(ExplosionRange))
             {
                 double dmg = Main.player[t].Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(" didn't survived a electric explosion."), projectile.damage, projectile.direction, true);
                 if (dmg > 0)
                 {
                     Main.player[t].AddBuff(Terraria.ID.BuffID.Electrified, 5 * 60);
                 }
             }
             if (t < 200 && Main.npc[t].active && tg.IsNpcHostile(Main.npc[t]) && !Main.npc[t].dontTakeDamage && Main.npc[t].getRect().Intersects(ExplosionRange))
             {
                 double dmg = Main.npc[t].StrikeNPC(projectile.damage, projectile.knockBack, projectile.direction);
                 if (dmg > 0)
                 {
                     Main.npc[t].AddBuff(Terraria.ID.BuffID.Electrified, 5 * 60);
                 }
             }
         }
         foreach (TerraGuardian othertg in MainMod.ActiveGuardians.Values)
         {
             if (tg.IsGuardianHostile(othertg) && othertg.HitBox.Intersects(ExplosionRange))
             {
                 int dmg = othertg.Hurt(projectile.damage, projectile.direction, false, false, " didn't survived a electric explosion.");
                 if (dmg > 0)
                 {
                     othertg.AddBuff(Terraria.ID.BuffID.Electrified, 5 * 60);
                 }
             }
         }
     }
     projectile.friendly = projectile.hostile = false;
 }
예제 #5
0
 public ProjMod(ProjMod pm)
 {
     type     = pm.type;
     priority = pm.priority;
     proj     = pm.proj;
 }
예제 #6
0
 public void AddNewProjMod(ProjModType type)
 {
     AddNewProjMod(ProjMod.GetProjModFromType(type));
 }
예제 #7
0
 public void AddNewProjMod(ProjMod mod)
 {
     mods.Add((ProjMod)mod.Clone());
     mods[mods.Count - 1].Initialize(null);
 }
예제 #8
0
 protected ProjectileContainer(ProjectileContainer other)
 {
     stats    = other.stats;
     graphics = other.graphics;
     mods     = ProjMod.CloneList(other.mods);
 }
예제 #9
0
 public ProjectileContainer(ProjectileStats _stats, ProjectileGraphics _graphics, List <ProjMod> _mods)
 {
     stats    = _stats;
     graphics = _graphics;
     mods     = ProjMod.CloneList(_mods);
 }