Advertisement
Guest User

Player

a guest
Dec 12th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Audio;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.GamerServices;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Media;
  11.  
  12. namespace Pokemon_Vs
  13. {
  14.     class Player
  15.     {
  16.         Matrix world;
  17.         Model lickitung;
  18.  
  19.         public Vector3 position;
  20.  
  21.         BoundingBox boundingBoxP;
  22.         Vector3 angle = Vector3.Zero;
  23.         //GraphicsDevice device;
  24.  
  25.         public Player()
  26.  
  27.         {
  28.             //this.device = device;
  29.             position = new Vector3(0, -3, -20);
  30.             this.world = Matrix.Identity;
  31.             this.world *= Matrix.CreateScale(0.5f);
  32.             this.world *= Matrix.CreateTranslation(position);
  33.             this.world *= Matrix.CreateRotationX(180);
  34.  
  35.             this.boundingBoxP = new BoundingBox();
  36.             //this.UpdateBoundingBox();
  37.         }
  38.  
  39.         public void LoadContent(ContentManager Content)
  40.         {
  41.  
  42.             this.lickitung = Content.Load<Model>(@"Models\Lickitung");
  43.  
  44.         }
  45.  
  46.         public void Update(_Camera camera, GameTime gameTime)
  47.         {
  48.             //this.world *= Matrix.CreateRotationX(180);
  49.  
  50.             //position.X = camera.position.X;
  51.             //position.Y = camera.position.Y - 3.5f;
  52.             //position.Z = camera.position.Z - 27;
  53.             //angle.Z++;
  54.  
  55.             this.world = Matrix.CreateScale(0.001f);
  56.             this.world *= Matrix.CreateTranslation(position);
  57.  
  58.             //world *= Matrix.CreateRotationY(-0.10f);
  59.  
  60.             if (Keyboard.GetState().IsKeyDown(Keys.A))
  61.             {
  62.                 position.X += 5;
  63.                 this.angle.Z += 100 * gameTime.ElapsedGameTime.Milliseconds * 0.001f;
  64.                 //this.UpdateBoundingBox();
  65.             }
  66.  
  67.             if (Keyboard.GetState().IsKeyDown(Keys.D))
  68.             {
  69.                 position.X -= 5;
  70.                 //this.angle.Z -= 100 * gameTime.ElapsedGameTime.Milliseconds * 0.001f;
  71.                 //this.UpdateBoundingBox();
  72.             }
  73.  
  74.             if (Keyboard.GetState().IsKeyDown(Keys.W))
  75.             {
  76.                 position.Z -= 5;
  77.                 //this.world *= Matrix.CreateRotationY(180);
  78.                 //this.UpdateBoundingBox();
  79.             }
  80.  
  81.             if (Keyboard.GetState().IsKeyDown(Keys.S))
  82.             {
  83.                 position.Z += 5;
  84.                 //this.UpdateBoundingBox();
  85.             }
  86.  
  87.             //this.world *= Matrix.CreateRotationX(MathHelper.ToRadians(this.angle.X));
  88.             //this.world *= Matrix.CreateRotationY(MathHelper.ToRadians(this.angle.Y));
  89.             //this.world *= Matrix.CreateRotationZ(MathHelper.ToRadians(this.angle.Z));
  90.  
  91.             this.world *= Matrix.CreateRotationY(50);
  92.             this.world = Matrix.CreateTranslation(position);
  93.  
  94.             //this.world = Matrix.CreateRotationY(MathHelper.ToRadians(camera.angleY));
  95.  
  96.             this.UpdateBoundingBox();
  97.         }
  98.  
  99.         public void Draw(_Camera camera)
  100.         {
  101.  
  102.             //device.SamplerStates[0] = SamplerState.LinearClamp;
  103.  
  104.  
  105.             foreach (ModelMesh mesh in this.lickitung.Meshes)
  106.             {
  107.                 foreach (BasicEffect effect in mesh.Effects)
  108.                 {
  109.                     effect.EnableDefaultLighting();
  110.  
  111.                     //effect.PreferPerPixelLighting = true;
  112.  
  113.  
  114.  
  115.                     effect.World = this.world;//Matrix.CreateRotationY((float)Math.PI / 2f) * Matrix.CreateTranslation(1,1,1);
  116.                     // *mesh.ParentBone.Transform;
  117.                     effect.View = camera.GetView();
  118.                     effect.Projection = camera.GetProjection();
  119.                 }
  120.                
  121.                 mesh.Draw();
  122.             }
  123.  
  124.         }
  125.  
  126.         void UpdateBoundingBox()
  127.         {
  128.             this.boundingBoxP.Min = this.position - Vector3.One;
  129.             this.boundingBoxP.Max = this.position + Vector3.One;
  130.         }
  131.  
  132.         public BoundingBox GetBoundingBox()
  133.         {
  134.             return this.boundingBoxP;
  135.         }
  136.     }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement