/// <summary> /// Creates a Tank represented by the given Model, at the given /// location, facing the given rotation, scaled to the given amount, /// and with the a collision sphere of the given size. /// </summary> /// <param name="tankModel">Model that represents the Tank</param> /// <param name="location">Location of the Tank</param> /// <param name="rotation">Rotation of the Tank</param> /// <param name="scale">Scale of the Tank</param> /// <param name="colliderSize"> /// Size of the Tanks collision sphere /// </param> public Tank(Model tankModel, Vector3 location, Vector3 rotation, Vector3 scale, float driveSpeed, float turnSpeed, float colliderSize) : base(location, rotation, scale, colliderSize) { this.driveSpeed = driveSpeed; this.turnSpeed = turnSpeed; this.models.Add(tankModel); }
/// <summary> /// Creates a Plane Prefab that is represented with the given model, at /// the given locaiton, facing the given rotation, scaled to the give /// size, and with the specified collider size. /// </summary> /// <param name="model">Model that represents the Plane</param> /// <param name="location">Location of the Plane</param> /// <param name="rotation">Rotaiton the Plane is facing</param> /// <param name="scale">Scale of the Plane</param> /// <param name="colliderSize">Size of the collider sphere</param> public Plane(Model model, Vector3 location, Vector3 rotation, Vector3 scale, float flightSpeed, float turnSpeed, float colliderSize) : base(location, rotation, scale, colliderSize) { this.flightSpeed = flightSpeed; this.turnSpeed = turnSpeed; this.models.Add(model); this.children.Add(new PlaneSmokeTrail(location)); }
/// <summary> /// Creates a single vanilla Bullet at the given location facing the /// given rotation. The Bullet is visually represented by the given /// Model, will travel that the given speed, inflict the given damage /// to Enemies it collides with, and will remain alive for the given /// lifespan unless a collision occures. /// </summary> /// <param name="owner">The Prefab that owns the Bullet</param> /// <param name="bulletModel">Model to represent Bullet</param> /// <param name="damage">Damage Bullet will inflict</param> /// <param name="lifespan">Time in seconds the bullet will remain in scene</param> /// <param name="speed">Speed bullet will travel at</param> public Bullet(Prefab owner, Model bulletModel, Vector3 location, Vector3 rotation, Vector3 scale, float damage, float lifespan, float speed) : base(location, rotation, scale) { this.owner = owner; this.damage = damage; this.lifespan = lifespan; this.timeAlive = 0.0f; this.speed = speed; this.models.Add(bulletModel); }
/// <summary> /// Creates a single TurretBarrel which will be represented by the /// given Model at the given location facing the given rotation. The /// TurretBarrel will be controlled by the given keyboard Device. /// </summary> /// <param name="barrelModel"> /// Model to represent the TurretBarrel /// </param> /// <param name="location">Location of the TurretBarrel</param> /// <param name="rotation">Rotation the TurretBarrel is facing</param> /// <param name="scale">Scale of the TurretBarrel</param> /// <param name="keyboard"> /// Keyboard Device used to control the TurretBarrel /// </param> public TurretBarrel(Vector3 location, Vector3 rotation, Vector3 scale, Model barrelModel, float maxRotation, float minRotation, float shootDelay, float pushSpeed, float pullSpeed, DI.Device keyboard) : base(location, rotation, scale) { this.keyboard = keyboard; this.minRotation = minRotation; this.maxRotation = maxRotation; this.drawLocation = location; this.shootDelay = shootDelay; this.pushSpeed = pushSpeed; this.pullSpeed = pullSpeed; this.models.Add(barrelModel); this.scripts.Add(new TurretShootScript(this)); }
/// <summary> /// Creates a single TurretBarrel which will be represented by the /// given Model at the given location facing the given rotation. The /// TurretBarrel will be controlled by the given keyboard Device. /// </summary> /// <param name="barrelModel"> /// Model to represent the TurretBarrel /// </param> /// <param name="location">Location of the TurretBarrel</param> /// <param name="rotation">Rotation the TurretBarrel is facing</param> /// <param name="scale">Scale of the TurretBarrel</param> /// <param name="keyboard"> /// Keyboard Device used to control the TurretBarrel /// </param> public TankBarrel(Tank tank, Vector3 location, Vector3 rotation, Vector3 scale, Model barrelModel, float maxRotation, float minRotation, float shootDistance, float shootDelay, float pushSpeed, float pullSpeed) : base(location, rotation, scale) { this.minRotation = minRotation; this.maxRotation = maxRotation; this.drawLocation = location; this.shootDistance = shootDistance; this.shootDelay = shootDelay; this.pushSpeed = pushSpeed; this.pullSpeed = pullSpeed; this.models.Add(barrelModel); this.scripts.Add(new TankShootScript(tank, this)); }
/// <summary> /// loads all the textures, materials, models, and other assets for use within game. /// </summary> /// <param name="device"></param> public static void initialize(Device device) { defaultTexture = null; testParticleTexture = TextureLoader.FromFile(device, Settings.TEST_PARTICLE_TEXTURE_PATH); explosionParticleTexture = TextureLoader.FromFile(device, Settings.EXPLOSION_PARTICLE_TEXTURE_PATH, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.White.ToArgb()); cloudParticleTexture = TextureLoader.FromFile(device, Settings.CLOUD_PARTICLE_TEXTURE_PATH, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.FromArgb(255,0,0,0).ToArgb()); // load health bar texture with alpha removed healthBarTexture = TextureLoader.FromFile(device, @"Content\Textures\healthBar.png", 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.White.ToArgb()); // to fill the bar healthTexture = TextureLoader.FromFile(device, @"Content\Textures\health.png"); defaultMaterial = new Material(); defaultMaterial.Diffuse = Color.White; defaultMaterial.Specular = Color.White; defaultMaterial.SpecularSharpness = 15.0f; basicBulletModel = new Model(Mesh.Sphere(device, Settings.BASIC_BULLET_SIZE, 3, 3), new Material[] { defaultMaterial }, new Texture[] { defaultTexture }, Vector3.Empty, device, true); testTurretBarrelModel = new Model(Mesh.Box(device, 0.1f, 1f, 0.1f), new Material[] { defaultMaterial }, new Texture[] { defaultTexture }, Vector3.Empty, device, true); testTurretBaseModel = new Model(Mesh.Cylinder(device, 1f, 1f, 2f, 10, 1), new Material[] { defaultMaterial }, new Texture[] { defaultTexture }, new Vector3(0f, (float)(Math.PI / 2), 0f), device, true); testTurretHeadModel = new Model(Mesh.Box(device, 1f, 0.5f, 1f), new Material[] { defaultMaterial }, new Texture[] { defaultTexture }, Vector3.Empty, device, true); basicTurretBarrelModel = new Model(Settings.BASIC_TURRET_BARREL_MODEL_PATH, Vector3.Empty, device); basicTurretBaseModel = new Model(Settings.BASIC_TURRET_BASE_MODEL_PATH, Vector3.Empty, device); basicTurretHeadModel = new Model(Settings.BASIC_TURRET_HEAD_MODEL_PATH, Vector3.Empty, device); basicPlaneModel = new Model(Settings.BASIC_PLANE_MODEL_PATH, new Vector3((float)Math.PI, 0f, 0f), device); basicTankBodyModel = new Model(Settings.BASIC_TANK_BODY_MODEL_PATH, Vector3.Empty, device); basicTankHeadModel = new Model(Settings.BASIC_TANK_HEAD_MODEL_PATH, Vector3.Empty, device); basicTankBarrelModel = new Model(Settings.BASIC_TANK_BARREL_MODEL_PATH, new Vector3(0, (float)(Math.PI / 2), 0), device); bombBulletModel = new Model(Settings.BOMB_BULLET_MODEL_PATH, Vector3.Empty, device); radarEnemy = TextureLoader.FromFile(device, @"Content\Textures\enemy.png", 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.White.ToArgb()); radar = TextureLoader.FromFile(device, @"Content\Textures\gui_radar.png", 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.White.ToArgb()); guiBack = TextureLoader.FromFile(device, @"Content\Textures\gui_box.png", 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.White.ToArgb()); worldBoxTop = TextureLoader.FromFile(device, Settings.WORLD_BOX_TOP_TEXTURE_PATH); worldBoxBottom = TextureLoader.FromFile(device, Settings.WORLD_BOX_BOTTOM_TEXTURE_PATH); worldBoxLeft = TextureLoader.FromFile(device, Settings.WORLD_BOX_LEFT_TEXTURE_PATH); worldBoxRight = TextureLoader.FromFile(device, Settings.WORLD_BOX_RIGHT_TEXTURE_PATH); worldBoxFront = TextureLoader.FromFile(device, Settings.WORLD_BOX_FRONT_TEXTURE_PATH); worldBoxBack = TextureLoader.FromFile(device, Settings.WORLD_BOX_BACK_TEXTURE_PATH); initialized = true; }