00001
00009 using System;
00010 using System.Collections.Generic;
00011 using System.Text;
00012
00013 using GRV11;
00014
00015 namespace Objects3D
00016 {
00024 public class Player
00025 {
00026 public static float Acceleration = 9.81F;
00027 public static byte Scale = 15;
00028
00029 protected static byte FDetails = 24;
00030
00031 protected bool FCollided = false;
00032 protected bool FFinished = false;
00033 protected float FGravity = 0;
00034 protected byte FID = 0;
00035 protected bool FJump = false;
00036 protected ServerCube FLastCube = null;
00037 protected int FRandom = 0;
00038 protected bool FStartJump = false;
00039
00040 protected Coordinate FPosition;
00041 protected Coordinate FRotation;
00042
00043 public Player()
00044 {
00045 FCollided = false;
00046 FFinished = false;
00047 FGravity = 0;
00048 FID = 0;
00049 FJump = false;
00050 FLastCube = null;
00051 FRandom = 0;
00052 FStartJump = false;
00053
00054 FPosition = new Coordinate();
00055 FRotation = new Coordinate();
00056 }
00057
00065 public static int ByteSize
00066 {
00067 get
00068 {
00069 return ((Coordinate.ByteSize * 2) + (sizeof(byte) * 1));
00070 }
00071 }
00072
00080 public bool Collided
00081 {
00082 get
00083 {
00084 return FCollided;
00085 }
00086
00087 set
00088 {
00089 FCollided = value;
00090 }
00091 }
00092
00100 public bool Finished
00101 {
00102 get
00103 {
00104 return FFinished;
00105 }
00106
00107 set
00108 {
00109 FFinished = value;
00110 }
00111 }
00112
00120 public byte ID
00121 {
00122 get
00123 {
00124 return FID;
00125 }
00126
00127 set
00128 {
00129 FID = value;
00130 }
00131 }
00132
00140 public float Gravity
00141 {
00142 get
00143 {
00144 return FGravity;
00145 }
00146
00147 set
00148 {
00149 FGravity = value;
00150 }
00151 }
00152
00160 public bool Jump
00161 {
00162 get
00163 {
00164 return FJump;
00165 }
00166
00167 set
00168 {
00169 FJump = value;
00170 }
00171 }
00172
00180 public ServerCube LastCube
00181 {
00182 get
00183 {
00184 return FLastCube;
00185 }
00186
00187 set
00188 {
00189 FLastCube = value;
00190 }
00191 }
00192
00200 public Coordinate Position
00201 {
00202 get
00203 {
00204 return FPosition;
00205 }
00206
00207 set
00208 {
00209 FPosition.Assign(value);
00210 }
00211 }
00212
00220 public int Random
00221 {
00222 get
00223 {
00224 return FRandom;
00225 }
00226
00227 set
00228 {
00229 FRandom = value;
00230 }
00231 }
00232
00240 public Coordinate Rotation
00241 {
00242 get
00243 {
00244 return FRotation;
00245 }
00246
00247 set
00248 {
00249 FRotation.Assign(value);
00250 }
00251 }
00252
00260 public bool StartJump
00261 {
00262 get
00263 {
00264 return FStartJump;
00265 }
00266
00267 set
00268 {
00269 FStartJump = value;
00270 }
00271 }
00272
00282 public byte[] GetBytes()
00283 {
00284 byte[] LResult = new byte[ByteSize];
00285
00286 byte[] LID = new byte[1]{FID};
00287
00288 byte[] LPosition = FPosition.GetBytes();
00289 byte[] LRotation = FRotation.GetBytes();
00290
00291 LID.CopyTo(LResult,(Coordinate.ByteSize * 0) + (sizeof(byte) * 0));
00292 LPosition.CopyTo(LResult,(Coordinate.ByteSize * 0) + (sizeof(byte) * 1));
00293 LRotation.CopyTo(LResult,(Coordinate.ByteSize * 1) + (sizeof(byte) * 1));
00294
00295 return LResult;
00296 }
00297
00310 public bool SetBytes(byte[] ABytes, int AOffset)
00311 {
00312 bool LResult = false;
00313
00314 if (((ABytes.Length - AOffset) >= ByteSize) && (AOffset >= 0))
00315 {
00316 FID = ABytes[(Coordinate.ByteSize * 0) + (sizeof(byte) * 0) + AOffset];
00317 FPosition.SetBytes(ABytes, (Coordinate.ByteSize * 0) + (sizeof(byte) * 1) + AOffset);
00318 FRotation.SetBytes(ABytes, (Coordinate.ByteSize * 1) + (sizeof(byte) * 1) + AOffset);
00319
00320 LResult = true;
00321 }
00322
00323 return LResult;
00324 }
00325
00337 public bool Assign(Player APlayer)
00338 {
00339 bool LResult = false;
00340
00341 if (APlayer != null)
00342 {
00343 Collided = APlayer.Collided;
00344 Finished = APlayer.Finished;
00345 Gravity = APlayer.Gravity;
00346 ID = APlayer.ID;
00347 Jump = APlayer.Jump;
00348 LastCube = APlayer.LastCube;
00349 Random = APlayer.Random;
00350 StartJump = APlayer.StartJump;
00351
00352 LResult = FPosition.Assign(APlayer.Position);
00353 LResult = (LResult && FRotation.Assign(APlayer.Rotation));
00354 }
00355
00356 return LResult;
00357 }
00358
00369 public void Draw(GR AGR, IntPtr AQuadric)
00370 {
00371 if ((AGR != null) && (AQuadric != null))
00372 {
00373 AGR.glTranslatef(-FPosition.X, -FPosition.Y, -FPosition.Z);
00374
00375
00376
00377
00378 AGR.gluSphere(AQuadric, Scale, FDetails, FDetails);
00379 }
00380 }
00381 }
00382 }