public Player(MonoGameLibrary.Game game, GameScreen screen, int x, int y, int width, int height) : base(game, screen, Assets.GameObject.Player, x, y, width, height) { IsRigitBody = true; a = new TextureAnimator(game, this, Assets.GameObject.Dust, 300, 0.1, -150, 120, 300, 100); Animators.Add(a); }
public testObject(MonoGameLibrary.Game game, Screen screen, int x, int y, int width, int height) : base(game, screen, Assets.enemy, x, y, width, height) { TextureAnimator a = new TextureAnimator(game, this, Assets.smoke, 360, 0, 0.016); Animators.Add(a); a.Start(); }
private GameObject CreateMapObject(SECTORS sector, string name, Triangulator.GeneratingGo generating) { //create lists for combining floor and ceiling meshes List <SubMesh> sectorMeshes = new List <SubMesh>(); Material[] sectorMaterials = new Material[2]; //theres a material for the floor and the ceiling //create floor SubMesh floor = Triangulator.CreateFloor(sector, reader.newWad.flats[sector.floorFlat], generating); sectorMeshes.Add(floor); //create ceiling sectorMeshes.Add(Triangulator.CreateCeiling(floor, sector, reader.newWad.flats[sector.ceilingFlat], generating)); //set the skybox's texture //DOOM2 SPECIFIC!!!! if (mapSelected <= 11) { Texture2D newSky = (Texture2D)reader.newWad.textures["SKY1"].mainTexture; sky = newSky; skybox.GetComponent <MeshRenderer>().material.SetColor("_LowerFogColor", AverageColorTop(newSky)); skybox.GetComponent <MeshRenderer>().material.SetColor("_UpperFogColor", AverageColorBottom(newSky)); } else if (mapSelected > 11 && mapSelected <= 20) { Texture2D newSky = (Texture2D)reader.newWad.textures["SKY2"].mainTexture; sky = newSky; skybox.GetComponent <MeshRenderer>().material.SetColor("_LowerFogColor", AverageColorTop(newSky)); skybox.GetComponent <MeshRenderer>().material.SetColor("_UpperFogColor", AverageColorBottom(newSky)); } else if (mapSelected > 20 && mapSelected <= 32) { Texture2D newSky = (Texture2D)reader.newWad.textures["SKY3"].mainTexture; sky = newSky; skybox.GetComponent <MeshRenderer>().material.SetColor("_LowerFogColor", AverageColorTop(newSky)); skybox.GetComponent <MeshRenderer>().material.SetColor("_UpperFogColor", AverageColorBottom(newSky)); } //create walls sectorMeshes.AddRange(Triangulator.CreateWalls(sector, reader.newWad, generating)); //remove null submeshes sectorMeshes.RemoveAll(x => x == null); //combine the meshes Mesh mesh = new Mesh(); Triangulator.CombineAsMesh(ref mesh, sectorMeshes, ref sectorMaterials); Renderer rend; MaterialPropertyBlock propBlock = new MaterialPropertyBlock(); //Setup GameObject GameObject go = new GameObject(); go.AddComponent <MeshFilter>(); go.AddComponent <MeshRenderer>(); go.name = name; go.transform.parent = sectorParent; //Set up some variables rend = go.GetComponent <Renderer>(); //Set the color for the material independently (for setting light level) propBlock.SetColor("_Color", new Color(sector.lightLevel / 255f, sector.lightLevel / 255f, sector.lightLevel / 255f, 1)); rend.SetPropertyBlock(propBlock); //fill in the materials and mesh for the gameobject go.GetComponent <MeshRenderer>().materials = sectorMaterials; go.GetComponent <MeshFilter>().mesh = mesh; go.AddComponent <MeshCollider>(); foreach (Material mat in go.GetComponent <MeshRenderer>().materials) { foreach (string str in AnimatedTextures.Keys) { if (AnimatedTextures[str].Contains(mat.mainTexture.name) && go.GetComponent <TextureAnimator>() == null) { TextureAnimator texAnim = go.AddComponent <TextureAnimator>(); texAnim.wad = reader.newWad; break; } } } go.tag = "Map"; return(go); }