Esempio n. 1
0
		public void CollectLargeBanana (SCNNode largeBanana)
		{
			// When the player hits a large banana, explode it into smaller bananas.
			// We explode into a predefined pattern: square, diamond, letterA, letterB

			// ignore collisions
			largeBanana.PhysicsBody = null;
			CoinsCollected++;

			LargeBananas.Remove (largeBanana);
			largeBanana.RemoveAllParticleSystems ();
			largeBanana.RemoveFromParentNode ();

			// Add to score.
			Score += 100;

			var square = new string[] {
				"1", "1", "1", "1", "1",
				"1", "1", "1", "1", "1",
				"1", "1", "1", "1", "1",
				"1", "1", "1", "1", "1",
				"1", "1", "1", "1", "1"
			};

			var diamond = new string[] {
				"0", "0", "1", "0", "0",
				"0", "1", "1", "1", "0",
				"1", "1", "1", "1", "1",
				"0", "1", "1", "1", "0",
				"0", "0", "1", "0", "0"
			};

			var letterA = new string[] {
				"1", "0", "0", "1", "0",
				"1", "0", "0", "1", "0",
				"1", "1", "1", "1", "0",
				"1", "0", "0", "1", "0",
				"0", "1", "1", "0", "0"
			};

			var letterB = new string[] {
				"1", "1", "0", "0", "0",
				"1", "0", "1", "0", "0",
				"1", "1", "0", "0", "0",
				"1", "0", "1", "0", "0",
				"1", "1", "0", "0", "0"
			};

			var choices = new List<string[]> { square, diamond, letterA, letterB };
			float vertSpacing = 40f;
			float spacing = 0.0075f;
			string[] choice = choices [new Random ().Next (0, choices.Count)];
			for (int y = 0; y < 5; y++) {
				for (int x = 0; x < 5; x++) {

					int place = Int32.Parse (choice [(y * 5) + x]);
					if (place != 1)
						continue;

					SCNNode banana = CreateBanana ();
					RootNode.AddChildNode (banana);
					banana.Position = largeBanana.Position;
					banana.PhysicsBody.CategoryBitMask = GameCollisionCategory.NoCollide;
					banana.PhysicsBody.CollisionBitMask = GameCollisionCategory.Ground;

					SCNVector3 endPoint = LocationAlongPath (TimeAlongPath + spacing * (x + 1));
					endPoint.Y += (vertSpacing * (y + 1));

					SCNAction flyoff = SCNAction.MoveTo (endPoint, MathUtils.RandomPercent () * 0.25f);
					flyoff.TimingMode = SCNActionTimingMode.EaseInEaseOut;

					banana.RunAction (flyoff, () => {
						banana.PhysicsBody.CategoryBitMask = GameCollisionCategory.Banana;
						banana.PhysicsBody.CollisionBitMask = GameCollisionCategory.Ground | GameCollisionCategory.Player;
						GameSimulation.Sim.PlaySound ("deposit.caf");
					});

					Bananas.Add (banana);
				}
			}
		}
Esempio n. 2
0
        public void CollectLargeBanana(SCNNode largeBanana)
        {
            // When the player hits a large banana, explode it into smaller bananas.
            // We explode into a predefined pattern: square, diamond, letterA, letterB

            // ignore collisions
            largeBanana.PhysicsBody = null;
            CoinsCollected++;

            LargeBananas.Remove(largeBanana);
            largeBanana.RemoveAllParticleSystems();
            largeBanana.RemoveFromParentNode();

            // Add to score.
            Score += 100;

            var square = new string[] {
                "1", "1", "1", "1", "1",
                "1", "1", "1", "1", "1",
                "1", "1", "1", "1", "1",
                "1", "1", "1", "1", "1",
                "1", "1", "1", "1", "1"
            };

            var diamond = new string[] {
                "0", "0", "1", "0", "0",
                "0", "1", "1", "1", "0",
                "1", "1", "1", "1", "1",
                "0", "1", "1", "1", "0",
                "0", "0", "1", "0", "0"
            };

            var letterA = new string[] {
                "1", "0", "0", "1", "0",
                "1", "0", "0", "1", "0",
                "1", "1", "1", "1", "0",
                "1", "0", "0", "1", "0",
                "0", "1", "1", "0", "0"
            };

            var letterB = new string[] {
                "1", "1", "0", "0", "0",
                "1", "0", "1", "0", "0",
                "1", "1", "0", "0", "0",
                "1", "0", "1", "0", "0",
                "1", "1", "0", "0", "0"
            };

            var choices = new List <string[]> {
                square, diamond, letterA, letterB
            };
            float vertSpacing = 40f;
            float spacing     = 0.0075f;

            string[] choice = choices [new Random().Next(0, choices.Count)];
            for (int y = 0; y < 5; y++)
            {
                for (int x = 0; x < 5; x++)
                {
                    int place = Int32.Parse(choice [(y * 5) + x]);
                    if (place != 1)
                    {
                        continue;
                    }

                    SCNNode banana = CreateBanana();
                    RootNode.AddChildNode(banana);
                    banana.Position = largeBanana.Position;
                    banana.PhysicsBody.CategoryBitMask  = GameCollisionCategory.NoCollide;
                    banana.PhysicsBody.CollisionBitMask = GameCollisionCategory.Ground;

                    SCNVector3 endPoint = LocationAlongPath(TimeAlongPath + spacing * (x + 1));
                    endPoint.Y += (vertSpacing * (y + 1));

                    SCNAction flyoff = SCNAction.MoveTo(endPoint, MathUtils.RandomPercent() * 0.25f);
                    flyoff.TimingMode = SCNActionTimingMode.EaseInEaseOut;

                    banana.RunAction(flyoff, () => {
                        banana.PhysicsBody.CategoryBitMask  = GameCollisionCategory.Banana;
                        banana.PhysicsBody.CollisionBitMask = GameCollisionCategory.Ground | GameCollisionCategory.Player;
                        GameSimulation.Sim.PlaySound("deposit.caf");
                    });

                    Bananas.Add(banana);
                }
            }
        }