Beispiel #1
0
        protected override void CheckCollisionWithGround()
        {
            if (this.Position.Y >= 15)
            {
                return;
            }
            LevelTile tile;
            int       index = Mathematics.PositionToIndex(Position.X);

            if (index >= 0 && index < refToLevel.LevelTiles.Count)
            {
                tile = refToLevel.LevelTiles[index];
                CollisionType c = tile.InCollision(this.boundRectangle);
                if (c == CollisionType.None)
                {
                    return;
                }

                //jesli nie da sie zniszczyc dany obiekt z dzialka.
                if (c == CollisionType.Hitbound || c == CollisionType.CollisionRectagle)
                {
                    if (refToLevel.LevelTiles[index] is BarrelTile)
                    {
                        BarrelTile barrel = refToLevel.LevelTiles[index] as BarrelTile;
                        if (!barrel.IsDestroyed)
                        {
                            barrel.Destroy();
                            refToLevel.Controller.OnTileDestroyed(barrel, null);
                            this.refToLevel.Statistics.HitByGun += refToLevel.KillVulnerableSoldiers(index, 2, false);
                        }
                    }
                    else
                    {
                        this.refToLevel.Statistics.HitByGun += refToLevel.KillVulnerableSoldiers(index, 0, false);
                    }
                }
                else if (c == CollisionType.Altitude)
                {
                    //refToLevel.Controller.OnTileBombed(tile, this);
                }

                this.Destroy();
                refToLevel.Controller.OnGunHit(refToLevel.LevelTiles[index], Position.X, System.Math.Max(this.Position.Y, 1));
            }
        }
Beispiel #2
0
        protected override void CheckCollisionWithGround()
        {
            int       index = Mathematics.PositionToIndex(Position.X);
            LevelTile tile;

            if (index > -1 && index < refToLevel.LevelTiles.Count)
            {
                tile = refToLevel.LevelTiles[index];
                if (tile is ShipTile)
                {
                    //boundRectangle.Intersects(
                }
                //CollisionType c = CollisionType.None;
                CollisionType c = tile.InCollision(this.boundRectangle);
                if (c == CollisionType.None)
                {
                    return;
                }

                //jesli nie da sie zniszczyc dany obiekt rakieta.
                if (c == CollisionType.Hitbound || c == CollisionType.CollisionRectagle)
                {
                    if (tile is BarrelTile)
                    {
                        BarrelTile destroyTile = tile as BarrelTile;
                        if (!destroyTile.IsDestroyed)
                        {
                            destroyTile.Destroy();
                            refToLevel.Controller.OnTileDestroyed(destroyTile, this);
                            refToLevel.Statistics.HitByRocket += refToLevel.KillVulnerableSoldiers(index, 2, true);
                        }
                        else
                        {
                            refToLevel.Controller.OnTileBombed(tile, this);
                        }
                    }
                    else if (tile is EnemyInstallationTile)
                    {
                        FortressBunkerTile    fortressTile = null;
                        EnemyInstallationTile enemyTile    = null;
                        LevelTile             destroyTile  = tile;
                        //Obsluga fortress bunker
                        if ((fortressTile = destroyTile as FortressBunkerTile) != null && !fortressTile.IsDestroyed)
                        {
                            //Trafienie zniszczonego fortress bunker
                            if (fortressTile.IsDestroyed)
                            {
                                refToLevel.Controller.OnTileBombed(destroyTile, this);
                            }
                            else
                            {
                                fortressTile.Hit();
                                //Ostatnie trafienie!
                                if (fortressTile.ShouldBeDestroyed)
                                {
                                    refToLevel.Controller.OnTileDestroyed(destroyTile, this);
                                    refToLevel.Statistics.HitByRocket++;
                                    fortressTile.Destroy();
                                }
                                //Trafienie rakiety uszkadzaj¹ce fortress bunker
                                else
                                {
                                    refToLevel.Controller.OnFortressHit(fortressTile, this);
                                    refToLevel.Statistics.HitByRocket++;
                                }
                            }
                        }
                        else if ((enemyTile = destroyTile as EnemyInstallationTile) != null && !enemyTile.IsDestroyed)
                        {
                            refToLevel.Controller.OnTileDestroyed(destroyTile, this);
                            refToLevel.Statistics.HitByRocket++;
                            enemyTile.Destroy();
                        }
                        else
                        {
                            refToLevel.Controller.OnTileBombed(tile, this);
                        }
                    }
                    else
                    {
                        refToLevel.Controller.OnTileBombed(tile, this);
                    }
                }
                else if (c == CollisionType.Altitude)
                {
                    refToLevel.Controller.OnTileBombed(tile, this);
                }


                //zabija zolnierzy, ktorzy sa w zasiegu.
                refToLevel.Statistics.HitByRocket += refToLevel.KillVulnerableSoldiers(index, 1, true);

                //niszcze rakiete
                Destroy();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Sprawdza kolizje z terenem, bunkrami , barakami, etc.
        /// </summary>
        /// <author>Michal Ziober</author>
        private void CheckCollisionWithGround()
        {
            int       index = Mathematics.PositionToIndex(Center.X);
            LevelTile tile;

            if (index > -1 && index < refToLevel.LevelTiles.Count)
            {
                tile = refToLevel.LevelTiles[index];
                //jeœli nie ma kolizji wyjdz.
                CollisionType c = refToLevel.LevelTiles[index].InCollision(this.boundRectangle);
                if (c == CollisionType.None)
                {
                    return;
                }

                if (tile is BarrelTile)
                {
                    BarrelTile destroyTile = tile as BarrelTile;
                    if (!destroyTile.IsDestroyed)
                    {
                        destroyTile.Destroy();
                        refToLevel.Controller.OnTileDestroyed(destroyTile, this);
                        refToLevel.Statistics.HitByBomb += refToLevel.KillVulnerableSoldiers(index, 2, true);
                    }
                    else
                    {
                        refToLevel.Controller.OnTileBombed(tile, this);
                    }
                }
                else if (tile is EnemyInstallationTile)
                {
                    WoodBunkerTile woodbunker = null;
                    ShipBunkerTile shipbunker = null;
                    BarrackTile    barrack    = null;
                    if (tile is WoodBunkerTile)
                    {
                        if ((woodbunker = tile as WoodBunkerTile) != null && !woodbunker.IsDestroyed)
                        {
                            refToLevel.Controller.OnTileDestroyed(tile, this);
                            refToLevel.Statistics.HitByBomb++;
                            woodbunker.Destroy();
                        }
                        else
                        {
                            refToLevel.Controller.OnTileBombed(tile, this);
                        }
                    }
                    else if (tile is ShipWoodBunkerTile)
                    {
                        if ((shipbunker = tile as ShipBunkerTile) != null && !shipbunker.IsDestroyed)
                        {
                            refToLevel.Controller.OnTileDestroyed(tile, this);
                            refToLevel.Statistics.HitByBomb++;
                            shipbunker.Destroy();
                        }
                        else
                        {
                            refToLevel.Controller.OnTileBombed(tile, this);
                        }
                    }
                    else if (tile is BarrackTile)
                    {
                        if ((barrack = tile as BarrackTile) != null && !barrack.IsDestroyed)
                        {
                            refToLevel.Controller.OnTileDestroyed(tile, this);
                            refToLevel.Statistics.HitByBomb++;
                            barrack.Destroy();
                        }
                        else
                        {
                            refToLevel.Controller.OnTileBombed(tile, this);
                        }
                    }
                    else
                    {
                        refToLevel.Controller.OnTileBombed(tile, this);
                    }
                }
                else
                {
                    refToLevel.Controller.OnTileBombed(tile, this);
                }

                //zabijam zolnierzy, ktorzy sa w polu razenia.
                refToLevel.Statistics.HitByBomb += refToLevel.KillVulnerableSoldiers(index, 1, true);

                //niszcze bombe.
                Destroy();
            }
        }