public override void ViewDidLoad() { base.ViewDidLoad(); if (GlobalSupport.EverythingOkay) { codeDatabase = DataBase.Instance(); SetGameSpeed(); robot = TiledParser.Parse(File.Open("Maps/" + GlobalSupport.GameDifficulty.ToString() + "/" + GlobalSupport.GameLevel, FileMode.Open, FileAccess.Read), GlobalSupport.GameLevel); achievementManager = new AchievementManager(); achievementManager.AchievementUnlocked += (sender, e) => { if (e is AchievementEventArgs) { var achievementString = (e as AchievementEventArgs).data.message; GlobalSupport.ShowPopupMessage("Achievement Unlocked", achievementString); } }; if (GlobalSupport.GameLanguage == EGameLanguage.Pascal) { achievementManager.RegisterEvent(EAchievementType.StartPascal, 0); } else if (GlobalSupport.GameLanguage == EGameLanguage.Python) { achievementManager.RegisterEvent(EAchievementType.StartPython, 0); } level = robot.level; defRobotX = robot.xPosition; defRobotY = robot.yPosition; Robot.UpdateRobotEvent += UpdateRobot; Robot.checkGoalsEvent += (object sender, EventArgs e) => { CheckGoals(sender,e); }; keyboardMoveView = new KeyboardMoveView(); keyboardMoveView.RegisterForKeyboardNotifications(); keyboardMoveView.ActiveView = txtCodeField; this.View.AddGestureRecognizer(new UITapGestureRecognizer(tap => { if (!txtCodeField.Frame.Contains(tap.LocationInView(this.View))) { if (txtCodeField.IsFirstResponder) { txtCodeField.ResignFirstResponder(); } } })); btnCodeSave.TouchUpInside += (object sender, EventArgs e) => { if (!String.IsNullOrEmpty(txtCodeField.Text)) { SaveCode(); // GlobalSupport.ShowPopupMessage("Code succesvol opgeslagen"); } }; btnCodeOpen.TouchUpInside += (object sender, EventArgs e) => { OpenCode(); }; btnCodeShare.TouchUpInside += (object sender, EventArgs e) => { ShareCode(); }; btnCodeDelete.TouchUpInside += (object sender, EventArgs e) => { DeleteCode(); }; btnCodeValidate.TouchUpInside += (object sender, EventArgs e) => { ValidateCode(); }; btnCodeReset.TouchUpInside += (object sender, EventArgs e) => { ResetCode(true); }; ResetCode(true); } else { this.NavigationController.PopViewController(true); } }
/// <summary> /// Creates an instance of the Robot /// </summary> /// <param name="position">robotPosition.</param> /// <param name="orientation">Orientation.</param> /// <created>Stef Chappin</created> public static Robot Create(EOrientation orientation, Map map) { instance = new Robot (orientation, map); return instance; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); /*SetContentView (new MapRenderer (this));*/ alert = new AlertDialog.Builder(this).Create(); codeDatabase = DataBase.Instance(); DisplayMetrics metrics = Resources.DisplayMetrics; SetContentView(Resource.Layout.Game); this.Title = "Level: " + GlobalSupport.GameLevel.Remove(GlobalSupport.GameLevel.Length - 4, 4) + "; Lang: " + GlobalSupport.GameLanguage.ToString(); SetGameSpeed(); mapRenderer = new MapRenderer(); robot = TiledParser.Parse(Assets.Open("Maps/" + GlobalSupport.GameDifficulty.ToString() + "/" + GlobalSupport.GameLevel), GlobalSupport.GameLevel); defRobotX = robot.xPosition; defRobotY = robot.yPosition; Robot.UpdateRobotEvent += new EventHandler(UpdateRobot); Robot.checkGoalsEvent += new EventHandler(CheckGoals); imgGameMap = FindViewById<ImageView>(Resource.Id.imgGameMap); imgGameMap.SetMinimumWidth(metrics.WidthPixels); imgGameMap.SetMinimumHeight(metrics.WidthPixels); imgGameMap.SetImageDrawable(new BitmapDrawable(Resources, mapRenderer.Render(robot.level, Resources, robot.xPosition, robot.yPosition))); txtCodeField = FindViewById<EditText>(Resource.Id.txtGameCodeInput); lblError = FindViewById<TextView>(Resource.Id.txtGameError); lblExecutedCode = FindViewById<TextView>(Resource.Id.btnGameCodeExecute); lblGoals = FindViewById<TextView>(Resource.Id.txtGoals); btnValidate = FindViewById<Button>(Resource.Id.btnGameCodeValidate); btnOptions = FindViewById<Button> (Resource.Id.btnGameOptions); _achievementManager = new AchievementManager(); _achievementManager.AchievementUnlocked += (sender, e) => { if (e is AchievementEventArgs) { var achievementString = (e as AchievementEventArgs).data.message; ShowPopUpMessage(achievementString); } }; if (GlobalSupport.GameLanguage == EGameLanguage.Pascal) { _achievementManager.RegisterEvent(EAchievementType.StartPascal, 0); } else if (GlobalSupport.GameLanguage == EGameLanguage.Python) { _achievementManager.RegisterEvent(EAchievementType.StartPython, 0); } btnValidate.Click += (object sender, EventArgs e) => { ValidateCode(); }; btnOptions.Click += (object sender, EventArgs e) => { var optionsMenu = new Intent(this, typeof(ActivityOptions)); StartActivity(optionsMenu); }; btnReset = FindViewById<Button>(Resource.Id.btnGameCodeReset); btnReset.Click += (object sender, EventArgs e) => { ResetCode(true); }; btnSaveCode = FindViewById<Button>(Resource.Id.btnGameCodeSave); btnSaveCode.Click += (object sender, EventArgs e) => { SaveCode(); }; btnOpenCode = FindViewById<Button>(Resource.Id.btnGameCodeOpen); btnOpenCode.Click += (object sender, EventArgs e) => { OpenCode(); }; btnShareCode = FindViewById<Button>(Resource.Id.btnGameCodeShare); btnShareCode.Click += (object sender, EventArgs e) => { ShareCode(); }; btnDeleteCode = FindViewById<Button>(Resource.Id.btnGameCodeDelete); btnDeleteCode.Click += (object sender, EventArgs e) => { DeleteCode(); }; txtHelp = FindViewById<TextView>(Resource.Id.txtGameHelp); txtHelp.Click += (sender, e) => { OpenHelp(); }; ResetCode(true); SetGoals(); }