private void Walk(DynValue eventLua, DynValue steps, DynValue directionLua, DynValue waitLua) { if (eventLua.Type == DataType.String) { var @event = Global.Instance().Maps.ActiveMap.GetEventNamed(eventLua.String); if (@event == null) { Debug.LogError("Couldn't find event " + eventLua.String); } else { var routine = @event.StepMultiRoutine(OrthoDirExtensions.Parse(directionLua.String), (int)steps.Number); if (!waitLua.IsNil() && waitLua.Boolean) { RunRoutineFromLua(routine); } else { @event.StartCoroutine(routine); } } } else { var function = eventLua.Table.Get("walk"); function.Function.Call(steps, directionLua, waitLua); } }
public void Populate(IDictionary <string, string> properties) { if (properties.ContainsKey(PropertyFacing)) { initialFacing = OrthoDirExtensions.Parse(properties[PropertyFacing]); facing = initialFacing; } if (properties.ContainsKey(PropertySprite)) { if (GetComponent <MapEvent3D>() != null) { doll = new GameObject("Doll"); doll.transform.parent = gameObject.transform; doll.transform.localPosition = new Vector3(0.5f, 0.0f, -0.5f); animator = doll.AddComponent <CharaAnimator>(); animator.parentEvent = GetComponent <MapEvent>(); } else { animator = gameObject.AddComponent <CharaAnimator>(); } animator.SetSpriteByKey(properties[PropertySprite]); animator.Populate(properties); } GetComponent <MapEvent>().Passable = false; }
private void TargetTeleport(DynValue mapName, DynValue targetEventName, DynValue facingLua, DynValue rawLua) { OrthoDir?facing = null; if (!facingLua.IsNil()) { facing = OrthoDirExtensions.Parse(facingLua.String); } var raw = rawLua.IsNil() ? false : rawLua.Boolean; RunRoutineFromLua(Global.Instance().Maps.TeleportRoutine(mapName.String, targetEventName.String, facing, raw)); }
private void Face(DynValue eventName, DynValue dir) { var @event = Global.Instance().Maps.ActiveMap.GetEventNamed(eventName.String); if (@event == null) { Debug.LogError("Couldn't find event " + eventName.String); } else { @event.GetComponent <CharaEvent>().Facing = OrthoDirExtensions.Parse(dir.String); } }
private void Teleport(DynValue mapName, DynValue x, DynValue y, DynValue facingLua, DynValue rawLua) { OrthoDir?facing = null; if (!facingLua.IsNil()) { facing = OrthoDirExtensions.Parse(facingLua.String); } var loc = new Vector2Int((int)x.Number, (int)y.Number); var raw = rawLua.IsNil() ? false : rawLua.Boolean; RunRoutineFromLua(Global.Instance().Maps.TeleportRoutine(mapName.String, loc, facing, raw)); }
public void Populate(IDictionary <string, string> properties) { if (properties.ContainsKey(PropertyFacing)) { InitialFacing = OrthoDirExtensions.Parse(properties[PropertyFacing]); Facing = InitialFacing; } if (properties.ContainsKey(PropertySprite)) { gameObject.AddComponent <CharaAnimator>().Populate(properties[PropertySprite]); } GetComponent <MapEvent>().Passable = false; }
// all meant to be called by proxy public void face(string directionName) { mapEvent.GetComponent <CharaEvent>().Facing = OrthoDirExtensions.Parse(directionName); }
public void cs_step(string directionName) { Global.Instance().Lua.RunRoutineFromLua(mapEvent.GetComponent <CharaEvent>().StepRoutine(OrthoDirExtensions.Parse(directionName))); }
public void cs_walk(string directionName, int count) { Global.Instance().Lua.RunRoutineFromLua(mapEvent.GetComponent <CharaEvent>().StepMultiRoutine(OrthoDirExtensions.Parse(directionName), count)); }
public void cs_step(string directionName) { context.RunRoutineFromLua(mapEvent.GetComponent <MapEvent>().StepRoutine(OrthoDirExtensions.Parse(directionName))); }
public void cs_walk(string directionName, int count) { context.RunRoutineFromLua(mapEvent.GetComponent <MapEvent>().StepMultiRoutine(OrthoDirExtensions.Parse(directionName), count)); }
public override void TmxAssetImported(TmxAssetImportedArgs args) { var map = args.ImportedSuperMap; var tsxMap = map.gameObject.AddComponent <TsxMap>(); tsxMap.grid = map.gameObject.GetComponentInChildren <Grid>(); var objectLayer = map.gameObject.GetComponentInChildren <SuperObjectLayer>(); if (objectLayer == null) { return; } tsxMap.objectLayer = objectLayer.gameObject.AddComponent <ObjectLayer>(); //foreach (var layer in tsxMap.layers) { // layer.GetComponent<TilemapRenderer>().material = materials.BackgroundMaterial; //} foreach (Transform child in objectLayer.transform) { if (child.GetComponent <SuperObject>() != null) { var tmxObject = child.GetComponent <SuperObject>(); child.gameObject.AddComponent <MapEvent2D>(); var mapEvent = child.gameObject.GetComponent <MapEvent2D>(); mapEvent.Size = new Vector2Int((int)tmxObject.m_Width / Map.PxPerTile, (int)tmxObject.m_Height / Map.PxPerTile); mapEvent.Properties = tmxObject.GetComponent <SuperCustomProperties>(); mapEvent.Position = new Vector2Int((int)tmxObject.m_X / Map.PxPerTile, (int)tmxObject.m_Y / Map.PxPerTile); var appearance = mapEvent.GetProperty(MapEvent.PropertyAppearance); if (appearance != null && appearance.Length > 0) { CharaEvent chara; Doll doll; if (mapEvent.GetComponent <FieldSpritesheetComponent>() == null) { mapEvent.gameObject.AddComponent <FieldSpritesheetComponent>(); } if (mapEvent.GetComponent <CharaEvent>() == null) { chara = mapEvent.gameObject.AddComponent <CharaEvent>(); var dollObject = (GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath <GameObject>(DollPrefabPath)); doll = dollObject.GetComponent <Doll>(); // doll.Renderer.material = materials.ForegroundMaterial; doll.transform.SetParent(mapEvent.transform); chara.Doll = doll; } else { chara = mapEvent.GetComponent <CharaEvent>(); doll = chara.Doll; } doll.transform.localPosition = Vector3.zero; if (IndexDatabase.Instance().FieldSprites.GetDataOrNull(appearance) != null) { // it's a literal chara.SetAppearanceByTag(appearance); } else { // this should be okay... it's a lua string } var facing = mapEvent.GetProperty("face"); if (facing != null && facing.Length > 0) { chara.Facing = OrthoDirExtensions.Parse(facing); } } } } }
public void cs_step(string directionName) { var context = Global.Instance().Maps.Lua; context.RunRoutineFromLua(mapEvent.StepRoutine(OrthoDirExtensions.Parse(directionName))); }
public void walk(string directionName, int count) { var context = Global.Instance().Maps.Lua; context.RunRoutineFromLua(mapEvent.StepMultiRoutine(OrthoDirExtensions.Parse(directionName), count)); }
private void Ladder(DynValue countLua, DynValue dirLua) { OrthoDir dir = OrthoDirExtensions.Parse(dirLua.String); RunRoutineFromLua(Global.Instance().Maps.Avatar.Event.LadderRoutine((int)countLua.Number, dir)); }
private void Diag(DynValue dirLua) { OrthoDir dir = OrthoDirExtensions.Parse(dirLua.String); RunRoutineFromLua(Global.Instance().Maps.Avatar.Event.DiagRoutine(dir)); }