private GameCenterButton(Texture2D buttonTexture, Sunfish.Constants.ViewLayer layer) : base(buttonTexture, Vector2.Zero, layer) { EnableTapGesture (HandleGameCenterButtonTap); Visible = true; PositionInTopRight (); }
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; }
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); }
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()); }
private void HandleRotateDialComplete(Sunfish.Views.Effects.Effect effectThatIsComplete) { if (LockModel.IsLocked ()) { LockIndicator.Texture = LockIndicatorLockedTexture; } else { LockIndicator.Texture = LockIndicatorUnlockedTexture; } if (OnDialRotateComplete != null) { OnDialRotateComplete (this); } }
public void AddChildView(Sunfish.Views.View childView) { ChildViews.Add (childView); }
public static Stars Create(int stars, Sunfish.Constants.ViewLayer layer) { Texture2D starsTexture = LocksGame.ActiveScreen.LoadTexture (GetStarsTextureFileName (stars)); return new Stars (starsTexture, layer); }
private void HandleResumeButtonTapped(Sunfish.Views.View pauseButton) { ResumeGame (); }
private void HandleQuitButtonFromSolvedPopupTapped(Sunfish.Views.View pauseButton) { SolvedPopup.TransitionAudioFilename = "PopupTransition"; SolvedPopup.Hide (); QuitGame (); }
private void HandlePauseButtonTapped(Sunfish.Views.View pauseButton) { PauseGame (); }
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 (); }
private void HandleStartButtonTap(Sunfish.Views.View startButton) { PlayPopup.Show (); }
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)); }
private void HandleCreditsPopupCloseButtonTap(Sunfish.Views.View closeButton) { CreditsPopup.Hide (); }
private void HandleBackButtonTap(Sunfish.Views.View backButton) { CurrentGame.SetActiveScreen (new Screens.Home (CurrentGame)); }
private void HandleRetryButtonTapped(Sunfish.Views.View retryButton) { SolvedPopup.TransitionAudioFilename = "PopupTransition"; SolvedPopup.Hide (); RetryLevel (); }
public static Overlay CreateOpaque(Sunfish.Screen screen) { return new Overlay (SunfishGame.ActiveScreen.LoadTexture ("OverlayOpaquePixel")); }
private void HandleSettingsButtonTapped(Sunfish.Views.View settingsButton) { SolvedPopup.TransitionAudioFilename = "PopupTransition"; SettingsPopup.Show (); }
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; }
private void HandleTutorialButtonTapped(Sunfish.Views.View tutorialButton) { if (TutorialEmphasisArrow != null && TutorialEmphasisArrow.Visible) { TutorialEmphasisArrow.ClearEffects (); TutorialEmphasisArrow.Visible = false; } TutorialPopup.Show (); }
private void StartNextLockShiftOrShowSolvedPopup(Sunfish.Views.Effects.Effect effectThatIsComplete) { CurrentlyAnimatingLockColumnShift++; if (CurrentlyAnimatingLockColumnShift > LastLockColumnToShift) { // Done shifting columns? StartLockRowShiftAndShowSolvedPopupWhenDone (); } else { StartLockColumnShift (CurrentlyAnimatingLockColumnShift); } }
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)); }
private Stars(Texture2D starsTexture, Sunfish.Constants.ViewLayer layer) : base(starsTexture, layer) { }
private void HandleSettingsButtonTap(Sunfish.Views.View settingsButton) { SettingsPopup.Show (); }
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); } }
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)); } }
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); } }
public LevelChooser(Sunfish.SunfishGame currentGame) : base(currentGame, Color.DarkGray, "HomeScreenBackground") { }
private void PulsateLockButton(Sunfish.Views.View lockButtonView) { lockButtonView.StartEffect (new Sunfish.Views.Effects.Pulsate (4000, 1, Color.White)); }
private void HandleSoundEffectsCheckboxTapped(Sunfish.Views.View soundEffectsCheckBox) { LocksGame.SoundEffectsOn = !LocksGame.SoundEffectsOn; }