Ejemplo n.º 1
0
        public void SetUpUI()
        {
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            toolbar.SetBackgroundColor(ColorCode.TeamColor(GameModel.Player.Team.ID));

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            ActionBar.SetHomeAsUpIndicator(Resource.Mipmap.ic_dehaze_white_24dp);
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout.DrawerStateChanged += DrawerLayout_DrawerStateChanged;

            Button changeUsernameBtn = FindViewById <Button>(Resource.Id.changeUsernameButton);
            Button changePasswordBtn = FindViewById <Button>(Resource.Id.changePasswordButton);
            Button switchTeamBtn     = FindViewById <Button>(Resource.Id.switchTeamButton);
            Button switchMapBtn      = FindViewById <Button>(Resource.Id.switchMapStyleButton);

            changeUsernameBtn.Click += ChangeUsernameBtn_Click;
            changePasswordBtn.Click += ChangePasswordBtn_Click;
            switchTeamBtn.Click     += SwitchTeamBtn_Click;
            switchMapBtn.Click      += SwitchMapBtn_Click;
        }
Ejemplo n.º 2
0
        protected override void OnResume()
        {
            base.OnResume();

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            toolbar.SetBackgroundColor(ColorCode.TeamColor(GameModel.Player.Team.ID));
        }
Ejemplo n.º 3
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Map);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            toolbar.SetBackgroundColor(ColorCode.TeamColor(GameModel.Player.Team.ID));

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            statusText     = FindViewById <TextView>(Resource.Id.textBelowMap);
            tagButton      = FindViewById <Button>(Resource.Id.claimButton);
            locationButton = FindViewById <Button>(Resource.Id.clientCameraLocationbtn);

            ActionBar.SetHomeAsUpIndicator(Resource.Mipmap.ic_dehaze_white_24dp);
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout.DrawerStateChanged += DrawerLayout_DrawerStateChanged;

            tagButton.Click      += TagButton_Click;
            locationButton.Click += LocationButton_Click;

            SetUpMap();

            var cellHubSetupTask = SetUpCellHub();

            if (CheckSelfPermission(Android.Manifest.Permission.AccessFineLocation) == Permission.Granted)
            {
                DisplayStatus("Finding location...");
                GetLocation();
            }
            else
            {
                RequestPermissions(LocationPermissions, RequestLocationID);
            }

            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);

                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_logout:
                    GameModel.Logout();
                    StartActivity(new Intent(this, typeof(LoginActivity)));
                    break;

                default:
                    break;
                }
                drawerLayout.CloseDrawers();
            };

            await cellHubSetupTask;
        }
Ejemplo n.º 4
0
        private async void ChangeTeam(object sender, long e)
        {
            int teamID = (int)e;

            await GameModel.Player.SwitchFaction(teamID);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            toolbar.SetBackgroundColor(ColorCode.TeamColor(GameModel.Player.Team.ID));

            Toast.MakeText(this, "Switched to the " + teams[e] + " faction.", ToastLength.Short).Show();
        }
Ejemplo n.º 5
0
        public MapOverlay(Cell cell)
        {
            CellID = cell.ID;

            PolygonOptions = new PolygonOptions();
            PolygonOptions.Add(new LatLng((double)cell.Latitude, (double)cell.Longitude)); //first rectangle point
            PolygonOptions.Add(new LatLng((double)cell.Latitude, (double)cell.Longitude + (double)GameModel.FrontierInterval));
            PolygonOptions.Add(new LatLng((double)cell.Latitude + (double)GameModel.FrontierInterval, (double)cell.Longitude + (double)GameModel.FrontierInterval));
            PolygonOptions.Add(new LatLng((double)cell.Latitude + (double)GameModel.FrontierInterval, (double)cell.Longitude)); //automatically connects last two points

            Color color = ColorCode.TeamColor(cell.TeamID);

            PolygonOptions.InvokeFillColor(color); //Transparent (alpha) int [0-255] 255 being opaque
            PolygonOptions.InvokeStrokeWidth(0);
        }
Ejemplo n.º 6
0
        public void SetUpUI()
        {
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            toolbar.SetBackgroundColor(ColorCode.TeamColor(GameModel.Player.Team.ID));

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            ActionBar.SetHomeAsUpIndicator(Resource.Mipmap.ic_dehaze_white_24dp);
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout.DrawerStateChanged += DrawerLayout_DrawerStateChanged;
        }
Ejemplo n.º 7
0
        protected override async void OnResume()
        {
            base.OnResume();


            if (CheckSelfPermission(Android.Manifest.Permission.AccessFineLocation) == Permission.Granted)
            {
                locMgr = GetSystemService(Context.LocationService) as LocationManager;
                RequestLocationUpdates();
            }
            if (CellHub.Connection.State != ConnectionState.Connected && CellHub.Connection.State != ConnectionState.Connecting)
            {
                await CellHub.Connection.Start();
            }

            if (mMap != null)
            {
                mMap.SetMapStyle(MapStyleOptions.LoadRawResourceStyle(this, GameModel.MapStyle));
                mMap.Clear();

                var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
                SetActionBar(toolbar);
                toolbar.SetBackgroundColor(ColorCode.TeamColor(GameModel.Player.Team.ID));
            }

            OverlaysToDraw.Clear();
            GameModel.CellsInView.Clear();
            GameModel.Player.AntiMines.Clear();
            GameModel.Player.Mines.Clear();

            // Get fresh player data
            GameModel.Player.AntiMines = await Database.GetAntiMines(GameModel.Player.ID);

            GameModel.Player.Mines = await Database.GetMines(GameModel.Player.ID);

            if (initialCameraLatLng != null)
            {
                // Refresh stale cell data
                await DrawCellsInView();
            }
        }
Ejemplo n.º 8
0
        public void SetUpUI()
        {
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            toolbar.SetBackgroundColor(ColorCode.TeamColor(GameModel.Player.Team.ID));

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            statusText     = FindViewById <TextView>(Resource.Id.textBelowMap);
            tagButton      = FindViewById <Button>(Resource.Id.claimButton);
            locationButton = FindViewById <Button>(Resource.Id.clientCameraLocationbtn);

            ActionBar.SetHomeAsUpIndicator(Resource.Mipmap.ic_dehaze_white_24dp);
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout.DrawerStateChanged += DrawerLayout_DrawerStateChanged;

            tagButton.Click      += TagButton_Click;
            locationButton.Click += LocationButton_Click;
        }
Ejemplo n.º 9
0
        public void UpdateOverlay(Cell updatedCell)
        {
            if (!Overlays.ContainsKey(updatedCell.ID))
            {
                RunOnUiThread(() =>
                {
                    MapOverlay mapOverlay = new MapOverlay(updatedCell);

                    mapOverlay.Draw(mMap);

                    Overlays.TryAdd(updatedCell.ID, mapOverlay);
                });
            }
            else
            {
                RunOnUiThread(() =>
                {
                    Overlays[updatedCell.ID].SetColor(ColorCode.TeamColor(updatedCell.TeamID));
                });
            }
        }
Ejemplo n.º 10
0
        public void UpdateColor(int holdStrength, int teamID)
        {
            if (teamID != GameModel.Player.Team.ID && MapOverlayClickHandler is FriendlyOverlayClickHandler)
            {
                MapOverlayClickHandler = new EnemyOverlayClickHandler();
            }
            else if (teamID == GameModel.Player.Team.ID && MapOverlayClickHandler is EnemyOverlayClickHandler)
            {
                MapOverlayClickHandler = new FriendlyOverlayClickHandler();
            }

            byte alpha = Convert.ToByte((int)(((float)holdStrength / GameModel.maxHoldStrength) * 255));

            if (alpha > 255)
            {
                alpha = 255;
            }

            Color overlayColor = ColorCode.TeamColor(teamID);

            overlayColor.A = alpha;

            SetColor(overlayColor);
        }