protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Achievement);
            AchievementManager achMan = new AchievementManager();

            List<string> achievements = achMan.GetAchievementsForGUI();

            List<string> achievementText = new List<string>();

            foreach (var item in achievements)
            {
                achievementText.Add(item.Split('=')[0]);
            }

            ListView listviewAchievements = FindViewById<ListView>(Resource.Id.listViewAchievements);
            listviewAchievements.Adapter = new ArrayAdapter<String>(this,
                                                                    Android.Resource.Layout.SimpleListItem1,
                                                                    achievementText);

            listviewAchievements.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
            {
            var bla = e.Id;
                // Handle the click event
                string lblText = (e.View as TextView).Text;
                if (achievements[Convert.ToInt32(e.Id)].Split('=')[1] == "V")
                {
                    ShareAchievement(lblText);
                }
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AchievementManager achMan = new AchievementManager();

            TBSAchievements source = new TBSAchievements(achMan.GetAchievementsForGUI().ToArray());

            source.OnRowSelected += (object sender, TBSAchievements.RowSelectedEventArgs e) =>
            {
                if (CheckColor(tbAchievements.Source.GetCell(tbAchievements, e.indexPath).BackgroundColor))
                {
                    ShareAchievement(tbAchievements.Source.GetCell(tbAchievements, e.indexPath).TextLabel.Text);
                }

                tbAchievements.DeselectRow(e.indexPath, true);
            };

            tbAchievements.Source = source;
            tbAchievements.ReloadData();
        }
Example #3
0
        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);
            }
        }
        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();
        }