コード例 #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
ファイル: Player.cs プロジェクト: solidhope/TManQuest
 public override void OnCollisionWith(BasicSprite other)
 {
     DoDie();
 }
コード例 #4
0
ファイル: BasicSprite.cs プロジェクト: solidhope/TManQuest
 public void CollidesWith(BasicSprite other)
 {
     collisionList.Add(new CollisionRecord(other));
 }
コード例 #5
0
ファイル: BasicSprite.cs プロジェクト: solidhope/TManQuest
 public CollisionRecord(BasicSprite sprite)
 {
     collidedWith = false;
     this.sprite = sprite;
 }
コード例 #6
0
ファイル: BasicSprite.cs プロジェクト: solidhope/TManQuest
 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;
 }