public void walkExternalPlayer(int currentX, int currentY, BasePlayer player, int dir, bool animated) { if (animated) { player.GetObject().transform.localEulerAngles = new Vector3(0, directionToRotation(dir), 0); //player.GetObject().transform.position = new Vector3(player.GetObject().transform.position.x, GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).height_ * 0.1339f, player.GetObject().transform.position.z); player.GetObject().transform.position = new Vector3(player.GetObject().transform.position.x, GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(player.GetCurrentVec().x, player.GetCurrentVec().y).height_ *LevelManager.TILE_SCALE * 0.447f, player.GetObject().transform.position.z); } //print("walk external :" + player.GetName() + " local x :" + currentX + " local y :" + currentY); //List<VRAR_Tile> list = GameStateManager.getInstance().getCurrentLevel().selectRadius(localPlayer.GetCurrentVec().x, localPlayer.GetCurrentVec().y, localPlayer.GetSight()); List <VRAR_Tile> list = GameStateManager.getInstance().getCurrentLevel().selectRadius(currentX, currentY, localPlayer.GetSight()); VRAR_Tile tileFromIndexPos = GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(player.GetCurrentVec().x, player.GetCurrentVec().y); if (list.Contains(tileFromIndexPos)) { //Debug.Log("EXTERNAL we can see the other player"); player.GetObject().GetComponentInChildren <SkinnedMeshRenderer>().enabled = true; //float y = tileFromIndexPos.hexObject.lossyScale.y * 0.447f - player.GetObject().transform.position.y; //float y = player.GetObject().transform.position.y - GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).height_ * 0.1339f; //this.SlowTranslatePlayer(player, VRAR_Level.getNeighborDistance(dir) + new Vector3(0f, y, 0f), speed * LevelManager.TILE_SCALE); this.SlowTranslatePlayer(player, VRAR_Level.getNeighborDistance(dir), speed * LevelManager.TILE_SCALE, animated); } else { //Debug.Log("EXTERNAL we CANNOT see the other player"); player.GetObject().GetComponentInChildren <SkinnedMeshRenderer>().enabled = false; this.SlowTranslatePlayer(player, VRAR_Level.getNeighborDistance(dir), speed * LevelManager.TILE_SCALE, false); } }
public void walkLocalPlayer(int currentX, int currentY, int dir) { /* * targetTransform.Translate(VRAR_Level.getNeighborDistance(VRAR_Level.getCounterTile(dir))); * float y = GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).hexObject.lossyScale.y * 0.447f - this.localPlayer.GetObject().transform.position.y; * localPlayer.GetObject().transform.Translate(new Vector3(0f, y * LevelManager.TILE_SCALE, 0f)); * this.spawnLevel(currentX, currentY); * this.updateSight(currentX, currentY); * * foreach (BasePlayer basePlayer in GamePlayManagerAR.instance.GetPlayers().Values) * { * if (basePlayer.GetPlayerId() != this.localPlayer.GetPlayerId()) * { * this.walkExternalPlayer(currentX, currentY, basePlayer, VRAR_Level.getCounterTile(dir)); * } * }*/ if (this.localPlayerTranslateWrapper == null) { this.localPlayerTranslateWrapper = new TileRenderer.SlowTranslateWrapper(this.targetTransform); } this.SlowTranslate(this.localPlayerTranslateWrapper, VRAR_Level.getNeighborDistance(VRAR_Level.getCounterTile(dir)), speed * LevelManager.TILE_SCALE, () => { if (GamePlayManagerAR.instance.localPlayer != null) {//update animation GamePlayManagerAR.instance.localPlayer.GetObject().transform.localEulerAngles = new Vector3(0, directionToRotation(dir), 0); m_Animator = GamePlayManagerAR.instance.localPlayer.GetObject().GetComponent <Animator>(); m_Animator.SetBool("isWalkingLocally", true); } this.spawnLevel(currentX, currentY); this.updateSight(currentX, currentY); }, () => { if (GamePlayManagerAR.instance.localPlayer != null) {//update animation m_Animator = GamePlayManagerAR.instance.localPlayer.GetObject().GetComponent <Animator>(); m_Animator.SetBool("isWalkingLocally", false); } this.spawnLevel(currentX, currentY); this.updateSight(currentX, currentY); }); //float y = GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(this.localPlayer.GetCurrentVec().x, this.localPlayer.GetCurrentVec().y).hexObject.lossyScale.y * 0.447f - this.localPlayer.GetObject().transform.position.y; //float y = GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).hexObject.lossyScale.y * 0.447f - this.localPlayer.GetObject().transform.position.y; float y = localPlayer.GetObject().transform.position.y - GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).height_ * 0.1339f; this.SlowTranslatePlayer(this.localPlayer, new Vector3(0f, -y, 0f), speed * LevelManager.TILE_SCALE, false); //localPlayer.GetObject().transform.position = new Vector3(localPlayer.GetObject().transform.position.x, GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).height_ * LevelManager.TILE_SCALE * 0.447f, localPlayer.GetObject().transform.position.z); foreach (BasePlayer basePlayer in GamePlayManagerAR.instance.GetPlayers().Values) { if (basePlayer.GetPlayerId() != this.localPlayer.GetPlayerId()) { this.walkExternalPlayer(currentX, currentY, basePlayer, VRAR_Level.getCounterTile(dir), false); } } }