public SimpleBulet createSigleBulet(SimpleShip ship,int liveSpam, int speed) { SimpleBulet bulet = new SimpleBulet(liveSpam, 0.1f); var rad = ((SimpleHitBox)ship.MainHitBox).Radius; var saveDistance = rad + 2 * bulet.Radius; Vector3 speedAngle = new Vector3((float)(speed * Math.Cos(ship.Rotation[2])), (float)(speed * Math.Sin( ship.Rotation[2])), 0f); Vector3 position = new Vector3((float)(ship.ObjectCenter[0] + saveDistance * Math.Cos(ship.Rotation[2])), (float)(ship.ObjectCenter[1] + saveDistance * Math.Sin(ship.Rotation[2])), 0f); bulet.ObjectCenter = position; bulet.Speed = speedAngle + ship.Speed; return bulet; }
public void AddShip(String name) { var newShip = new SimpleShip(200, 1, 100, 5,2000,200, 2f,10000,5000); int startLocation = ships.Count % 8; // Vector3 newShip.ObjectCenter = newShip.ObjectCenter; //Vector3 newShip.Rotation = newShip.Rotation; switch (startLocation) { case 1: { newShip.ObjectCenter.X = -2.5f; newShip.ObjectCenter.Y = 0; newShip.Rotation.Z = (float)(0); break; } case 2: { newShip.ObjectCenter.X = -2.5f; newShip.ObjectCenter.Y = -2.5f; newShip.Rotation.Z = (float)(Math.PI * 1 / 4); break; } case 3: { newShip.ObjectCenter.X = 0; newShip.ObjectCenter.Y = -2.5f; newShip.Rotation.Z = (float)(Math.PI * 1 / 2); break; } case 4: { newShip.ObjectCenter.X = 2.5f; newShip.ObjectCenter.Y = -2.5f; newShip.Rotation.Z = (float)(Math.PI * 3 / 4); break; } case 5: { newShip.ObjectCenter.X = 2.5f; newShip.ObjectCenter.Y = 0; newShip.Rotation.Z = (float)(Math.PI * 1); break; } case 6: { newShip.ObjectCenter.X = 2.5f; newShip.ObjectCenter.Y = 2.5f; newShip.Rotation.Z = (float)(Math.PI * 5 / 4); break; } case 7: { newShip.ObjectCenter.X = 0; newShip.ObjectCenter.Y = 2.5f; newShip.Rotation.Z = (float)(Math.PI * 3 / 2); break; } case 0: { newShip.ObjectCenter.X = -2.5f; newShip.ObjectCenter.Y = 2.5f; newShip.Rotation.Z = (float)(Math.PI * 7 / 4); break; } } ships.Add(name, newShip); }