Example #1
0
    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 = "";
        }
    }
Example #2
0
    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;
        }
    }
Example #3
0
    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);
    }
Example #4
0
 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 = "";
     }
 }
Example #5
0
    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);
        }
    }
Example #6
0
    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 = "";
            }
        }
    }