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(); } }
// 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); }
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; }