예제 #1
0
파일: Tank.cs 프로젝트: solidhope/TManQuest
        public Tank(Game game, SceneObjectParent parent,TileMap tileMap)
            : base(tileMap,parent,GetImage(game))
        {
            Texture2D tankTurretImage = game.Content.Load<Texture2D>(@"Textures/TankTurret");

            tankTurret = new BasicSprite(this, tankTurretImage);
            this.SetHandle(new Vector2(GetImage(game).Width / 2, GetImage(game).Height / 2));
            tankTurret.SetLocalPosition(new Vector2(GetImage(game).Width / 2, GetImage(game).Height / 2));
            tankTurret.SetHandle(new Vector2(7, 7));
            tankTurret.SetLocalRotation((float)Math.PI / 4);
            this.tileMap = tileMap;
        }
예제 #2
0
파일: Tank.cs 프로젝트: solidhope/TManQuest
 /// <summary>
 /// This is the constructor for a Tank object
 /// </summary>
 /// <param name="game">The Game to use to load the assets</param>
 /// <param name="parent">The parent scene object to make the tank
 /// a child of</param>
 /// <param name="tileMap">The tilemap to scroll when we get too close to an edge</param>
 public Tank(Game game, SceneObjectParent parent,TileMap tileMap)
     : base(tileMap,parent)
 {
     //Load the images of the tank body and turret
     Texture2D tankBodyImage = game.Content.Load<Texture2D>(@"Textures/TankBody");
     Texture2D tankTurretImage = game.Content.Load<Texture2D>(@"Textures/TankTurret");
     // Now make the tank body a basicSprite that is a child of the Tank
     tankBody = new BasicSprite(this, tankBodyImage);
     // Now make the tank turret a BasicSprite that is a child of the body
     tankTurret = new BasicSprite(tankBody, tankTurretImage);
     // set the rotation and translation origin of the tank body at its center
     tankBody.SetHandle(new Vector2(tankBodyImage.Width / 2, tankBodyImage.Height / 2));
     // set the turret's origin at the approximate center of the round part
     tankTurret.SetHandle(new Vector2(7, 7));
     // set the turret's position as being at the center of the tank
     tankTurret.SetLocalPosition(new Vector2(tankBodyImage.Width / 2, tankBodyImage.Height / 2));
     // save the tile map
     this.tileMap = tileMap;
 }
예제 #3
0
 public override void OnCollisionWith(BasicSprite other)
 {
     DoDie();
 }
예제 #4
0
 public void CollidesWith(BasicSprite other)
 {
     collisionList.Add(new CollisionRecord(other));
 }
예제 #5
0
 public CollisionRecord(BasicSprite sprite)
 {
     collidedWith = false;
     this.sprite = sprite;
 }
예제 #6
0
 public virtual void OnCollisionWith(BasicSprite other)
 {
     //nop is default
 }
예제 #7
0
파일: Tank.cs 프로젝트: solidhope/TManQuest
 public override void OnCollisionExitWith(BasicSprite other)
 {
     base.OnCollisionEnterWith(other);
     Console.WriteLine("Collision exit");
     currentCollisionObject = null;
 }