예제 #1
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);
     }
 }
예제 #2
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
                                });
                            }
                        }
                    }
                }
            }
        }
예제 #3
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));
    }