Ejemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            DatabaseUpdates dataUpdates = GameMaster.DBUpdates;

            dataUpdates.SetContext(this);

            SetContentView(Resource.Layout.Main);

            Button button     = FindViewById <Button>(Resource.Id.MyButton);
            Button playButton = FindViewById <Button>(Resource.Id.PlayButton);

            PopulateTable <Ability>(dataUpdates);
            PopulateTable <Character>(dataUpdates);
            PopulateTable <Division>(dataUpdates);

            button.Click += (sender, e) =>
            {
                dataUpdates.GetAbility("Fireball").ReportAbility(dataUpdates.GetAbility("Fireball"));
                Console.WriteLine();
                Character mary = dataUpdates.GetCharacter("Mary");
                Console.WriteLine();
                Division div = dataUpdates.GetDivision("Mage");
                Console.WriteLine();
            };

            playButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(Activities.PlayActivity));
                StartActivity(intent);
            };
        }
Ejemplo n.º 2
0
 public void SetContext(Context context)
 {
     dbUpdates.SetContext(context);
 }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            DatabaseUpdates mydata = AppManager.DBUpdates;

            mydata.SetContext(this);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button playButton       = FindViewById <Button>(Resource.Id.PlayButton);
            Button friendsButton    = FindViewById <Button>(Resource.Id.FriendsButton);
            Button shopButton       = FindViewById <Button>(Resource.Id.ShopButton);
            Button claimCoinsButton = FindViewById <Button>(Resource.Id.ClaimCoinsButton);
            Button resetButton      = FindViewById <Button>(Resource.Id.ResetButton);

            List <string> allCollNames   = new List <string>();
            List <string> allFriendNames = new List <string>();

            PopupateRand();

            //foreach (Collectable coll in mydata.GetAllCollectables())
            //{
            //    allCollNames.Add(coll.Name);
            //}

            //foreach (Collectable coll in AppManager.Collectables)
            //{
            //    if (!allCollNames.Contains(coll.Name))
            //    {
            //        mydata.AddCollectable(coll);
            //    }
            //}

            //foreach (Friend friend in mydata.GetAllFriends())
            //{
            //    allFriendNames.Add(friend.Name);
            //}

            //foreach (Friend friend in AppManager.Friends)
            //{
            //    if (!allFriendNames.Contains(friend.Name))
            //    {
            //        mydata.AddFriend(friend);
            //    }
            //}

            //mydata.AddPlayer(new Player(AppManager.PlayerName));

            PopulateTable <Collectable>(mydata);
            PopulateTable <Player>(mydata);
            PopulateTable <Friend>(mydata);

            playButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(Puffin.PlayActivity));
                //intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
                StartActivity(intent);
            };

            friendsButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(Puffin.CollectionActivity));
                StartActivity(intent);
            };

            shopButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(Puffin.ShopActivity));
                StartActivity(intent);
            };

            claimCoinsButton.Click += (sender, e) =>
            {
                Player player = AppManager.DBUpdates.GetPlayer(AppManager.PlayerName);
                player.Coins += AppManager.ClaimCoin;
                AppManager.DBUpdates.UpdatePlayer(player);
                AppManager.ClaimCoin = 0;

                Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                {
                    FindViewById <TextView>(Resource.Id.ClaimCoinsButton).Text = String.Format("Claim {0} coins", AppManager.ClaimCoin.ToString());
                });
            };

            resetButton.Click += (sender, e) =>
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);

                alert.SetTitle(string.Format("Are you sure you want to reset all data?"));

                alert.SetPositiveButton("Yes", (senderAlert, args) =>
                {
                    //foreach (Collectable coll in AppManager.DBUpdates.GetAllCollectables())
                    //{
                    //    AppManager.DBUpdates.DeleteCollectable(coll);
                    //}
                    //foreach (Player player in AppManager.DBUpdates.GetAllPlayers())
                    //{
                    //    AppManager.DBUpdates.DeletePlayer(player);
                    //}
                    //foreach (Friend friend in AppManager.DBUpdates.GetAllFriends())
                    //{
                    //    AppManager.DBUpdates.DeleteFriend(friend);
                    //}
                    //foreach (Collectable coll in AppManager.Collectables)
                    //{
                    //    mydata.AddCollectable(coll);
                    //}
                    //mydata.AddPlayer(new Player(AppManager.PlayerName));
                    //foreach (Friend friend in AppManager.Friends)
                    //{
                    //    mydata.AddFriend(friend);
                    //}

                    ClearTable <Collectable>();
                    ClearTable <Player>();
                    ClearTable <Friend>();

                    PopulateTable <Collectable>(mydata);
                    PopulateTable <Player>(mydata);
                    PopulateTable <Friend>(mydata);
                });

                alert.SetNegativeButton("No", (senderAlert, args) =>
                {
                });

                Dialog dialog = alert.Create();
                dialog.Show();
            };


            Xamarin.Forms.Forms.Init(this, bundle);
            var timer = new System.Threading.Timer(e => OnTimer(), null, TimeSpan.Zero, TimeSpan.FromSeconds(5));
        }