示例#1
0
        public void Shot(Vector2 direction)
        {
            direction.Normalize ();
            Console.WriteLine ("{0} is shotting to direction: {1}", this.name, direction);
            // 0 left; 1 top; 2 right; 3 bottom; 4: top-left; 5: top-right; 6: bottom-left; 7: bottom-right
            Bullet bullet = new Bullet (this, direction);
            float xMod = direction.X + 0.5f;
            float yMod = direction.Y + 0.5f;
            bullet.x = this.x + (int)(this.width * xMod);
            bullet.y = this.y + (int)(this.height * yMod);

            bullet.radius = level.shotRadius;
            bullet.color = shotColor;
            this.engine.SpawnObject (
                string.Format("{2}_bullet_{0}_{1}", this.name, bulletCounter, ((Game)engine.objects["game"]).currentFloor.currentRoom.name), bullet
            );
            bulletCounter++;
        }
示例#2
0
 // bullet hits enemy
 public bool Hits(Bullet bullet, Character enemy, Collision collision)
 {
     return Hits((Character) bullet.owner, enemy, collision,
         (Character ch0, Character ch1) =>
         {
             return (int) (ch0.level.attack*((double) bullet.speed/bullet.startingSpeed));
         });
 }