Esempio n. 1
0
 void Start()
 {
     // SUPER JANK
     StartCoroutine(showAfterTime());
     this.transform.position = ScreenUtilities.GetWSofSSPosition(0.0f, 0.0f) + new Vector3(0, 0, Camera.main.transform.position.z + 200);
     playerMovement          = GameCritical.GameMaster.Instance.m_PlayerMovement;
 }
Esempio n. 2
0
        private void SetContent(bool orientationChanged = false)
        {
            ContentPager.Adapter = null;

            adapter = GetAdapter(this.Resources.Configuration.Orientation);
            if (!orientationChanged || adapter == null)
            {
                adapter = new DesktopContentAdapter(SupportFragmentManager);
                var rowHeight   = Resources.GetDimensionPixelSize(Resource.Dimension.AppCardHeightSize);
                var columnWidth = Resources.GetDimensionPixelSize(Resource.Dimension.AppCardWithtSize);

                AppsToShowForPage = ScreenUtilities.CalculateNumberOfAppsForRows(this, BtnConfig.Height, 0, rowHeight, columnWidth);
                int index = 0;
                var lst   = Helper.Global.AppInfoList.Count;
                if (Helper.Global.AppInfoList != null && AppsToShowForPage > 0)
                {
                    while (Helper.Global.AppInfoList.Count >= (index + 1) * AppsToShowForPage)
                    {
                        var index1 = index;
                        adapter.AddFragmentView((i, v, b) =>
                        {
                            var skip           = index1 * AppsToShowForPage;
                            var view           = i.Inflate(Resource.Layout.AppsFragmentLayout, v, false);
                            var grdview        = view.FindViewById <GridView>(Resource.Id.DescktopAppsGrid);
                            grdview.ItemClick -= GrdviewOnItemClick;
                            grdview.ItemClick += GrdviewOnItemClick;
                            var apps           = Helper.Global.AppInfoList.Skip(skip).Take(AppsToShowForPage).ToList();
                            grdview.Adapter    = new AppAdapter(this, apps);

                            return(view);
                        });
                        index++;
                    }

                    if (Helper.Global.AppInfoList.Count > index * AppsToShowForPage)
                    {
                        adapter.AddFragmentView((i, v, b) =>
                        {
                            var skip           = index * AppsToShowForPage;
                            var view           = i.Inflate(Resource.Layout.AppsFragmentLayout, v, false);
                            var grdview        = view.FindViewById <GridView>(Resource.Id.DescktopAppsGrid);
                            grdview.ItemClick -= GrdviewOnItemClick;
                            grdview.ItemClick += GrdviewOnItemClick;
                            var apps           =
                                Helper.Global.AppInfoList.Skip(skip)
                                .Take(Helper.Global.AppInfoList.Count - index * AppsToShowForPage)
                                .ToList();
                            grdview.Adapter = new AppAdapter(this, apps);
                            return(view);
                        });
                    }
                }

                SetAdapter(this.Resources.Configuration.Orientation, adapter);
            }

            ContentPager.Adapter = adapter;
            ContentPager.SetCurrentItem(CurrentPage, false);
        }
Esempio n. 3
0
        public WarpZone SpawnDeadZone()
        {
            Vector3 topMiddleInWorldSpace = ScreenUtilities.GetWSofSSPosition(0.5f, 1.0f);

            topMiddleInWorldSpace = new Vector3(topMiddleInWorldSpace.x, topMiddleInWorldSpace.y, GameMaster.Instance.m_PlayerMovement.transform.position.z);
            m_WarpZone            = (WarpZone)Instantiate(m_WarpZonePrefab, topMiddleInWorldSpace + m_WarpZonePrefab.GetOriginOffsetPosition(), Quaternion.identity);
            return(m_WarpZone);
        }
Esempio n. 4
0
        private void OnBrightnessChanged(object sender, ProgressChangedEventArgs e)
        {
            var prog = e.Progress;
            // change brightness
            float brightness = (float)(e.Progress) / 100f;

            ScreenUtilities.SetManualScreenBrightnessLevel(this, brightness);
        }
Esempio n. 5
0
        void Start()
        {
            // calculate camera offset by a percentage. So if offset is 0.8f then ball will be 80% up the screen.
            Vector3 playerTargetLocationWS = ScreenUtilities.GetWSofSSPosition(0.5f, m_CamOffsetAsPercentage);
            Vector3 cameraTargetLocationWS = ScreenUtilities.GetWSofSSPosition(0.5f, 0.5f);
            Vector3 camOffset = playerTargetLocationWS - cameraTargetLocationWS;

            camOffset = -camOffset;
            GameMaster.Instance.m_CameraFollow.SetOffset(camOffset, m_LerpTimeToCamOffset);

            DeathStar deathStar = GameMaster.Instance.m_DeathStar;

            if (deathStar)
            {
                deathStar.SetIsMoving(false);
            }
            SetWarpParticleSystem(true);
        }
Esempio n. 6
0
        private void GetAndSetBrightnessBrightness()
        {
            // get current brightness mode
            var mode          = ScreenUtilities.GetScreenBrightnessMode(this);
            var brightness    = ScreenUtilities.GetScreenBrightnessWithMode(this, mode);
            var brightnessInt = (int)Math.Round(brightness * 100);

            // set the level on the control if different from current position (user or system may have altered the brightness outside the app)
            // <0 check done in case auto value returned
            if (brightnessInt >= 0 && brightnessInt != _brightnessControl.Progress)
            {
                _brightnessControl.Progress = brightnessInt;
            }
            else if (brightnessInt < 0 && _brightnessControl.Progress != 100)  // Done for initialization purposed - especially on emulators
            {
                _brightnessControl.Progress = 100;
            }
        }
Esempio n. 7
0
        public void SetPositionLaserPost(Vector3 pos, bool onRightSide)
        {
            m_IsOnRight = onRightSide;

            this.transform.position = pos;
            m_TargetPosition        = pos;

            // get vector based on screen percentage laser takes up
            Vector3 laserVector        = ScreenUtilities.GetWSofSSPosition(m_LaserLength, 0.0f);
            Vector3 centerScreenVector = ScreenUtilities.GetWSofSSPosition(0.0f, 0.0f);

            laserVector = centerScreenVector - laserVector;

            m_LaserBlinkInstance = Instantiate(
                m_LaserBlinkPrefab,
                this.transform.position,
                Quaternion.identity,
                this.transform);

            // orient laser based on if it is on left or right side of screen.
            if (onRightSide)
            {
                this.transform.localRotation = Quaternion.Euler(0, 0, 180.0f);
                m_LaserBlinkInstance.transform.localRotation = Quaternion.Euler(0, 0, 180.0f);
                m_TargetPosition += laserVector;
            }
            else
            {
                this.transform.localRotation = Quaternion.Euler(0, 0, 0);
                m_LaserBlinkInstance.transform.localRotation = Quaternion.Euler(0, 0, 180.0f);
                m_TargetPosition -= laserVector;
            }

            // move original position of laser
            m_LineRenderer.SetPosition(0, this.transform.position);
            m_LineRenderer.SetPosition(1, this.transform.position);
        }
Esempio n. 8
0
        public static void ReCalculateAddonPositions()
        {
            Rectangle rect;
            var       handles   = GetGameHandles();
            var       locations = new Dictionary <IntPtr, Rectangle>();

            for (var i = 0; i < handles.Count; i++)
            {
                var handle = handles[i];

                try
                {
                    GetWindowRect(handle, out rect);
                    SetForegroundWindow(handle);
                    Thread.Sleep(500);
                    rect.Width  -= rect.X;
                    rect.Height -= rect.Y;
                    Bitmap clone;

                    var bounds        = ScreenUtilities.GetScreenBounds();
                    var winBottomLeft = new Point(rect.X, rect.Y + rect.Height);
                    var scanArea      = new Rectangle(winBottomLeft.X, winBottomLeft.Y - 500, 500, 500);

                    if (scanArea.Y < 0)
                    {
                        scanArea.Height += scanArea.Y;
                        scanArea.Y       = 0;
                    }
                    if (scanArea.X < 0)
                    {
                        scanArea.Width += scanArea.X;
                        scanArea.X      = 0;
                    }

                    Console.WriteLine($"Scan area x:{scanArea.X}, y:{scanArea.Y}, w:{scanArea.Width}, h:{scanArea.Height}");
                    using (var bitmap = new Bitmap(bounds.Width, bounds.Height))
                    {
                        using (var g = Graphics.FromImage(bitmap))
                        {
                            g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
                        }
                        clone = bitmap.Clone(scanArea, PixelFormat.Format24bppRgb);
                    }

                    var addonBottomLeft = FindAddonBottomLeft(clone);
                    var frameSize       = CalculateFrameSize(addonBottomLeft, clone);
                    if (frameSize <= 1)
                    {
                        Console.WriteLine("Could not locate addon on screen.");
                        locations.Add(handles[i], new Rectangle(1, 1, 1, 1));
                        continue;
                    }

                    var settings = SettingsLoader.LoadSettings <AppSettings>("settings.json");

                    var location = new Rectangle(
                        scanArea.X + addonBottomLeft.X,
                        scanArea.Y + addonBottomLeft.Y - (frameSize * settings.AddonRowCount) + 1,
                        frameSize * settings.AddonColumnCount,
                        frameSize * settings.AddonRowCount);

                    if (location.Height == 0 || location.Width == 0)
                    {
                        Console.WriteLine("Could not locate addon on screen.");
                        location = new Rectangle(1, 1, 1, 1);
                    }
                    else
                    {
                        Console.WriteLine("Ingame addon successfully located on screen: " + location);
                    }
                    locations.Add(handles[i], location);
                    Thread.Sleep(200);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("Exception: Could not locate addon on screen.");
                    locations.Add(handles[i], new Rectangle(1, 1, 1, 1));
                }
            }

            InGameAddonLocations = locations;
        }
Esempio n. 9
0
 public ScreenChangedDispatcher()
     : base()
 {
     EventName     = "ScreenChanged";
     _screenbounds = ScreenUtilities.GetScreenBounds();
 }
Esempio n. 10
0
 private void Awake()
 {
     ScreenUtilities.Initialize();
     ConfigurationManager.Initialize();
     Pools.Initialize();
 }
Esempio n. 11
0
        public void Init()
        {
            // pre fill the zap grid before shuffling.
            m_ZapGrid = new List <List <Zap> >();
            for (int i = 0; i < m_Rows + 1; i++)
            {
                List <Zap> zapRowToFill = new List <Zap>();

                if (i >= m_Rows)
                {
                    for (int j = 0; j < m_Cols; j++)
                    {
                        zapRowToFill.Add(m_EndZapPrefab);
                    }
                }
                else
                {
                    // spawn all required zaps for this row
                    int totalForcedPrefabsAdded = 0;
                    for (int j = 0; j < m_ZapPrefabsForced.Count; j++)
                    {
                        int numOfPrefabToSpawn = m_ZapPrefabsForced[j];
                        Zap prefabToSpawn      = m_ZapPrefabs[j];
                        for (int k = 0; k < numOfPrefabToSpawn; k++)
                        {
                            zapRowToFill.Add(prefabToSpawn);
                            totalForcedPrefabsAdded++;
                        }
                    }

                    for (int j = totalForcedPrefabsAdded; j < m_Cols; j++)
                    {
                        // spawn zap
                        Zap zapPrefab = GetRandomZapPrefab();
                        zapRowToFill.Add(zapPrefab);
                    }

                    // shuffle the zaps in each row
                    for (int k = 0; k < zapRowToFill.Count; k++)
                    {
                        Zap temp        = zapRowToFill[k];
                        int randomIndex = (int)Random.Range(0, zapRowToFill.Count - 1);
                        zapRowToFill[k]           = zapRowToFill[randomIndex];
                        zapRowToFill[randomIndex] = temp;
                    }
                }

                m_ZapGrid.Add(zapRowToFill);
            }

            // Do one time calculations for grid before spawning zaps.
            Vector3 topLeftInWorldSpace = Camera.main.ScreenToWorldPoint(
                new Vector3(0, 1.5f * ScreenUtilities.GetDistanceInWS(1.0f), 0));
            Vector3 origin = topLeftInWorldSpace;

            origin.z = 1.0f;
            this.transform.position = origin;
            m_ZapWidth = CalculateZapWidth(m_EndZapPrefab, m_Cols);

            for (int i = 0; i < m_Rows + 1; i++)
            {
                Vector3 spawnPos = Vector3.zero;
                for (int j = 0; j < m_Cols; j++)
                {
                    // set position accordingly relative to previous zap.
                    if (j > 0)
                    {
                        Zap prevZap = m_ZapGrid[i][j - 1];
                        spawnPos = prevZap.transform.position + new Vector3(prevZap.Width, 0, 0);
                    }
                    else // spawn start zap in row
                    {
                        spawnPos = origin + new Vector3(0, i * m_RowGapDistance, 0);
                    }

                    Zap zapPrefab = m_ZapGrid[i][j];
                    if (zapPrefab != null)
                    {
                        Zap zap = (Zap)Instantiate(zapPrefab, this.transform);
                        if (zap.IsDangerousZap)
                        {
                            m_DangerousZaps.Add(zap);
                        }
                        if (zap.m_HasPoints && zap.m_Points > 0)
                        {
                            m_LucrativeZaps.Add(zap);
                        }
                        zap.transform.position = spawnPos;
                        zap.SetWidth(m_ZapWidth);
                        zap.SetHeight(m_ZapHeight);
                        zap.SetOffsetDistance(m_OffsetDistance);
                        zap.Row         = i;
                        zap.Col         = j;
                        m_ZapGrid[i][j] = zap;

                        // spawn things randomly on zap
                        // SpawnRandomObstacle(i, j, m_ChanceOfObstacle);
                    }
                }
            }

            // randomly determine if there is zap money on this zap
            for (int i = 0; i < m_MaxZapMoneys; i++)
            {
                float randomPercentChance = Random.Range(0.0f, 1.0f);
                if (randomPercentChance <= m_ZapMoneyProbability)
                {
                    Zap randomZap = GetRandomZap();
                    if (randomZap != null && !randomZap.GetIsOccupied())
                    {
                        ZapMoney zapMoney = Instantiate(
                            m_ZapMoneyPrefab,
                            randomZap.GetOffsetPosition(),
                            Quaternion.identity,
                            this.transform);
                        randomZap.SetOccupied(true);
                    }
                }
            }
        }