private void StartState()
 {
     captureTimer += Time.deltaTime;
     if (team1 > team2)
     {
         bIsCapturing = false;
         if (!aIsCapturing)
         {
             aIsCapturing = true;
             captureTimer = 0f;
             state        = DominationState.Team1Capturing;
             RpcSetState((byte)DominationState.Team1Capturing);
         }
         if (captureTimer > timeToCapture)
         {
             sp = new StatePointer(TeamAState);
             RpcSetState((byte)DominationState.Team1);
             state        = DominationState.Team1;
             aIsCapturing = false;
             bIsCapturing = false;
             return;
         }
     }
     if (team2 > team1)
     {
         aIsCapturing = false;
         if (!bIsCapturing)
         {
             bIsCapturing = true;
             captureTimer = 0f;
             RpcSetState((byte)DominationState.Team2Capturing);
             state = DominationState.Team2Capturing;
         }
         if (captureTimer > timeToCapture)
         {
             sp    = new StatePointer(TeamBState);
             state = DominationState.Team2;
             RpcSetState((byte)DominationState.Team2);
             aIsCapturing = false;
             bIsCapturing = false;
             return;
         }
     }
     if (team1 == team2 && team1 == 0 && state != DominationState.Even)
     {
         captureTimer = 0f;
         aIsCapturing = false;
         bIsCapturing = false;
         state        = DominationState.Even;
         RpcSetState((byte)DominationState.Even);
     }
     if (team1 == team2 && team1 != 0 && state != DominationState.Contested)
     {
         captureTimer = 0f;
         aIsCapturing = false;
         bIsCapturing = false;
         state        = DominationState.Contested;
         RpcSetState((byte)DominationState.Contested);
     }
 }
 public void RpcSetState(byte newstate)
 {
     if (newstate == (byte)DominationState.Even)
     {
         OwnerImage.color   = NoneOwned;
         MiddleCircle.color = NoneOwned;
         domMat.SetFloat("_NeutralEvent", 1f);
         domMat.SetFloat("_Capturing", 0f);
         state       = DominationState.Even;
         status.text = "Objective A Active";
         SetObjectiveText("New objective active", 3);
         HideCapturing();
     }
     if (newstate == (byte)DominationState.Contested)
     {
         state       = DominationState.Contested;
         status.text = "Contested";
         domMat.SetFloat("_NeutralEvent", 1f);
         domMat.SetFloat("_Capturing", 1f);
         HideCapturing();
     }
     if (newstate == (byte)DominationState.Team1)
     {
         state       = DominationState.Team1;
         status.text = "Team A has point A";
         SetObjectiveText("Orange team has captured the point", 3);
         domMat.SetFloat("_ColorChange", 1f);
         domMat.SetFloat("_Capturing", 0f);
         domMat.SetFloat("_NeutralEvent", 0f);
         Captured(Orange);
         HideCapturing();
     }
     if (newstate == (byte)DominationState.Team1Capturing)
     {
         state               = DominationState.Team1Capturing;
         status.text         = "Team A is Capturing point A";
         currentCaptureColor = Orange;
         domMat.SetFloat("_Capturing", 1f);
         Capturing(Orange);
     }
     if (newstate == (byte)DominationState.Team2)
     {
         state = DominationState.Team2;
         //status.text = "Team B has point A";
         SetObjectiveText("Blue team has captured the point", 3);
         domMat.SetFloat("_ColorChange", 0f);
         domMat.SetFloat("_NeutralEvent", 0f);
         domMat.SetFloat("_Capturing", 0f);
         Captured(Blue);
         HideCapturing();
     }
     if (newstate == (byte)DominationState.Team2Capturing)
     {
         state               = DominationState.Team2Capturing;
         status.text         = "Team B is Capturing point A";
         currentCaptureColor = Blue;
         domMat.SetFloat("_Capturing", 1f);
         Capturing(Blue);
     }
     if (newstate == (byte)DominationState.Waiting)
     {
         state              = DominationState.Waiting;
         OwnerImage.color   = NoneOwned;
         MiddleCircle.color = NoneOwned;
         domMat.SetFloat("_NeutralEvent", 1f);
         domMat.SetFloat("_Capturing", 0f);
         animatedDom.SetActive(false);
         status.text = "Waiting for next Domination Point";
         HideCapturing();
     }
 }
    private void TeamBState()
    {
        if (!aIsCapturing && state != DominationState.Contested)
        {
            pointTimer += Time.deltaTime;
        }
        //if (pointTimer >= 1f)
        //{
        //    pointTeamB++;
        //    pointTimer = 0f;
        //}
        if (state != DominationState.Contested)
        {
            pointTeamB += Time.deltaTime;
        }
        //pointTeamB += Time.deltaTime;
        captureTimer += Time.deltaTime;
        if (team2 > team1 && state != DominationState.Team2)
        {
            state = DominationState.Team2;
            RpcSetState((byte)state);
        }
        if (team1 > team2)
        {
            if (!aIsCapturing)
            {
                aIsCapturing = true;
                captureTimer = 0f;
                RpcSetState((byte)DominationState.Team1Capturing);
                state = DominationState.Team1Capturing;
            }
            if (captureTimer > timeToCapture)
            {
                sp         = new StatePointer(TeamAState);
                pointTimer = 0f;
                RpcSetState((byte)DominationState.Team1);
                bIsCapturing = false;
                aIsCapturing = false;

                return;
            }
        }
        if (team1 == team2 && team1 == 0 && state != DominationState.Team2)
        {
            captureTimer = 0f;

            aIsCapturing = false;
            state        = DominationState.Team2;
            RpcSetState((byte)DominationState.Team2);
        }
        if (team1 == team2 && team1 != 0 && state != DominationState.Contested)
        {
            captureTimer = 0f;

            aIsCapturing = false;
            state        = DominationState.Contested;
            RpcSetState((byte)DominationState.Contested);
        }
        if (pointTeamB >= winConidtion)
        {
            sp    = new StatePointer(WaitingForNextState);
            state = DominationState.Waiting;
            RpcSetState((byte)state);
            RpcGivePointToTeam(1);
            ScorePointB++;
            if (ScorePointB == 1)
            {
                //tema0 vann första pointen
                players = NetworkServer.objects;
                foreach (KeyValuePair <NetworkInstanceId, NetworkIdentity> entry in players)
                {
                    if (entry.Value.isLocalPlayer)
                    {
                        NetworkServer.FindLocalObject(entry.Key).GetComponent <VoiceActing>().PointCaptured(1);
                    }
                }
            }
            if (CheckVictory(ScorePointB))
            {
                RpcTeamWins(1);
                status.text = "Team B won!";
                matchOver   = true;
            }
            aIsCapturing = false;
            bIsCapturing = false;
            captureTimer = 0f;
            pointTeamA   = 0;
            pointTeamB   = 0;
        }
    }