Exemple #1
0
 internal static void Explosion_Init()
 {
     for (var i = 0; i < g_explosions.Length; i++)
     {
         g_explosions[i] = new CExplosion();                                           //memset(g_explosions, 0, EXPLOSION_MAX * sizeof(Explosion));
     }
 }
Exemple #2
0
    /*
     * Stop performing an explosion.
     * @param e The Explosion to end.
     * @param parameter Unused parameter.
     */
    static void Explosion_Func_Stop(CExplosion e)
    {
        g_map[Tile_PackTile(e.position)].hasExplosion = false;

        Explosion_Update(0, e);

        e.commands = null;
    }
Exemple #3
0
    /*
     * Check if there is a bloom at the location, and make it explode if needed.
     * @param e The Explosion to perform the explosion on.
     * @param parameter Unused parameter.
     */
    static void Explosion_Func_BloomExplosion(CExplosion e)
    {
        ushort packed;

        packed = Tile_PackTile(e.position);

        if (g_map[packed].groundTileID != g_bloomTileID)
        {
            return;
        }

        Map_Bloom_ExplodeSpice(packed, (byte)g_playerHouseID);
    }
Exemple #4
0
        /// <summary>
        /// Creates an explosion entity which is what happens when a bomb goes off.
        /// Can kill players.
        /// </summary>
        /// <param name="handler">Optional method to call instead of default when explosion is complete.</param>
        public Entity CreateExplosion(int x, int y, ElapsedEventHandler handler = null)
        {
            Entity     result = CreateBasicEntity(x, y, EntityType.Explosion);
            CExplosion exp    = new CExplosion(result);

            result.AddComponent <CExplosion>(exp);
            if (handler == null)
            {
                handler = exp.onComplete;
            }
            result.AddComponent <CTimer>(new CTimer(result, Settings.ExplosionLength, handler));
            return(result);
        }
Exemple #5
0
    /*
     * Shake the screen.
     * @param e The Explosion.
     * @param parameter Unused parameter.
     */
    static void Explosion_Func_ScreenShake(CExplosion e, ushort parameter)
    {
        int i;

        Debug.WriteLine($"DEBUG: Explosion_Func_ScreenShake({e}, {parameter})");

        for (i = 0; i < 2; i++)
        {
            MSleep(30);
            Video_SetOffset(320);
            MSleep(30);
            Video_SetOffset(0);
        }
    }
Exemple #6
0
    /*
     * Update the tile a Explosion is on.
     * @param type Are we introducing (0) or updating (2) the tile.
     * @param e The Explosion in question.
     */
    static void Explosion_Update(ushort type, CExplosion e)
    {
        if (e == null)
        {
            return;
        }

        if (type == 1 && e.isDirty)
        {
            return;
        }

        e.isDirty = type != 0;

        Map_UpdateAround(24, e.position, null, g_functions[2][type]);
    }
Exemple #7
0
    /*
     * Set the animation of a Explosion.
     * @param e The Explosion to change.
     * @param animationMapID The animation map to use.
     */
    static void Explosion_Func_SetAnimation(CExplosion e, ushort animationMapID)
    {
        ushort packed;

        packed = Tile_PackTile(e.position);

        if (Structure_Get_ByPackedTile(packed) != null)
        {
            return;
        }

        animationMapID += (ushort)(Tools_Random_256() & 0x1);
        animationMapID += (ushort)(g_table_landscapeInfo[Map_GetLandscapeType(packed)].isSand ? 0 : 2);

        Debug.Assert(animationMapID < 16);
        Animation_Start(g_table_animation_map[animationMapID], e.position, 0, e.houseID, 3);
    }
    // Se llama desde CPlayerBullet cuando una bala nos toca.
    public void hit()
    {
        setDead(true);

        int t = 0;

        // Si es un asteroide grande, se crean asteroides medianos.
        if (getType() == TYPE_BIG)
        {
            t = TYPE_MEDIUM;
        }
        // Si el asteroide es mediano, se crean asteroides chicos.
        else if (getType() == TYPE_MEDIUM)
        {
            t = TYPE_SMALL;
        }

        // Si el asteroide es chico, se saltea esta parte.
        // No se crean asteroides.
        if (getType() != TYPE_SMALL)
        {
            for (int i = 0; i < 2; i++)
            {
                // Crear los asteroides: se le pasa como parámetro el tipo y color (el color es el mismo).
                CAsteroid asteroid = new CAsteroid(t, mColor);
                asteroid.setXY(getX(), getY());
                asteroid.setVelX(CMath.randomFloatBetween(-500, 500));
                asteroid.setVelY(CMath.randomFloatBetween(-500, 500));
                CEnemyManager.inst().add(asteroid);
            }
        }

        CExplosion explosion = new CExplosion();

        explosion.setXY(getX(), getY());
        CParticleManager.inst().add(explosion);
    }
Exemple #9
0
 /*
  * Play a voice for a Explosion.
  * @param e The Explosion to play the voice on.
  * @param voiceID The voice to play.
  */
 static void Explosion_Func_PlayVoice(CExplosion e, ushort voiceID) =>
 Voice_PlayAtTile((short)voiceID, e.position);
Exemple #10
0
    /*
     * Handle damage to a tile, removing spice, removing concrete, stuff like that.
     * @param e The Explosion to handle damage on.
     * @param parameter Unused parameter.
     */
    static void Explosion_Func_TileDamage(CExplosion e)
    {
        ushort        packed;
        ushort        type;
        CTile         t;
        short         iconMapIndex;
        ushort        overlayTileID;
        Span <ushort> iconMap;

        packed = Tile_PackTile(e.position);

        if (!Map_IsPositionUnveiled(packed))
        {
            return;
        }

        type = Map_GetLandscapeType(packed);

        if (type is ((ushort)LandscapeType.LST_STRUCTURE)or((ushort)LandscapeType.LST_DESTROYED_WALL))
        {
            return;
        }

        t = g_map[packed];

        if (type == (ushort)LandscapeType.LST_CONCRETE_SLAB)
        {
            t.groundTileID = (ushort)(g_mapTileID[packed] & 0x1FF);
            Map_Update(packed, 0, false);
        }

        if (g_table_landscapeInfo[type].craterType == 0)
        {
            return;
        }

        /* You cannot damage veiled tiles */
        overlayTileID = t.overlayTileID;
        if (!Tile_IsUnveiled(overlayTileID))
        {
            return;
        }

        iconMapIndex = craterIconMapIndex[g_table_landscapeInfo[type].craterType];
        iconMap      = g_iconMap.AsSpan(g_iconMap[iconMapIndex]);

        if (iconMap[0] <= overlayTileID && overlayTileID <= iconMap[10])
        {
            /* There already is a crater; make it bigger */
            overlayTileID -= iconMap[0];
            if (overlayTileID < 4)
            {
                overlayTileID += 2;
            }
        }
        else
        {
            /* Randomly pick 1 of the 2 possible craters */
            overlayTileID = (ushort)(Tools_Random_256() & 1);
        }

        /* Reduce spice if there is any */
        Map_ChangeSpiceAmount(packed, -1);

        /* Boom a bloom if there is one */
        if (t.groundTileID == g_bloomTileID)
        {
            Map_Bloom_ExplodeSpice(packed, (byte)g_playerHouseID);
            return;
        }

        /* Update the tile with the crater */
        t.overlayTileID = (ushort)(overlayTileID + iconMap[0]);
        Map_Update(packed, 0, false);
    }
Exemple #11
0
 /*
  * Set position at the left of a row.
  * @param e The Explosion to change.
  * @param row Row number.
  */
 static void Explosion_Func_MoveYPosition(CExplosion e, ushort row) =>
 e.position.y += row;
Exemple #12
0
 /*
  * Set timeout for next the activity of \a e to a random value up to \a value.
  * @param e The Explosion to change.
  * @param value The maximum amount of timeout.
  */
 static void Explosion_Func_SetRandomTimeout(CExplosion e, ushort value) =>
 e.timeOut = g_timerGUI + Tools_RandomLCG_Range(0, value);
Exemple #13
0
 /*
  * Set timeout for next the activity of \a e.
  * @param e The Explosion to change.
  * @param value The new timeout value.
  */
 static void Explosion_Func_SetTimeout(CExplosion e, ushort value) =>
 e.timeOut = g_timerGUI + value;
Exemple #14
0
    /*
     * Set the SpriteID of the Explosion.
     * @param e The Explosion to change.
     * @param spriteID The new SpriteID for the Explosion.
     */
    static void Explosion_Func_SetSpriteID(CExplosion e, ushort spriteID)
    {
        e.spriteID = spriteID;

        Explosion_Update(2, e);
    }