public override IEnumerator TeleportRoutine(AvatarEvent avatar) { if (avatar.GetComponent <CharaEvent>().facing != dir) { yield break; } if (Global.Instance().Memory.GetSwitch("lift_" + floor)) { yield return(base.TeleportRoutine(avatar)); } else { string oldName = gameObject.name; string origName = GetComponent <MapEvent>().parent.name; mapName = "ElevatorShaft"; targetEventName = "target"; yield return(base.TeleportRoutine(avatar)); avatar.PauseInput(); yield return(CoUtils.Wait(2.0f)); yield return(CoUtils.RunParallel(new IEnumerator[] { avatar.GetComponent <MapEvent>().StepRoutine(OrthoDir.South), CoUtils.Wait(0.4f) }, Global.Instance())); targetEventName = oldName; yield return(Global.Instance().Maps.TeleportRoutine(origName, targetEventName)); avatar.UnpauseInput(); } }
void Update() { AvatarEvent avatar = Global.Instance().Maps.avatar; float z = avatar.transform.localPosition.z; float t; if (maxZ - minZ > 0.0f) { float clampZ = Mathf.Clamp(z, minZ, maxZ); t = (maxZ - clampZ) / (maxZ - minZ); } else { t = z > maxZ ? 1 : 0; } if (GetComponent <TilemapRenderer>() != null) { GetComponent <TilemapRenderer>().material.SetColor("_Color", new Color(1, 1, 1, t)); } else { GetComponent <MeshRenderer>().enabled = t > 0.5f; } }
private void Awake() { if (OnUpdated == null) { OnUpdated = new AvatarEvent(); } }
private void OnInteract(AvatarEvent avatar) { if (!IsOpen() && @event.IsSwitchEnabled) { StartCoroutine(OpenRoutine()); } }
// called when the avatar stumbles into us // facing us if impassable, on top of us if passable private void OnInteract(AvatarEvent avatar) { if (GetComponent <CharaEvent>() != null) { GetComponent <CharaEvent>().facing = DirectionTo(avatar.GetComponent <MapEvent>()); } luaObject.Run(PropertyInteract); }
private void Flip() { if (MapOverlayUI.Instance().phoneSystem.IsFlipped) { RunRoutineFromLua(MapOverlayUI.Instance().phoneSystem.FlipRoutine()); } else { RunRoutineFromLua(AvatarEvent.PhoneRoutine()); } }
private void OnInteract(AvatarEvent avatar) { if (Opened || ItemKey == null || ItemKey.Length == 0) { Opened = true; StartCoroutine(Textbox.GetInstance().ShowSystemText("Empty.")); } else { Opened = true; UpdateAppearance(); ItemData item = ItemData.ItemByName(ItemKey); StartCoroutine(Textbox.GetInstance().ShowSystemText("Found " + item.Name + ".")); } }
public virtual IEnumerator TeleportRoutine(AvatarEvent avatar) { if (avatar.GetComponent <CharaEvent>().facing != dir) { yield break; } if (!GetComponent <MapEvent>().switchEnabled) { yield break; } if (requiresGlitch && !Global.Instance().Memory.GetSwitch("glitch_on")) { Global.Instance().Audio.PlaySFX("locked"); yield break; } if (requiresLightsOff && !Global.Instance().IsLightsOutMode()) { Global.Instance().Audio.PlaySFX("locked"); yield break; } Global.Instance().Audio.PlaySFX("door"); avatar.PauseInput(); while (avatar.GetComponent <MapEvent>().tracking) { yield return(null); } yield return(animator.PlayRoutine()); yield return(CoUtils.Wait(animator.frameDuration * 2)); Vector3 targetPx = avatar.GetComponent <MapEvent>().positionPx + avatar.GetComponent <CharaEvent>().facing.Px3D(); yield return(CoUtils.RunParallel(new IEnumerator[] { avatar.GetComponent <MapEvent>().LinearStepRoutine(targetPx), avatar.GetComponent <CharaEvent>().FadeRoutine(1.0f / avatar.GetComponent <MapEvent>().tilesPerSecond * 0.75f) }, this)); yield return(CoUtils.Wait(animator.frameDuration * 2)); yield return(Global.Instance().Maps.TeleportRoutine(mapName, targetEventName)); yield return(avatar.GetComponent <MapEvent>().StepRoutine(avatar.GetComponent <CharaEvent>().facing)); avatar.UnpauseInput(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); MapCamera2D camera = (MapCamera2D)target; if (GUILayout.Button("Attach and Center")) { AvatarEvent avatar = GameObject.FindObjectOfType <AvatarEvent>(); if (avatar != null) { camera.target = avatar.GetComponent <MapEvent>(); camera.ManualUpdate(); } else { Debug.LogError("No avatar could be found in the scene"); } } }
public void RegisterAvatar(AvatarEvent avatar) { GlobalContext.Globals["avatar"] = avatar.GetComponent <MapEvent>().LuaObject; }
// called when the avatar stumbles into us // facing us if impassable, on top of us if passable private void OnInteract(AvatarEvent avatar) { LuaObject.Run(PropertyLuaInteract); }
// called when the avatar stumbles into us // before the step if impassable, after if passable private void OnCollide(AvatarEvent avatar) { LuaObject.Run(PropertyLuaCollide); }