public Mesh GenMesh(ArtObject ao) { Mesh mesh = GenMesh(ao.Geometry); mesh.name = ao.Name; return(mesh); }
public static Mesh ArtObjectToMesh(ArtObject ao) { Mesh m = new Mesh(); Vector3[] vertices = new Vector3[ao.Geometry.Vertices.Length]; int[] triangles = new int[ao.Geometry.Indices.Length]; Vector2[] uv = new Vector2[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { vertices[i] = ao.Geometry.Vertices[i].Position; uv[i] = ao.Geometry.Vertices[i].TextureCoordinate; } for (int i = 0; i < triangles.Length; i += 3) { triangles[i] = ao.Geometry.Indices[i + 2]; triangles[i + 1] = ao.Geometry.Indices[i + 1]; triangles[i + 2] = ao.Geometry.Indices[i]; } m.vertices = vertices; m.triangles = triangles; m.uv = uv; m.RecalculateNormals(); m.Optimize(); return(m); }
// Update is called once per frame void Update() { GalleryWanderer gw = GetComponent <GalleryWanderer> (); if (gw.IsMoving() || gw.observing == null || observed == gw.observing) { return; } if (!observing) { observing = true; observationTime = Random.Range(minObservationTime, maxObservationTime); } if (GetComponent <GalleryVisitor> ().CanTalk() && FindObjectOfType <Challenge> () == null) { observationTime -= Time.deltaTime; if (observationTime <= 0) { gw.WaitUntilMove(postObservationWait); observed = gw.observing; List <ArtProperties> ps = (opinions[observed] ? observed.goodProperties : observed.badProperties); ArtProperties commentProperty = ps[Random.Range(0, ps.Count)]; if (preventRepeats) { commentProperty = ps[(ps.IndexOf(observed.lastPropertyStated) + 1) % ps.Count]; } Statement st = GetComponent <StatementMaker> ().State(commentProperty, observed, opinions[observed]); gw.WaitUntilMove(st.lifespan); } } }
public void Init(ArtProperties property, GalleryVisitor emitter, ArtObject topic, bool opinion) { this.property = property; this.emitter = emitter; this.topic = topic; this.opinion = opinion; transform.position = emitter.transform.position + offset; text = "Hmm..."; textmesh = this.gameObject.GetComponentInChildren <TextMesh> (); textmesh.text = "Hmm..."; transform.localScale = new Vector3(0.0f, 0.0f, 1.0f); repeat = topic.lastPropertyStated == property; topic.lastPropertyStated = property; foreach (Challenge ch in FindObjectsOfType <Challenge> ()) { if (ch.victim == emitter && ch.topic == topic) { Destroy(ch.gameObject); } } if (opinion) { emitter.GetComponent <Speaker> ().playGood(); } else { emitter.GetComponent <Speaker> ().playBad(); } textmesh.gameObject.renderer.sortingLayerID = 3; }
void OnGUI() { GUI.skin = style; oldMatrix = GUI.matrix; GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, GeneralRessources.Scale); if (GUI.Button(buttonPosition, content, style.customStyles [0])) { drunkenness += 0.1f; // Kill all challenges foreach (Challenge ch in FindObjectsOfType <Challenge> ()) { ArtObject ao = GalleryVisitor.GetClosestArtwork(transform.position); if (ch.victim == gameObject.GetComponent <GalleryVisitor> () && ch.topic == ao) { Destroy(ch.gameObject); } } // Go to another place if (drink != null) { GetComponent <AudioSource> ().PlayOneShot(drink); } GetComponentInChildren <Animator> ().SetTrigger("pDrink"); GetComponent <ParticleSystem> ().Play(); StartCoroutine(Teleport()); } GUI.matrix = oldMatrix; }
// Update is called once per frame void Update() { timeUntilMove -= Time.deltaTime; timeUntilNotMoving -= Time.deltaTime; if (CanMove()) { ArtObject target = FindNextTarget(); if (target != null) { int[] freeTile = FindFreeAdjacentTile(target.GetComponent <OnGrid> ()); if (freeTile != null) { //Debug.Log("Moving to " + freeTile[0] + " / " + freeTile[1] + " = " + GetComponent<OnGrid>().V3Position(gridTargetX, gridTargetY)); gridTargetX = freeTile [0]; gridTargetY = freeTile [1]; observing = target; if (!visited.Contains(target)) { visited.Add(target); } iTween.MoveTo(this.gameObject, GetComponent <OnGrid> ().V3Position(gridTargetX, gridTargetY), moveTime); timeUntilNotMoving = moveTime; WaitUntilMove(moveTime + Random.Range(minObserveTime, maxObserveTime)); } } } }
public void LoadArtObject(string name) { Debug.Log("Load"); string path = OutputPath.OutputPathDir + "art objects/" + name.ToLower() + ".xnb"; ArtObject aoL = FmbUtil.ReadObject <ArtObject>(path); if (aoCache.ContainsKey(aoL.Name)) { return; } else { aoCache.Add(aoL.Name, aoL); } Debug.Log("Cached"); if (!aoMeshCache.ContainsKey(aoL)) { aoMeshCache.Add(aoL, FezToUnity.ArtObjectToMesh(aoL)); } ListAOUnderUI(); Debug.Log("Displayed"); }
//-------Art Objects------- public static void LoadAO(string toLoad) { if (IsAOLoaded(toLoad)) { return; } string filePathXNB = OutputPath.OutputPathDir + "art objects/" + toLoad + ".xnb"; if (!File.Exists(filePathXNB)) { Debug.LogError("No model!"); return; } //---AO loader--- ArtObject loaded = (ArtObject)FmbUtil.ReadObject(filePathXNB); loaded.Cubemap.filterMode = FilterMode.Point; /*/---Image loader--- * Texture2D texture = new Texture2D(1, 1); * byte[] image = File.ReadAllBytes(texturePath); * * texture.LoadImage(image); * texture.filterMode=FilterMode.Point; * * //Assign texture to set * //TODO, add materials somehow so we don't always need new ones * loaded.Cubemap=texture;*/ loadedArtObjects.Add(toLoad, loaded); }
public void LoadAOMeshes() { foreach (ArtObjectInstance ao in loaded.ArtObjects.Values) { ArtObject aoL = aoCache[ao.Id]; aoMeshCache.Add(aoL, FezToUnity.ArtObjectToMesh(aoL)); } }
public static Mesh GetUnityMesh(this ArtObject ao) { Mesh mesh; if (!FezManager.Instance.ArtObjectMeshes.TryGetValue(ao.Name, out mesh)) { FezManager.Instance.ArtObjectMeshes[ao.Name] = mesh = FezManager.Instance.GenMesh(ao); } return(mesh); }
public Statement State(ArtProperties property, ArtObject topic, bool opinion) { GameObject bubble = (GameObject)Instantiate(statementPrefab); bubble.GetComponent <Statement> ().Init(property, GetComponent <GalleryVisitor> (), topic, opinion); Statement s = bubble.GetComponent <Statement> (); OnStatementMade(new StatementEventArgs(s)); return(s); }
public void LoadUsedArtObjects() { foreach (KeyValuePair <int, ArtObjectInstance> ao in loaded.ArtObjects) { string path = OutputPath.OutputPathDir + "art objects/" + ao.Value.ArtObjectName.ToLower() + ".xnb"; ArtObject aoL = FmbUtil.ReadObject <ArtObject>(path); aoCache.Add(ao.Key, aoL); } }
public void ChangeAOKeyTo(string prev, string curr) { if (!aoCache.ContainsKey(prev) && !aoCache.ContainsKey(curr)) { return; } ArtObject reference = aoCache[prev]; aoCache.Remove(prev); aoCache.Add(curr, reference); }
public void LoadAOMeshes() { foreach (ArtObjectInstance ao in loaded.ArtObjects.Values) { ArtObject aoL = aoCache[ao.ArtObjectName]; if (aoMeshCache.ContainsKey(aoL)) { continue; } aoMeshCache.Add(aoL, FezToUnity.ArtObjectToMesh(aoL)); } }
public static ArtObject GetClosestArtwork(Vector3 position) { ArtObject result = artworks [0]; float smallestDistance = float.PositiveInfinity; foreach (var item in artworks) { float tempDistance = Vector3.Distance(position, item.transform.position); if (tempDistance <= smallestDistance) { smallestDistance = tempDistance; result = item; } } return(result); }
public void GenerateAO(Vector3 pos, string name) { if (!aoCache.ContainsKey(name)) { return; } ArtObject ao = aoCache[name]; ArtObjectInstance newImport = new ArtObjectInstance(); newImport.ArtObjectName = name; newImport.Position = pos; newImport.Scale = Vector3.one; GameObject newTrile; if (aoObjectCache.Count > 0) { newTrile = aoObjectCache[0]; aoObjectCache.RemoveAt(0); newTrile.SetActive(true); } else { newTrile = Instantiate(aoPrefab); } MeshFilter mf = newTrile.GetComponent <MeshFilter>(); MeshRenderer mr = newTrile.GetComponent <MeshRenderer>(); MeshCollider mc = newTrile.GetComponent <MeshCollider>(); ArtObjectImported aoI = newTrile.GetComponent <ArtObjectImported>(); aoI.myInstance = newImport; mr.material = FezToUnity.GeometryToMaterial(aoCache[name].Cubemap); mf.mesh = aoMeshCache[aoCache[name]]; mc.sharedMesh = aoMeshCache[aoCache[name]]; newTrile.transform.position = pos; newTrile.transform.rotation = newImport.Rotation; newTrile.name = name; newTrile.transform.parent = transform.FindChild("ArtObjects"); }
private async Task AddProcess(Request request) { var objectId = Guid.NewGuid(); var newObject = new ArtObject { CreationDate = request.ArtObjectCreationDate, Description = request.ArtObjectDescription, Id = objectId, Latitude = request.ArtObjectLatitude.Value, Longitude = request.ArtObjectLongitude.Value, Name = request.ArtObjectName, TypeKey = (int)request.ArtObjectType, }; var photoRequests = request.PhotoRequest?.ToList() ?? new List <PhotoRequest>(); var photos = new List <Photo>(); for (var index = 0; index < photoRequests.Count; index++) { var photo = new Photo { Id = Guid.NewGuid(), ArtObjectId = objectId, Index = index, PhotoPath = photoRequests[index].PhotoPath }; photos.Add(photo); } try { await context.ArtObject.AddAsync(newObject); await context.Photo.AddRangeAsync(photos); await context.SaveChangesAsync(); } catch { throw new Exception(ArtMapConstants.DbWriteError); } }
// Update is called once per frame void Update() { if (!GetComponent <GalleryVisitor> ().CanTalk() || FindObjectOfType <Challenge> () != null) { return; } GalleryWanderer gw = GetComponent <GalleryWanderer> (); GalleryVisitor gv = GetComponent <GalleryVisitor> (); if (gw.IsMoving()) { return; } GalleryVisitor pgv = GameObject.FindWithTag("Player").GetComponent <GalleryVisitor> (); if (gv.reputation > pgv.reputation + maxMoreReputation) { return; } if (Random.Range(0.0f, 1.0f) > Time.deltaTime * askChancePerSecond) { return; } if ((transform.position - pgv.transform.position).sqrMagnitude <= maxPlayerDist * maxPlayerDist) { ArtObject ao = nearbyArt(pgv); if (ao != null) { GetComponent <Speaker> ().playAsk(); GameObject cho = (GameObject)Instantiate(challengePrefab); cho.GetComponent <Challenge>().Init(ao, pgv); cho.transform.position = transform.position; gw.WaitUntilMove(cho.GetComponent <Challenge>().remainingTime); } } }
private async Task DeleteProcess(Request request) { ArtObject artObject = await context.ArtObject .Include(a => a.Photo) .FirstOrDefaultAsync(x => x.Id == request.ArtObjectId); if (artObject == null) { throw new Exception(ArtMapConstants.EmptyRequest); } try { context.Photo.RemoveRange(artObject.Photo); context.ArtObject.Remove(artObject); await context.SaveChangesAsync(); } catch { throw new Exception(ArtMapConstants.DbWriteError); } }
ArtObject FindNextTarget() { ArtObject[] objs = FindObjectsOfType <ArtObject> (); List <ArtObject> candidates = new List <ArtObject> (); for (int i = 0; i < objs.Length; i++) { ArtObject o = objs [i]; if (!visited.Contains(o)) { candidates.Add(o); } } if (candidates.Count > 0) { return(candidates [Random.Range(0, candidates.Count)]); } else { return(objs [Random.Range(0, objs.Length)]); } }
public ArtObjectMaterializer(ArtObject artObject) { this.artObject = artObject; ServiceHelper.InjectServices((object)this); artObject.Materializer = this; this.size = artObject.Size; if (artObject.MissingTrixels == null) { return; } this.added = new HashSet <TrixelFace>(); this.removed = new HashSet <TrixelFace>(); this.missingTrixels = artObject.MissingTrixels; if (artObject.TrixelSurfaces == null) { artObject.TrixelSurfaces = this.surfaces = new List <TrixelSurface>(); } else { this.surfaces = artObject.TrixelSurfaces; } }
private static void Print(object obj) { Console.WriteLine("Asset type: " + obj.GetType().FullName); if (obj is TrileSet) { TrileSet ts = (TrileSet)obj; Console.WriteLine("TrileSet name: " + ts.Name); Console.WriteLine("Trile count: " + ts.Triles.Count); foreach (Trile trile in ts.Triles.Values) { Console.WriteLine(trile.Id + " Name: " + trile.Name); Console.WriteLine(trile.Id + " SurfaceType: " + trile.SurfaceType); } } if (obj is ArtObject) { ArtObject ao = (ArtObject)obj; Console.WriteLine("ArtObject name: " + ao.Name); Console.WriteLine("ActorType: " + ao.ActorType); } if (obj is Sky) { Sky sky = (Sky)obj; Console.WriteLine("Sky name: " + sky.Name); Console.WriteLine("Background: " + sky.Background); Console.WriteLine("Stars: " + sky.Stars); Console.WriteLine("Layer count: " + sky.Layers.Count); for (int i = 0; i < sky.Layers.Count; i++) { Console.WriteLine(i + ": " + sky.Layers[i].Name); } } }
void OnGUI() { if (!GetComponent <GalleryVisitor> ().CanTalk()) { return; } GUI.skin = skin; // Setup GUI scaling oldMatrix = GUI.matrix; GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, GeneralRessources.Scale); //Show list GUILayout.BeginArea(positionOfList); GUILayout.BeginScrollView(scrollViewPosition); foreach (Statement item in inventory) { if (GUILayout.Button(item.text)) { ArtObject talkedAboutArtwork = gv.GetClosestArtwork(); Statement st = item; if (GetComponent <Champagne> ().doNonsense()) { st = inventory[Random.Range(0, inventory.Count)]; GetComponent <ParticleSystem> ().Play(); } GetComponent <StatementMaker> ().State(st.property, talkedAboutArtwork, st.opinion); } } GUILayout.EndScrollView(); GUILayout.EndArea(); // Reset GUI scaling GUI.matrix = oldMatrix; }
private void TryInitialize() { this.Destroy(); this.Visible = this.Enabled = this.LevelManager.Name == "HEX_REBUILD"; if (!this.Enabled) { return; } this.GameState.HideHUD = true; this.CameraManager.ChangeViewpoint(Viewpoint.Right, 0.0f); this.PlayerManager.Background = false; ArtObject artObject = this.CMProvider.CurrentLevel.Load <ArtObject>("Art Objects/NEW_HEXAO"); int key = IdentifierPool.FirstAvailable <ArtObjectInstance>(this.LevelManager.ArtObjects); this.HexahedronAo = new ArtObjectInstance(artObject) { Id = key }; this.LevelManager.ArtObjects.Add(key, this.HexahedronAo); this.HexahedronAo.Initialize(); this.HexahedronAo.Hidden = true; this.WhiteCube = new Mesh() { Effect = (BaseEffect) new DefaultEffect.VertexColored(), Blending = new BlendingMode?(BlendingMode.Additive), DepthWrites = false }; this.WhiteCube.Rotation = this.CameraManager.Rotation * Quaternion.CreateFromRotationMatrix(Matrix.CreateLookAt(Vector3.One, Vector3.Zero, Vector3.Up)); this.WhiteCube.AddColoredBox(new Vector3(4f), Vector3.Zero, Color.White, true); FinalRebuildHost finalRebuildHost = this; Mesh mesh1 = new Mesh(); Mesh mesh2 = mesh1; DefaultEffect.LitTextured litTextured1 = new DefaultEffect.LitTextured(); litTextured1.Specular = true; litTextured1.Emissive = 0.5f; litTextured1.AlphaIsEmissive = true; DefaultEffect.LitTextured litTextured2 = litTextured1; mesh2.Effect = (BaseEffect)litTextured2; mesh1.Blending = new BlendingMode?(BlendingMode.Opaque); Mesh mesh3 = mesh1; finalRebuildHost.SolidCubes = mesh3; this.OriginalCubeRotation = this.SolidCubes.Rotation = this.WhiteCube.Rotation; ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> geometry1 = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.CubeShard)).Geometry; ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> geometry2 = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)).Geometry; this.sHexAppear = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/HexAppear"); this.sCubeAppear = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/CubeAppear"); this.sMotorSpin1 = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/MotorStart1"); this.sMotorSpin2 = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/MotorStart2"); this.sMotorSpinAOK = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/MotorStartAOK"); this.sMotorSpinCrash = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/MotorStartCrash"); this.sRayWhiteout = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/RayWhiteout"); this.sAku = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/Aku"); this.sZoomIn = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/ZoomIn"); this.sAmbientDrone = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/AmbientDrone"); for (int index = 0; index < Math.Min(this.GameState.SaveData.CubeShards + this.GameState.SaveData.SecretCubes, 64); ++index) { Vector3 vector3 = this.CubeOffsets[index]; ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> indexedPrimitives = index < this.GameState.SaveData.CubeShards ? geometry1 : geometry2; Group group = this.SolidCubes.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionNormalTextureInstance>(Enumerable.ToArray <VertexPositionNormalTextureInstance>((IEnumerable <VertexPositionNormalTextureInstance>)indexedPrimitives.Vertices), indexedPrimitives.Indices, indexedPrimitives.PrimitiveType); group.Position = vector3; group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float)RandomHelper.Random.Next(0, 4) * 1.570796f); group.Enabled = false; group.Material = new Material(); } this.SolidCubes.Texture = this.LevelMaterializer.TrilesMesh.Texture; this.InvertEffect = new InvertEffect(); this.RaysMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.VertexColored(), Blending = new BlendingMode?(BlendingMode.Additive), DepthWrites = false }; this.FlareMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.Textured(), Texture = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/flare_alpha")), Blending = new BlendingMode?(BlendingMode.Alphablending), SamplerState = SamplerState.AnisotropicClamp, DepthWrites = false, AlwaysOnTop = true }; this.FlareMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, true); this.RtHandle = this.TargetRenderer.TakeTarget(); this.TargetRenderer.ScheduleHook(this.DrawOrder, this.RtHandle.Target); ServiceHelper.AddComponent((IGameComponent)(this.Glitches = new NesGlitches(this.Game))); }
public async Task Update(ArtObject artObject) { await this.service.Update(artObject); }
private async Task EditProcess(Request request) { ArtObject artObject = await context.ArtObject .Include(a => a.Photo) .FirstOrDefaultAsync(x => x.Id == request.ArtObjectId); if (artObject == null) { throw new Exception(ArtMapConstants.EmptyRequest); } artObject.Name = request.ArtObjectName ?? artObject.Name; artObject.Description = request.ArtObjectDescription ?? artObject.Description; artObject.Latitude = request.ArtObjectLatitude ?? artObject.Latitude; artObject.Longitude = request.ArtObjectLongitude ?? artObject.Longitude; artObject.TypeKey = request.ArtObjectType ?? artObject.TypeKey; var photoRequests = request.PhotoRequest.ToList(); var lastIndex = 0.0; if (artObject.Photo.Any()) { lastIndex = artObject.Photo .Select(p => p.Index) .Max(); } var addPhotos = new List <Photo>(); var delPhotos = new List <Photo>(); foreach (var photoRequest in photoRequests) { switch (photoRequest.PhotoRequestType) { case (int)PhotoRequestType.AddPhoto: var addPhoto = new Photo { Id = Guid.NewGuid(), ArtObjectId = artObject.Id, Index = lastIndex, PhotoPath = photoRequest.PhotoPath }; addPhotos.Add(addPhoto); lastIndex++; break; case (int)PhotoRequestType.DeletePhoto: var delPhoto = artObject.Photo .FirstOrDefault(p => p.Id == photoRequest.PhotoId); delPhotos.Add(delPhoto); break; default: throw new ArgumentOutOfRangeException(); } } await context.Photo.AddRangeAsync(addPhotos); context.Photo.RemoveRange(delPhotos); context.ArtObject.Update(artObject); await context.SaveChangesAsync(); }
public async Task Add(ArtObject artObject) { await this.service.Add(artObject); }
public void SetToAO(string aoID) { isTrile = false; ao = LevelManager.Instance.GetAO(aoID); UpdateFields(); }
public void Init(ArtObject topic, GalleryVisitor victim) { this.topic = topic; this.victim = victim; }