public override WorldDamage GetWeaponDamage()
    {
        WorldDamage wd = new WorldDamage();

        wd.BaseWeaponDamage = myWeapon.BaseDamage;
        return(wd);
    }
    public override WorldDamage GetWeaponDamage()
    {
        WeaponItem  weapon = (equipment.GetItemFromEquippedDict(WorldItems.WorldItemTypes.WeaponWearable) as WeaponItem);
        WorldDamage wd     = new WorldDamage();

        wd.BaseWeaponDamage = weapon.BaseDamage;
        return(wd);
    }
 public override void GetHit(WorldDamage damage)
 {
     DeductHealth(damage);
     if (Health <= 0)
     {
         SetDefeated();
     }
 }
예제 #4
0
 public void PunchWallDamage(float dt)
 {
     if (Grid.Solid[base.smi.sm.wallCellToBreak] && Grid.StrengthInfo[base.smi.sm.wallCellToBreak] < 100)
     {
         WorldDamage instance         = WorldDamage.Instance;
         int         wallCellToBreak  = base.smi.sm.wallCellToBreak;
         float       amount           = 0.06f * dt;
         int         wallCellToBreak2 = base.smi.sm.wallCellToBreak;
         string      source_name      = BUILDINGS.DAMAGESOURCES.MINION_DESTRUCTION;
         instance.ApplyDamage(wallCellToBreak, amount, wallCellToBreak2, -1, source_name, UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.MINION_DESTRUCTION);
     }
 }
예제 #5
0
 /// <summary>
 /// Applies rocket damage. Since the amount is known to be instant, the method can be
 /// simplified greatly.
 /// </summary>
 private static float ApplyRocketDamage(WorldDamage instance, int cell, float amount,
                                        int _, int destroyCallback, string sourceName, string popText)
 {
     if (Grid.Solid[cell])
     {
         bool hadBuilding = false;
         // Destroy the cell immediately
         var obj = Grid.Objects[cell, (int)ObjectLayer.FoundationTile];
         if (obj != null)
         {
             // Break down the building on that cell
             var hp = obj.GetComponent <BuildingHP>();
             if (hp != null)
             {
                 // Damage for all it has left
                 obj.Trigger((int)GameHashes.DoBuildingDamage, new BuildingHP.
                             DamageSourceInfo {
                     damage    = hp.HitPoints,
                     source    = sourceName,
                     popString = popText
                 });
                 if (!hp.destroyOnDamaged)
                 {
                     hadBuilding = true;
                 }
             }
         }
         Grid.Damage[cell] = 1.0f;
         if (hadBuilding)
         {
             // Destroy tile completely
             SimMessages.ReplaceElement(cell, SimHashes.Vacuum, CellEventLogger.
                                        Instance.SimCellOccupierDestroySelf, 0.0f, 0.0f, 255, 0,
                                        destroyCallback);
         }
         else
         {
             // Regular tile, break it normally
             instance.DestroyCell(cell, destroyCallback);
         }
     }
     return(amount);
 }
예제 #6
0
        private static void DoWorldDamage(GameObject part, Vector3 apparentPosition)
        {
            OccupyArea component = part.GetComponent <OccupyArea>();

            component.UpdateOccupiedArea();
            CellOffset[] occupiedCellsOffsets = component.OccupiedCellsOffsets;
            foreach (CellOffset offset in occupiedCellsOffsets)
            {
                int num = Grid.OffsetCell(Grid.PosToCell(apparentPosition), offset);
                if (Grid.IsValidCell(num))
                {
                    if (Grid.Solid[num])
                    {
                        WorldDamage instance    = WorldDamage.Instance;
                        int         cell        = num;
                        float       amount      = 10000f;
                        int         src_cell    = num;
                        string      source_name = BUILDINGS.DAMAGESOURCES.ROCKET;
                        instance.ApplyDamage(cell, amount, src_cell, -1, source_name, UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.ROCKET);
                    }
                    else if (Grid.FakeFloor[num])
                    {
                        GameObject gameObject = Grid.Objects[num, 38];
                        if ((Object)gameObject != (Object)null)
                        {
                            BuildingHP component2 = gameObject.GetComponent <BuildingHP>();
                            if ((Object)component2 != (Object)null)
                            {
                                gameObject.Trigger(-794517298, new BuildingHP.DamageSourceInfo
                                {
                                    damage    = component2.MaxHitPoints,
                                    source    = (string)BUILDINGS.DAMAGESOURCES.ROCKET,
                                    popString = (string)UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.ROCKET
                                });
                            }
                        }
                    }
                }
            }
        }
 public void DeductHealth(WorldDamage damage)
 {
     Health -= damage.CalculateDamage();
 }
 public abstract void GetHit(WorldDamage damage);
예제 #9
0
    private float DamageTiles(int cell, int prev_cell, float input_damage)
    {
        GameObject gameObject = Grid.Objects[cell, 9];
        float      num        = 1f;
        bool       flag       = false;

        if ((Object)gameObject != (Object)null)
        {
            if (gameObject.GetComponent <KPrefabID>().HasTag(GameTags.Window))
            {
                num = windowDamageMultiplier;
            }
            else if (gameObject.GetComponent <KPrefabID>().HasTag(GameTags.Bunker))
            {
                num = bunkerDamageMultiplier;
                if ((Object)gameObject.GetComponent <Door>() != (Object)null)
                {
                    Game.Instance.savedInfo.blockedCometWithBunkerDoor = true;
                }
            }
            SimCellOccupier component = gameObject.GetComponent <SimCellOccupier>();
            if ((Object)component != (Object)null && !component.doReplaceElement)
            {
                flag = true;
            }
        }
        Element element = (!flag) ? Grid.Element[cell] : gameObject.GetComponent <PrimaryElement>().Element;

        if (element.strength == 0f)
        {
            return(0f);
        }
        float num2 = input_damage * num / element.strength;

        PlayTileDamageSound(element, Grid.CellToPos(cell));
        if (num2 == 0f)
        {
            return(0f);
        }
        float num3;

        if (flag)
        {
            BuildingHP component2 = gameObject.GetComponent <BuildingHP>();
            float      a          = (float)component2.HitPoints / (float)component2.MaxHitPoints;
            float      f          = num2 * (float)component2.MaxHitPoints;
            component2.gameObject.Trigger(-794517298, new BuildingHP.DamageSourceInfo
            {
                damage    = Mathf.RoundToInt(f),
                source    = (string)BUILDINGS.DAMAGESOURCES.COMET,
                popString = (string)UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.COMET
            });
            num3 = Mathf.Min(a, num2);
        }
        else
        {
            WorldDamage instance    = WorldDamage.Instance;
            float       amount      = num2;
            string      source_name = BUILDINGS.DAMAGESOURCES.COMET;
            num3 = instance.ApplyDamage(cell, amount, prev_cell, -1, source_name, UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.COMET);
        }
        destroyedCells.Add(cell);
        float num4 = num3 / num2;

        return(input_damage * (1f - num4));
    }
 public override void GetHit(WorldDamage damage)
 {
     DeductHealth(damage);
     print(health);
     combatui.SetPlayerHealthDisplay(health);
 }