コード例 #1
0
ファイル: Player.cs プロジェクト: betooo0997/Programmierung-2
        /// <summary>
        /// Shoots a PlayerProjectile
        /// </summary>
        /// <param name="TileMapPosition">Position of the TileMap</param>
        protected void Shoot(Vector2f TileMapPosition)
        {
            pProjectile = new PlayerProjectile(fAngle, (Vector2f)vMousePositionFromPlayer, 1);

            lProjectile.Add(pProjectile);

            SoundManager.PlaySpecificSound(Sounds.Shot);
        }
コード例 #2
0
        /// <summary>
        /// Reduces Health of the Enemy if hit by PlayerProjectile
        /// </summary>
        /// <param name="iProjectile">Projectile that Collision with Enemy is checked</param>
        /// <param name="Damage">Damage inflicted to the Enemy if hit</param>
        /// <returns></returns>
        protected bool EnemyProjectileCollision(PlayerProjectile iProjectile, uint Damage)
        {
            List <Enemy> lEnemy;

            lEnemy = MainMap.GetEnemies();

            for (int x = 0; x < lEnemy.Count; x++)
            {
                Vector2f b = lEnemy[x].sEntity.Position;

                if (Utilities.DistanceBetweenVectors(iProjectile.vEntityPosition, b) <= 25)
                {
                    lEnemy[x].ReduceHealth(Damage, iProjectile.GetDirection());
                    return(true);
                }
            }
            return(false);
        }