void StartGame() { Console.WriteLine("Start game"); gameLogo.RunAction(SKAction.MoveTo( new CGPoint( x: Frame.GetMidX() - 50, y: Frame.GetMidY() + 600), 0.5), () => gameLogo.Hidden = true); bestScore.RunAction(SKAction.MoveTo( new CGPoint( x: Frame.GetMidX(), y: Frame.GetMidY() + (Frame.Size.Height / -2f) + 20), 0.4)); playButton.RunAction(SKAction.ScaleTo(0, 0.3), () => playButton.Hidden = true); gameBG.SetScale(0); currentScore.SetScale(0); gameBG.Hidden = false; currentScore.Hidden = false; gameBG.RunAction(SKAction.ScaleTo(1, 0.4)); currentScore.RunAction(SKAction.ScaleTo(1, 0.4)); game.InitGame(); }
public async void finishingTimeAnimation() { var scale1 = SKAction.ScaleBy(6.0f, 0.5); TimeLabel.RunAction(scale1); var scale2 = scale1.ReversedAction; TimeLabel.RunAction(scale2); }
public async void loadStarter() { var scoreLoad = new SKLabelNode() { Text = "" + (GameObj.ToBeatScore + 1) + " To Win", //.ToString (); Position = new CGPoint(Size.Width / 2, (Size.Height / 2) - 200), FontSize = 66, FontColor = UIColor.White, FontName = "GillSans-Bold", }; scoreLoad.SetScale(0.1f); var moveUpAction = SKAction.MoveTo((new CGPoint(Size.Width / 2, Size.Height / 2)), 1.0); var scaleUpAction = SKAction.ScaleBy(9f, 1.0); AddChild(scoreLoad); scoreLoad.RunAction(moveUpAction); scoreLoad.RunAction(scaleUpAction); await System.Threading.Tasks.Task.Delay(2000); scoreLoad.RemoveFromParent(); for (int i = 0; i < 3; i++) { var startGameNode = new SKLabelNode() { Text = "" + (3 - i), Position = new CGPoint(Size.Width / 2, (Size.Height / 2) - 200), FontSize = 80, FontColor = UIColor.Red, FontName = "GillSans-Bold", }; startGameNode.SetScale(0.1f); var moveUpAction1 = SKAction.MoveTo((new CGPoint(Size.Width / 2, Size.Height / 2)), 1.0); var scaleUpAction1 = SKAction.ScaleBy(9f, 1.0); AddChild(startGameNode); startGameNode.RunAction(moveUpAction1); startGameNode.RunAction(scaleUpAction1); await System.Threading.Tasks.Task.Delay(2000); startGameNode.RemoveFromParent(); } }
// Remove the Info Text (fade out) private void ReleaseInfoText() { SKAction actionOut = SKAction.FadeOutWithDuration(0.2); infoLabel1.RemoveAllActions(); infoLabel2.RemoveAllActions(); infoLabel3.RemoveAllActions(); infoLabel4.RemoveAllActions(); infoLabel5.RemoveAllActions(); infoLabel6.RemoveAllActions(); infoLabel7.RemoveAllActions(); infoNode.RemoveAllActions(); infoNode2.RemoveAllActions(); infoNode3.RemoveAllActions(); cancelSpark.RemoveAllActions(); teatimeSprite.RemoveAllActions(); infoLabel1.RunAction(actionOut); infoLabel2.RunAction(actionOut); infoLabel3.RunAction(actionOut); infoLabel4.RunAction(actionOut); infoLabel5.RunAction(actionOut); infoLabel6.RunAction(actionOut); infoLabel7.RunAction(actionOut); infoNode.RunAction(actionOut); infoNode2.RunAction(actionOut); infoNode3.RunAction(actionOut); cancelSpark.RunAction(actionOut); teatimeSprite.RunAction(actionOut); }
/// <summary> /// Анимация счета за уничтожение цепочки /// </summary> /// <param name="chain">Уничтожаемая цепочка.</param> private void AnimateScore(GemList chain) { SKSpriteNode firstGem = chain.GetFirstGem().Sprite; SKSpriteNode lastGem = chain.GetLastGem().Sprite; CGPoint centerPoint = new CGPoint( (firstGem.Position.X + lastGem.Position.X) / 2, (firstGem.Position.Y + lastGem.Position.Y) / 2 - 8); SKLabelNode scoreLabel = new SKLabelNode("GillSans-BoldItalic") { FontSize = 16, Text = chain.GetScore() + "", Position = centerPoint, ZPosition = 300 }; gemLayer.AddChild(scoreLabel); SKAction moveAction = SKAction.MoveBy(0, 3, 0.7); //.Move(by: CGVector(dx: 0, dy: 3), duration: 0.7) moveAction.TimingMode = SKActionTimingMode.EaseOut; scoreLabel.RunAction(SKAction.Sequence(moveAction, SKAction.RemoveFromParent())); }
public void textScaling(SKLabelNode scaled) { var up = SKAction.ScaleBy(1.2f, 0.8f); //var down = SKAction.ScaleBy (0.8f, 0.5f); var seq = SKAction.Sequence(new SKAction[] { up, up.ReversedAction }); //({up,down}); var fort = SKAction.RepeatActionForever(seq); scaled.RunAction(fort); }
private void MoveToUpFromCenterClear() { spriteTopBg.RemoveAllActions(); spriteTop.RemoveAllActions(); spriteBelowBg.RemoveAllActions(); spriteBelow.RemoveAllActions(); navSpriteTop.RemoveAllActions(); navLabelTop.RemoveAllActions(); navSpriteBottom.RemoveAllActions(); navLabelBottom.RemoveAllActions(); SKAction actionTop = SKAction.MoveToY((View.Frame.Height * 1.5f) - 60, 0.2); SKAction actionBelow = SKAction.MoveToY((View.Frame.Height / 2) - 60, 0.2); SKAction actionBelowLabel = SKAction.MoveToY(View.Frame.Height - 100, 0.2); SKAction actionTopLabel = SKAction.MoveToY(View.Frame.Height - 40, 0.2); spriteTopBg.RunAction(actionTop); spriteTop.RunAction(actionTop); spriteBelowBg.RunAction(actionBelow); spriteBelow.RunAction(actionBelow); navSpriteTop.RunAction(actionTopLabel); navLabelTop.RunAction(actionTopLabel); navSpriteBottom.RunAction(actionBelowLabel); navLabelBottom.RunAction(actionBelowLabel); gameMode = 1; }
public void DidBeginContact(SKPhysicsContact contact) { inprogress = false; Console.WriteLine("We Collided!"); gameended = true; void gameOver() { var textures = Enumerable.Range(1, 4).Select( (i) => SKTexture.FromImageNamed(String.Format("Death-{0}", i))).ToArray(); deathSpin = SKAction.RepeatAction(SKAction.AnimateWithTextures(textures, .1), 4); var shrink = SKAction.ScaleTo(0f, 2f); var death = SKAction.Sequence(deathSpin, shrink); playerObject.RunAction(death); var playDeath = SKAction.PlaySoundFileNamed("playerDeath", false); playerDied.RunAction(playDeath); gameSong.RunAction(SKAction.CreateStop()); } void animateOver() { var grow = SKAction.ScaleTo(2.0f, 1.5); var shrink = SKAction.ScaleTo(.5f, 1.5); var animate = SKAction.RepeatActionForever(SKAction.Sequence(grow, shrink)); endGame.RunAction(animate); } playerObject.RemoveAllActions(); obstacle.RemoveAllActions(); sidewalk1.RemoveAllActions(); sidewalk2.RemoveAllActions(); sidewalk3.RemoveAllActions(); building1.RemoveAllActions(); building2.RemoveAllActions(); building3.RemoveAllActions(); building4.RemoveAllActions(); building5.RemoveAllActions(); building6.RemoveAllActions(); building7.RemoveAllActions(); building8.RemoveAllActions(); building9.RemoveAllActions(); building10.RemoveAllActions(); building11.RemoveAllActions(); building12.RemoveAllActions(); building13.RemoveAllActions(); building14.RemoveAllActions(); road1.RemoveAllActions(); road2.RemoveAllActions(); road3.RemoveAllActions(); road4.RemoveAllActions(); road5.RemoveAllActions(); road6.RemoveAllActions(); obstacle1.RemoveAllActions(); obstacle2.RemoveAllActions(); enemy.RemoveAllActions(); obstacle4.RemoveAllActions(); scores.Add(score); scores.Sort((a, b) => - 1 * a.CompareTo(b)); var sl = scores.Count; if (sl >= 10) { { sl = 10; } } var plist = NSUserDefaults.StandardUserDefaults; for (int i = 0; i < sl; i++) { { Console.WriteLine(scores[i]); plist.SetInt(scores[i], String.Format("Score-{0}", i)); } } score = 0; //unsubscribe obstacle objects at the end of the round timer.Elapsed -= sendobstacle; timer1.Elapsed -= sendobstacle1; timer2.Elapsed -= sendobstacle2; timer3.Elapsed -= sendobstacle3; timer4.Elapsed -= sendobstacle4; gameOver(); AddChild(endGame); animateOver(); }
public PostGameMenu(CGSize frameSize, IGameUIState gameStateDelegate) { GameStateDelegate = gameStateDelegate; nfloat menuHeight = frameSize.Height * 0.8f; var background = new SKSpriteNode(AppKit.NSColor.Black, new CGSize(frameSize.Width * 0.8f, menuHeight)); background.ZPosition = -1; background.Alpha = 0.5f; background.Position = new CGPoint(0, -0.2f * menuHeight); myLabel = InGameScene.LabelWithText("Final Score", 65); myLabel.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY()); Position = new CGPoint(frameSize.Width * 0.5f, frameSize.Height * 0.5f); UserInteractionEnabled = true; myLabel.UserInteractionEnabled = true; AddChild(myLabel); InGameScene.DropShadowOnLabel(myLabel); var bananaLocation = new CGPoint(frameSize.Width * -0.4f, Frame.GetMidY() * -0.4f); var coinLocation = new CGPoint(frameSize.Width * -0.4f, Frame.GetMidY() * -0.6f); var totalLocation = new CGPoint(frameSize.Width * -0.4f, Frame.GetMidY() * -0.8f); var bananaScoreLocation = new CGPoint(frameSize.Width * +0.4f, Frame.GetMidY() * -0.4f); var coinScoreLocation = new CGPoint(frameSize.Width * +0.4f, Frame.GetMidY() * -0.6f); var totalScoreLocation = new CGPoint(frameSize.Width * +0.4f, Frame.GetMidY() * -0.8f); bananaText = (SKLabelNode)myLabel.Copy(); bananaText.Text = "Bananas"; bananaText.FontSize = 0.1f * menuHeight; bananaText.SetScale(0.8f); bananaLocation.X += bananaText.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f; bananaText.Position = new CGPoint(bananaLocation.X, -2000); AddChild(bananaText); InGameScene.DropShadowOnLabel(bananaText); bananaScore = (SKLabelNode)bananaText.Copy(); bananaScore.Text = "000"; bananaScoreLocation.X -= bananaScore.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f; bananaScore.Position = new CGPoint(bananaScoreLocation.X, -2000); AddChild(bananaScore); coinText = (SKLabelNode)bananaText.Copy(); coinText.Text = "Large Bananas"; coinLocation.X += coinText.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f; coinText.Position = new CGPoint(coinLocation.X, -2000f); AddChild(coinText); InGameScene.DropShadowOnLabel(coinText); coinScore = (SKLabelNode)coinText.Copy(); coinScore.Text = "000"; coinScoreLocation.X -= coinScore.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f; coinScore.Position = new CGPoint(coinScoreLocation.X, -2000f); AddChild(coinScore); totalText = (SKLabelNode)bananaText.Copy(); totalText.Text = "Total"; totalLocation.X += totalText.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f; totalText.Position = new CGPoint(totalLocation.X, -2000f); AddChild(totalText); InGameScene.DropShadowOnLabel(totalText); totalScore = (SKLabelNode)totalText.Copy(); totalScore.Text = "000"; totalScoreLocation.X -= totalScore.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f; totalScore.Position = new CGPoint(totalScoreLocation.X, -2000f); AddChild(totalScore); SKAction flyup = SKAction.MoveTo(new CGPoint(frameSize.Width * 0.5f, frameSize.Height - 100), 0.25); flyup.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupBananas = SKAction.MoveTo(bananaLocation, 0.25); flyupBananas.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupBananasScore = SKAction.MoveTo(bananaScoreLocation, 0.25f); flyupBananasScore.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupCoins = SKAction.MoveTo(coinLocation, 0.25); flyupCoins.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupCoinsScore = SKAction.MoveTo(coinScoreLocation, 0.25); flyupCoinsScore.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupTotal = SKAction.MoveTo(totalLocation, 0.25); flyupTotal.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupTotalScore = SKAction.MoveTo(totalScoreLocation, 0.25); flyupTotalScore.TimingMode = SKActionTimingMode.EaseInEaseOut; int bananasCollected = gameStateDelegate.BananasCollected; int coinsCollected = gameStateDelegate.CoinsCollected; int totalCollected = bananasCollected + (coinsCollected * 100); SKAction countUpBananas = SKAction.CustomActionWithDuration(bananasCollected / 100f, ((node, elapsedTime) => { if (bananasCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)(elapsedTime / (bananasCollected / 100.0f) * bananasCollected); label.Text = total.ToString(); if (total % 10 == 0) { GameSimulation.Sim.PlaySound("deposit.caf"); } } })); SKAction countUpCoins = SKAction.CustomActionWithDuration(coinsCollected / 100f, ((node, elapsedTime) => { if (coinsCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)((elapsedTime / (coinsCollected / 100.0f)) * coinsCollected); label.Text = total.ToString(); if (total % 10 == 0) { GameSimulation.Sim.PlaySound("deposit.caf"); } } })); SKAction countUpTotal = SKAction.CustomActionWithDuration(totalCollected / 500.0f, ((node, elapsedTime) => { if (totalCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)((elapsedTime / (totalCollected / 500.0f)) * totalCollected); label.Text = total.ToString(); if (total % 25 == 0) { GameSimulation.Sim.PlaySound("deposit.caf"); } } })); RunAction(flyup, () => { bananaText.RunAction(flyupBananas); bananaScore.RunAction(flyupBananasScore, () => { bananaScore.RunAction(countUpBananas, () => { bananaScore.Text = bananasCollected.ToString(); coinText.RunAction(flyupCoins); coinScore.RunAction(flyupCoinsScore, () => { coinScore.RunAction(countUpCoins, () => { coinScore.Text = coinsCollected.ToString(); totalText.RunAction(flyupTotal); totalScore.RunAction(flyupTotalScore, () => { totalScore.RunAction(countUpTotal, () => { totalScore.Text = totalCollected.ToString(); }); }); }); }); }); }); }); }
public async void AnalyzeTouch() { var touchDiff = LastTouch.Y - FirstTouch.Y; var touchDiffX = LastTouch.X - FirstTouch.X; if (touchDiff > 66) { var sprite = new SKSpriteNode("dart_blue") { Position = new CGPoint( FirstTouch.X, -5f) }; //dart_blue // var sprite1 = new SKSpriteNode ("knife1") { // Position = new CGPoint( // FirstTouch.X,-5f ) // }; sprite.SetScale(1.5f); AddChild(sprite); var finaldest = new CGPoint(); var action = SKAction.MoveTo(finaldest, 0.3); if (touchDiff < 150) { finaldest = new CGPoint(LastTouch.X + (touchDiffX * 0.5f), LastTouch.Y + (touchDiff * 0.3f)); action = SKAction.MoveTo(finaldest, 0.3); //FollowPath (np, 3.0); } else { finaldest = new CGPoint(LastTouch.X + (touchDiffX * 0.5f), LastTouch.Y + (touchDiff * 0.6f)); action = SKAction.MoveTo(finaldest, 0.2); } nfloat rotatingAngle = touchDiffX / 333; Console.WriteLine("touchDiff:::" + touchDiffX); Console.WriteLine("toRadians:::" + rotatingAngle); //to radians var RotAction = SKAction.RotateToAngle(-rotatingAngle, 0); //to small size var scaleAction = SKAction.ScaleTo(0.8f, 0.1555); sprite.RunAction(action); sprite.RunAction(RotAction); sprite.RunAction(scaleAction); SpriteCount++; //COLLISION if (PhotoNode.ContainsPoint(finaldest)) { CurrentScore++; System.Diagnostics.Debug.WriteLine("POINTS: " + CurrentScore); System.Diagnostics.Debug.WriteLine("collideddddddd::::::::::::::::::::::"); await System.Threading.Tasks.Task.Delay(200); await System.Threading.Tasks.Task.Delay(200); var displayScoreNode = new SKLabelNode(); displayScoreNode.Text = "" + CurrentScore; //.ToString (); displayScoreNode.Position = new CGPoint(Size.Width / 2, (Size.Height / 2) - 200); displayScoreNode.FontSize = 80; displayScoreNode.FontColor = UIColor.Red; displayScoreNode.FontName = "GillSans-Bold"; displayScoreNode.SetScale(0.1f); var moveUpAction = SKAction.MoveTo((new CGPoint(Size.Width / 2, Size.Height / 2)), 0.5); var scaleUpAction = SKAction.ScaleBy(9f, 0.5); AddChild(displayScoreNode); displayScoreNode.RunAction(moveUpAction); displayScoreNode.RunAction(scaleUpAction); await System.Threading.Tasks.Task.Delay(1000); displayScoreNode.RemoveFromParent(); } else { await System.Threading.Tasks.Task.Delay(300); SystemSound.Vibrate.PlaySystemSound(); //.PlayAlertSound(); SystemSound.Vibrate.Close(); } //REMOVE SLOW DART if (touchDiff < 100) { await System.Threading.Tasks.Task.Delay(200); sprite.RemoveFromParent(); SpriteCount--; } if (touchDiff > 120 && (!PhotoFrameNode.ContainsPoint(finaldest))) { await System.Threading.Tasks.Task.Delay(300); SystemSound.Vibrate.PlaySystemSound(); //.PlayAlertSound(); SystemSound.Vibrate.Close(); await System.Threading.Tasks.Task.Delay(200); } } }
public void ProcessControllerAction(TVControllerAction item) { if (map.IsGameOver && item == TVControllerAction.Flag) item = TVControllerAction.Tap; switch (item) { case TVControllerAction.Left: CurrentX--; if (CurrentX < 0) CurrentX = 0; break; case TVControllerAction.Right: CurrentX++; if (CurrentX >= map.MapColumns) CurrentX = map.MapColumns - 1; break; case TVControllerAction.Up: CurrentY--; if (CurrentY < 0) CurrentY = 0; break; case TVControllerAction.Down: CurrentY++; if (CurrentY >= map.MapRows) CurrentY = map.MapRows - 1; break; case TVControllerAction.Flag: var flagResults = map.FlagSpot (CurrentX, CurrentY); flagResults.AffectedSpots.ForEach (RedisplaySpot); if (flagResults.GameReset) { DisplayMap (); } MoveCurrentPositionToTop (); UpdateLevelDisplay (); break; case TVControllerAction.Tap: var actionDetails = map.ClickOnSpot (CurrentX, CurrentY); actionDetails.AffectedSpots.ForEach (RedisplaySpot); if (actionDetails.GameOver) { RedisplaySpot (new Spot (CurrentX, CurrentY)); // Blow up all the spots MakeExplosionAtPoint (new Spot (CurrentX, CurrentY)); var allMines = map.GetAllMinesNear (new Spot (CurrentX, CurrentY)); allMines.ForEach (MakeExplosionAtPoint); gameOverNode = new SKLabelNode (displayFontGameOver) { Text = "Game Over", Position = new CGPoint(Scene.Frame.GetMidX(), Scene.Frame. GetMidY()), FontColor = UIColor.Blue, FontSize = displayFontSizeGameOver, VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center, HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center }; float miniBuffer = 3f; gameOverNode2 = new SKLabelNode (displayFontGameOver) { Text = "Game Over", Position = new CGPoint(gameOverNode.Position.X + miniBuffer, gameOverNode.Position.Y - miniBuffer), FontColor = UIColor.FromRGBA(0.0f, 0f, 0f, 0.25f), FontSize = displayFontSizeGameOver, VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center, HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center }; AddChild (gameOverNode2); AddChild (gameOverNode); gameOverNode.RunAction (SKAction.RotateByAngle ( (nfloat)(Math.PI / 180) * 720, 1.0)); gameOverNode2.RunAction (SKAction.RotateByAngle ( (nfloat)(Math.PI / 180) * 720, 1.0)); currentSpot.RunAction(SKAction.RemoveFromParent()); currentSpot = null; } if (actionDetails.GameReset) { DisplayMap (); } MoveCurrentPositionToTop (); UpdateLevelDisplay (); break; } UpdateCurrentSpot(); currentSpot.RunAction (SKAction.MoveTo ( GetCellPosition (CurrentX, CurrentY), 0.25 )); }
public override void DidMoveToView(SKView view) { // Setup your scene here var myLabel = new SKLabelNode("Chalkduster") { Text = "Helicopter Destroyers \n**COMING SOON**!", FontSize = 45, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2) }; var myLabel1 = new SKLabelNode("Black") { Text = "BDD copyright 2017", FontSize = 35, Position = new CGPoint(Frame.Width / 2, Frame.Height / 3), Name = "myLabel1" }; var ScoreLabel = new SKLabelNode("Comicsans") { Text = "Score: ", FontSize = 42, Position = new CGPoint(Frame.Width - 100, 100), Name = "ScoreLabel" }; var NavArrow = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("NavArrow", "png")); var Compass = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("compassgauge_small", "png")); var Image1 = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("SideS", "png")); Image1.Position = new CGPoint(Frame.Width / 2, Frame.Height / 4); Compass.Position = new CGPoint(Frame.Width - 50, 50); Compass.Name = "Compass"; NavArrow.Position = new CGPoint(Frame.Width - 50, 50); NavArrow.Name = "NavArrow"; NavArrow.SetScale((nfloat)1.5); //INITIALIZE PLAYER BULLET MAGAZINE for (int j = 0; j < PlayerMagazine.Length; j += 1) { PlayerMagazine[j] = new Bullets(); } //INITIALIZE TOWER ARRAY for (int i = 0; i < EnemyTowers.Length; i += 1) { EnemyTowers[i] = new Towers(5);//towers with 5 guards //for now the number of guards means 2 bullets per guard } for (int i = 0; i < EnemyTanks.Length; i += 1) { EnemyTanks[i] = new Tanks(); } //PLACE TOWERS RANDOMLY THROUGHOUT THE FRAME Random randx = new Random((int)Frame.Width); Random randy = new Random((int)Frame.Height); for (int i = 0; i < EnemyTowers.Length; i += 1) { nfloat randomx = (nfloat)randx.Next() % Frame.Width; nfloat randomy = (nfloat)randy.Next() % Frame.Height; EnemyTowers[i].tower.Position = new CGPoint(randomx, randomy); EnemyTowers[i].tower.Name = "Tower_" + i.ToString(); } for (int i = 0; i < EnemyTanks.Length; i += 1) { nfloat randomx = (nfloat)randx.Next() % Frame.Width; nfloat randomy = (nfloat)randy.Next() % Frame.Height; EnemyTanks[i].enemySprite.Position = new CGPoint(randomx, randomy); EnemyTanks[i].enemySprite.Name = "EnemyTank_" + i.ToString(); } //ADD THE TOWERS TO THE GAMESCENE (PARENT) for (int i = 0; i < EnemyTowers.Length; i += 1) { AddChild(EnemyTowers[i].tower); } //ADD THE TANKS TO THE GAMESENE (PARENT) for (int i = 0; i < EnemyTanks.Length; i += 1) { AddChild(EnemyTanks[i].enemySprite); } //ADD THE LABELS TO THE GAMESCENE (PARENT) AddChild(myLabel); AddChild(myLabel1); AddChild(ScoreLabel); //ADD THE GAUGES TO THE GAMESCENE AddChild(Compass); AddChild(NavArrow); //ESTABLISH AND RUN AN ACTION FOR myLabel and ScoreLabel var fadeout1 = SKAction.FadeOutWithDuration(5); var fadeout2 = SKAction.FadeOutWithDuration(5); myLabel.RunAction(fadeout2); myLabel1.RunAction(fadeout1); }
public PostGameMenu (CGSize frameSize, IGameUIState gameStateDelegate) { GameStateDelegate = gameStateDelegate; nfloat menuHeight = frameSize.Height * 0.8f; var background = new SKSpriteNode (AppKit.NSColor.Black, new CGSize (frameSize.Width * 0.8f, menuHeight)); background.ZPosition = -1; background.Alpha = 0.5f; background.Position = new CGPoint (0, -0.2f * menuHeight); myLabel = InGameScene.LabelWithText ("Final Score", 65); myLabel.Position = new CGPoint (Frame.GetMidX (), Frame.GetMidY ()); Position = new CGPoint (frameSize.Width * 0.5f, frameSize.Height * 0.5f); UserInteractionEnabled = true; myLabel.UserInteractionEnabled = true; AddChild (myLabel); InGameScene.DropShadowOnLabel (myLabel); var bananaLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.4f); var coinLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.6f); var totalLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.8f); var bananaScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.4f); var coinScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.6f); var totalScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.8f); bananaText = (SKLabelNode)myLabel.Copy (); bananaText.Text = "Bananas"; bananaText.FontSize = 0.1f * menuHeight; bananaText.Scale = 0.8f; bananaLocation.X += bananaText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; bananaText.Position = new CGPoint (bananaLocation.X, -2000); AddChild (bananaText); InGameScene.DropShadowOnLabel (bananaText); bananaScore = (SKLabelNode)bananaText.Copy (); bananaScore.Text = "000"; bananaScoreLocation.X -= bananaScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; bananaScore.Position = new CGPoint (bananaScoreLocation.X, -2000); AddChild (bananaScore); coinText = (SKLabelNode)bananaText.Copy (); coinText.Text = "Large Bananas"; coinLocation.X += coinText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; coinText.Position = new CGPoint (coinLocation.X, -2000f); AddChild (coinText); InGameScene.DropShadowOnLabel (coinText); coinScore = (SKLabelNode)coinText.Copy (); coinScore.Text = "000"; coinScoreLocation.X -= coinScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; coinScore.Position = new CGPoint (coinScoreLocation.X, -2000f); AddChild (coinScore); totalText = (SKLabelNode)bananaText.Copy (); totalText.Text = "Total"; totalLocation.X += totalText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; totalText.Position = new CGPoint (totalLocation.X, -2000f); AddChild (totalText); InGameScene.DropShadowOnLabel (totalText); totalScore = (SKLabelNode)totalText.Copy (); totalScore.Text = "000"; totalScoreLocation.X -= totalScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; totalScore.Position = new CGPoint (totalScoreLocation.X, -2000f); AddChild (totalScore); SKAction flyup = SKAction.MoveTo (new CGPoint (frameSize.Width * 0.5f, frameSize.Height - 100), 0.25); flyup.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupBananas = SKAction.MoveTo (bananaLocation, 0.25); flyupBananas.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupBananasScore = SKAction.MoveTo (bananaScoreLocation, 0.25f); flyupBananasScore.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupCoins = SKAction.MoveTo (coinLocation, 0.25); flyupCoins.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupCoinsScore = SKAction.MoveTo (coinScoreLocation, 0.25); flyupCoinsScore.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupTotal = SKAction.MoveTo (totalLocation, 0.25); flyupTotal.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupTotalScore = SKAction.MoveTo (totalScoreLocation, 0.25); flyupTotalScore.TimingMode = SKActionTimingMode.EaseInEaseOut; int bananasCollected = gameStateDelegate.BananasCollected; int coinsCollected = gameStateDelegate.CoinsCollected; int totalCollected = bananasCollected + (coinsCollected * 100); SKAction countUpBananas = SKAction.CustomActionWithDuration (bananasCollected / 100f, ((node, elapsedTime) => { if (bananasCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)(elapsedTime / (bananasCollected / 100.0f) * bananasCollected); label.Text = total.ToString (); if (total % 10 == 0) GameSimulation.Sim.PlaySound ("deposit.caf"); } })); SKAction countUpCoins = SKAction.CustomActionWithDuration (coinsCollected / 100f, ((node, elapsedTime) => { if (coinsCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)((elapsedTime / (coinsCollected / 100.0f)) * coinsCollected); label.Text = total.ToString (); if (total % 10 == 0) GameSimulation.Sim.PlaySound ("deposit.caf"); } })); SKAction countUpTotal = SKAction.CustomActionWithDuration (totalCollected / 500.0f, ((node, elapsedTime) => { if (totalCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)((elapsedTime / (totalCollected / 500.0f)) * totalCollected); label.Text = total.ToString (); if (total % 25 == 0) GameSimulation.Sim.PlaySound ("deposit.caf"); } })); RunAction (flyup, () => { bananaText.RunAction (flyupBananas); bananaScore.RunAction (flyupBananasScore, () => { bananaScore.RunAction (countUpBananas, () => { bananaScore.Text = bananasCollected.ToString (); coinText.RunAction (flyupCoins); coinScore.RunAction (flyupCoinsScore, () => { coinScore.RunAction (countUpCoins, () => { coinScore.Text = coinsCollected.ToString (); totalText.RunAction (flyupTotal); totalScore.RunAction (flyupTotalScore, () => { totalScore.RunAction (countUpTotal, () => { totalScore.Text = totalCollected.ToString (); }); }); }); }); }); }); }); }