protected override void OnLoad(EventArgs e) { //GL.ShadeModel (All.Flat); GL.ShadeModel(All.Smooth); GL.ClearColor(0, 0, 0, 1); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.ClearDepth(1.0f); GL.Enable(All.DepthTest); GL.DepthFunc(All.Lequal); GLTextureAdmin.UnLoadGLTextures(); GLTextureAdmin.AddTexturesFromResource(Context, new string[] { "earth", "moon", "tex", "darkgray", "f_spot", "pattern", "borg" }); _scene.LoadFromAndroidAsset(Context, "scene.xml"); var ent = _scene.GetObjectByName("Enterprise") as GLSpaceShip; ent.MoveToCenter(); ent.Magnify(0.12); ent.OrbitEllipse.RadiusMajor = 6; ent.OrbitEllipse.RadiusMinor = 5; ent.OrbitAngle = 90; SetupCamera(); }
public void NewLevel() { GLTextureAdmin.UnLoadGLTextures(); GLTextureAdmin.AddTexturesFromResource(Context, new string[] { "blue0", "blue1", "labBottomF", "labBottomL", "labBottomS", "labTop", "labTopF", "labTopL", "labTopS", "labWall0", "labWall1", "labWall2", "labWall3", "labWallF", "labWallL", "labWallS", "money", "moneySmall", "blue0", "labBottom" }); var labyrinth = (_scene.GetObjectByName("labyrinth") as GLLabyrinthObj); int moves; int items; if (labyrinth.Level <= 5) // 1 .. 5 level => 5 * 2 .. 25 * 10 { moves = labyrinth.Level * 5; items = labyrinth.Level * 2; } else if (labyrinth.Level <= 20) // 6 .. 20 level => 26 * 11 .. 40 * 25 { moves = 20 + labyrinth.Level; items = 5 + labyrinth.Level; } else { moves = 40; items = 25; } labyrinth.Generate(Context, moves, items); _scene.Observer.Position = labyrinth.LabPointToScenePoint(labyrinth.StartPos); _scene.Observer.Rotation = new GLVector(0, 180, 0); _lastTapCrossMove = null; _lastTapRotateMove = null; UpdateDisplays(); }
public GLTexture GetRandomTexture(string texName) { var texNameIndex = 0; if (Rnd.Next(0, 3) == 1) { texNameIndex = 1; } else if (Rnd.Next(0, 3) == 1) { texNameIndex = 3; } else if (Rnd.Next(0, 7) == 1) { texNameIndex = 2; } texName = texName + texNameIndex.ToString(); var tex = GLTextureAdmin.GetTextureByName(texName); return(tex); }
protected override void Dispose(bool disposing) { GLTextureAdmin.UnLoadGLTextures(); base.Dispose(disposing); }
public List <GLPolygon> GeneratePosition(double x, double y, double z, bool left, bool right, bool front, bool back, string specialTexture = null, string specialBottomTexture = null, string specialTopTexture = null) { var polygons = new List <GLPolygon>(); // bottom var bottomPolygon = new GLPolygon(); bottomPolygon.Points = new List <GLPoint>() { new GLPoint(x + TileWidth, y, z + TileWidth), new GLPoint(x + TileWidth, y, z), new GLPoint(x, y, z), new GLPoint(x, y, z + TileWidth), }; bottomPolygon.Texture = specialBottomTexture == null?GLTextureAdmin.GetTextureByName("labBottom") : GLTextureAdmin.GetTextureByName(specialBottomTexture); polygons.Add(bottomPolygon); // top var topPolygon = new GLPolygon(); topPolygon.Points = new List <GLPoint>() { new GLPoint(x, y + TileWidth, z + TileWidth), new GLPoint(x + TileWidth, y + TileWidth, z + TileWidth), new GLPoint(x + TileWidth, y + TileWidth, z), new GLPoint(x, y + TileWidth, z), }; topPolygon.Texture = specialTopTexture == null?GLTextureAdmin.GetTextureByName("labTop") : GLTextureAdmin.GetTextureByName(specialTopTexture); polygons.Add(topPolygon); if (left) { var leftPolygon = new GLPolygon(); leftPolygon.Points = new List <GLPoint>() { new GLPoint(x + TileWidth, y, z), new GLPoint(x + TileWidth, y + TileWidth, z), new GLPoint(x + TileWidth, y + TileWidth, z + TileWidth), new GLPoint(x + TileWidth, y, z + TileWidth), }; leftPolygon.Texture = specialTexture == null?GetRandomTexture("labWall") : GLTextureAdmin.GetTextureByName(specialTexture); polygons.Add(leftPolygon); } if (right) { var rightPolygon = new GLPolygon(); rightPolygon.Points = new List <GLPoint>() { new GLPoint(x, y, z), new GLPoint(x, y + TileWidth, z), new GLPoint(x, y + TileWidth, z + TileWidth), new GLPoint(x, y, z + TileWidth), }; rightPolygon.Texture = specialTexture == null?GetRandomTexture("labWall") : GLTextureAdmin.GetTextureByName(specialTexture); polygons.Add(rightPolygon); } if (front) { var frontPolygon = new GLPolygon(); frontPolygon.Points = new List <GLPoint>() { new GLPoint(x + TileWidth, y, z + TileWidth), new GLPoint(x + TileWidth, y + TileWidth, z + TileWidth), new GLPoint(x, y + TileWidth, z + TileWidth), new GLPoint(x, y, z + TileWidth) }; frontPolygon.Texture = specialTexture == null?GetRandomTexture("labWall") : GLTextureAdmin.GetTextureByName(specialTexture); polygons.Add(frontPolygon); } if (back) { var backPolygon = new GLPolygon(); backPolygon.Points = new List <GLPoint>() { new GLPoint(x + TileWidth, y, z), new GLPoint(x + TileWidth, y + TileWidth, z), new GLPoint(x, y + TileWidth, z), new GLPoint(x, y, z) }; backPolygon.Texture = specialTexture == null?GetRandomTexture("labWall") : GLTextureAdmin.GetTextureByName(specialTexture); polygons.Add(backPolygon); } foreach (var polygon in polygons) { Polygons.Add(polygon); } return(polygons); }