static uint GetPlayerFaceSprite(PlayerFace face) { if (face != 0u) { return(0x10b + (uint)face); } return(0x119u); // sprite_face_none }
internal PlayerInfo(PlayerFace character, Color color, uint intelligence, uint supplies, uint reproduction) { SetCharacter(character); Color = color; Intelligence = intelligence; Supplies = supplies; Reproduction = reproduction; CastlePosition = Position.None; }
public CameraManager(Game game) : base(game) { //Hack //fball = ((Game1)game).Fball; PlayerFace = ((Game1)game).FaceTracker; fbm = ((Game1)game).FBM; gameConsole = (GameConsole)game.Services.GetService(typeof(IGameConsole)); this.LFaces = new List <PlayerFace>(); //try to create the capture if (_capture == null) { try { //gameConsole.GameConsoleWrite("Camera intialized:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FORMAT).ToString()); _capture = new Capture(); //240 X 90 //_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 160); //_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 120); //_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 240); //_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 90); //_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 320); //_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 240); _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 720); _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 405); //_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS, 15); gameConsole.GameConsoleWrite("Camera FPS:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS).ToString()); gameConsole.GameConsoleWrite("Camera WIDTH:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH).ToString()); gameConsole.GameConsoleWrite("Camera HEIGHT:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT).ToString()); } catch (NullReferenceException excpt) { //show errors if there is any throw excpt; } } this.UpdateCameraFrameInterval = 400; this.UpdateFaceFrameInterval = this.UpdateCameraFrameInterval + 0; this.UpdateMotionDetectorFrameInterval = this.UpdateCameraFrameInterval + 0; fd = new FaceDetector(); md = new MotionDetector(game); input = (InputHandler)game.Services.GetService(typeof(IInputHandler)); gameConsole = (GameConsole)game.Services.GetService(typeof(IGameConsole)); }
public static uint GetGraphicIndex(this PlayerFace face) { if (face == PlayerFace.None) { return(281u); } if (face <= PlayerFace.Friend) { return(267u + (uint)face); } return(600u + (uint)face - (uint)PlayerFace.YouRed); }
internal void AddPlayer(PlayerFace character, Color color, uint intelligence, uint supplies, uint reproduction) { AddPlayer(new PlayerInfo(character, color, intelligence, supplies, reproduction)); }
public Character(PlayerFace face, string name, string characterization) { Face = face; Name = name; Characterization = characterization; }
internal void SetCharacter(PlayerFace character) { Face = character; }
public static bool IsHuman(this PlayerFace face) { return(face == PlayerFace.You || face == PlayerFace.Friend); }
public void SetCharacter(PlayerFace character) { Face = Characters[(int)character].Face; }
public override void Update(GameTime gameTime) { // The time since Update was called last // Time elapsed since the last call to update. double elapsedTime = gameTime.TotalGameTime.TotalMilliseconds; //only Check camera less than 60 times a second if (elapsedTime > ReadFrameTime) { this.ProcessFrame(gameTime, elapsedTime); if (this.SetBitmap) { CameraBackGround = TextureFromBitmap(this.Bimage); //CameraBackGround = CreateTextureFromBitmap(this.Bimage); } ReadFrameTime = elapsedTime + this.UpdateCameraFrameInterval; //milliseconds to check camera } //floatingball Manager if (this.FindMotion) { if (this.md.OverallMotionPixelCount > 1000 && this.md.TotalMotionsFound > 10) //500 is a filter to find big motions { //gameConsole.DebugText = Vector2.Normalize(cm.md.MotionSum).ToString(); Vector2 fixedVector = Vector2.Normalize(this.md.MotionSum) * new Vector2(1, -1); //fball.GravityDir = fixedVector; //fball.SetTexture(true); foreach (FloatingBall f in fbm.FloatingBalls) { f.GravityDir = fixedVector; f.SetTexture(true); } } else { //fball.GravityDir = Vector2.Zero; //fball.SetTexture(false); foreach (FloatingBall f in fbm.FloatingBalls) { f.GravityDir = Vector2.Zero;; f.SetTexture(false); } } } //PacMan Test if (this.fd.Faces.Count > 0) { LFaces = new List <PlayerFace>(); foreach (FaceController f in this.fd.Faces) { //spriteBatch.DrawString(font, f.About(), f.Location - new Vector2(0, -50), Color.AliceBlue); PlayerFace foundFace = PlayerFace; foundFace.Location = f.Location; foundFace.Scale = f.Scale; LFaces.Add(foundFace); } PlayerFace.Enabled = true; if (DrawPlayerFace) { PlayerFace.Visible = true; } //PlayerFace.Location = this.fd.Faces[0].Location; PlayerFace.Location = new Vector2(this.fd.Faces[0].Rect.Center.X, this.fd.Faces[0].Rect.Center.Y); //2.5 is a HACK bese on the PacMan texture size PlayerFace.Scale = this.fd.Faces[0].Scale / PlayerFace.spriteTexture.Width * 4.5f; } else { PlayerFace.Enabled = false; if (DrawPlayerFace) { PlayerFace.Visible = false; } } //KeyBoard input #region Keyboard Input //V toggles Video if (input.KeyboardState.WasKeyPressed(Keys.V)) { if (this.SetBitmap) { this.SetBitmap = false; } else { this.SetBitmap = true; } gameConsole.GameConsoleWrite("SetBitmap " + this.SetBitmap); } //A toggles AccurateAndSlow if (input.KeyboardState.WasKeyPressed(Keys.A)) { if (this.fd.AccurateAndSlow) { this.fd.AccurateAndSlow = false; } else { this.fd.AccurateAndSlow = true; } gameConsole.GameConsoleWrite("AccurateAndSlow " + this.fd.AccurateAndSlow); } //F toggles Find Eyers if (input.KeyboardState.WasKeyPressed(Keys.F)) { if (this.fd.FindEyes) { this.fd.FindEyes = false; } else { this.fd.FindEyes = true; } gameConsole.GameConsoleWrite("FindEyes " + this.fd.FindEyes); } //S toggles Scale location if (input.KeyboardState.WasKeyPressed(Keys.S)) { if (FaceController.ScaleLocation) { FaceController.ScaleLocation = false; } else { FaceController.ScaleLocation = true; } gameConsole.GameConsoleWrite("FaceController.ScaleLocation " + FaceController.ScaleLocation); gameConsole.GameConsoleWrite("Video Size:" + this.CameraWidth + " " + this.CameraHeight); } //Up and down UpdateCameraFrameInterval Interval Interval if (input.KeyboardState.WasKeyPressed(Keys.OemOpenBrackets)) { this.UpdateCameraFrameInterval -= 50; if (this.UpdateCameraFrameInterval < 50) { this.UpdateCameraFrameInterval = 50; } gameConsole.GameConsoleWrite("UpdateFrameInterval: " + this.UpdateCameraFrameInterval); this.UpdateFaceFrameInterval = this.UpdateCameraFrameInterval; this.UpdateMotionDetectorFrameInterval = this.UpdateCameraFrameInterval; } if (input.KeyboardState.WasKeyPressed(Keys.OemCloseBrackets)) { this.UpdateCameraFrameInterval += 50; gameConsole.GameConsoleWrite("UpdateFrameInterval: " + this.UpdateCameraFrameInterval); this.UpdateFaceFrameInterval = this.UpdateCameraFrameInterval; this.UpdateMotionDetectorFrameInterval = this.UpdateCameraFrameInterval; } //Up and down UpdateMotionDetectorFrameInterval Interval Interval if (input.KeyboardState.WasKeyPressed(Keys.OemSemicolon)) { this.UpdateMotionDetectorFrameInterval -= 10; if (this.UpdateMotionDetectorFrameInterval < 10) { this.UpdateMotionDetectorFrameInterval = 10; } gameConsole.GameConsoleWrite("UpdateMotionDetectorFrameInterval: " + this.UpdateMotionDetectorFrameInterval); } if (input.KeyboardState.WasKeyPressed(Keys.OemQuotes)) { this.UpdateMotionDetectorFrameInterval += 10; gameConsole.GameConsoleWrite("UpdateMotionDetectorFrameInterval: " + this.UpdateMotionDetectorFrameInterval); } //Up and down UpdateFaceFrameInterval Interval Interval if (input.KeyboardState.WasKeyPressed(Keys.OemComma)) { this.UpdateFaceFrameInterval -= 10; if (this.UpdateFaceFrameInterval < 10) { this.UpdateFaceFrameInterval = 10; } gameConsole.GameConsoleWrite("UpdateFaceFrameInterval: " + this.UpdateFaceFrameInterval); } if (input.KeyboardState.WasKeyPressed(Keys.OemPeriod)) { this.UpdateFaceFrameInterval += 10; gameConsole.GameConsoleWrite("UpdateFaceFrameInterval: " + this.UpdateFaceFrameInterval); } //Find Faces if (input.KeyboardState.WasKeyPressed(Keys.NumPad1)) { if (this.FindFaces) { this.FindFaces = false; //Disable all face objects ((Game1)Game).FaceTracker.Enabled = false; ((Game1)Game).FaceTracker.Visible = false; ((Game1)Game).faceChaser.Enabled = false; ((Game1)Game).faceChaser.Visible = false; } else { this.FindFaces = true; //Enable all face objects ((Game1)Game).FaceTracker.Enabled = true; //((Game1)Game).FaceTracker.Visible = true; ((Game1)Game).faceChaser.Enabled = true; ((Game1)Game).faceChaser.Visible = true; } gameConsole.GameConsoleWrite("FindFaces: " + this.FindFaces); } //Find Motion if (input.KeyboardState.WasKeyPressed(Keys.NumPad2)) { EnableMotion(); gameConsole.GameConsoleWrite("FindMotion: " + this.FindMotion); } #endregion base.Update(gameTime); if (input.KeyboardState.WasKeyPressed(Keys.M)) { this.ChangeRes(2); gameConsole.GameConsoleWrite("Camera FPS:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS).ToString()); gameConsole.GameConsoleWrite("Camera wIDTH:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH).ToString()); gameConsole.GameConsoleWrite("Camera height:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT).ToString()); } if (input.KeyboardState.WasKeyPressed(Keys.N)) { this.ChangeRes(-.5f); gameConsole.GameConsoleWrite("Camera FPS:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS).ToString()); gameConsole.GameConsoleWrite("Camera wIDTH:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH).ToString()); gameConsole.GameConsoleWrite("Camera height:" + _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT).ToString()); } }
internal static UserActionData CreateChangeFaceUserAction(byte number, PlayerFace face) { return(new UserActionData(number, 0u, UserAction.ChangeFace, new byte[1] { (byte)face })); }