public IEnumerator OnVisibleRoutine(PCEvent pc) { while (IsAnimating()) { yield return(null); } BattleEvent ev = GetComponent <BattleEvent>(); if (ev != null) { BattleUnit unit = ev.unit; var ui = FindObjectOfType <RogueUI>(); yield return(ui.PrepareTalkRoutine(unit)); ui.face2.Populate(unit); pc.GetComponent <CharaEvent>().FaceToward(unit.battler.GetComponent <MapEvent>()); unit.battler.GetComponent <CharaEvent>().FaceToward(pc.GetComponent <MapEvent>()); LuaScript script = new LuaScript(ui.GetComponent <LuaContext>(), luaVisible); ui.GetComponent <LuaContext>().SetGlobal("name", unit.ToString()); ui.rightDisplayEnabled = true; yield return(script.RunRoutine()); ui.rightDisplayEnabled = false; } else { yield return(luaObject.RunRoutine(PropertyVisible)); } }
public IEnumerator OpenRoutine(PCEvent pc) { while (pc.GetComponent <MapEvent>().IsAnimating()) { yield return(null); } pc.GetComponent <BattleEvent>().unit.battle.Log(pc.unit + " found a chest...", true); pc.GetComponent <BattleEvent>().AnimateBump(); yield return(CoUtils.RunSequence(new IEnumerator[] { pc.GetComponent <BattleEvent>().FinishAnims(), doll.PlayOnceRoutine(), OnOpenRoutine(pc), })); }
// called when the avatar stumbles into us // facing us if impassable, on top of us if passable public IEnumerator InteractRoutine(PCEvent pc) { if (GetComponent <CharaEvent>() != null) { GetComponent <CharaEvent>().facing = DirectionTo(pc.GetComponent <MapEvent>()); } yield return(luaObject.RunRoutine(PropertyInteract)); }
// called when the pc stumbles into us // before the step if impassable, after if passable public IEnumerator CollideRoutine(PCEvent pc) { while (pc.GetComponent <MapEvent>().IsAnimating()) { yield return(null); } yield return(luaObject.RunRoutine(PropertyCollide)); }
// === OUR ROUTINES ============================================================================ private IEnumerator WalkRoutine(DynValue path) { PCEvent pc = Global.Instance().Maps.pc; foreach (DynValue dynDir in path.Tuple) { EightDir dir; if (dynDir.String.Equals("forward")) { dir = pc.GetComponent <CharaEvent>().facing; } else { dir = EightDirExtensions.Parse(dynDir.String); } yield return(pc.GetComponent <MapEvent>().StepRoutine( pc.GetComponent <MapEvent>().location, pc.GetComponent <MapEvent>().location + dir.XY())); } }
public IEnumerator OnOpenRoutine(PCEvent pc) { if (!pc.GetComponent <BattleEvent>().unit.IsDead()) { string qty1 = (quantity > 1) ? "" : "a "; string qty2 = (quantity > 1) ? (" x" + quantity) : ""; pc.GetComponent <BattleEvent>().unit.battle.Log("It contained " + qty1 + contents.ItemName() + qty2 + "!", false); pc.PickUpItem(contents, quantity); } pc.GetComponent <CharaEvent>().facing = EightDir.S; pc.GetComponent <CharaEvent>().armMode = ArmMode.Overhead; SpriteRenderer sprite = pc.pickup; sprite.sprite = contents.sprite; yield return(CoUtils.Wait(0.8f)); sprite.sprite = null; pc.GetComponent <CharaEvent>().armMode = ArmMode.Disabled; opened = true; yield return(null); }
public void RecalculateVisibilityMap() { Profiler.BeginSample("los"); mesh = GetComponent <TacticsTerrainMesh>(); if (seenMap == null) { seenMap = new bool[mesh.size.x, mesh.size.y]; for (int y = 0; y < mesh.size.y; y += 1) { for (int x = 0; x < mesh.size.x; x += 1) { seenMap[x, y] = false; } } if (Application.isPlaying) { pc = Global.Instance().Maps.pc; } if (pc == null) { pc = FindObjectOfType <PCEvent>(); } } if (oldLosTexture != null) { Destroy(oldLosTexture); } oldLosTexture = losTexture; oldHeroPos = heroPos; losTexture = new Texture2D(mesh.size.x, mesh.size.y, TextureFormat.ARGB32, false); losTexture.filterMode = FilterMode.Point; losTexture.wrapMode = TextureWrapMode.Clamp; heroPos = pc.GetComponent <MapEvent3D>().TileToWorldCoords(pc.GetComponent <MapEvent>().location); heroPos += new Vector3(0.5f, 1.5f, 0.5f); map = new Color[mesh.size.x * mesh.size.y]; BattleEvent battler = pc.GetComponent <BattleEvent>(); Vector2Int v = new Vector2Int(); for (int y = 0; y < mesh.size.y; y += 1) { for (int x = 0; x < mesh.size.x; x += 1) { float r = 1.0f; float b = 1.0f; v.x = x; v.y = y; if (battler.CanSeeLocation(mesh, v)) { seenMap[x, y] = true; } else { r = 0.0f; b = seenMap[x, y] ? 1.0f : 0.0f; } map[y * mesh.size.x + x] = new Color(r, 0.0f, b); } } losTexture.SetPixels(0, 0, mesh.size.x, mesh.size.y, map); losTexture.Apply(); foreach (PCVisibility vis in GetComponent <Map>().GetEvents <PCVisibility>()) { Vector2Int location = vis.GetComponent <MapEvent>().location; vis.SetVisibleByPC(CachedIsVisible(location)); } Profiler.EndSample(); }