new public void TryActivate() { if (timeToNextMessage < 0) { timeToNextMessage = messageTimer; PaddleNetworking pn = GetComponent <PaddleNetworking>(); if (!NetworkManager.singleton.isNetworkActive || NetworkServer.connections.Count > 0) { myPowers[myPowers.Count - 1].Activate(); currentPowerName = ""; } else { pn.CmdActivatePower(); currentPowerName = ""; } if (pn.isServer) { pn.RpcSetCurrentPower(""); } if (!powerText) { GameObject powerUI = GameObject.FindGameObjectWithTag("PowerUp"); powerText = powerUI.transform.GetChild(playerIndex).GetComponent <Text>(); } powerText.text = ""; } }
public virtual void SendInput(string input, bool isPress) { if (NetworkManager.singleton.isNetworkActive) { bool willSend = false; if (!remoteInputs.ContainsKey(input)) { remoteInputs.Add(input, isPress); willSend = true; } else { bool lastState = remoteInputs[input]; //needs optimizing willSend = (lastState != isPress); } if (!willSend) { return; } PaddleNetworking pn = GetComponent <PaddleNetworking>(); if (pn.isServer) { pn.RpcSendInput(input, isPress); } else { //isClient pn.CmdSendInput(input, isPress); } remoteInputs[input] = isPress; } }
protected void ObstructClient(bool isCleanup = false) { if (!isHost || !NetworkManager.singleton.isNetworkActive) { return; } PaddleNetworking pn = targets[0].GetComponent <PaddleNetworking>(); pn.RpcObstructMe(obstacle.transform.position.z, isCleanup); }
new public void TryActivate() { if (!NetworkManager.singleton.isNetworkActive || NetworkServer.connections.Count > 0) { myPowers[myPowers.Count - 1].Activate(); } else { PaddleNetworking pn = gameObject.GetComponent <PaddleNetworking>(); pn.CmdActivatePower(); currentPowerName = ""; } }
void giveNewPower(PaddleBase player) { float randFloat = Random.Range(1, (float)(powerTypes.POWER_COUNT)); int randInt = Mathf.FloorToInt(randFloat); string powerName = powerMapping[(powerTypes)randInt]; player.AddPower(powerName); Debug.Log("Power Granted: " + powerMapping[(powerTypes)randInt].ToString() + " to player " + ownerId); if (NetworkManager.singleton.isNetworkActive) { PaddleNetworking pNet = player.gameObject.GetComponent <PaddleNetworking>(); pNet.RpcSetCurrentPower(powerName); } }
new public void TryActivate() { //Check for other active paddle controllers // client doesnt disable SimpleAI when player takes control PaddleNetworking pn = GetComponent <PaddleNetworking>(); if (!NetworkManager.singleton.isNetworkActive || NetworkServer.connections.Count > 0 && myPowers.Count > 0 && currentPowerName != "" && !GetComponent <Player>().enabled) { myPowers[myPowers.Count - 1].Activate(); if (!powerText) { GameObject powerUI = GameObject.FindGameObjectWithTag("PowerUp"); powerText = powerUI.transform.GetChild(playerIndex).GetComponent <Text>(); } if (pn.isServer) { pn.RpcSetCurrentPower(""); powerText.text = ""; currentPowerName = ""; } else if (pn.isClient) { //Client AI only needs to update the UI through recieved messages } else //local { powerText.text = ""; currentPowerName = ""; } } }