internal void AddToken(MapToken mapToken) { GameObject goToken = Instantiate(this.TokenPrefab, new Vector2(mapToken.x, mapToken.y), Quaternion.identity); Token token = goToken.GetComponent <Token>(); switch (mapToken.tokenType) { case TokenType.trainer: if (this.trainerStatuses.ContainsKey(mapToken.repID)) { token.SetStatusPanel(this.trainerStatuses[mapToken.repID]); } break; case TokenType.pokemon: if (this.pokemonStatuses.ContainsKey(mapToken.repID)) { token.SetStatusPanel(this.pokemonStatuses[mapToken.repID]); } break; } token.LoadToken(mapToken.tokenID, mapToken.imageID, mapToken.repID, mapToken.tokenType, mapToken.owner); this.tokens.Add(goToken); }
public void InstantiateMap() { if (this.background == null) { this.background = Instantiate(this.BackgroundPrefab, Vector3.zero, Quaternion.identity); } this.SetBackground(); foreach (GameObject token in this.tokens) { Destroy(token); } this.tokens = new List <GameObject>(); if (this.socket.Tokens != null) { foreach (int key in this.socket.Tokens.Keys) { MapToken token = this.socket.Tokens[key]; this.AddToken(token); } } }
/// トークンを動的生成する public static MapToken CreateMapToken(float x, float y, string SpriteFile, string SpriteName, string objName = "MapToken") { GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); GameObject token = DgGenerator.Instance.mapToken; GameObject obj = GameObject.Instantiate(token, new Vector3(x, 0, y), Quaternion.identity) as GameObject; obj.transform.SetParent(canvas.transform); obj.AddComponent <MapToken> (); MapToken t = obj.GetComponent <MapToken>(); // スプライト設定 t.setSprite("wall1"); // 座標を設定 t.X = x; t.Y = y; return(t); }
internal void UpdateMap(MapToken token) { GameObject goToken = this.tokens.First <GameObject>((g) => g.GetComponent <Token>().tokenID == token.tokenID); goToken.transform.position = new Vector2(token.x, token.y); }