예제 #1
0
파일: Lock.cs 프로젝트: fordream/Locks
 public static Sunfish.Views.Sprite CreateDial(int currentPosition)
 {
     Sunfish.Views.Sprite dial = new Sunfish.Views.Sprite (LocksGame.ActiveScreen.LoadTexture ("LockDial"), Sunfish.Constants.ViewLayer.Layer5);
     if (currentPosition != 0) {
         dial.RotationRadians = PositionsToRadians (currentPosition);
     }
     return dial;
 }
예제 #2
0
파일: Lock.cs 프로젝트: fordream/Locks
        public Lock(Models.Lock lockModel, int worldNumber, bool isFirstRow, bool isLastRow, bool isFirstCol, bool isLastCol)
            : base(LoadLockBackground(worldNumber), new Vector2(0,0), Sunfish.Constants.ViewLayer.Layer2, Sunfish.Constants.ViewContainerLayout.Absolute)
        {
            WorldNumber = worldNumber;
            LockModel = lockModel;

            CreateGearsAndPipes (isFirstRow, isLastRow, isFirstCol, isLastCol);

            Texture2D facePlateTexture = LocksGame.ActiveScreen.LoadTexture ("LockFaceplate_" + (worldNumber + 1).ToString ());
            Sunfish.Views.Sprite faceplate = new Sunfish.Views.Sprite (facePlateTexture, Sunfish.Constants.ViewLayer.Layer3);
            AddChild (faceplate);

            Layout = Sunfish.Constants.ViewContainerLayout.FloatLeft;

            CreateLockIndicatorAndDial ();
            CreateLockButtons ();
        }
예제 #3
0
파일: Lock.cs 프로젝트: fordream/Locks
        private void CreateLockIndicatorAndDial()
        {
            LockIndicator = CreateLockIndicator (LockModel.IsUnlocked ());
            Dial = CreateDial (LockModel.CurrentPosition);

            Sunfish.Views.Container dialContainer = new Sunfish.Views.Container (Width, 0, Sunfish.Constants.ViewLayer.Layer4, Sunfish.Constants.ViewContainerLayout.StackCentered);
            dialContainer.ShouldExpandHeight = true;
            dialContainer.AddChild (LockIndicator, 0, PixelsWithDensity (4));
            dialContainer.AddChild (Dial, 0, PixelsWithDensity (5) - PixelsWithDensity(63));
            AddChild (dialContainer);
        }
예제 #4
0
파일: Lock.cs 프로젝트: fordream/Locks
        private void CreateGearsAndPipes(bool isFirstRow, bool isLastRow, bool isFirstCol, bool isLastCol)
        {
            float halfWidth = (float)Width * 0.5f;
            float halfHeight = (float)Height * 0.5f;

            string worldNumberForTexture = (WorldNumber + 1).ToString ();

            // Gears
            Texture2D gearTexture = LocksGame.ActiveScreen.LoadTexture ("Gear_" + worldNumberForTexture);
            Vector2 gearLeftPosition = new Vector2 ((halfWidth - ((float)gearTexture.Width) * 0.5f) - PixelsWithDensity (20), PixelsWithDensity (35));
            Vector2 gearRightPosition = new Vector2 ((halfWidth - ((float)gearTexture.Width) * 0.5f) + PixelsWithDensity (20), PixelsWithDensity (35));
            GearLeft = new Sunfish.Views.Sprite (gearTexture, gearLeftPosition, Sunfish.Constants.ViewLayer.Layer2);
            GearRight = new Sunfish.Views.Sprite (gearTexture, gearRightPosition, Sunfish.Constants.ViewLayer.Layer2);
            AddChild (GearLeft);
            AddChild (GearRight);

            Sunfish.Views.Sprite pipeSprite = null;

            // Horizontal Pipes
            //			Texture2D pipeHorizontal = LocksGame.ActiveScreen.LoadTexture ("PipeHorizontal1");
            //			float halfPipeHorizontalHeight = pipeHorizontal.Height * 0.5f;
            //			if (isLastCol) {
            //				Vector2 pipePosition = new Vector2 (-pipeHorizontal.Width, halfHeight - halfPipeHorizontalHeight);
            //				pipeSprite = new Sunfish.Views.Sprite (pipeHorizontal, pipePosition, Sunfish.Constants.ViewLayer.Layer1);
            //			} else {
            //				Vector2 pipePosition = new Vector2 (Width, halfHeight - halfPipeHorizontalHeight);
            //				pipeSprite = new Sunfish.Views.Sprite (pipeHorizontal, pipePosition, Sunfish.Constants.ViewLayer.Layer1);
            //			}
            //			pipeSprite.OverlayColor = new Color (0.5f, 0.5f, 0.5f, 0.5f);
            //			AddChild (pipeSprite);
            int pipeIndex = ((LockModel.GridRow + LockModel.GridCol) % 2) + 1;
            if (!isLastCol) {
                Texture2D pipeHorizontal = LocksGame.ActiveScreen.LoadTexture ("PipeHorizontal" + pipeIndex.ToString());
                float halfPipeHorizontalHeight = pipeHorizontal.Height * 0.5f;
                Vector2 pipePosition = new Vector2 (Width, halfHeight - halfPipeHorizontalHeight);
                pipeSprite = new Sunfish.Views.Sprite (pipeHorizontal, pipePosition, Sunfish.Constants.ViewLayer.Layer1);
                //pipeSprite.OverlayColor = new Color (0.5f, 0.5f, 0.5f, 0.5f);
                AddChild (pipeSprite);
            }

            // Vertical Pipes
            Texture2D pipeVertical = LocksGame.ActiveScreen.LoadTexture ("PipeVertical" + pipeIndex.ToString());
            float halfPipeVerticalWidth = pipeVertical.Width * 0.5f;
            if (isLastRow) {
                Vector2 pipePosition = new Vector2 (halfWidth - halfPipeVerticalWidth, 0);
                pipeSprite = new Sunfish.Views.Sprite (pipeVertical, pipePosition, Sunfish.Constants.ViewLayer.Layer1);
            } else {
                Vector2 pipePosition = new Vector2 (halfWidth - halfPipeVerticalWidth, Height);
                pipeSprite = new Sunfish.Views.Sprite (pipeVertical, pipePosition, Sunfish.Constants.ViewLayer.Layer1);
            }
            //pipeSprite.OverlayColor = new Color (0.5f, 0.5f, 0.5f, 0.5f);
            AddChild (pipeSprite);
        }
예제 #5
0
파일: Level.cs 프로젝트: fordream/Locks
        private void CreateSolvedPopup()
        {
            StarsView = Views.Stars.Create (0, Sunfish.Constants.ViewLayer.Modal);

            string initialTextForSizing = Model.IsLastLevel () ? "All Levels Complete!" : "Solved in 99 Turns";
            SolvedLabel = new Label (initialTextForSizing, LocksGame.GetTopBarFont (), Color.AntiqueWhite, Sunfish.Constants.ViewLayer.Modal);

            Sunfish.Views.Sprite nextLevelButton = null;
            if ( ! Model.IsLastLevel()) {
                nextLevelButton = new Sunfish.Views.Sprite (LoadTexture ("NextLevelButton"), Sunfish.Constants.ViewLayer.Modal);
                nextLevelButton.EnableTapGesture (HandleNextLevelButtonTapped);
            }

            Sunfish.Views.Sprite retryButton = new Sunfish.Views.Sprite (LoadTexture ("RetryButton"), Sunfish.Constants.ViewLayer.Modal);
            retryButton.EnableTapGesture (HandleRetryButtonTapped);

            Sunfish.Views.Sprite quitButton = new Sunfish.Views.Sprite (LoadTexture ("QuitGameButton"), Sunfish.Constants.ViewLayer.Modal);
            quitButton.EnableTapGesture (HandleQuitButtonFromSolvedPopupTapped);

            SolvedPopup = AddPopup (LoadTexture ("PopupBackground"), Sunfish.Constants.ViewContainerLayout.StackCentered);
            SolvedPopup.TransitionAudioVolume = 0.8f;

            /** Add solved popup children **/

            SolvedPopup.AddChild (StarsView, 0, PixelsWithDensity (Model.IsLastLevel() ? 60 : 35));
            SolvedPopup.AddChild (SolvedLabel, 0, PixelsWithDensity (12));
            if (nextLevelButton != null) {
                SolvedPopup.AddChild (nextLevelButton, 0, PixelsWithDensity (25));
            }
            SolvedPopup.AddChild (retryButton, 0, PixelsWithDensity (Model.IsLastLevel() ? 60 : 25));
            SolvedPopup.AddChild (quitButton, 0, PixelsWithDensity (25));
        }
예제 #6
0
파일: Level.cs 프로젝트: fordream/Locks
        private void CreatePausedPopup()
        {
            PausedPopup = AddPopup (LoadTexture ("PopupBackground"), Sunfish.Constants.ViewContainerLayout.StackCentered);
            PausedPopup.TransitionAudioFilename = "PopupTransition";
            PausedPopup.TransitionAudioVolume = 0.8f;

            Sunfish.Views.Sprite resumeButton = new Sunfish.Views.Sprite (LoadTexture ("ResumeGameButton"), Sunfish.Constants.ViewLayer.Modal);
            Sunfish.Views.Sprite restartButton = new Sunfish.Views.Sprite (LoadTexture ("RestartGameButton"), Sunfish.Constants.ViewLayer.Modal);
            Sunfish.Views.Sprite quitButton = new Sunfish.Views.Sprite (LoadTexture ("QuitGameButton"), Sunfish.Constants.ViewLayer.Modal);

            resumeButton.EnableTapGesture (HandleResumeButtonTapped);
            restartButton.EnableTapGesture (HandleRestartButtonTapped);
            quitButton.EnableTapGesture (HandleQuitButtonFromPausedPopupTapped);

            PausedPopup.AddChild (resumeButton, 0, PixelsWithDensity (80));
            PausedPopup.AddChild (restartButton, 0, PixelsWithDensity (30));
            PausedPopup.AddChild (quitButton, 0, PixelsWithDensity (30));
        }
예제 #7
0
파일: Level.cs 프로젝트: fordream/Locks
        private void CreateAndPopulateTopBar()
        {
            Sunfish.Views.Sprite pauseButton = new Sunfish.Views.Sprite (LoadTexture ("PauseButton"));
            pauseButton.EnableTapGesture (HandlePauseButtonTapped);

            Sunfish.Views.Sprite settingsButton = new Sunfish.Views.Sprite (LoadTexture ("SettingsButton"));
            settingsButton.EnableTapGesture (HandleSettingsButtonTapped);

            Sunfish.Views.Sprite tutorialButton = new Sunfish.Views.Sprite (LoadTexture ("TutorialButton"));
            tutorialButton.EnableTapGesture (HandleTutorialButtonTapped);

            Sunfish.Views.Sprite turnsIcon = new Sunfish.Views.Sprite (LoadTexture ("TopBarTurn"));
            TurnsLabel = new Sunfish.Views.Label ("0", LocksGame.GetTopBarFont (), Color.AntiqueWhite);
            UpdateTurnsLabel ();

            Sunfish.Views.Sprite gemIcon = new Sunfish.Views.Sprite (LoadTexture ("TopBarGem"));
            LockedCountLabel = new Sunfish.Views.Label ("0", LocksGame.GetTopBarFont (), Color.AntiqueWhite);
            UpdateLockCountLabel ();

            int levelNumberForLabel = (WorldNumber * Locks.Core.Constants.WorldLevelCount) + LevelNumber + 1;
            Sunfish.Views.Sprite levelIcon = new Sunfish.Views.Sprite (LoadTexture ("TopBarWorld" + (WorldNumber+1).ToString()));
            Sunfish.Views.Label levelLabel = new Sunfish.Views.Label ("Level " + levelNumberForLabel.ToString (), LocksGame.GetTopBarFont (), Color.AntiqueWhite);

            SettingsPopup = new Views.SettingsPopup ();
            AddChildView (SettingsPopup);

            GameCenterButton gameCenterButton = new GameCenterButton ();

            CreateTopBar ();
            TopBar.AddChild (pauseButton, PixelsWithDensity (10), PixelsWithDensity (10));
            TopBar.AddChild (settingsButton, PixelsWithDensity (10), PixelsWithDensity (10));
            TopBar.AddChild (tutorialButton, PixelsWithDensity (10), PixelsWithDensity (10));
            TopBar.AddChild (turnsIcon, PixelsWithDensity (70), PixelsWithDensity (25));
            TopBar.AddChild (TurnsLabel, PixelsWithDensity (5), PixelsWithDensity (20));
            TopBar.AddChild (gemIcon, PixelsWithDensity (70), PixelsWithDensity (25));
            TopBar.AddChild (LockedCountLabel, PixelsWithDensity (5), PixelsWithDensity (20));
            TopBar.AddChild (levelIcon, PixelsWithDensity (70), PixelsWithDensity (25));
            TopBar.AddChild (levelLabel, PixelsWithDensity (5), PixelsWithDensity (20));
            TopBar.AddChild (gameCenterButton);
            gameCenterButton.PositionInTopRight ();

            if (LevelNumber == 0 && WorldNumber == 0 && LocksGame.GameProgress.GetSolvedLevel (LevelNumber, WorldNumber) == null) {
                TutorialEmphasisArrow = new Sunfish.Views.Sprite (LoadTexture ("UpArrow"), Sunfish.Constants.ViewLayer.Layer5);
                Vector2 initialPosition = new Vector2 (tutorialButton.Position.X + PixelsWithDensity(10), tutorialButton.Position.Y + tutorialButton.Height + PixelsWithDensity (10));
                Vector2 finalPosition = new Vector2 (tutorialButton.Position.X + PixelsWithDensity(10), tutorialButton.Position.Y + tutorialButton.Height - PixelsWithDensity(10));
                TutorialEmphasisArrow.Position = initialPosition;
                TutorialEmphasisArrow.StartEffect(new Sunfish.Views.Effects.BackAndForth(initialPosition, finalPosition, 400d));
                TutorialEmphasisArrow.StartEffect (new Sunfish.Views.Effects.Pulsate (800d, 500, Color.Green));
                AddChildView (TutorialEmphasisArrow);
            }
        }