protected virtual void spawnBox() { spawnTimer = 0; Box box; if(coloredCatcher != null) { if(counter < deltaBox && random.Next(0, 2) == 0) { box = new Box(Color.Blue); counter++; } else { box = new Box(); counter = 0; } } else box = new Box(); if(!(spawnTimer >= spawnTime)) box.ExtraPoints = (spawnTime - spawnTimer) / 60; boxesOnscreen.Add(box); RenderingDevice.Add(box); BoxesRemaining--; }
protected void spawnDebugBox() { if(intList == null) intList = new List<int>(); if(Input.CheckKeyboardJustPressed(Keys.Enter)) { spawnlevel++; place = 1; isNegative = false; intList.Clear(); } else if(Input.CheckKeyboardJustPressed(Keys.Tab)) { spawnlevel = 0; place = 1; isNegative = false; location = Vector3.Zero; intList.Clear(); return; } else if(Input.CheckKeyboardJustPressed(Keys.RightShift)) { location = lastLocation; spawnlevel = 4; } if(spawnlevel == 0) return; Keys[] pressedKeys = Input.KeyboardState.GetPressedKeys(); if(pressedKeys.Length > 1 && pressedKeys[0] == Keys.None) // then something weird is going on and it needs to be fixed { Keys[] temp = new Keys[pressedKeys.Length - 1]; for(int i = 1; i < pressedKeys.Length; i++) temp[i - 1] = pressedKeys[i]; pressedKeys = temp; } if(pressedKeys.Length > 0) if(pressedKeys[0] != Keys.None && pressedKeys[0] != Keys.Enter) { if(Input.CheckKeyboardJustPressed(pressedKeys[0])) { int numberKey = ((int)pressedKeys[0] - 48); if((numberKey < 0 || numberKey > 9) && numberKey != 141 && numberKey != -40 && numberKey != 113) return; if(numberKey == 141) { isNegative = !isNegative; return; } switch(spawnlevel) { case 1: if(numberKey == -40) { location.X = 0; intList.Clear(); return; } intList.Add(numberKey); location.X = 0; place = 1; for(int i = intList.Count; i > 0; i--) { location.X += intList[i - 1] * place; place *= 10; } if(isNegative) location.X = -location.X; break; case 2: if(numberKey == -40) { location.Y = 0; intList.Clear(); return; } intList.Add(numberKey); location.Y = 0; place = 1; for(int i = intList.Count; i > 0; i--) { location.Y += intList[i - 1] * place; place *= 10; } if(isNegative) location.Y = -location.Y; break; case 3: if(numberKey == -40) { location.Z = 0; intList.Clear(); return; } intList.Add(numberKey); location.Z = 0; place = 1; for(int i = intList.Count; i > 0; i--) { location.Z += intList[i - 1] * place; place *= 10; } if(isNegative) location.Z = -location.Z; break; } } } if(spawnlevel == 4) { place = 1; Box b = new Box(location); boxesOnscreen.Add(b); RenderingDevice.Add(b); if(BoxesRemaining > 0) BoxesRemaining--; lastLocation = location; location = Vector3.Zero; spawnlevel = 0; GameManager.Cutter.WriteToLog(this, "Box unnaturally spawned at: " + location.ToString()); } }
public void CatchBox(Box b) { if(b is BlackBox) { (b as BlackBox).Remove(); if(!Ending) { MediaSystem.PlaySoundEffect(SFXOptions.Box_Death); boxesSaved--; score -= baseBoxValue; multiplier = multiplierStages[0]; index = 0; BoxesDestroyed++; } } if(!Ending) { MediaSystem.PlaySoundEffect(SFXOptions.Box_Success); boxesSaved++; score += (int)(baseBoxValue * multiplier + b.ExtraPoints); if(index + 1 == multiplierStages.Length) multiplier = multiplierStages[index]; else multiplier = multiplierStages[++index]; } boxesOnscreen.Remove(b); RenderingDevice.RemovePermanent(b); GameManager.Space.Remove(b); }
public void DestroyBox(Box b) { if(!Ending) { BoxesDestroyed++; multiplier = multiplierStages[0]; index = 0; if(score < baseBoxValue) score = 0; else score -= baseBoxValue; MediaSystem.PlaySoundEffect(SFXOptions.Box_Death); } boxesOnscreen.Remove(b); RenderingDevice.RemovePermanent(b); GameManager.Space.Remove(b); }
public void Ready() { box = new Box(new Vector3(0, 0, 20)); Random r = new Random(); box.Ent.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(r.Next(-25, 25))) * Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(r.Next(-25, 25))) * Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(r.Next(-25, 25))); RenderingDevice.Camera.SetForResultsScreen(); GameManager.Space.Add(entity); GameManager.State = GameState.Results; RenderingDevice.Add(box); ADVertexFormat[] verts = new ADVertexFormat[4]; float halfWidth = 80; verts[1] = new ADVertexFormat(new Vector3(-halfWidth, -halfWidth, 0), new Vector2(0, 0), new Vector3(0, 0, 1)); verts[0] = new ADVertexFormat(new Vector3(-halfWidth, halfWidth, 0), new Vector2(0, 1), new Vector3(0, 0, 1)); verts[2] = new ADVertexFormat(new Vector3(halfWidth, halfWidth, 0), new Vector2(1, 0), new Vector3(0, 0, 1)); verts[3] = new ADVertexFormat(new Vector3(halfWidth, -halfWidth, 0), new Vector2(1, 1), new Vector3(0, 0, 1)); buff = new VertexBuffer(RenderingDevice.GraphicsDevice, ADVertexFormat.VertexDeclaration, 4, BufferUsage.WriteOnly); buff.SetData(verts); RenderingDevice.Add(buff, Resources.MetalTex); RenderingDevice.SetUpLighting(RenderingDevice.LightingData.Results); timer.Start(); }
protected override void updateVelocities() { base.updateVelocities(); if(doingSomething) { double pathTimeLastFrame = pathTime; pathTime += GameManager.Space.TimeStepSettings.TimeStepDuration; if(pathTimeLastFrame < 2 && pathTime > 2) { baseJoint.AngularMotor.Settings.Servo.Goal = angle; //ResetVelocity(); } else if(pathTime > 3 && !exploded && Math.Abs(baseJoint.AngularMotor.RelativeVelocity) < epsilon) { //if(TeleportPoint != Vector3.Zero) //{ // // This block of code does nothing except teleport boxes inside the cannon to a specific point if and only if there is one box inside. // (Space as Space).BroadPhase.QueryAccelerator.GetEntries(baseJoint.AngularJoint.ConnectionB.CollisionInformation.BoundingBox, boxes); // boxes = boxes.FindAll(v => { return v.Tag is Box; }); // if(boxes.Count == 1) // { // (boxes[0].Tag as Box).Ent.Position = TeleportPoint; // (boxes[0].Tag as Box).Ent.Orientation = new Quaternion(0.09443433f, -0.9264939f, -0.3610983f, -0.04794991f); // } //} (Space as Space).BroadPhase.QueryAccelerator.GetEntries(baseJoint.AngularJoint.ConnectionB.CollisionInformation.BoundingBox, boxes); boxes = boxes.FindAll(v => { return v.Tag is Box; }); if(boxes.Count == 1) path.Add(boxes[0].Tag as Box); else if(boxes.Count > 1) { Box[] lololol = new Box[boxes.Count]; int i = 0; foreach(BroadPhaseEntry b in boxes) lololol[i++] = b.Tag as Box; path.Add(lololol); } boxes.Clear(); //explosion.Explode(); exploded = true; particles.Activate(); stopMachineNoise(); // add a little kickback //modelList[0].Ent.AngularMomentum = Vector3.Transform(Vector3.Cross(Vector3.Normalize(unitsToTranslate), rotationAxis), Quaternion.CreateFromAxisAngle(rotationAxis, angle)) * 15; MediaSystem.PlaySoundEffect(SFXOptions.Explosion);//, modelList[0].ModelPosition); } else if(pathTimeLastFrame < 4 && pathTime > 4) { baseJoint.AngularMotor.Settings.Servo.Goal = 0; fetchMachineNoise(); if(machineNoise != null) machineNoise.Play(); } else if(pathTimeLastFrame < 5 && pathTime > 5) baseJoint.LinearMotor.Settings.Servo.Goal = 0; else if(pathTime > 5 && Math.Abs(baseJoint.LinearMotor.RelativeVelocity) < epsilon) { stopMachineNoise(); doingSomething = false; pathTime = 0; exploded = false; } } //if(doingSomething) // foreach(BaseModel m in modelList) // m.Ent.AngularVelocity = GetAngularVelocity(m.Ent.Orientation, curve.Evaluate(pathTime), // GameManager.Space.TimeStepSettings.TimeStepDuration); //else // ResetVelocity(); }
protected void explode() { boxes.Clear(); (Space as Space).BroadPhase.QueryAccelerator.GetEntries(joints[0].BallSocketJoint.ConnectionB.CollisionInformation.BoundingBox, boxes); boxes = boxes.FindAll(v => { return v.Tag is Box; }); if(boxes.Count == 1) pathFinder.Add(boxes[0].Tag as Box); else if(boxes.Count > 1) { Box[] lololol = new Box[boxes.Count]; int i = 0; foreach(BroadPhaseEntry b in boxes) lololol[i++] = b.Tag as Box; pathFinder.Add(lololol); } //explosion.Explode(); particles.Activate(); MediaSystem.PlaySoundEffect(SFXOptions.Explosion); }
/// <summary> /// Add a box and forget about it! /// </summary> /// <param name="b"></param> public void Add(Box b) { EntityMover m = new EntityMover(b.Ent); m.LinearMotor.Settings.MaximumForce = m.LinearMotor.Settings.Servo.MaxCorrectiveVelocity = 500; movers.Add(m, 0.5f); GameManager.Space.Add(m); b.Ent.AngularMomentum += new Vector3((float)r.NextDouble() * 3, (float)r.NextDouble() * 3, (float)r.NextDouble() * 3); }
/// <summary> /// Be careful when you use this. /// </summary> public static void OnGDMCreation(Effect shader, Texture2D texture) { #if DEBUG vertices = new VertexPositionColor[6]; vertices[0] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Red); vertices[1] = new VertexPositionColor(new Vector3(10000, 0, 0), Color.Red); vertices[2] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Green); vertices[3] = new VertexPositionColor(new Vector3(0, 10000, 0), Color.Green); vertices[4] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Blue); vertices[5] = new VertexPositionColor(new Vector3(0, 0, 10000), Color.Blue); xyz = new BasicEffect(GraphicsDevice); vertexBuff = new VertexBuffer(GraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.None); #endif lights = new LightingSystem(shader, texture); SpriteBatch = new SpriteBatch(GraphicsDevice); //untexturedModels.Clear(); texturedModels.Clear(); shaderModels.Clear(); glassModels.Clear(); masterDict.Clear(); if(Resources.boxModel != null) { Box b = new Box(Vector3.Zero); // necessary because otherwise it looks for the current level's Add(b); RemovePermanent(b); // this gets the box model in the masterDict for the spinning saving box } primitives.Clear(); onGDMReset(new object(), EventArgs.Empty); if(manager != null) manager.DestroyAndRemoveAllParticleSystems(); if(GameManager.CurrentLevel != null) GameManager.CurrentLevel.AddModels(); }