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 override void tick() { var jable = this as JSONAble; if (previousStatus == "") { previousStatus = jable.toJSONObject().ToString(); } if (this.saludmod != 0) { this.salud += this.saludmod; this.saludmod = 0; } if (this.sedmod != 0) { this.sed += this.sedmod; this.sedmod = 0; } if (this.energiamod != 0) { this.energia += this.energiamod; this.energiamod = 0; } if (this.forceuses) { Hands hands = this.GetComponent <Hands>(); List <TWItemScript> items = new List <TWItemScript>(); if (hands.leftHand != null) { items.Add(hands.leftHand); } if (hands.rightHand != null) { if (!items.Contains(hands.rightHand)) { items.Add(hands.rightHand); } } Cell pos = (Cell)this.Entity.Position; List <Cell> vecinas = new List <Cell>(pos.Map.getNeightbours(pos)); vecinas.Add(pos); TWItemScript its; foreach (Cell v in vecinas) { if (v != null) { foreach (Entity e in v.getEntities()) { its = e.GetComponent <TWItemScript>(); if (its != null) { if (!items.Contains(its)) { items.Add(its); } } } } } if (items.Count != 0) { } this.use(items.ToArray()); this.forceuses = false; } if (previousStatus != jable.toJSONObject().ToString()) { GameEvent ge = GameEvent.CreateInstance <GameEvent>(); ge.name = "update minion"; ge.setParameter("minion", this); Game.main.enqueueEvent(ge); previousStatus = jable.toJSONObject().ToString(); } if (this.uses) { IList <object> obs = (IList <object>)ge.getParameter("items"); List <ItemData> items = new List <ItemData>(); foreach (object o in obs) { items.Add((ItemData)o); } GameEvent ret = this.use(items.ToArray()); ret.setParameter("minion_id", this.gameObject.GetInstanceID()); Game.main.enqueueEvent(ret); this.uses = false; } if (this.observes) { TWItemScript [] items = GameObject.FindObjectsOfType <TWItemScript>(); Map mapa = ((Cell)this.Entity.Position).Map; Vector2 myCoords = mapa.getCoords(this.Entity.gameObject), itmCoords; List <object> itemsFloor = new List <object>(), itemsHand = new List <object>(); foreach (TWItemScript twi in items) { if (twi.Entity.Position is Cell) { itmCoords = mapa.getCoords(((Cell)twi.Entity.Position).gameObject); if ((myCoords - itmCoords).magnitude < this.visionrange) { ItemData id = ScriptableObject.CreateInstance <ItemData>(); id.setItem(twi); itemsFloor.Add(id); } } else if (twi.Entity.Position is Entity) { itmCoords = mapa.getCoords(((Cell)((Entity)twi.Entity.Position).Position).gameObject); if ((myCoords - itmCoords).magnitude < this.visionrange) { ItemData id = ScriptableObject.CreateInstance <ItemData>(); id.setItem(twi); itemsHand.Add(id); } } } GameEvent ge = ScriptableObject.CreateInstance <GameEvent>(); ge.Name = "observereport"; ge.setParameter("minion_id", this.gameObject.GetInstanceID()); ge.setParameter("items_floor", itemsFloor); ge.setParameter("items_hand", itemsHand); observes = false; Game.main.enqueueEvent(ge); } if (emote) { if (this.emotion != null) { GameObject.DestroyImmediate(this.emotion); } switch (this.emotionName) { case "think": this.emotion = GameObject.Instantiate(Resources.Load <GameObject>("EmoteThinkingPrefab")); break; case "stop thinking": this.emotion = null; break; case "idea": this.emotion = GameObject.Instantiate(Resources.Load <GameObject>("EmoteIdeaPrefab")); break; case "win": this.emotion = GameObject.Instantiate(Resources.Load <GameObject>("EmoteWinPrefab")); break; case "fail": this.emotion = GameObject.Instantiate(Resources.Load <GameObject>("EmoteFailPrefab")); break; } if (this.emotion != null) { Decoration anim = this.emotion.GetComponent <Decoration>(); anim.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); anim.Father = this.GetComponent <Decoration>(); anim.adaptate(); } emote = false; } }