/// <summary> /// го поместува играчот во десно. /// </summary> public void moveRight() { Character.UpdateCharacterImage(); if (!endOfLevel) { if (!MoveBackground) { if (Character.X <= FixedPoint) { Character.X += 5; } if (Character.X >= FixedPoint) { ComesBackToStart = false; } } else { Bckgr.startingX -= 5; Coins.Move("RIGHT"); Bananas.Move("RIGHT"); } } else { if (Character.X <= this.Width - 60) { Character.X += 5; } } }
private void Start() { bananaScript = this; for (int i = 0; i < maxNumBananas; i++) { GrowBanana(); } }
private void Start() { bananaScript = this; for(int i = 0; i < maxNumBananas; i++) { GrowBanana(); } }
public void DeleteBanana(Banana banana) { Bananas.Remove(banana); Fruits.Remove(banana); var n = 0; foreach (Banana b in Bananas) { b.Number = n++; } }
static void Main(string[] args) { GoldenMushroom goldenMushroom1 = new GoldenMushroom(); goldenMushroom1.itemoutput(); Bananas banana1 = new Bananas(); banana1.itemoutput(); Coin coin1 = new Coin(); coin1.itemoutput(); }
public void CollideWithCoconut(SCNNode coconut, SCNVector3 contactPoint) { // No more collisions. Let it bounce away and fade out. coconut.PhysicsBody.CollisionBitMask = 0; coconut.RunAction(SCNAction.Sequence(new SCNAction[] { SCNAction.Wait(1.0), SCNAction.FadeOut(1.0), SCNAction.RemoveFromParentNode() }), () => { Coconuts.Remove((Coconut)coconut); }); // Decrement score int amountToDrop = Score / 10; amountToDrop = Math.Max(1, amountToDrop); amountToDrop = Math.Min(10, amountToDrop); if (amountToDrop > Score) { amountToDrop = Score; } Score -= amountToDrop; // Throw bananas float spacing = 40f; for (int x = 0; x < amountToDrop; x++) { SCNNode banana = CreateBanana(); RootNode.AddChildNode(banana); banana.Position = contactPoint; banana.PhysicsBody.CategoryBitMask = GameCollisionCategory.NoCollide; banana.PhysicsBody.CollisionBitMask = GameCollisionCategory.Ground; SCNVector3 endPoint = SCNVector3.Zero; endPoint.X -= (spacing * x) + spacing; SCNAction flyoff = SCNAction.MoveBy(endPoint, MathUtils.RandomPercent() * 0.750f); flyoff.TimingMode = SCNActionTimingMode.EaseInEaseOut; banana.RunAction(flyoff, () => { banana.PhysicsBody.CategoryBitMask = GameCollisionCategory.Banana; banana.PhysicsBody.CollisionBitMask = GameCollisionCategory.Ground | GameCollisionCategory.Player; }); Bananas.Add(banana); } PlayerCharacter.InHitAnimation = true; }
public void CollectBanana(SCNNode banana) { // Flyoff the banana to the screen space position score label. // Don't increment score until the banana hits the score label. // ignore collisions banana.PhysicsBody = null; BananasCollected++; int variance = 60; nfloat duration = 0.25f; nfloat apexY = worldSpaceLabelScorePosition.Y * 0.8f + (new Random().Next(0, variance) - variance / 2); worldSpaceLabelScorePosition.Z = banana.Position.Z; var apex = new SCNVector3(banana.Position.X + 10 + (new Random().Next(0, variance) - variance / 2), apexY, banana.Position.Z); SCNAction startFlyOff = SCNAction.MoveTo(apex, duration); startFlyOff.TimingMode = SCNActionTimingMode.EaseOut; SCNAction endFlyOff = SCNAction.CustomAction(duration, new SCNActionNodeWithElapsedTimeHandler((node, elapsedTime) => { nfloat t = elapsedTime / duration; var v = new SCNVector3( apex.X + ((worldSpaceLabelScorePosition.X - apex.X) * t), apex.Y + ((worldSpaceLabelScorePosition.Y - apex.Y) * t), apex.X + ((worldSpaceLabelScorePosition.Z - apex.Z) * t)); node.Position = v; })); endFlyOff.TimingMode = SCNActionTimingMode.EaseInEaseOut; SCNAction flyoffSequence = SCNAction.Sequence(new SCNAction[] { startFlyOff, endFlyOff }); banana.RunAction(flyoffSequence, () => { Bananas.Remove(banana); banana.RemoveFromParentNode(); // Add to score. Score++; GameSimulation.Sim.PlaySound("deposit.caf"); // Game Over if (Bananas.Count == 0) { DoGameOver(); } }); }
/// <summary> /// го поместува играчот во лево. /// </summary> public void moveLeft() { Character.UpdateCharacterImage(); if (!endOfLevel) { if (!MoveBackground) { if (Character.X > 0) { Character.X -= 5; } } else { if (!CanComeBack) { if (counterComeBack <= 100) { counterComeBack++; ComesBackToStart = true; MoveBackground = false; } else { Bckgr.startingX += 5; Coins.Move("LEFT"); Bananas.Move("LEFT"); } } else { ComesBackToStart = true; MoveBackground = false; } } } else { if (Character.X >= 30) { Character.X -= 5; } } }
/// <summary> /// исцртување на главната панела (позадина, карактер, по потреба куршуми, непријатели, скорови ... итн) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawImage(BckgrBitmap, Bckgr.startingX, 0, BckgrBitmap.Width, BckgrBitmap.Height); e.Graphics.DrawImage(Character.CurrentCharacterImage, Character.X, Character.Y); if (VisibleBullet) { BulletInjection.DrawInjection(e.Graphics); } MyEnemies.DrawEvilMinions(e.Graphics); Coins.Draw(e.Graphics); Bananas.Draw(e.Graphics); e.Graphics.DrawString("COINS: " + CollectedCoins.ToString(), font, brush, point); //e.Graphics.DrawString("FOOD: " + CollectedBananas.ToString(), font, brush, point2); this.DrawLifeAndKilledEM(e.Graphics); if (!VectorVillian.IsKilled && gamemode == GameMode.Hard) { VectorVillian.DrawVector(e.Graphics); } }
public void AddBanana() { if (Bananas == null) { Bananas = new List <Banana>(); } if (Fruits == null) { Fruits = new List <IFruit>(); } var number = Bananas.Count; var newBanana = new Banana { Number = number, ContainedBy = this }; // var lastBanana = Bananas[Bananas.Count - 1]; // var index = Fruits.LastIndexOf(lastBanana); // Fruits.Insert(index + 1, newBanana); Fruits.Add(newBanana); Bananas.Add(newBanana); }
/// <summary> /// тајмерот проверува дали каракатерот дошол до фиксната точка, ако да /// го фиксира и притоа ја придвижува позадината согласно кон кој правец /// се движи играчот како би се створила илузија на движење на позадината. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TmrMoving_Tick(object sender, EventArgs e) { MovingTimer(); if (counterShooting++ == 2) { ShootingTimer(); counterShooting = 0; // + анимација на парички (се совпаѓа), мењање на моментална слика. Coins.UpdateImage(); Coins.IsCollected(Character); Coins.IsntCollectedPassed(); Bananas.IsCollected(Character); Bananas.IsntCollectedPassed(); } if (counterKilling++ == 1) { counterKilling = 0; if (VisibleBullet) { VisibleBullet = MyEnemies.IsEnemyKilled(BulletInjection); } CharLosesLife = MyEnemies.KillingCharacter(Character); } if (!endOfLevel) { if (counterMove++ == SpeedOfGame) { counterMove = 0; MyEnemies.UpdateEvilMinions(); } if (counterAddEnemy++ == 60) { counterAddEnemy = 0; MyEnemies.AddEnemy(); } } if (Character.Hit >= 3) { Character.Killed = true; this.TmrMoving.Stop(); GameOver gm = new GameOver(); gm.ShowDialog(); } if (CollectedCoinsPlusLife == 50) { CollectedCoinsPlusLife = 0; Lifes++; } if (CharLosesLife) { PlayAgain(); CharLosesLife = false; } if (endOfLevel) { TmrMoving.Stop(); pnlWinning.Visible = true; lblCongrats.Visible = true; lblEndWinning.Visible = true; lblNextLevel.Visible = true; this.DrawSavedGirl(pnlWinning.CreateGraphics()); EndOfGame(); } if ((++CounterVector == 200)) { CounterVector = 0; if ((gamemode == GameMode.Hard) && (VectorCanShowUp)) { VectorVillian = new Vector(); VectorCanShowUp = false; } } if (++CounterVectorMoving == 2) { CounterVectorMoving = 0; if (gamemode == GameMode.Hard && !VectorCanShowUp) { VectorVillian.updatePosition(); if (VectorVillian.VectorAttacked(BulletInjection)) { CounterVectorKilled++; lblVector.Text = "VECTOR DEFEATED " + CounterVectorKilled.ToString() + " TIMES !!"; VectorCanShowUp = true; } } } if (gamemode == GameMode.Hard) { if (VectorVillian.X + VectorVillian.CurrentImage.Width < 0) { VectorCanShowUp = true; } } Invalidate(); }
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); } } }
private void Load(EndianBinaryReader input) { int unk0 = input.ReadInt32(); int unk4 = input.ReadInt32(); int numCollission = input.ReadInt32(); int collisionOffset = input.ReadInt32(); if (input.ReadInt32() != 0xA0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x10] == 0xA0."); } int unk14 = input.ReadInt32(); int numGoals = input.ReadInt32(); int goalsOffset = input.ReadInt32(); if (input.ReadInt32() != numGoals) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x18] == StageLayout[0x20]."); } if (input.ReadInt32() != 0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x24] == 0."); } int numBumbers = input.ReadInt32(); int bumpersOffset = input.ReadInt32(); int numJamabars = input.ReadInt32(); int jamabarsOffset = input.ReadInt32(); int numBananas = input.ReadInt32(); int bananasOffset = input.ReadInt32(); int numUnk40 = input.ReadInt32(); int unk40Offset = input.ReadInt32(); int numUnk48 = input.ReadInt32(); int unk48Offset = input.ReadInt32(); int numUnk50 = input.ReadInt32(); int unk50Offset = input.ReadInt32(); int numModelNames = input.ReadInt32(); int modelNamesOffset = input.ReadInt32(); // Looks like a number/offset to some struct of size 0x20, mostly floats int numUnk60 = input.ReadInt32(); int unk60Offset = input.ReadInt32(); int unk68 = input.ReadInt32(); int unk6C = input.ReadInt32(); int numUnk70 = input.ReadInt32(); int unk70Offset = input.ReadInt32(); int unk78 = input.ReadInt32(); int unk7C = input.ReadInt32(); int unk80 = input.ReadInt32(); int unk84 = input.ReadInt32(); int unk88 = input.ReadInt32(); int unk8C = input.ReadInt32(); int unk90 = input.ReadInt32(); if (input.ReadInt32() != 0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x94] == 0."); } if (input.ReadInt32() != 0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x98] == 0."); } if (input.ReadInt32() != 0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x9C] == 0."); } //if (numCollission != 0) Console.WriteLine(numCollission + "/" + collisionOffset); /* * if (unk78 != 0) * { * input.BaseStream.Position = unk7C; * for (int i = 0; i < unk78 + 5; i++) * { * byte[] bytes = input.ReadBytes(0x38); * if (i >= unk78) Console.Write("XXX "); * Console.WriteLine(string.Join(" ", bytes.Select(b => b.ToString("X2")))); * } * * Console.ReadKey(); * } */ input.BaseStream.Position = collisionOffset; for (int i = 0; i < numCollission; i++) { StageLayoutCollision collision = new StageLayoutCollision(); collision.Load(input); Collision.Add(collision); } input.BaseStream.Position = modelNamesOffset; for (int i = 0; i < numModelNames; i++) { StageLayoutModelName modelName = new StageLayoutModelName(); modelName.Load(input); ModelNames.Add(modelName); } input.BaseStream.Position = goalsOffset; for (int i = 0; i < numGoals; i++) { StageLayoutGoal goal = new StageLayoutGoal(); goal.Load(input); Goals.Add(goal); } input.BaseStream.Position = bumpersOffset; for (int i = 0; i < numBumbers; i++) { StageLayoutItem bumper = new StageLayoutItem(); bumper.Load(input); Bumpers.Add(bumper); } input.BaseStream.Position = jamabarsOffset; for (int i = 0; i < numJamabars; i++) { StageLayoutItem jamabar = new StageLayoutItem(); jamabar.Load(input); Jamabars.Add(jamabar); } input.BaseStream.Position = bananasOffset; for (int i = 0; i < numBananas; i++) { StageLayoutBanana banana = new StageLayoutBanana(); banana.Load(input); Bananas.Add(banana); } input.BaseStream.Position = unk40Offset; for (int i = 0; i < numUnk40; i++) { StageLayoutItemExt unk40 = new StageLayoutItemExt(); unk40.Load(input); Unk40.Add(unk40); } input.BaseStream.Position = unk48Offset; for (int i = 0; i < numUnk48; i++) { StageLayoutUnk48 unk48 = new StageLayoutUnk48(); unk48.Load(input); Unk48.Add(unk48); } input.BaseStream.Position = unk50Offset; for (int i = 0; i < numUnk50; i++) { StageLayoutUnk50 unk50 = new StageLayoutUnk50(); unk50.Load(input); Unk50.Add(unk50); } input.BaseStream.Position = unk60Offset; for (int i = 0; i < numUnk60; i++) { StageLayoutUnk60 unk60 = new StageLayoutUnk60(); unk60.Load(input); Unk60.Add(unk60); } input.BaseStream.Position = unk70Offset; for (int i = 0; i < numUnk70; i++) { StageLayoutUnk70 unk70 = new StageLayoutUnk70(); unk70.Load(input); Unk70.Add(unk70); } }