Ejemplo n.º 1
0
 private GameCenterButton(Texture2D buttonTexture, Sunfish.Constants.ViewLayer layer)
     : base(buttonTexture, Vector2.Zero, layer)
 {
     EnableTapGesture (HandleGameCenterButtonTap);
     Visible = true;
     PositionInTopRight ();
 }
Ejemplo n.º 2
0
 public static Texture2D LoadTexture(GraphicsDevice device, Sunfish.Canvas.H2BitmapCollection.BitmapData meta, byte[] raw)
 {
     int width, height;
     int bitsPerPixel = GetBBP(meta.Format);
     if ((meta.Flags & H2BitmapCollection.BitmapData.EFlags.Power_Of_2_Dimensions) == H2BitmapCollection.BitmapData.EFlags.Power_Of_2_Dimensions)
     {
         width = meta.Width;
         height = meta.Height;
     }
     else
     {
         width = meta.Width + (16 - (meta.Width % 16) == 16 ? 0 : 16 - (meta.Width % 16));
         int x = width;
         int mipWidth = x;
         for (int i = 0; i < meta.MIPMapCount; i++)
         {
             mipWidth /= 2;
             x += mipWidth;//broken, not broken? Probably still broken but WHATEVER.
         }
         height = raw.Length / (x * (bitsPerPixel / 8));
     }
     SurfaceFormat format = SurfaceFormatDictionary[meta.Format];
     Texture2D t = new Texture2D(device, width, height, 1, TextureUsage.None, format);
     byte[] newRaw = new byte[(int)(width * height * ((float)bitsPerPixel / 8.0f))];
     Array.Copy(raw, newRaw, newRaw.Length);
     if ((meta.Flags & H2BitmapCollection.BitmapData.EFlags.Swizzled) == H2BitmapCollection.BitmapData.EFlags.Swizzled)
         newRaw = Swizzler.Swizzle(newRaw, width, height, 1, bitsPerPixel, true);
     t.SetData<byte>(newRaw);
     return t;
 }
Ejemplo n.º 3
0
 private WorldLevelButton(Sunfish.Views.Sprite buttonSprite, Stars stars, int worldNumber, int levelNumber)
     : base(Math.Max(buttonSprite.Width, stars.Width), buttonSprite.Height + stars.Height, new Vector2(0,0), Sunfish.Constants.ViewLayer.Layer1, Sunfish.Constants.ViewContainerLayout.StackCentered)
 {
     WorldNumber = worldNumber;
     LevelNumber = levelNumber;
     AddChild (buttonSprite);
     AddChild (stars);
 }
        public void SunfishIsTypeAnimalAndAquatic()
        {
            Sunfish sox = new Sunfish();

            Assert.IsAssignableFrom <Animal>(sox);
            Assert.IsAssignableFrom <Aquatic>(sox);
            Assert.IsAssignableFrom <Fish>(sox);
        }
Ejemplo n.º 5
0
        public Level(Sunfish.SunfishGame currentGame, int worldNumber, int levelNumber)
            : base(currentGame, "WorldBackground_" + (worldNumber + 1).ToString ())
        {
            WorldNumber = worldNumber;
            LevelNumber = levelNumber;
            Model = Rules.Level.ReadLevel (WorldNumber, LevelNumber);
            LockViewsDictionary = new Dictionary<string, Views.Lock> ();

            // Compute the space between the locks, which is used during the animation when the user solves the level
            Texture2D pipeHorizontal = LocksGame.ActiveScreen.LoadTexture ("PipeHorizontal1");
            SpaceBetweenLocks = pipeHorizontal.Width;
        }
        public void DerivedClassesHaveSoundFromAnimalAndIsOverriden()
        {
            HouseCat sox   = new HouseCat("Black&White", 10);
            Sunfish  sox2  = new Sunfish();
            Snakes   sox3  = new Snakes(false, true);
            Tiger    socks = new Tiger();
            Bird     skcos = new Bird();
            Frog     frog  = new Frog();

            Assert.Equal("Meow meow", sox.Sound());
            Assert.Equal("glug glug", sox2.Sound());
            Assert.Equal("Croaaaak", frog.Sound());
            Assert.Equal("hissssss", sox3.Sound());
            Assert.Equal("Rawwwwr", socks.Sound());
            Assert.Equal("Tweet tweet", skcos.Sound());
        }
Ejemplo n.º 7
0
 private void HandleRotateDialComplete(Sunfish.Views.Effects.Effect effectThatIsComplete)
 {
     if (LockModel.IsLocked ()) {
         LockIndicator.Texture = LockIndicatorLockedTexture;
     } else {
         LockIndicator.Texture = LockIndicatorUnlockedTexture;
     }
     if (OnDialRotateComplete != null) {
         OnDialRotateComplete (this);
     }
 }
Ejemplo n.º 8
0
 public void AddChildView(Sunfish.Views.View childView)
 {
     ChildViews.Add (childView);
 }
Ejemplo n.º 9
0
 public static Stars Create(int stars, Sunfish.Constants.ViewLayer layer)
 {
     Texture2D starsTexture = LocksGame.ActiveScreen.LoadTexture (GetStarsTextureFileName (stars));
     return new Stars (starsTexture, layer);
 }
Ejemplo n.º 10
0
 private void HandleResumeButtonTapped(Sunfish.Views.View pauseButton)
 {
     ResumeGame ();
 }
Ejemplo n.º 11
0
 private void HandleQuitButtonFromSolvedPopupTapped(Sunfish.Views.View pauseButton)
 {
     SolvedPopup.TransitionAudioFilename = "PopupTransition";
     SolvedPopup.Hide ();
     QuitGame ();
 }
Ejemplo n.º 12
0
 private void HandlePauseButtonTapped(Sunfish.Views.View pauseButton)
 {
     PauseGame ();
 }
Ejemplo n.º 13
0
 private void HandleNextLevelButtonTapped(Sunfish.Views.View nextLevelButton)
 {
     SolvedPopup.TransitionAudioFilename = "LightSwoosh";
     SolvedPopup.TransitionAudioVolume = 0.8f;
     if (LevelNumber == Core.Constants.WorldLevelCount - 1) {
         CurrentGame.SetActiveScreen (new Screens.Level (CurrentGame, WorldNumber + 1, 0));
     } else {
         CurrentGame.SetActiveScreen (new Screens.Level (CurrentGame, WorldNumber, LevelNumber + 1));
     }
     SolvedPopup.Hide ();
 }
Ejemplo n.º 14
0
 private void HandleStartButtonTap(Sunfish.Views.View startButton)
 {
     PlayPopup.Show ();
 }
Ejemplo n.º 15
0
        private void HandleGameButtonTap(Sunfish.Views.View playButton)
        {
            Views.PlaySlotButton playSlotButton = (Views.PlaySlotButton)playButton;
            Models.GameProgress[] gameProgress = Rules.GameProgress.LoadGameProgress ();
            LocksGame.GameProgress = gameProgress [playSlotButton.Slot];

            // New game?
            if (LocksGame.GameProgress == null) {
                LocksGame.GameProgress = new Models.GameProgress (playSlotButton.Slot);
            }

            PlayPopup.Hide ();
            CurrentGame.SetActiveScreen (new Screens.LevelChooser (CurrentGame));
        }
Ejemplo n.º 16
0
 private void HandleCreditsPopupCloseButtonTap(Sunfish.Views.View closeButton)
 {
     CreditsPopup.Hide ();
 }
Ejemplo n.º 17
0
 private void HandleBackButtonTap(Sunfish.Views.View backButton)
 {
     CurrentGame.SetActiveScreen (new Screens.Home (CurrentGame));
 }
Ejemplo n.º 18
0
 private void HandleRetryButtonTapped(Sunfish.Views.View retryButton)
 {
     SolvedPopup.TransitionAudioFilename = "PopupTransition";
     SolvedPopup.Hide ();
     RetryLevel ();
 }
Ejemplo n.º 19
0
 public static Overlay CreateOpaque(Sunfish.Screen screen)
 {
     return new Overlay (SunfishGame.ActiveScreen.LoadTexture ("OverlayOpaquePixel"));
 }
Ejemplo n.º 20
0
 private void HandleSettingsButtonTapped(Sunfish.Views.View settingsButton)
 {
     SolvedPopup.TransitionAudioFilename = "PopupTransition";
     SettingsPopup.Show ();
 }
Ejemplo n.º 21
0
        public static Texture2D[] LoadCubemap(GraphicsDevice device, Sunfish.Canvas.H2BitmapCollection.BitmapData meta, byte[] raw)
        {
            int size = 0;
            int bitsPerPixel = GetBBP(meta.Format);
            if ((meta.Flags & H2BitmapCollection.BitmapData.EFlags.Power_Of_2_Dimensions) == H2BitmapCollection.BitmapData.EFlags.Power_Of_2_Dimensions)
            {
                size = meta.Width;
            }

            SurfaceFormat format = SurfaceFormatDictionary[meta.Format];
            Texture2D[] textures = new Texture2D[6];

            for (int i = 0; i < 6; i++)
            {
                textures[i] = new Texture2D(device, size, size, 1, TextureUsage.None, format);
                byte[] newRaw = new byte[(int)(size * size * ((float)bitsPerPixel / 8.0f))];
                Array.Copy(raw, GetSurfaceLength(size, meta.MIPMapCount, bitsPerPixel) * i, newRaw, 0, newRaw.Length);
                if ((meta.Flags & H2BitmapCollection.BitmapData.EFlags.Swizzled) == H2BitmapCollection.BitmapData.EFlags.Swizzled)
                    newRaw = Swizzler.Swizzle(newRaw, size, size, 1, bitsPerPixel, true);
                textures[i].SetData<byte>(newRaw);
            }
            return textures;
        }
Ejemplo n.º 22
0
 private void HandleTutorialButtonTapped(Sunfish.Views.View tutorialButton)
 {
     if (TutorialEmphasisArrow != null && TutorialEmphasisArrow.Visible) {
         TutorialEmphasisArrow.ClearEffects ();
         TutorialEmphasisArrow.Visible = false;
     }
     TutorialPopup.Show ();
 }
Ejemplo n.º 23
0
 private void StartNextLockShiftOrShowSolvedPopup(Sunfish.Views.Effects.Effect effectThatIsComplete)
 {
     CurrentlyAnimatingLockColumnShift++;
     if (CurrentlyAnimatingLockColumnShift > LastLockColumnToShift) { // Done shifting columns?
         StartLockRowShiftAndShowSolvedPopupWhenDone ();
     } else {
         StartLockColumnShift (CurrentlyAnimatingLockColumnShift);
     }
 }
Ejemplo n.º 24
0
 private void HandleLevelButtonTap(Sunfish.Views.View levelButtonView)
 {
     PlaySoundEffect ("LightSwoosh", 0.8f);
     Views.WorldLevelButton levelButton = (Views.WorldLevelButton)levelButtonView;
     CurrentGame.SetActiveScreen (new Screens.Level (CurrentGame, levelButton.WorldNumber, levelButton.LevelNumber));
 }
Ejemplo n.º 25
0
 private Stars(Texture2D starsTexture, Sunfish.Constants.ViewLayer layer)
     : base(starsTexture, layer)
 {
 }
Ejemplo n.º 26
0
 private void HandleSettingsButtonTap(Sunfish.Views.View settingsButton)
 {
     SettingsPopup.Show ();
 }
Ejemplo n.º 27
0
        private void CreateNode(ref Sunfish.Mode.Node[] nodes, short currentNode, NodeModel parent)
        {
            //if (p == 6)
            //{
            //}
            //Matrix m = Matrix.CreateTranslation(new Vector3(vector3.X, vector3.Y, vector3.Z));
            //m *= Matrix.CreateFromQuaternion(new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W));
            //m *= Matrix.CreateTranslation(new Vector3(nodes[p].Translation.X, nodes[p].Translation.Y, nodes[p].Translation.Z));
            ////m *= Matrix.CreateFromQuaternion(new Quaternion(nodes[p].Rotation.X, nodes[p].Rotation.Y, nodes[p].Rotation.Z, nodes[p].Rotation.W));


            //Vector3 v = Vector3.Transform(Vector3.Zero, m);


            NodeModel node = new NodeModel(nodes[currentNode]);
            //node.Rotation *= new Quaternion(nodes[p].Rotation.X, nodes[p].Rotation.Y, nodes[p].Rotation.Z, nodes[p].Rotation.W);
            //node.Position = v;

            //NodeModels.Add(NodeModel.Join(parent, node));
            NodeModels.Add(node); 
            parent.AddChild(node);
            //triangleList.AddRange(new short[] { nodes[p].ParentNodeIndex, p });
            //Vertices[p] = new VertexPositionColor(v, Color.DarkBlue);
            if (nodes[currentNode].FirstSiblingNodeIndex > -1)
                CreateNode(ref nodes, nodes[currentNode].FirstSiblingNodeIndex, parent);

            if (nodes[currentNode].FirstChildNodeIndex > -1)
            {
                //Quaternion q;
                //Vector3 s, t;
                //m.Decompose(out s, out q, out t);
                CreateNode(ref nodes, nodes[currentNode].FirstChildNodeIndex, node);
            }
        }
Ejemplo n.º 28
0
 private void PopulateWorldContainer(Sunfish.Views.Container worldContainer, int worldNumber)
 {
     bool worldIsUnlocked = LocksGame.GameProgress.IsWorldUnlocked (worldNumber);
     bool isFirstUnsolvedLevel = true;
     for (int levelNumber=0; levelNumber < 9; levelNumber++) {
         Models.SolvedLevel solvedLevel = LocksGame.GameProgress.GetSolvedLevel (worldNumber, levelNumber);
         Views.WorldLevelButton levelButton;
         if (solvedLevel == null) {
             if (isFirstUnsolvedLevel && worldIsUnlocked) {
                 levelButton = Views.WorldLevelButton.CreateFirstUnsolved (worldNumber, levelNumber);
                 levelButton.EnableTapGesture(HandleLevelButtonTap);
                 isFirstUnsolvedLevel = false;
             } else {
                 levelButton = Views.WorldLevelButton.CreateUnsolved (worldNumber, levelNumber);
             }
         } else {
             levelButton = Views.WorldLevelButton.CreateSolved (worldNumber, levelNumber, solvedLevel.Stars);
             levelButton.EnableTapGesture(HandleLevelButtonTap);
         }
         worldContainer.AddChild (levelButton, PixelsWithDensity(10), PixelsWithDensity(10));
     }
 }
Ejemplo n.º 29
0
        private void HandleButtonTap(Sunfish.Views.View buttonThatWasTapped)
        {
            // Obtain and update the lock button model
            Models.LockButton lockButton = (Models.LockButton)buttonThatWasTapped.Data;
            int previousPosition = lockButton.ContainingLock.CurrentPosition;
            Models.LockButtonPushResult pushResult = lockButton.Push ();

            // Start the effects in the UI
            RotateDial (lockButton.ContainingLock.CurrentPosition - previousPosition);
            LocksGame.ActiveScreen.PlaySoundEffect ("LockDialTurning", 0.8f);
            PulsateLockButton (buttonThatWasTapped);
            RotateGearsForLockButton (lockButton);

            // Notify the handler of the button push
            if (OnLockButtonPush != null) {
                OnLockButtonPush (pushResult);
            }
        }
Ejemplo n.º 30
0
 public LevelChooser(Sunfish.SunfishGame currentGame)
     : base(currentGame, Color.DarkGray, "HomeScreenBackground")
 {
 }
Ejemplo n.º 31
0
 private void PulsateLockButton(Sunfish.Views.View lockButtonView)
 {
     lockButtonView.StartEffect (new Sunfish.Views.Effects.Pulsate (4000, 1, Color.White));
 }
Ejemplo n.º 32
0
 private void HandleSoundEffectsCheckboxTapped(Sunfish.Views.View soundEffectsCheckBox)
 {
     LocksGame.SoundEffectsOn = !LocksGame.SoundEffectsOn;
 }