Exemple #1
0
    private IEnumerator ExplosionRoutine(Matrix matrix)
    {
        var explosionCenter = transform.position.RoundToInt();

        // First - play boom sound and shake ground
        PlaySoundAndShake(explosionCenter);

        // Now let's create explosion shape
        int radiusInteger = (int)radius;
        var shape         = EffectShape.CreateEffectShape(explosionType, explosionCenter, radiusInteger);

        var explosionCenter2d = explosionCenter.To2Int();
        var tileManager       = GetComponentInParent <TileChangeManager>();
        var longestTime       = 0f;

        foreach (var tilePos in shape)
        {
            float distance  = Vector3Int.Distance(tilePos, explosionCenter);
            var   tilePos2d = tilePos.To2Int();

            // Is explosion goes behind walls?
            if (IsPastWall(explosionCenter2d, tilePos2d, distance))
            {
                // Heat the air
                matrix.ReactionManager.ExposeHotspotWorldPosition(tilePos2d, 3200, 0.005f);

                // Calculate damage from explosion
                int damage = CalculateDamage(tilePos2d, explosionCenter2d);

                if (damage > 0)
                {
                    // Damage poor living things
                    DamageLivingThings(tilePos, damage);

                    // Damage all objects
                    DamageObjects(tilePos, damage);

                    // Damage all tiles
                    DamageTiles(tilePos, damage);
                }

                // Calculate fire effect time
                var fireTime     = DistanceFromCenter(explosionCenter2d, tilePos2d, minEffectDuration, maxEffectDuration);
                var localTilePos = MatrixManager.WorldToLocalInt(tilePos, matrix.Id);
                StartCoroutine(TimedFireEffect(localTilePos, fireTime, tileManager));

                // Save longest fire effect time
                if (fireTime > longestTime)
                {
                    longestTime = fireTime;
                }
            }
        }

        // Wait until all fire effects are finished
        yield return(WaitFor.Seconds(longestTime));

        Destroy(gameObject);
    }
Exemple #2
0
 public bool IsSameEffectShape(EffectShape centerShape)
 {
     if (this.mShape == centerShape || this.mShape == EffectShape.NONE)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
        private void PushPullObjects()
        {
            int distance;

            switch (currentStage)
            {
            case SingularityStages.Stage0:
                distance = 1;
                break;

            case SingularityStages.Stage1:
                distance = 2;
                break;

            case SingularityStages.Stage2:
                distance = 3;
                break;

            case SingularityStages.Stage3:
                distance = 8;
                break;

            case SingularityStages.Stage4:
                distance = 10;
                break;

            case SingularityStages.Stage5:
                distance = 14;
                break;

            default:
                distance = 1;
                break;
            }

            foreach (var tile in EffectShape.CreateEffectShape(EffectShapeType.Circle, registerTile.WorldPositionServer, distance).ToList())
            {
                var objects = MatrixManager.GetAt <PushPull>(tile, true);

                foreach (var objectToMove in objects)
                {
                    if (objectToMove.registerTile.ObjectType == ObjectType.Item)
                    {
                        ThrowItem(objectToMove, registerTile.WorldPositionServer - objectToMove.registerTile.WorldPositionServer);
                    }
                    else
                    {
                        PushObject(objectToMove, registerTile.WorldPositionServer - objectToMove.registerTile.WorldPositionServer);
                    }
                }
            }
        }
Exemple #4
0
    private void IndocrinateMessageArea()
    {
        // get effect shape around artifact
        var objCenter = gameObject.AssumedWorldPosServer().RoundToInt();
        var shape     = EffectShape.CreateEffectShape(EffectShapeType.Square, objCenter, auraRadius);

        foreach (var pos in shape)
        {
            // check if tile has any alive player
            var players = MatrixManager.GetAt <PlayerScript>(pos, true).Distinct();
            foreach (var player in players)
            {
                if (!player.IsDeadOrGhost)
                {
                    // send them message
                    Indocrinate(player.gameObject);
                }
            }
        }
    }
Exemple #5
0
        private void DestroyObjectsAndTiles()
        {
            int radius;

            switch (currentStage)
            {
            case SingularityStages.Stage0:
                radius = 0;
                break;

            case SingularityStages.Stage1:
                radius = 1;
                break;

            case SingularityStages.Stage2:
                radius = 2;
                break;

            case SingularityStages.Stage3:
                radius = 3;
                break;

            case SingularityStages.Stage4:
                radius = 4;
                break;

            case SingularityStages.Stage5:
                radius = 5;
                break;

            default:
                radius = 0;
                break;
            }

            var coords =
                EffectShape.CreateEffectShape(EffectShapeType.Square, registerTile.WorldPositionServer, radius);

            DestroyObjects(coords);
            DamageTiles(coords);
        }
    public override void DoEffectAura()
    {
        base.DoEffectAura();

        // get effect shape around artifact
        var objCenter = gameObject.AssumedWorldPosServer().RoundToInt();
        var shape     = EffectShape.CreateEffectShape(effectShapeType, objCenter, teleportAuraRadius);

        foreach (var pos in shape)
        {
            // check if tile has any alive player
            var players = MatrixManager.GetAt <PlayerScript>(pos, true).Distinct();
            foreach (var player in players)
            {
                if (!player.IsDeadOrGhost)
                {
                    // teleport player
                    TeleportUtils.ServerTeleportRandom(player.gameObject, minTeleportDistance, maxTeleportDistance, avoidSpace, avoidImpassable);
                }
            }
        }
    }
Exemple #7
0
    public static void SetShape(BlownUpStatus[,] blownUpStatus, int pivotRow, int pivotCol, int[,] indexList, EffectShape shape)
    {
        int i;

        for (i = 0; i < indexList.GetLength(0); i++)
        {
            int currentRow = pivotRow + indexList[i, 0];
            int currentCol = pivotCol + indexList[i, 1];

            if (!blownUpStatus[currentRow, currentCol].IsSameEffectShape(shape))
            {
                return;
            }
        }

        for (i = 0; i < indexList.GetLength(0); i++)
        {
            int currentRow = pivotRow + indexList[i, 0];
            int currentCol = pivotCol + indexList[i, 1];

            blownUpStatus[currentRow, currentCol].mShape = shape;
        }
    }
Exemple #8
0
 public BlownUpStatus()
 {
     this.mVertical   = false;
     this.mHorizontal = false;
     this.mShape      = EffectShape.NONE;
 }
Exemple #9
0
        private void PushPullObjects()
        {
            int distance;

            switch (currentStage)
            {
            case SingularityStages.Stage0:
                distance = 1;
                break;

            case SingularityStages.Stage1:
                distance = 2;
                break;

            case SingularityStages.Stage2:
                distance = 3;
                break;

            case SingularityStages.Stage3:
                distance = 8;
                break;

            case SingularityStages.Stage4:
                distance = 10;
                break;

            case SingularityStages.Stage5:
                distance = 14;
                break;

            default:
                distance = 1;
                break;
            }

            foreach (var tile in EffectShape.CreateEffectShape(EffectShapeType.Circle, registerTile.WorldPositionServer, distance).ToList())
            {
                if (DMMath.Prob(50))
                {
                    continue;
                }

                var objects = MatrixManager.GetAt <PushPull>(tile, true);

                foreach (var objectToMove in objects)
                {
                    if (objectToMove.registerTile.ObjectType == ObjectType.Item)
                    {
                        if (pushRecently.Contains(objectToMove.gameObject))
                        {
                            continue;
                        }

                        ThrowItem(objectToMove, registerTile.WorldPositionServer - objectToMove.registerTile.WorldPositionServer);

                        if (objectToMove.TryGetComponent <Integrity>(out var integrity) && integrity != null)
                        {
                            //Just to stop never ending items being thrown about, and increasing points forever
                            integrity.ApplyDamage(10, AttackType.Melee, DamageType.Brute, true, ignoreArmor: true);
                        }
                    }
                    else
                    {
                        PushObject(objectToMove, registerTile.WorldPositionServer - objectToMove.registerTile.WorldPositionServer);
                    }
                }
            }
        }
Exemple #10
0
 public Effect(string name, float time, object parameteri)
 {
     data = BigBase.Instance.effects.Get(name);
     timeLeft = time;
     parameter = parameteri;
 }
Exemple #11
0
 public Effect(string name, float time)
 {
     data = BigBase.Instance.effects.Get(name);
     timeLeft = time;
 }
Exemple #12
0
 public bool Has(EffectShape shape)
 {
     return data.Where(e => e.data == shape).Count() > 0;
 }