public override void ReceiveEvent(GameEvent ev) { if (ev.Name == "ShowAnimation") { Decoration dec = (ev.getParameter("Objetive") as GameObject).GetComponent <Decoration>(); GameObject animation = (GameObject)ev.getParameter("Animation"); GameObject go = (GameObject)GameObject.Instantiate(animation); Decoration animation2 = go.GetComponent <Decoration>(); animation2.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); animation2.Father = dec; animation2.adaptate(); AutoAnimator anim = go.GetComponent <AutoAnimator>(); anim.registerEvent(ev); } }
public override void ReceiveEvent(IGameEvent ev) { if (ev.Name == "ShowAnimation") { Decoration dec = (ev.getParameter("Objective") as GameObject).GetComponent <Decoration>(); GameObject animation = (GameObject)ev.getParameter("Animation"); GameObject go = (GameObject)GameObject.Instantiate(animation); Decoration animation2 = go.GetComponent <Decoration>(); animation2.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); animation2.Father = dec; animation2.adaptate(); AutoAnimator anim = go.GetComponent <AutoAnimator>(); anim.registerEvent(ev); } if (ev.Name == "show decoration animation") { Decoration dec = (ev.getParameter("objective") as GameObject).GetComponent <Decoration>(); GameObject go = GameObject.CreatePrimitive(PrimitiveType.Quad); Decoration decoration = go.AddComponent <Decoration>(); decoration.IsoDec = (IsoDecoration)ev.getParameter("animation"); decoration.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); decoration.Father = dec; decoration.Centered = true; decoration.adaptate(); decoration.SendMessage("Update"); AutoAnimator anim = go.AddComponent <AutoAnimator>(); anim.FrameSecuence = new int[8] { 0, 1, 2, 3, 4, 5, 6, 7 }; anim.FrameRate = 0.07f; anim.AutoDestroy = true; anim.Repeat = 1; anim.registerEvent(ev); } }
public override void ReceiveEvent(IGameEvent ev) { if (ev.Name == "ShowAnimation") { Decoration dec = (ev.getParameter("Objective") as GameObject).GetComponent <Decoration>(); GameObject animation = (GameObject)ev.getParameter("Animation"); GameObject go = (GameObject)GameObject.Instantiate(animation); Decoration animation2 = go.GetComponent <Decoration>(); animation2.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); animation2.Father = dec; animation2.adaptate(); AutoAnimator anim = go.GetComponent <AutoAnimator>(); anim.registerEvent(ev); } if (ev.Name == "show decoration animation") { Decoration dec = (ev.getParameter("objective") as GameObject).GetComponent <Decoration>(); GameObject go = GameObject.CreatePrimitive(PrimitiveType.Quad); Decoration decoration = go.AddComponent <Decoration>(); decoration.IsoDec = (IsoDecoration)ev.getParameter("animation"); decoration.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); decoration.Father = dec; decoration.adaptate(); AutoAnimator anim = go.AddComponent <AutoAnimator>(); anim.FrameRate = 0.1f; anim.AutoDestroy = true; anim.Repeat = 1; anim.registerEvent(ev); go.transform.Translate(new Vector3(0, 0, -0.1f)); } }
public void OnSceneGUI(SceneView scene) { HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); RaycastHit info = new RaycastHit(); GameObject selected = null; Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); if (Physics.Raycast(ray, out info /*, LayerMask.NameToLayer("Cells Layer")*/)) //TODO Arreglar esto porque al parecer la distancia no funciona correctamente { if (info.collider.transform.IsChildOf(this.map.transform)) { selected = info.collider.gameObject; } } /** * Mouse Events of painting mode */ bool decorateLater = false; if (Event.current.isMouse && Event.current.button == 0 && selected != null && Event.current.type == EventType.MouseUp) { decorateLater = true; } /** * Working zone */ if (selected != null) { Cell cs = selected.GetComponent <Cell>(); if (cs != null) { FaceNoSC f = (cs != null) ? cs.getFaceByPoint(info.point) : null; if (f != null) { Vector3 position = selected.transform.position; if (cs != null) { position.y = cs.Height; } Vector3[] vertex = f.SharedVertex; int[] indexes = f.VertexIndex; Vector3[] puntos = new Vector3[5]; for (int i = 0; i < indexes.Length; i++) { puntos[i] = cs.transform.TransformPoint(vertex[indexes[i]]); } if (indexes.Length == 3)//Triangular faces { puntos[3] = cs.transform.TransformPoint(vertex[indexes[2]]); } puntos[puntos.Length - 1] = puntos[0]; // Closes the line Handles.DrawPolyLine(puntos); Vector2 directions = new Vector2(puntos[1].x - puntos[0].x, puntos[2].y - puntos[1].y); int ang = 0; if (directions.x == 0f) { if (directions.y == 0f) { ang = 0; } else { ang = 2; } } else { ang = 1; } if (paintingIsoDecoration != null) { if (decorateLater) { GameObject tmpdec = cs.addDecoration(info.point, ang, parallelDecoration, (Event.current.shift) ? false : true, paintingIsoDecoration); if (autoanimate) { AutoAnimator tmpautoanim = tmpdec.AddComponent <AutoAnimator>() as AutoAnimator; tmpautoanim.FrameSecuence = this.FrameSecuence; tmpautoanim.FrameRate = this.FrameRate; } cs.refresh(); } else { map.ghostDecoration(cs, info.point, ang, parallelDecoration, (Event.current.shift) ? false : true, paintingIsoDecoration, 0.5f); } } } } } }