// Remove last added client void RemoveClient() { if (backgroundGames.Count > 0) { GameObject removedClient = backgroundGames.Dequeue(); DemoGUI.GetGameLogic(removedClient).Disconnect(); Destroy(removedClient); } }
/// <summary> /// Check if local player has joined the game /// </summary> /// <returns></returns> private bool LocalPlayerJoined() { GameLogic localPlayerGameLogic = DemoGUI.GetGameLogic("Local Player"); if (localPlayerGameLogic.State == ClientState.Joined && localPlayerGameLogic.LocalRoom != null && this.gameLogic.State == ClientState.Joined) { return(true); } return(false); }
// Initialization code void Start() { gameLogic = new GameLogic(DemoGUI.ServerAddress, DemoGUI.AppId, DemoGUI.GameVersion); gameLogic.Start(); // Set the client color float scale = DemoGUI.playgroundScale / this.gameLogic.GridSize; renderer.material.color = DemoGUI.IntToColor(this.gameLogic.LocalPlayer.Color); new Vector3(this.gameLogic.LocalPlayer.PosX * transform.localScale.x + transform.localScale.x / 2, scale / 2, this.gameLogic.LocalPlayer.PosY * transform.localScale.y + transform.localScale.y / 2); }
public void OnGUI() { GUI.skin.button.stretchWidth = true; GUI.skin.button.fixedWidth = 0; if (gameInstance == null) { DemoGUI gui = GameObject.FindObjectOfType(typeof(DemoGUI)) as DemoGUI; gameInstance = gui.GameInstance; } if (gameInstance == null || this.gameInstance.State != ClientState.Joined) { return; } GUILayout.BeginArea(rightToolBar); GUILayout.Label("Clicks of"); int turnToShow = this.gameInstance.turnNumber; GUILayout.Label("turn " + turnToShow); string allTiles = ""; if (turnToShow > 0 && turnToShow < this.gameInstance.lastTilesClicked.Count && this.gameInstance.lastTilesClicked[turnToShow] != null) { foreach (int i in this.gameInstance.lastTilesClicked[turnToShow]) { allTiles += i + ", "; } } GUILayout.Label(allTiles); if (GUILayout.Button("Clear " + turnToShow)) { this.gameInstance.ClearTileClickEvForTurn(turnToShow); } turnToShow = turnToShow - 1; GUILayout.Label("turn " + turnToShow); allTiles = ""; if (turnToShow > 0 && turnToShow < this.gameInstance.lastTilesClicked.Count && this.gameInstance.lastTilesClicked[turnToShow] != null) { foreach (int i in this.gameInstance.lastTilesClicked[turnToShow]) { allTiles += i + ", "; } } GUILayout.Label(allTiles); if (GUILayout.Button("Clear " + turnToShow)) { this.gameInstance.ClearTileClickEvForTurn(turnToShow); } GUILayout.EndArea(); }
// Set the playground texture // Current texture depends on interest management setting private void SetPlaygroundTexture() { GameObject playground = GameObject.Find("Playground"); Material playgroundMaterial; Texture texture; float textureScale; Material playgroundGridMaterial; Texture gridTexture; float gridTextureScale; Material[] materials; materials = playground.renderer.materials; playgroundMaterial = new Material(Shader.Find("Diffuse")); playgroundGridMaterial = new Material(Shader.Find("Transparent/Diffuse")); gridTexture = Resources.Load("interest management grid") as Texture; gridTextureScale = DemoGUI.GetGameLogic("Local Player").GridSize; playgroundGridMaterial.mainTexture = gridTexture; if (GetGameLogic("Local Player").UseInterestGroups) { texture = Resources.Load("interest groups enabled texture") as Texture; textureScale = 1.0f; materials[0] = playgroundMaterial; materials[0].mainTexture = texture; materials[0].mainTextureScale = new Vector2(textureScale, textureScale); } else { texture = Resources.Load("interest groups disabled texture") as Texture; textureScale = DemoGUI.GetGameLogic("Local Player").GridSize; materials[0] = playgroundMaterial; materials[0].mainTexture = texture; materials[0].mainTextureScale = new Vector2(textureScale, textureScale); } materials[1] = playgroundGridMaterial; materials[1].mainTexture = gridTexture; materials[1].mainTextureScale = new Vector2(gridTextureScale, gridTextureScale); texture.wrapMode = TextureWrapMode.Repeat; gridTexture.wrapMode = TextureWrapMode.Repeat; playground.renderer.materials = materials; }
void Start() { demogui = Canvas.GetComponent <DemoGUI>(); set = 0; subset = 0; audioSource = this.gameObject.GetComponent <AudioSource>(); audioSource.clip = deside; logS = GetComponent <logSave>(); timeC = GetComponent <TimeCount>(); inputtingNow1 = false; inputtingNow2 = false; /* 機能制限 */ isAutoSetChange = true; }
/// <summary> /// Render cubes onto the scene /// </summary> void RenderPlayers() { float newscale = DemoGUI.playgroundScale / this.logic.localPlayer.GridSize; if (newscale != scaleRatio) { scaleRatio = newscale; SetPlaygroundTexture(); } Vector3 localScale = new Vector3(scaleRatio, scaleRatio, scaleRatio); lock (logic.localPlayer) { foreach (ParticlePlayer p in logic.localPlayer.LocalRoom.Players.Values) { foreach (GameObject cube in logic.cubes) { if (cube.name == p.NickName) { float alpha = 1.0f; if (!p.IsLocal && p.UpdateAge > 500) { cube.GetComponent <Renderer>().material.shader = Shader.Find("Transparent/Diffuse"); alpha = (p.UpdateAge > 1000) ? 0.3f : 0.8f; } cube.transform.localScale = localScale; Color cubeColor = DemoGUI.IntToColor(p.Color); cube.GetComponent <Renderer>().material.color = new Color(cubeColor.r, cubeColor.g, cubeColor.b, alpha); cube.transform.position = new Vector3(p.PosX * localScale.x + localScale.x / 2, scaleRatio / 2, p.PosY * localScale.y + localScale.y / 2); break; } } } } }
void OnGUI() { if (DemoGUI.ShowUserInfo && LocalPlayerJoined()) { // Get 2D coordinates from 3D coordinates of the client Vector3 posVector = Camera.main.WorldToScreenPoint(transform.position); GUIStyle labelStyle = new GUIStyle(); labelStyle.normal.textColor = Color.white; if (name == "Local Player") { labelStyle.fontStyle = FontStyle.Bold; labelStyle.normal.textColor = Color.white; renderer.material.color = DemoGUI.IntToColor(this.gameLogic.LocalPlayer.Color); } else { labelStyle.normal.textColor = Color.gray; } // Output the client's name GUI.Label(new Rect(posVector.x, Screen.height - posVector.y, 100, 20), this.gameLogic.PlayerName, labelStyle); } }
public CustomMessageListener(DemoGUI container) { this.container = container; }
// Check if the local player joined the game private bool IsLocalPlayerInGame() { return(DemoGUI.GetGameLogic("Local Player").LocalPlayer != null ? true : false); }