public void addBrokenEgg(Vector3 eggPosition) { brokenEggList[numBrokeEgg] = new BrokenEggClass(content, graphics); brokenEggList[numBrokeEgg].position = eggPosition; numBrokeEgg++; }
public void initilizeTutorialLevel() { myScene = content.Load<Model>("Models\\farmScene[8]"); aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio; //camera cameraViewMatrix = Matrix.CreateLookAt( cameraPosition, cameraLookAt, Vector3.Up); cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(45.0f), graphics.GraphicsDevice.Viewport.AspectRatio, 1.0f, 10000.0f * 50); //intilize all values stage = 0; buttonDown = false; //stage0 up = false; down = false; left = false; right = false; //stage1 cUp = false; cDown = false; cIn = false; cOut = false; menustage = false; //character Character = new CharacterClass(content, graphics); Character.InitializeCharacter(); layEgg = 0; numCount = 0; //chicken Chicken[0] = new ChickenClass(content, graphics); Chicken[0].InitializeChicken(0); //Rooster Rooster[0] = new RoosterClass(content, graphics); Rooster[0].InitializeRooster(13); numRooster = 1; //egg eggList[0] = new EggClass(content, graphics); eggList[0].initializeEgg(); numEgg = 0; //borken egg numBrokeEgg = 0; brokenEggList[0] = new BrokenEggClass(content, graphics); brokenEggList[0].initializeBrokenEgg(); //boots myBootList[0] = new RubberBootClass(content, graphics); myBootList[0].initializeBoots(); //initilize fox myFox = new FoxClass(content, graphics); myFox.initializeFox(new Vector3(3600, 80, 3600), 1); //eggslip displacement = 0; speed = 15.0f; force = 2.0f; moveBack = false; slip = false; noSlip = false; buttonstage = 0; //which to draw/update chickenB = false; roosterB = false; foxB = false; tmpPosition = new Vector3(0, 0, 0); //camera cameraLookAt = new Vector3(3500, 0, 3500); cameraPosition = new Vector3(3500.0f, 450.0f, 6000.0f); //initial camera position camRearOffset = 1000.0f; //default distance between camera and character camHeightOffset = 800f; //default distance between camera and ground maxCamHeight = 2000f; minCamHeight = 200f; maxCamOffset = 3000f; minCamOffset = 200f; }
public void update(GameTime gameTime, BrokenEggClass[] brokenEggLst, int numBrokeEgg, bool bootEquipped, ref Vector3 cameraPosition, ref Vector3 cameraLookAt, ref Matrix cameraViewMatrix, EconomicsClass player, ref int totalEggs) { elapsed += (float)gameTime.ElapsedGameTime.TotalSeconds; moveNormal(cameraPosition, ref cameraViewMatrix); //if there are broken eggs on ground for (int i = 0; i < numBrokeEgg; i++) { //test to see if character is walking on broken eggs //if on eggs, slide until off if (Vector3.Distance(position, brokenEggLst[i].position) <= 250 && bootEquipped == false) { //slide code Chicken.AudioManager.instance.setSlipEffectInstance(Chicken.AudioManager.instance.eggSlipSound); if (Chicken.AudioManager.instance.sFXOn == true && Chicken.AudioManager.instance. sFXeggSlipInstance.State != SoundState.Playing && GameUI.gameWorld.instance.isPaused != true) { Chicken.AudioManager.instance.sFXeggSlipInstance.Volume = 0.1f; Chicken.AudioManager.instance.sFXeggSlipInstance.Play(); } displacement = ((speed * speed) / 2) / force; if (moveBack == true) { position.X -= displacement * (float)Math.Sin(rotation); position.Z -= displacement * (float)Math.Cos(rotation); } else { position.X += displacement * (float)Math.Sin(rotation); position.Z += displacement * (float)Math.Cos(rotation); } } } //hotkey for eat egg GamePadState gamePadState = GamePad.GetState(PlayerIndex.One); KeyboardState keyBoardState = Keyboard.GetState(); //eat egg gamepad hotkey if (gamePadState.IsButtonDown(Buttons.Y) && buttonDown == false) { //eat egg player.eatEgg(ref hitPoints, maxHP, ref totalEggs); buttonDown = true; } if (gamePadState.IsButtonUp(Buttons.Y) && buttonDown == true) { buttonDown = false; } //eat egg keyboard hotkey if (keyBoardState.IsKeyDown(Keys.E) && buttonDown2 == false) { //eat egg player.eatEgg(ref hitPoints, maxHP, ref totalEggs); buttonDown2 = true; } if (keyBoardState.IsKeyUp(Keys.E) && buttonDown2 == true) { buttonDown2 = false; } }