예제 #1
0
 protected override void onPickup(Player player)
 {
     // player.gunEquipped = new BasicGun(2, new LinearLocationEquation(-Math.PI / 2, 1),
     //                GraphicsLoader.getGraphicsLoader().getTexture("bullet"), 500, TEAM.FRIENDLY);
     // player.gunEquipped.GunShotHandler += BHGame.Canvas.OnGunShot;
     //FIXME:
     player.gunEquipped = new Gun(1, GraphicsLoader.getGraphicsLoader().getBulletTexture(),
                                  BulletFactoryFactory.make("surround"), TEAM.FRIENDLY);
     player.gunEquipped.GunShotHandler += BHGame.Canvas.OnGunShot;
 }
예제 #2
0
        private Player MakePlayer(Controller controller)
        {
            Texture2D playerTexture = graphicsLoader.getTexture("player");
            Texture2D heartTexture  = graphicsLoader.getTexture("heart");
            // Texture2D playerTexture = null;
            Player player = new Player(canvas, playerTexture, new Vector2(SCREEN_WIDTH / 2 - playerTexture.Width / 2, 300), controller, heartTexture);

            player.SetSize(72, 100);
            player.gunEquipped = new Gun(.7F, GraphicsLoader.getGraphicsLoader().getTexture("player-bullet"),
                                         BulletFactoryFactory.make("basic"), TEAM.FRIENDLY, -Math.PI / 2);
            player.PropertyChanged            += canvas.OnWeaponChange;
            player.gunEquipped.GunShotHandler += canvas.OnGunShot;
            player.Hitbox = new CollidingCircle(player.Location, new Vector2(player.Rect.Width / 2, player.Rect.Height / 2), 15);
            collisionManager.addToTeam(player, TEAM.FRIENDLY);
            return(player);
        }
예제 #3
0
        private Enemy makeEnemy(string textureName, int health, Path path, string gunType, float delay, double scale = 1)
        {
            Texture2D texture = GraphicsLoader.getGraphicsLoader().getTexture(textureName);
            Enemy     enemy;

            try
            {
                enemy = new Enemy(texture, path, health, BulletFactoryFactory.make(gunType), delay);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error loading gun " + gunType);
                Console.WriteLine(e.Message);
                enemy = new Enemy(texture, path, health);
            }
            Gun gun = gunFactory.makeGun(gunType);

            enemy.Hitbox = HitboxRepo.getHitboxRepo().getHitbox(textureName).Copy();
            enemy.Scale(scale);
            enemy.healthbar = new HealthBar(enemy.Location, new Vector2(8, 0), enemy.Rect.Width, 10, enemy.Health);


            return(enemy);
        }
예제 #4
0
        public Player(Canvas canvas, Texture2D texture, Vector2 startLocation, Controller controller, Texture2D heart_texture) : base(texture, startLocation)
        {
            //invulnerable = true;
            this.respawnLocation = startLocation;
            this.canvas          = canvas;
            InputControl.AssignPlayer(this);
            // gunEquipped = new BasicGun(1, new LinearLocationEquation(-Math.PI / 2, 1),
            //     GraphicsLoader.getGraphicsLoader().getTexture("bullet"), 500, TEAM.FRIENDLY);

            // gunEquipped = new BasicGun(1, new LinearLocationEquation(-Math.PI / 2, 1), GraphicsLoader.getGraphicsLoader().getBulletTexture(), 1000, true);

            healthPoints = 5;      //player lives

            MakeHearts(heart_texture);
            AddHearts(healthPoints);
            gunEquipped = new Gun(1, GraphicsLoader.getGraphicsLoader().getTexture("player-bullet"), BulletFactoryFactory.make("basic"), TEAM.FRIENDLY, -Math.PI / 2);

            subscribeToController(controller);
        }