void Awake() { _instance = this; Content_String = "IM"; Content_CharArray.Initialize(); mAudio = gameObject.GetComponent <AudioSource> (); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { ScreenManager.Update(gameTime); #if WINDOWS KeyBoardManager keyboard = KeyBoardManager.Instance; if (keyboard.IsKeyPressed(Keys.P)) { using (System.IO.Stream stream = System.IO.File.Create(String.Format("ScreenShots//{0}.png", ScreenManager.MainScreen))) { Texture2D image = ScreenManager.GetScreen(ScreenManager.MainScreen).RenderTarget; image.SaveAsPng(stream, image.Width, image.Height); } } #else if (ScreenManager.MainScreen != "Game") { elapsedAdRefreshTime += gameTime.ElapsedGameTime; if (elapsedAdRefreshTime >= adRefreshTime) { elapsedAdRefreshTime = TimeSpan.Zero; Global.LoadAds(); } } #endif base.Update(gameTime); }
protected override void Initialize() { Setting setting = Setting.Create(); Global.MusicEnabled = setting.Get <bool>("music"); Global.SFXEnabled = setting.Get <bool>("sfx"); Global.Control = setting.Get <int>("control").Cast <ControlTypes>(); //need to check if android can actually store longs for (int i = 0; i < Global.HighScores.Length; i++) { Global.HighScores[i] = TimeSpan.FromTicks(setting.Get <long>(String.Format("HighScore{0}", i))); Global.HighScoresType[i] = setting.Get <int>(String.Format("HighScoreControl{0}", i)).Cast <ControlTypes>(); Global.HighScoreDates[i] = new DateTime(setting.Get <long>(String.Format("HighScoresDate{0}", i))); } Global.PlayTutorial = true; setting.Set("music", Global.MusicEnabled, typeof(bool)); setting.Set("sfx", Global.SFXEnabled, typeof(bool)); setting.Set("control", Global.Control.ToInt(), typeof(int)); for (int i = 0; i < Global.HighScores.Length; i++) { setting.Set(String.Format("HighScore{0}", i), Global.HighScores[i].Ticks, typeof(long)); setting.Set(String.Format("HighScoreControl{0}", i), Global.HighScoresType[i].ToInt(), typeof(int)); setting.Set(String.Format("HighScoresDate{0}", i), Global.HighScoreDates[i].Ticks, typeof(long)); } #if !WINDOWS TouchManager touchManager = TouchManager.Create(this); touchManager.GestureTypes = GestureType.DragComplete | GestureType.Flick | GestureType.HorizontalDrag | GestureType.FreeDrag | GestureType.Tap; Components.Add(touchManager); //TouchPanel.EnabledGestures = GestureType.DragComplete | GestureType.VerticalDrag | GestureType.HorizontalDrag | GestureType.Tap; #else Components.Add(KeyBoardManager.Create(this)); Components.Add(MouseManager.Create(this)); Global.Control = ControlTypes.Tap; #endif //TargetElapsedTime = TimeSpan.FromMilliseconds(1000f / 30f); //IsFixedTimeStep = false; base.Initialize(); }
public override void OnGazeClick(PointerEventData data) { Debug.Log("input click"); if (mKeyBoard == null) { mKeyBoard = GameObject.Find("KeyBoard"); Debug.Log("input click mKeyBoard" + (mKeyBoard == null)); } KeyBoardManager kbm = mKeyBoard.GetComponent <KeyBoardManager>(); kbm.keyBoardShow(!kbm.mIsShowKeyboard); if (mKeyBoard.activeSelf) { mKeyBoard.GetComponent <KeyBoardManager>().mInput = transform.Find("Text").GetComponent <Text>(); } }
private void handleInput() { #if WINDOWS KeyBoardManager keybaord = KeyBoardManager.Instance; if (keybaord.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Left) && playerIndex != 0) { direction = Direction.Left; } else if (keybaord.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Right) && playerIndex != fallingLocation.Length - 1) { direction = Direction.Right; } else if (keybaord.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.LeftAlt)) { debug = !debug; } #else TouchManager touch = TouchManager.Instance; if (touch.TouchPoints.Count == 1 && !isTouchAlready) { isTouchAlready = true; foreach (var touchPoint in touch.TouchPoints) { Vector2 tapLocationTranslation = touchPoint.Position / Scale; if (tapLocationTranslation.X < RenderTarget.Width / 2) { direction = Direction.Left; } else { direction = Direction.Right; } } } else if (touch.TouchPoints.Count == 0) { isTouchAlready = false; } #endif switch (direction) { case Direction.Right: playerIndex++; if (playerIndex < 0 || playerIndex > fallingLocation.Length - 1) { player.CurrentState = CharacterState.Idle; direction = Direction.None; } else { player.CurrentState = CharacterState.Moving; player.Effect = SpriteEffects.FlipHorizontally; if (Global.SFXEnabled) { rightSwipe.Play(); //XnaAudio.MediaPlayer.Play(rightSwipe); } } break; case Direction.Left: playerIndex--; if (playerIndex < 0 || playerIndex > fallingLocation.Length - 1) { player.CurrentState = CharacterState.Idle; direction = Direction.None; } else { player.CurrentState = CharacterState.Moving; player.Effect = SpriteEffects.None; if (Global.SFXEnabled) { leftSwipe.Play(); //XnaAudio.MediaPlayer.Play(leftSwipe); } } break; default: //do nothing break; } CheckLocation(); if (direction == Direction.Right) { player.X = fallingLocation[playerIndex].X; } }