public static void SetupPrevBar(GameEntity ent, Map.MapTypes type) { if (TpDict.ContainsKey(ent)) { return; } var bar = staticPrevBar.GetComponent <RectTransform>(); var objPos = ent.Current3Dpos; var rend = ent.GetComponent <SpriteRenderer>(); var posR = ClickManager.GetPosForChooser(objPos, rend.size, new Vector3()); var prevBar = Instantiate(bar.gameObject, objPos, bar.rotation); prevBar.transform.SetParent(ent.transform); prevBar.transform.position = new Vector3(objPos.x, posR.y + bar.rect.height, -3); var button = prevBar.transform.GetChild(0).GetComponent <Button>(); var prevChunk = ChunkConnecter.GetFromConnection(type, ent.ChunkNumber); button.onClick.AddListener(delegate { ChunkManager.ChangeChunkTo(prevChunk); }); TpDict.Add(ent, prevBar); }
public static int GetToConnection(Map.MapTypes type, int from) { if (!ConnectToDict.ContainsKey(from) || !ConnectToDict[from].ContainsKey(type)) { return(-1); } return(ConnectToDict[from][type]); }
public static void SetupNextBar(GameEntity ent, Map.MapTypes type) { Debug.LogError(TpDict.ContainsKey(ent)); if (TpDict.ContainsKey(ent)) { return; } var nextChunk = ChunkConnecter.IsConnectedToType(type, ent.ChunkNumber) ? ChunkConnecter.GetToConnection(type, ent.ChunkNumber) : Chunk.ChunkCounter; SetupNextBar(ent, nextChunk, type); }
public static void SetConnection(Map.MapTypes type, int from, int to) { if (ConnectToDict.ContainsKey(from) && ConnectToDict[from].ContainsKey(type)) { return; } if (!ConnectToDict.ContainsKey(from)) { ConnectToDict.Add(from, new Dictionary <Map.MapTypes, int>()); } ConnectToDict[from].Add(type, to); }
public static int GetFromConnection(Map.MapTypes type, int to) { foreach (var _1 in ConnectToDict) { var _2 = _1.Value; if (_2 != null && _2.ContainsKey(type) && _2[type] == to) { return(_1.Key); } } return(-1); }
public static bool IsConnectedToType(Map.MapTypes type, int from) { return(ConnectToDict.ContainsKey(from) && ConnectToDict[from].ContainsKey(type)); }