Ejemplo n.º 1
0
    public override void HandleMessage(string flag, string value)
    {
        if (flag == "SCORE")
        {
            if (IsClient)
            {
                score = int.Parse(value);
            }
        }

        if (flag == "CRT")
        {
            if (IsServer)
            {
                Vector3 ipos = new Vector3(Random.Range(-9, 9), -3, Random.Range(-5, 5));
                MyCore.NetCreateObject(0, int.Parse(value), ipos);
            }
        }

        if (flag == "CJ")
        {
            CanJump = bool.Parse(value);
        }

        if (flag == "JUMP")
        {
            if (IsServer && CanJump)
            {
                Debug.Log("Player " + int.Parse(value) + " jumped");
                jumpCount++;
                CanJump = false;
                SendUpdate("CJ", false.ToString());
                SendUpdate("JUMP", jumpCount.ToString());
                //Set timer.
                StartCoroutine(WaitForJump());
                //Server sends an update to clients with the value of jump count.
                //We are using the same flag so the handle message function doesn't become too complicated. We use 1 if condition instead of 2
            }

            if (IsClient)
            {
                jumpCount = int.Parse(value);
            }
        }

        if (flag == "PN")
        {
            //We are not changing all of the pnames of each client running the simple synchronization script. Only the object that sends a command receives an update.
            pname = value;
            if (IsServer)
            {
                SendUpdate("PN", value);
            }
        }
    }
Ejemplo n.º 2
0
 public override void HandleMessage(string flag, string value)
 {
     if (flag == "Shoot")
     {
         if (IsServer && canShoot == true)
         {
             temp = MyCore.NetCreateObject(3, 500, new Vector3(player.transform.position.x, player.transform.position.y, player.transform.position.z));
             temp.GetComponent <Rigidbody>().AddForce(transform.forward * 10);
             canShoot = false;
             SendUpdate("Can Shoot", false.ToString());
             StartCoroutine(waitforShoot());
         }
     }
 }
Ejemplo n.º 3
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name == "Lava")
     {
         MyCore.NetDestroyObject(this.NetId);
     }
     else if (IsServer && switched >= 1)
     {
         switched -= 1;
         GameObject temp = MyCore.NetCreateObject(12 + ItemSpawn, this.Owner, this.transform.position);
         temp.GetComponent <ItemContainer>().IsCrateDrop = true;
         MyCore.NetDestroyObject(this.NetId);
     }
 }
Ejemplo n.º 4
0
    public void PointChange(int point)
    {
        if (IsServer)
        {
            NNMA.MyAgent.destination = NNMA.Points.transform.Find("Point" + point).position;
            SendUpdate("POINT", ("" + point));


            if (boxSpawn)
            {
                GameObject temp = MyCore.NetCreateObject(12, this.Owner, this.transform.position + new Vector3(0, -1, 0));
                temp.GetComponent <CrateScript>().ItemSpawn = Random.Range(1, ItemPads.Length + 1);
                boxCount++;
                boxSpawn = false;
            }
        }
    }
Ejemplo n.º 5
0
 public void NextPhase()
 {
     //Activate Next Checkpoint
     if (newControlPoint.Length > currControlPoint + 1)
     {
         MyCore.NetCreateObject(2, -1, newControlPoint[currControlPoint + 1]);
         currControlPoint++;
         SendUpdate("CURRCP", currControlPoint.ToString());
         //Move Lava, but wait for x seconds
         StartCoroutine(lava.LavaDelay(5));
     }
     else
     {
         //Set end game to true
         //Declare Winner
     }
 }
Ejemplo n.º 6
0
 public void SpawnTP()
 {
     if(IsServer)
     {
         for (int i = 0; i < 5 - existingTP; i++)
         {
             int randomRoll = Random.Range(0, 101);
             if(randomRoll < 95)
             {
                 MyCore.NetCreateObject(7, -1, new Vector3(Random.Range(180.66f, 227f), 1.44f, Random.Range(124.83f, 172f)));
             }
             else
             {
                 MyCore.NetCreateObject(9, -1, new Vector3(Random.Range(180.66f, 227f), 1.44f, Random.Range(124.83f, 172f)));
             }
         }
     }
 }
Ejemplo n.º 7
0
 public void ChangeTeam(string team, NetworkPlayerController player, NetworkPlayer playerManager)
 {
     if (team != "GREEN")
     {
         redPlayers++;
         greenPlayers--;
         MyCore.NetDestroyObject(player.NetId);
         playerManager.ModelNum = 11;
     }
     else
     {
         redPlayers--;
         greenPlayers++;
         MyCore.NetDestroyObject(player.NetId);
         playerManager.ModelNum = 10;
     }
     playerManager.SendUpdate("REMOVEWEAPONS", playerManager.Owner.ToString());
     playerManager.SendUpdate("MODEL", playerManager.ModelNum.ToString());
     playerManager.SendUpdate("PNAME", playerManager.PNAME);
     MyCore.NetCreateObject(playerManager.ModelNum, playerManager.Owner, player.transform.position, player.transform.rotation);
 }
Ejemplo n.º 8
0
    public IEnumerator RespawnPlayer(float time, NetworkPlayerController player)
    {
        yield return(new WaitForSeconds(time));

        SendUpdate("ARROW", "true");
        NetworkPlayer[] MyPlayers = FindObjectsOfType <NetworkPlayer>();
        foreach (NetworkPlayer p in MyPlayers)
        {
            if (p.Owner == player.Owner)
            {
                if (p.Team == "RED")
                {
                    MyCore.NetCreateObject(player.Type, player.Owner,
                                           gm.TeamRedSpawn[gm.currControlPoint].transform.GetChild(p.Owner % 7).transform.position,
                                           gm.TeamRedSpawn[gm.currControlPoint].transform.GetChild(p.Owner % 7).transform.rotation);
                }
                else if (p.Team == "GREEN")
                {
                    MyCore.NetCreateObject(player.Type, player.Owner, gm.TeamGreenSpawn[gm.currControlPoint].transform.GetChild(0).transform.position);
                }
                break;
            }
        }
    }
Ejemplo n.º 9
0
    public override IEnumerator SlowUpdate()
    {
        
        if (IsServer)
        {
            spawnObjects = GameObject.FindGameObjectsWithTag("Respawn");
            while (!GameStarted || MyCore.Connections.Count == 0)
            {
                if (MyCore.Connections.Count != 0)
                {
                    GameStarted = true;
                }

                playerList = FindObjectsOfType<NetworkPlayerOption>();
                foreach (NetworkPlayerOption player in playerList)
                {
                    if (!player.ready)
                    {
                        GameStarted = false;
                    }
                }

                yield return new WaitForSeconds(MyCore.MasterTimer);
            }

            SendUpdate("START", "True");

            for (int i = 0; i < playerList.Length; i++)
            {
                if(playerList[i].shape <= 2)
                {
                    GameObject temp = MyCore.NetCreateObject(playerList[i].shape, playerList[i].Owner, spawnObjects[playerList[i].Owner % 4].transform.position);
                    GameCharacter gcTemp = temp.GetComponent<GameCharacter>();

                    //Setting values of GameCharacter
                    gcTemp.Pname = playerList[i].Pname;
                    gcTemp.color = playerList[i].color;
                }
                else if(playerList[i].shape == 3)
                {
                    GameObject temp = MyCore.NetCreateObject(10, playerList[i].Owner, spawnObjects[playerList[i].Owner % 4].transform.position);
                    GameCharacter gcTemp = temp.GetComponent<GameCharacter>();

                    //Setting values of GameCharacter
                    gcTemp.Pname = playerList[i].Pname;
                    gcTemp.color = playerList[i].color;
                }
                else
                {
                    GameObject temp = MyCore.NetCreateObject(11, playerList[i].Owner, spawnObjects[playerList[i].Owner % 4].transform.position);
                    GameCharacter gcTemp = temp.GetComponent<GameCharacter>();

                    //Setting values of GameCharacter
                    gcTemp.Pname = playerList[i].Pname;
                    gcTemp.color = playerList[i].color;
                }
            }

            StartCoroutine(CheckTP());

            while (!GameEnded)
            {

                GameEnded = true;

                if(turnedIn < maxTurnIn)
                {
                    GameEnded = false;
                }

                yield return new WaitForSeconds(MyCore.MasterTimer);
            }

            //When this part is reached, the game has ended.
            Debug.Log("Game has ended.");
            SendUpdate("END", "True");
        }  

    }
Ejemplo n.º 10
0
    public override void HandleMessage(string flag, string value)
    {
        if (flag == "Name")
        {
            fakeText.text = value;
        }

        if (flag == "Next")
        {
            j = i;

            if (firstTime == true)
            {
                firstTime = false;

                i++;

                if (IsServer)
                {
                    temp = MyCore.NetCreateObject(i, 1, new Vector3(0, 0, 0));
                    temp.transform.localScale = new Vector3(5, 5, 5);
                    temp.transform.LookAt(Camera.main.transform.forward);
                }
            }

            if (firstTime == false)
            {
                MyCore.NetDestroyObject(temp.GetComponent <NetworkID>().NetId);

                i++;

                if (i >= 9)
                {
                    i = 5;
                    j = 8;
                }

                if (IsServer)
                {
                    temp = MyCore.NetCreateObject(i, 1, new Vector3(0, 0, 0));
                    temp.transform.localScale = new Vector3(5, 5, 5);
                    temp.transform.LookAt(Camera.main.transform);
                }
            }
        }

        if (flag == "Previous")
        {
            j = i;

            if (firstTime == true)
            {
                firstTime = false;

                i--;

                if (IsServer)
                {
                    temp = MyCore.NetCreateObject(i, 1, new Vector3(0, 0, 0));
                    temp.transform.localScale = new Vector3(4, 4, 4);
                    temp.transform.LookAt(Camera.main.transform);
                }
            }

            if (firstTime == false)
            {
                MyCore.NetDestroyObject(temp.GetComponent <NetworkID>().NetId);

                i--;

                if (i <= 4)
                {
                    i = 8;
                    j = 5;
                }

                if (IsServer)
                {
                    temp = MyCore.NetCreateObject(i, 1, new Vector3(0, 0, 0));
                    temp.transform.localScale = new Vector3(5, 5, 5);
                    temp.transform.LookAt(Camera.main.transform);
                }
            }
        }

        if (flag == "Ready")
        {
            count++;

            this.gameObject.SetActive(false);

            MyCore.NetDestroyObject(temp.GetComponent <NetworkID>().NetId);

            switch (i)
            {
            case 5:
                i = 1;
                break;

            case 6:
                i = 2;
                break;

            case 7:
                i = 3;
                break;

            case 8:
                i = 4;
                break;
            }

            if (IsServer)
            {
                temp = MyCore.NetCreateObject(i, 1, spawn);
                temp.transform.GetChild(0).GetComponent <TextMesh>().text = nameText;
                Camera.main.transform.position = new Vector3(743, 1278, -2878);
                Camera.main.transform.Rotate(74, 0, 0);

                foreach (GameObject enemy in enemies)
                {
                    enemy.GetComponent <Bad_Guy_Movement>().enabled = true;
                }
            }
        }
    }
Ejemplo n.º 11
0
    public override void HandleMessage(string flag, string value)
    {
        if (flag == "PNAME")
        {
            Pname          = value;
            MyTextbox.text = value;
            ready          = true;
        }

        if (flag == "COLOR")
        {
            color = int.Parse(value);
            this.GetComponent <MeshRenderer>().material = manager.materialList[color];
        }

        char[] remove = { '(', ')' };

        //Testing Infection debuff
        if (flag == "SPEED")
        {
            velRate = float.Parse(value);
        }

        if (flag == "SCORE")
        {
            score = int.Parse(value);
        }

        if (flag == "CARRIED")
        {
            inventory.tpCarried = int.Parse(value);
        }

        if (flag == "HEALTH")
        {
            health = float.Parse(value);
        }

        if (flag == "INFECTION")
        {
            isInfected = bool.Parse(value);

            //Activates the InfectedPanel on local players if true, otherwise it disactivates it.
            if (IsLocalPlayer)
            {
                if (bool.Parse(value))
                {
                    Overlay.InfectedPanel.SetActive(true);
                }
                else
                {
                    Overlay.InfectedPanel.SetActive(false);
                }
            }
        }

        if (flag == "HASSPEED")
        {
            spedUp = bool.Parse(value);
        }

        if (flag == "HEALING")
        {
            healing = bool.Parse(value);
        }

        if (flag == "SHOOT")
        {
            if (IsServer && CanShoot)
            {
                CanShoot = false;
                SendUpdate("CS", false.ToString());
                string[] data  = value.Split(':');                  //Separates into data[0], data[1], data[2] - data[0] is the owner of bullet.
                string[] data2 = data[1].Trim(remove).Split(',');   //data[1] - position of bullet,
                string[] data3 = data[2].Trim(remove).Split(',');   //data[2] - direction of bullet.
                Debug.Log(value);
                Vector3 pos = new Vector3(
                    float.Parse(data2[0]),
                    float.Parse(data2[1]),
                    float.Parse(data2[2])
                    );
                Vector3 dir = new Vector3(
                    float.Parse(data3[0]),
                    float.Parse(data3[1]),
                    float.Parse(data3[2])
                    );
                Debug.Log(pos);
                GameObject     bullet = MyCore.NetCreateObject(6, int.Parse(data[0]), pos);
                BulletBehavior bb     = bullet.GetComponent <BulletBehavior>();
                bb.direction = dir;
                StartCoroutine(WaitForShoot());
            }
        }

        if (flag == "CS")
        {
            CanShoot = bool.Parse(value);
        }

        if (flag == "DEAD")
        {
            dead = bool.Parse(value);
        }
    }
Ejemplo n.º 12
0
    public override void HandleMessage(string flag, string value)
    {
        if (flag == "Color")
        {
            if (ColorUtility.TryParseHtmlString(value, out tempColor))
            {
                colorObj = tempColor;
            }

            if (IsServer)
            {
                SendUpdate("Color", colorObj.ToString());
            }
        }

        if (flag == "Shape")
        {
            switch (value)
            {
            case "Sphere":
                shapeArr = 5;
                break;

            case "Cube":
                shapeArr = 1;
                break;

            case "Capsule":
                shapeArr = 0;
                break;

            case "Cylinder":
                shapeArr = 2;
                break;

            case "Plane":
                shapeArr = 3;
                break;

            case "Quad":
                shapeArr = 6;
                break;
            }

            if (IsServer)
            {
                SendUpdate("Shape", shapeArr.ToString());
            }
        }

        if (flag == "Name")
        {
            playName = value;

            if (IsServer)
            {
                SendUpdate("Name", playName.ToString());
            }
        }

        if (flag == "Ready")
        {
            playCount++;

            if (IsClient)
            {
                canSee = false;
                this.gameObject.SetActive(false);
            }

            if (playCount == MyCore.Connections.Count)
            {
                if (IsServer)
                {
                    canSee = false;
                    this.gameObject.SetActive(false);
                    temp = MyCore.NetCreateObject(shapeArr, 1, new Vector3(Random.Range(-3, 3), Random.Range(-3, 3), 0));
                    GameObject.FindGameObjectWithTag("Player").GetComponent <MeshRenderer>().material.SetColor("_Color", colorObj);
                    GameObject.FindGameObjectWithTag("Player").transform.GetChild(0).transform.GetComponent <TextMesh>().text = playName;
                    SendUpdate("Update Player", "1");
                }
            }
        }

        if (flag == "Update Player")
        {
            if (IsLocalPlayer)
            {
                this.gameObject.SetActive(false);
                temp = MyCore.NetCreateObject(shapeArr, 1, new Vector3(Random.Range(-3, 3), Random.Range(-3, 3), 0));
                GameObject.FindGameObjectWithTag("Player").GetComponent <MeshRenderer>().material.SetColor("_Color", colorObj);
                GameObject.FindGameObjectWithTag("Player").transform.GetChild(0).transform.GetComponent <TextMesh>().text = playName;
            }
            if (IsClient)
            {
                temp = MyCore.NetCreateObject(shapeArr, 1, new Vector3(Random.Range(-3, 3), Random.Range(-3, 3), 0));
                GameObject.FindGameObjectWithTag("Player").GetComponent <MeshRenderer>().material.SetColor("_Color", colorObj);
                GameObject.FindGameObjectWithTag("Player").transform.GetChild(0).transform.GetComponent <TextMesh>().text = playName;
            }
        }
    }
Ejemplo n.º 13
0
    public override IEnumerator SlowUpdate()
    {
        if (IsClient && IsLocalPlayer)
        {
            NetworkPlayer[] MyPlayers = GameObject.FindObjectsOfType <NetworkPlayer>();

            NetworkMan = GameObject.FindGameObjectWithTag("NetworkManager");
            NetworkMan.transform.GetChild(0).GetComponent <Canvas>().transform.GetChild(0).gameObject.SetActive(false);

            PauseMenu = this.transform.GetChild(0).GetComponent <Canvas>().transform.GetChild(1).gameObject;

            //GameObject.FindGameObjectWithTag("NetworkManager").transform.GetChild(0).GetComponent<Canvas>().transform.GetChild(0).gameObject.SetActive(false);

            //NetworkPlayer[] MyPlayers = GameObject.FindObjectsOfType<NetworkPlayer>();

            //foreach (NetworkPlayer x in MyPlayers)
            //{
            //    if (x.NetId == this.NetId)
            //    {
            //        x.transform.GetChild(0).GetComponent<Canvas>().gameObject.SetActive(true);
            //    }
            //}

            this.transform.GetChild(0).GetComponent <Canvas>().gameObject.SetActive(true);

            PointToCP temp = Camera.main.transform.GetChild(1).GetComponent <PointToCP>();
            temp.gm      = gm;
            temp.canLook = true;
        }

        while (!isReady)
        {
            if (IsServer)
            {
                if (IsDirty)
                {
                    //Update non-movement varialbes
                    SendUpdate("PNAME", PNAME);
                    SendUpdate("READY", isReady.ToString());
                    SendUpdate("COLOR", ColorType);
                    SendUpdate("MODEL", ModelNum.ToString());
                    SendUpdate("TEAM", Team);
                }
            }
            yield return(new WaitForSeconds(MyCore.MasterTimer));
        }

        if (IsServer)
        {
            if (gm.redPlayers <= gm.greenPlayers)
            {
                //Assign to Red Model
                MyCore.NetCreateObject(11, Owner, new Vector3(-18 + ((Owner * 2) % 10), 48, -296));
                ModelNum = 11;
                gm.redPlayers++;
                Team = "RED";
                SendUpdate("TEAM", "RED");
            }
            else
            {
                //Assign to Green Model
                MyCore.NetCreateObject(10, Owner, new Vector3(-18 + ((Owner * 2) % 10), 48, -296));
                ModelNum = 10;
                gm.greenPlayers++;
                Team = "GREEN";
                SendUpdate("TEAM", "GREEN");
            }
            SendUpdate("MODEL", ModelNum.ToString());
            SendUpdate("PNAME", PNAME);
        }

        if (IsClient && IsLocalPlayer)
        {
            //NetworkPlayer[] MyPlayers = GameObject.FindObjectsOfType<NetworkPlayer>();

            //Hide Ready Panel

            //foreach (NetworkPlayer x in MyPlayers)
            //{
            //    if (x.NetId == this.NetId)
            //    {
            //        x.transform.GetChild(0).GetComponent<Canvas>().gameObject.SetActive(false);
            //    }
            //}

            this.transform.GetChild(0).GetComponent <Canvas>().transform.GetChild(0).gameObject.SetActive(false);
        }

        while (true)
        {
            if (IsServer)
            {
                //Choose to toggle display of lava rising
                //Check if value has changed
                if (gm.lava.lavaWarning && lavaRise && !gm.GameEnd)
                {
                    SendUpdate("SHOWLAVA", lavaRise.ToString());
                    lavaRise = false;
                }
                else if (!lavaRise && !gm.lava.lavaWarning)
                {
                    SendUpdate("SHOWLAVA", lavaRise.ToString());
                    lavaRise = true;
                }

                if (gm.GameEnd)
                {
                    SendUpdate("WINNER", gm.scoreTeamRed.ToString() + "," + gm.scoreTeamGreen.ToString());
                }
                if (IsDirty)
                {
                    //Update non-movement varialbes
                    SendUpdate("PNAME", PNAME);
                    SendUpdate("READY", isReady.ToString());
                    SendUpdate("COLOR", ColorType);
                    SendUpdate("MODEL", ModelNum.ToString());
                    SendUpdate("TEAM", Team);
                    IsDirty = false;
                }
            }
            yield return(new WaitForSeconds(MyCore.MasterTimer)); //Master timer is 0.05f
        }
    }
Ejemplo n.º 14
0
    public override void HandleMessage(string flag, string value)
    {
        if (string.CompareOrdinal(flag, "LFT") == 0)
        {
            playerIsLeft = bool.Parse(value);
        }
        if (string.CompareOrdinal(flag, "RIT") == 0)
        {
            playerIsRight = bool.Parse(value);
        }
        if (string.CompareOrdinal(flag, "LTS") == 0)
        {
            leftButton.interactable = false;
            //leftButtonHit = true;
            //rightButton.interactable = false;
        }
        if (string.CompareOrdinal(flag, "RTS") == 0)
        {
            rightButton.interactable = false;
            //rightButtonHit = true;
        }
        if (string.CompareOrdinal(flag, "RET") == 0)
        {
            isReset = true;
        }
        if (string.CompareOrdinal(flag, "NID") == 0)
        {
            myNetId = int.Parse(value);
        }
        if (string.CompareOrdinal(flag, "GET") == 0)
        {
            // and unopcupied spot or too many of that item
            // will need item manager
            Debug.Log("Item being sent:" + value);
            Debug.Log("Food:" + spawnManager.canFoodSpawn);
            Debug.Log("Cook:" + spawnManager.canCookSpawn);
            if (foodDictionary.ContainsKey(value))
            {
                if (spawnManager.canFoodSpawn)
                {
                    MyCore.NetCreateObject(foodDictionary[value], NetId, spawnManager.foodSpawn);
                }
            }
            else if (cookwareDictionary.ContainsKey(value))
            {
                if (spawnManager.canCookSpawn)
                {
                    MyCore.NetCreateObject(cookwareDictionary[value], NetId, spawnManager.cookSpawn);
                }
            }
        }
        if (string.CompareOrdinal(flag, "MKE") == 0)
        {
            //new Vector3(Random.Range(5f, -5f), Random.Range(1f, -1f), Random.Range(5f, -5f))

            temp = MyCore.NetCreateObject(1, myNetId, new Vector3(0, 0, 0));
            //temp.gameObject.tag = "hero";
            handScript = temp.GetComponent <HandNetwork>();
            handScript.SetHand(playerIsLeft, playerIsRight);
            //get available spawn slot
        }
    }
Ejemplo n.º 15
0
    public override void HandleMessage(string flag, string value)
    {
        if (flag == "MOVE" && IsServer)
        {
            string[] args = value.Split(',');
            tempVelocity = (this.transform.forward * float.Parse(args[0]) + this.transform.right * float.Parse(args[1])).normalized * MoveSpeed + new Vector3(0, MyRig.velocity.y, 0);
            if (!IsLaunched)
            {
                MyRig.velocity = tempVelocity;
            }
            else if (IsLaunched)
            {
                Vector3 temptemp = tempVelocity + MyRig.velocity;
                if (temptemp.magnitude < MyRig.velocity.magnitude)
                {
                    MyRig.velocity = temptemp;
                }
            }
            SendUpdate("ANIMATION", args[0].ToString() + "," + args[1].ToString());
            //if((temptemp.x > -MoveSpeed && temptemp.x<MoveSpeed) && (temptemp.y > -JumpHeight && temptemp.y<JumpHeight) && (temptemp.z > -MoveSpeed && temptemp.z<MoveSpeed))
            //{
            //    MyRig.velocity = temptemp;
            //}
        }

        if (flag == "ANIMATION")
        {
            string[] args = value.Split(',');

            switch (int.Parse(args[0]))
            {
            case 1:
                UpdateAnimator(1);
                break;

            case -1:
                UpdateAnimator(2);
                break;

            case 0:
                switch (int.Parse(args[1]))
                {
                case 1:
                    UpdateAnimator(3);
                    break;

                case -1:
                    UpdateAnimator(4);
                    break;

                case 0:
                    UpdateAnimator(0);
                    break;
                }
                break;
            }
        }

        if (flag == "ROTATE" && IsServer)
        {
            string[] args = value.Split(',');
            MyRig.transform.eulerAngles = new Vector3(0, float.Parse(args[0]), 0);
        }

        if (flag == "PNAME")
        {
            PNAME = value;
            //Set Name above players head
            this.transform.GetChild(7).GetChild(0).GetComponent <Text>().text = value;

            if (IsServer)
            {
                SendUpdate("PNAME", value);
            }
        }

        if (flag == "COLOR")
        {
            Color colorTemp = new Color();
            switch (value)
            {
            case "RED":
                colorTemp = Color.red;
                break;

            case "GREEN":
                colorTemp = Color.green;
                break;

            case "BLUE":
                colorTemp = Color.blue;
                break;

            default:
                colorTemp = Color.red;
                break;
            }

            this.gameObject.GetComponent <MeshRenderer>().material.color = colorTemp;

            if (IsServer)
            {
                SendUpdate("COLOR", value);
            }
        }

        if (flag == "JUMP")
        {
            if (IsServer)
            {
                MyRig.velocity = new Vector3(MyRig.velocity.x, JumpHeight, MyRig.velocity.z);
            }
            JumpNum--;
        }

        if (flag == "ADDWEP")
        {
            if (Weapons.Contains(int.Parse(value)))
            {
                if (WepInHand.ItemID == int.Parse(value))
                {
                    WepInHand.Reload();
                }
                else
                {
                    WeaponParent.transform.GetChild(int.Parse(value)).GetComponent <Weapon>().Reload();
                }
            }
            else
            {
                Weapons.Add(int.Parse(value));
                WeaponParent.transform.GetChild(int.Parse(value)).GetComponent <Weapon>().OnPickUp();
                int UINum = int.Parse(value) * 3;

                if (IsLocalPlayer)
                {
                    WeaponPanel.transform.GetChild(UINum).gameObject.SetActive(true);
                    WeaponPanel.transform.GetChild(UINum + 1).gameObject.SetActive(true);
                    WeaponPanel.transform.GetChild(UINum + 2).gameObject.SetActive(true);
                }
            }
        }

        if (flag == "SWITCHWEP")
        {
            Filler.transform.SetSiblingIndex(WeaponParent.transform.childCount - 1);
            if (WepInHand != null)
            {
                WepInHand.transform.SetParent(WeaponParent.transform);
                WepInHand.transform.SetSiblingIndex(WepInHand.ItemID);
                WepInHand.gameObject.SetActive(false);
            }
            WepInHand = WeaponParent.transform.GetChild(int.Parse(value)).GetComponent <Weapon>();
            WepInHand.gameObject.SetActive(true);
            WepInHand.MyController = this;
            WepInHand.SetID();

            if (IsLocalPlayer)
            {
                WepInHand.transform.SetParent(MyCam.transform.GetChild(0));
                Filler.transform.SetSiblingIndex(int.Parse(value));

                AmmoPanel.transform.GetChild(0).GetComponent <Text>().text = WepInHand.ItemName;
                AmmoPanel.transform.GetChild(1).GetComponent <Text>().text = WepInHand.CurrentAmmo.ToString();
            }

            if (IsServer)
            {
                SendUpdate("SWITCHWEP", value);
            }
        }

        if (flag == "FIRE")
        {
            if (WepInHand.CanShoot && IsServer)
            {
                WepInHand.CanShoot = false;
                string[]   args = value.Split(',');
                GameObject temp = MyCore.NetCreateObject(WepInHand.Projectile.GetComponent <Bullet>().MyType, this.Owner,
                                                         new Vector3(float.Parse(args[0]), float.Parse(args[1]), float.Parse(args[2])), this.transform.rotation);
                temp.GetComponent <Rigidbody>().velocity = new Vector3(float.Parse(args[3]), float.Parse(args[4]), float.Parse(args[5]));
                WepInHand.CurrentAmmo--;
                StartCoroutine(WepInHand.FireDelay());

                SendUpdate("FIRE", "1");
            }
            if (IsClient)
            {
                Sound.PlayOneShot(WepInHand.FireSound);
            }
        }
    }