Get() публичный статический Метод

public static Get ( Component component ) : PhotonView,
component Component
Результат PhotonView,
Пример #1
0
    void Update()
    {
        soundDeath = GetComponent <AudioSource>();
        if (transform.position.x == hitpoint.x && transform.position.z == hitpoint.z)
        {
            if (Anim.GetBool("isgun"))
            {
                GetComponent <Tir>().ActiveArme(armes[0], true);
            }
            else
            {
                GetComponent <Tir>().ActiveArme(armes[0], false);
            }
            PhotonView.Get(this).RPC("PlayAnimWalk", PhotonTargets.MasterClient, false);
            PhotonView.Get(this).RPC("PlayAnimRun", PhotonTargets.MasterClient, false);
            PhotonView.Get(this).RPC("PlayAnimIsgunmove", PhotonTargets.MasterClient, false);
        }

        if (deadd)
        {
            deadText.SetActive(true);
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.Confined;
            Time.timeScale   = 0;
        }
        else
        {
//			deadText.SetActive(false);
            Cursor.visible = true;
            Time.timeScale = 1;
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                m.GetComponent <MENU>().ResumeBut();
            }
            if (Input.GetMouseButton(0))
            {
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, 100000, mask))
                {
                    hitpoint = hit.point;
                    if (!GetComponent <SpellController>().run)
                    {
                        GetComponent <Tir>().ActiveArme(armes[0], false);
                        PhotonView.Get(this).RPC("PlayAnimWalk", PhotonTargets.MasterClient, true);
                        PhotonView.Get(this).RPC("PlayAnimIsgun", PhotonTargets.MasterClient, false);
                        PhotonView.Get(this).RPC("PlayAnimIsgunmove", PhotonTargets.MasterClient, true);
                    }

                    else
                    {
                        GetComponent <Tir>().ActiveArme(armes[0], false);
                        PhotonView.Get(this).RPC("PlayAnimRun", PhotonTargets.MasterClient, true);
                        PhotonView.Get(this).RPC("PlayAnimIsgun", PhotonTargets.MasterClient, false);
                        PhotonView.Get(this).RPC("PlayAnimIsgunmove", PhotonTargets.MasterClient, true);
                    }
                    motor.MoveToPoint(hit.point);
                }
            }
            if (Input.GetMouseButton(2))
            {
                Ray        ray1 = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit1;
                if (Physics.Raycast(ray1, out hit1, 100000, mask) && Vector3.Distance(hit1.point, transform.position) >= 3)
                {
                    transform.LookAt(hit1.point);
                }
            }



            if (Input.GetKeyDown(KeyCode.L))
            {
                if (Life - 15 > 0)
                {
                    Life -= 15;
                }
                else
                {
                    Life = 0;
                    deadText.SetActive(true);
                }
            }
            if (Input.GetKeyDown(KeyCode.M))
            {
                if (Life + 20 < maxlife)
                {
                    Life += 20;
                }
                else
                {
                    Life = maxlife;
                }
            }
            if (energieV >= maxenergie)
            {
                energieV = maxenergie;
            }

            if (Life >= maxlife)
            {
                Life = maxlife;
            }
            else if (Life <= 0)
            {
                if (PlayerPrefs.GetInt("Resurection") == 1)
                {
                    Life       = 50;
                    energieV   = 0;
                    consT.text = "Resurection !!!!!!!!!!!!!!!!!!!!!!";
                }
                else
                {
                    soundDeath.clip = rip;
                    soundDeath.Play();
                    Life  = 0;
                    deadd = true;
                }
            }

            vieSlider.GetComponent <AffichageNumb>().n.GetComponent <Text>().text     = Life + " / " + maxlife;
            energieSlider.GetComponent <AffichageNumb>().n.GetComponent <Text>().text = energieV + " / " + maxenergie;
            vieSlide.value     = Life / maxlife;
            energieSlide.value = energieV / maxenergie;
            vie.value          = (float)Life / maxlife;
            energie.value      = (float)energieV / maxenergie;


            if (Input.GetKeyDown(KeyCode.I))
            {
                int index2 = index + 1;
                GetComponent <PlayerController>().consT.text = index2 + ":" + " " + inventaire[index];
                index += 1;
                if (inventaire[index] == "" | -index >= 10)
                {
                    index = 0;
                }
            }
        }
    }
Пример #2
0
 void Start()
 {
     photonView = PhotonView.Get(this);
 }
Пример #3
0
    public void updateNumPlayersInRoom(int playerIndex, bool isInRoom)
    {
        PhotonView photonView = PhotonView.Get(this);

        photonView.RPC("UpdateNumPlayersInRoom_RPC", PhotonTargets.AllBufferedViaServer, playerIndex, isInRoom);
    }
Пример #4
0
 //------------------------------------------------------------------------------------------------------------------------------//
 public void ChangeAction(string animeId)
 {
     // 全てのクライアントにアニメキーを送信
     PhotonView.Get(this).RPC("OnChangeAction", RpcTarget.All, animeId);
 }
Пример #5
0
 public void Start()
 {
     inv = GameObject.Find("Inventory").GetComponent <Inventory>();
     pv  = PhotonView.Get(this);
 }
Пример #6
0
 void Start()
 {
     PunTeams.Team team = PhotonView.Get(transform.root.gameObject).owner.GetTeam();
     renderer.material = ServerController.GetObjectFromTeam <Material>(team, redTeamMaterial, blueTeamMaterial, noneTeamMaterial);
 }
    public bool CheckIfValid(string CardType)
    {
        char StartingSuit = 'N';

        if (PlayedCards.Count > 0)
        {
            if (PlayedCards[0][0] == 'J' && PlayedCards[0][1] == AlternateSuits[Trump])
            {
                StartingSuit = Trump;
            }
            else
            {
                StartingSuit = PlayedCards[0][1];
            }
        }
        if (!((PlayedCards.Count == 0) || (StartingSuit == CardType[1] && !(CardType[0] == 'J' && CardType[1] == AlternateSuits[Trump] && StartingSuit == AlternateSuits[Trump])) ||
              (CardType[1] == AlternateSuits[Trump] && CardType[0] == 'J' && StartingSuit == Trump)))
        {
            foreach (GameObject Card in DisplayedCards)
            {
                if ((Card.GetComponent <CardComponent>().GetTargetPosition().y == -600) &&
                    (((Card.GetComponent <CardComponent>().GetCardType()[1] == StartingSuit) &&
                      !(Card.GetComponent <CardComponent>().GetCardType()[0] == 'J' &&
                        Card.GetComponent <CardComponent>().GetCardType()[1] == AlternateSuits[Trump] &&
                        StartingSuit == AlternateSuits[Trump])) || (Card.GetComponent <CardComponent>().GetCardType()[0] == 'J' &&
                                                                    Card.GetComponent <CardComponent>().GetCardType()[1] == AlternateSuits[Trump] &&
                                                                    StartingSuit == Trump)))
                {
                    return(false);
                }
            }
        }
        PhotonView.Get(this).RPC("PlayCard", RpcTarget.Others, CardType);
        PlayedCards.Add(CardType);
        int Num = 4;

        if (PlayerToSkip != -1)
        {
            Num -= 1;
        }
        if (PlayedCards.Count == Num)
        {
            Ticks = 0;
            Waits.Enqueue(new List <string> {
                "Score"
            });
        }
        else
        {
            DoRound();
        }
        if (PlayedCards.Count > 0) //If the player who plays the card begins the new trick, don't make all their cards locked
        {
            foreach (GameObject Card in DisplayedCards)
            {
                Card.GetComponent <CardComponent>().SetUnlocked(new List <bool> {
                    false, false, false
                });
            }
        }
        return(true);
    }
Пример #8
0
    public void OnPhotonPlayerDisconnected(PhotonPlayer player)
    {
        // Setup as we don't have enough players
        if (PhotonNetwork.isMasterClient && PhotonNetwork.room.PlayerCount < minimumPlayers)
        {
            if (!((int)PhotonNetwork.room.CustomProperties["S"] > 1))
            {
                // End round/Game and move on.
                StandByCam.SetActive(true);

                currentPhase = 0; // Set backup for next round.

                // Delete players
                GameObject[] allPlayers = GameObject.FindGameObjectsWithTag("PlayerController");

                foreach (GameObject chara in allPlayers)
                {
                    chara.GetComponent <PhotonView>().RPC("destroyThis", PhotonTargets.All, "RoundEnd");
                }

                spawned = false;

                UIHandler uiHandler = (UIHandler)PlayerUI.GetComponent(typeof(UIHandler));

                // Update UI
                uiHandler.updateStatus("PREPEARING");
                uiHandler.updateSideUI("Undecided");
                uiHandler.closeWin();
                uiHandler.toggleWeapons(false);

                uiHandler.toggleTimer(false);

                // Wipe lists
                aliveInnocents = new List <PhotonPlayer>();
                aliveTraitors  = new List <PhotonPlayer>();
                deadInnocents  = new List <PhotonPlayer>();
                deadTraitors   = new List <PhotonPlayer>();

                // Remove time
                timeLeft = 0;
            }
            else
            {
                int side = (int)player.CustomProperties["Team"];

                if (side == 1)
                {
                    aliveTraitors.Remove(player);
                    deadTraitors.Add(player);
                }
                else
                {
                    aliveInnocents.Remove(player);
                    deadInnocents.Add(player);
                }

                if (aliveInnocents.Count <= 0)
                {
                    PhotonView.Get(this).RPC("roundWin", PhotonTargets.All, "traitor", "Innocents Eliminated");
                }
                else if (aliveTraitors.Count <= 0)
                {
                    PhotonView.Get(this).RPC("roundWin", PhotonTargets.All, "innocent", "Traitors Eliminated");
                }
            }
        }
    }
Пример #9
0
 public void Start()
 {
     itemData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/StreamingAssets/Items.json"));
     inv      = GameObject.Find("Inventory").GetComponent <Inventory>();
     pv       = PhotonView.Get(this);
 }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     blackScore = 0;
     whiteScore = 0;
     photonView = PhotonView.Get(this);
 }
Пример #11
0
    int currentPhase = 0; // 0 - Not Start, 1 - Prepearing, 2 - Playing, 3 - Ending.

    // This function is used to call for the phase timing by the host.
    public void nextPhase(bool timeWin)
    {
        if (PhotonNetwork.isMasterClient && timeLeft <= 0)
        {
            if (currentPhase == 0 && PhotonNetwork.room.PlayerCount >= minimumPlayers)
            {
                PhotonView photonView = PhotonView.Get(this);
                photonView.RPC("SpawnUser", PhotonTargets.All);

                ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable()
                {
                    { "S", 1 }
                };
                PhotonNetwork.room.SetCustomProperties(hash);

                currentPhase += 1;

                PhotonView.Get(this).RPC("updatePhase", PhotonTargets.All, "PREPEARING"); // Setup UI

                timeLeft = preparingTime;
                StartCoroutine("timePhase");
            }
            else if (currentPhase == 1 && PhotonNetwork.room.PlayerCount >= minimumPlayers)
            {
                currentPhase += 1;

                ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable()
                {
                    { "S", 2 }
                };
                PhotonNetwork.room.SetCustomProperties(hash);

                // Code for selecting traitors etc.
                selectTraitors();

                PhotonView.Get(this).RPC("updatePhase", PhotonTargets.All, "PLAYING"); // Setup UI

                timeLeft = gamingTime;
                StartCoroutine("timePhase");
            }
            else if (currentPhase == 2)
            {
                currentPhase += 1;

                ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable()
                {
                    { "S", 3 }
                };
                PhotonNetwork.room.SetCustomProperties(hash);

                if (timeWin)
                {
                    // If it makes it to this point, they innocents win by time!
                    PhotonView.Get(this).RPC("roundWin", PhotonTargets.All, "innocent", "Time Up");
                }

                PhotonView.Get(this).RPC("updatePhase", PhotonTargets.All, "ROUND END"); // Setup UI

                Debug.Log("Yay");

                timeLeft = endingTime;
                Debug.Log(timeLeft);
                StartCoroutine("timePhase");
            }
            else
            {
                // Next round?
                PhotonView.Get(this).RPC("nextRound", PhotonTargets.All);
            }
        }
    }
Пример #12
0
 // Use this for initialization
 void Start()
 {
     this.photonView = PhotonView.Get(this);
     PhotonNetwork.isMessageQueueRunning = true;
     player = GameObject.Find("Player").GetComponent <Player>();
 }
Пример #13
0
 public void TriggerGivePhysControlOnAll(bool givePhysControl)
 {
     //Debug.Log("Control changed");
     PhotonView.Get(this).RPC("GivePhysSysControl", RpcTarget.All, givePhysControl);
 }
Пример #14
0
 // Use this for initialization
 private void Start()
 {
     pv = PhotonView.Get(this);
 }
Пример #15
0
    public void populateAllPlayersList()
    {
        PhotonView photonView = PhotonView.Get(this);

        AllPlayers = PhotonNetwork.playerList;
    }
Пример #16
0
 public void Start()
 {
     PV = PhotonView.Get(this);
     startAndend.text = "StartTurn";
 }
Пример #17
0
 public void Start()
 {
     inv = GameObject.Find("Inventory").GetComponent <Inventory>();
     pv  = PhotonView.Get(this);
     cityui.SetActive(false);
 }
Пример #18
0
 void SyncPortTransparency()
 {
     PhotonView.Get(this).RPC("SetPortTransparency", RpcTarget.Others);
     SetPortTransparency();
 }
    public void ScoreTrick()
    {
        List <int> Best = new List <int> {
            0, 0
        };                                       // 0th - best player, 1st - best card
        char StartingSuit = PlayedCards[0][1];

        if (PlayedCards[0][0] == 'J' && PlayedCards[0][1] == AlternateSuits[Trump])
        {
            StartingSuit = AlternateSuits[Trump];
        }
        PlayedCards.Reverse();
        for (int i = 0; i < PlayedCards.Count; i++)
        {
            if (EvaluateCard(PlayedCards[i], StartingSuit) > Best[1])
            {
                Best[1] = EvaluateCard(PlayedCards[i], StartingSuit);
                Best[0] = Turn;
                for (int i2 = 0; i2 < i; i2++)
                {
                    Best[0] -= 1;
                    if (Best[0] < 0)
                    {
                        Best[0] += 4;
                    }
                    else if (Best[0] > 3)
                    {
                        Best[0] -= 4;
                    }
                    if (Best[0] == PlayerToSkip)
                    {
                        Best[0] -= 1;
                    }
                    if (Best[0] < 0)
                    {
                        Best[0] += 4;
                    }
                    else if (Best[0] > 3)
                    {
                        Best[0] -= 4;
                    }
                }
            }
        }
        Turn = Best[0] - 1;
        if ((Best[0] % 2) == 0)
        {
            Team1Tricks += 1;
        }
        else
        {
            Team2Tricks += 1;
        }
        PlayedCards = new List <string>();
        int Removed = 0;
        int Temp    = DisplayedCards.Count;

        for (int i = 0; i < Temp; i++)
        {
            if (!(DisplayedCards[i - Removed].GetComponent <CardComponent>().GetTargetPosition().y == -600))
            {
                Destroy(DisplayedCards[i - Removed]);
                DisplayedCards.RemoveAt(i - Removed);
                Removed += 1;
            }
        }
        if (Team1Tricks + Team2Tricks == 5)
        {
            int Temp2 = DisplayedCards.Count;
            for (int i = 0; i < Temp2; i++)
            {
                Destroy(DisplayedCards[0]);
                DisplayedCards.RemoveAt(0);
            }
            if (TrumpPickerTeam == 0)
            {
                if (Team1Tricks == 5)
                {
                    if (PlayerToSkip != -1)
                    {
                        Team1Score += 4;
                    }
                    else
                    {
                        Team1Score += 2;
                    }
                }
                else if (Team1Tricks > 2)
                {
                    Team1Score += 1;
                }
                else
                {
                    Team2Score += 2;
                }
            }
            else
            {
                if (Team2Tricks == 5)
                {
                    if (PlayerToSkip != -1)
                    {
                        Team2Score += 4;
                    }
                    else
                    {
                        Team2Score += 2;
                    }
                }
                else if (Team2Tricks > 2)
                {
                    Team2Score += 1;
                }
                else
                {
                    Team1Score += 2;
                }
            }
            Loaded         = false;
            Deck           = new List <string>();
            Hands          = new List <string>();
            PlayedCards    = new List <string>();
            DisplayedCards = new List <GameObject>();
            if (Host)
            {
                Initialise();
                PhotonView.Get(this).RPC("SyncOtherPlayer", RpcTarget.Others, string.Join("", Hands), string.Join("", Deck), -1, "", -1, -2);
                PhotonView.Get(this).RPC("GameStart", RpcTarget.All, PlayerNames[0], PlayerNames[1], PlayerNames[2], PlayerNames[3]);
            }
        }
        else
        {
            DoRound();
        }
    }
Пример #20
0
    public void setupGame(int playerChoice)
    {
        Debug.Log(PhotonNetwork.LocalPlayer.NickName + " " + PhotonNetwork.LocalPlayer.CustomProperties["TeamNum"]);
        Debug.Log("Setup for " + playerChoice);

        // TEMPORARY
        if (!PhotonNetwork.IsConnected)
        {
            for (int i = 0; i < 6; i++)
            {
                if (i == playerChoice)
                {
                    teamTypes[i] = Team.Type.player;
                }
                else
                {
                    teamTypes[i] = Team.Type.ai;
                }
            }
        }

        createTeams();

        if (PhotonNetwork.IsConnected)
        {
            GameObject.Find("OverlayCanvas/UISidePanel/UIShipControl/GoButton/GoText").GetComponent <Text>().text = "Click to Ready Up";
            for (int i = 0; i < teamTypes.Length; i++)
            {
                switch (teamTypes[i])
                {
                case (Team.Type) 2:
                    Debug.Log("Team " + teams[i].TeamFaction + " is off");
                    teams[i].setTeamType((Team.Type) 2);
                    break;

                case (Team.Type) 1:
                    Debug.Log("Team " + teams[i].TeamFaction + " is human");
                    teams[i].setTeamType((Team.Type) 1);
                    break;

                case (Team.Type) 0:
                default:
                    Debug.Log("Team " + teams[i].TeamFaction + " is ai");
                    teams[i].setTeamType((Team.Type) 0);
                    break;
                }
                foreach (Player p in PhotonNetwork.PlayerList)
                {
                    if ((int)p.CustomProperties["TeamNum"] == i)
                    {
                        GameObject.Find("OverlayCanvas/UIBottomPanel/Player" + (i + 1) + "Text").GetComponent <Text>().text = p.NickName;
                    }
                }
            }

            foreach (Team t in teams)
            {
                if (t.TeamType == (Team.Type) 1)
                {
                    t.aiTeam = false;
                }
            }
        }

        if (PhotonNetwork.IsMasterClient)
        {
            foreach (Team t in teams)
            {
                if (t.TeamType == (Team.Type) 0)
                {
                    PhotonView.Get(this).RPC("SetDefaultAITextColor", RpcTarget.All, ((int)t.TeamFaction + 1));
                }
            }
        }


        playerFaction = (Team.Faction)playerChoice;
        playerTeam    = teams[(int)playerFaction];

        Debug.Log("My playerFaction is " + playerFaction.ToString());
        Debug.Log("My team is " + playerTeam.TeamFaction.ToString());

        //if (PhotonNetwork.IsConnected)
        //    PhotonView.Get(this).RPC("teamIsHuman",RpcTarget.All,playerChoice);
        if (playerTeam == null)
        {
            Debug.LogError("Player's team is null");
        }

        createPorts();


        if (playerTeam == null)
        {
            Debug.LogError("Player's team is null");
        }

        createShips();

        if (!PhotonNetwork.IsConnected || (PhotonNetwork.IsConnected && PhotonNetwork.IsMasterClient))
        {
            assignAI();

            setAIDirections();

            uiControl.PostTeamSelection();
        }

        if (!PhotonNetwork.IsConnected)
        {
            SetPortTransparency();

            SetInitialRedirects();

            RevealRedirects();
        }

        if (PhotonNetwork.IsConnected)
        {
            ExitGames.Client.Photon.Hashtable ht = PhotonNetwork.LocalPlayer.CustomProperties;
            ht["LoadedGame"] = true;
            PhotonNetwork.LocalPlayer.SetCustomProperties(ht);
        }

        cameraLock = false;
        GameObject.Find("TeamIcon").GetComponent <Image>().sprite = playerTeam.getPortSprite();
    }
Пример #21
0
    public void sendAttack()
    {
        PhotonView photonView = PhotonView.Get(this);

        photonView.RPC("Attack", RpcTarget.All);
    }
Пример #22
0
 void Awake()
 {
     photonView = PhotonView.Get(this);
 }
Пример #23
0
    /*###########
    #   START   #
    ###########*/

    // Use this for initialization
    void Start()
    {
        //On récupère l'ID du joueur
        PhotonView photonView = PhotonView.Get(this);
        int        myID       = photonView.owner.ID;

        //We activate the scoreScript
        scoreScript scoreEn = GetComponent <scoreScript>();

        if (photonView.isMine)
        {
            scoreEn.enabled = true;
        }
        else
        {
            scoreEn.enabled = false;
        }


        //On change le nom du joueur
        PhotonNetwork.playerName = PlayerPrefs.GetString("Gamertag");         /*--------------------------------------------------------BUG WITH THE PLAYER NAME, PUT BACK TO NORMAL, JUST FOR TEST -----------------------------*/

        /*int playerNumb = Random.Range(0, 10000);
         * PhotonNetwork.playerName = "player" + playerNumb.ToString();*/


        networkManager netMan = (networkManager)GameObject.Find("multiScripts").GetComponent("networkManager");


        /*----- IN MATCH -----*/

        blueSpawn = GameObject.Find("spawn_Blue");

        spawnBlue1 = blueSpawn.transform.Find("spawnBlue1").gameObject;
        spawnBlue2 = blueSpawn.transform.Find("spawnBlue2").gameObject;

        playerCountUpdateTimer = 0f;


        //We change the team of the player
        if (PhotonNetwork.isMasterClient)
        {
            blueCount = 0;
            redCount  = 0;
            scoreScript scoreMan = GetComponent <scoreScript>();

            if (blueCount <= redCount)
            {
                actualTeam = "Blue";
                blueCount++;
                scoreMan.myTeam = "Blue";
            }
            else
            {
                actualTeam = "Red";
                redCount++;
                scoreMan.myTeam = "Red";
            }
        }
        else
        {
            this.photonView.RPC("ajoutTeam", PhotonTargets.MasterClient, myID);
        }
    }
Пример #24
0
    void updateMe(int senderID)
    {
        //********** ADDING US ON THE BOARD

        //We get the ID of the new player who needs to be updated
        PhotonPlayer sender = PhotonPlayer.Find(senderID);

        //We get our own ID
        PhotonView myView = PhotonView.Get(this);
        int        myID   = myView.owner.ID;

        //We get our basic stats
        string myTag = "";

        int  iA    = 0;
        bool doneA = false;

        //Retrieving our gamertag

        /*while(iA<4 && doneA==false)
         * {
         *      if(myTeam=="Blue")
         *      {
         *              myTag = playerTagsBlue[iA];
         *      }
         *      else
         *      {
         *              myTag = playerTagsRed[iA];
         *      }
         *      iA++;
         * }*/

        myTag = PlayerPrefs.GetString("Gamertag");

        //We pack all of this
        string myTagTeam = myID.ToString() + ";" + myTag + ";" + myTeam;

        //We add ourself on his board
        myView.RPC("addOnBoard", PhotonTargets.All, myTagTeam);


        //********* UPDATING OUR STATS ON THE BOARD
        //We get our stats
        int myKill   = 0;
        int myAssist = 0;
        int myDeath  = 0;

        int  iU    = 0;
        bool doneU = false;

        //Retrieving our score

        /*while(iU<4 && doneU==false)
         * {
         *      if(myTeam=="Blue")
         *      {
         *              if(playerScoreBlue[iU,0]==myID)
         *              {
         *                      myKill = playerScoreBlue[iU,1];
         *                      myAssist = playerScoreBlue[iU,2];
         *                      myDeath = playerScoreBlue[iU,3];
         *                      doneU=true;
         *              }
         *      }
         *      else {
         *              if(playerScoreRed[iU,0]==myID)
         *              {
         *                      myKill = playerScoreRed[iU,1];
         *                      myAssist = playerScoreRed[iU,2];
         *                      myDeath = playerScoreRed[iU,3];
         *                      doneU=true;
         *              }
         *      }
         *      iU++;
         * }*/

        while (iU < 4 && doneU == false)
        {
            if (myTeam == "Blue")
            {
                if (playerScoreBlue[4 * iU] == myID)
                {
                    myKill   = playerScoreBlue[4 * iU + 1];
                    myAssist = playerScoreBlue[4 * iU + 2];
                    myDeath  = playerScoreBlue[4 * iU + 3];
                    doneU    = true;
                }
            }
            else
            {
                if (playerScoreRed[4 * iU] == myID)
                {
                    myKill   = playerScoreRed[4 * iU + 1];
                    myAssist = playerScoreRed[4 * iU + 2];
                    myDeath  = playerScoreRed[4 * iU + 3];
                    doneU    = true;
                }
            }
            iU++;
        }

        //We pack this into a string
        string myTagScore = myID.ToString() + ";" + myKill.ToString() + ";" + myAssist.ToString() + ";" + myDeath.ToString();

        myView.RPC("updateScore", PhotonTargets.All, myTagScore);
    }
Пример #25
0
 public void Start()
 {
     view      = PhotonView.Get(this);
     instance  = this;
     checklist = new bool[] { false, false, false, false };
 }
Пример #26
0
    void addOnBoard(string ident)
    {
        PhotonView photonView = PhotonView.Get(this);

        //We take back his infos
        string[] playerSet = ident.Split(';');

        int    playerID   = int.Parse(playerSet[0]);
        string playerTag  = playerSet[1];
        string playerTeam = playerSet[2];

        //We look for an empty place on the board
        int  i    = 0;
        bool done = false;

        /*while(i<4 && done==false)
         * {
         *      if(playerScoreBlue[i,0]==playerID || playerScoreRed[i,0]==playerID)
         *              done=true;
         *
         *      if(playerScoreBlue[i,0]==0 && playerTeam=="Blue" && done==false)
         *      {
         *              playerScoreBlue[i,0]=playerID;
         *              playerScoreBlue[i,1]=0;
         *              playerScoreBlue[i,2]=0;
         *              playerScoreBlue[i,3]=0;
         *
         *              playerTagsBlue[i]=playerTag;
         *              Debug.Log("Added player " + playerID + " on team " + playerTeam);
         *              done=true;
         *      }
         *      if(playerScoreRed[i,0]==0 && playerTeam=="Red" && done==false)
         *      {
         *              playerScoreRed[i,0]=playerID;
         *              playerScoreRed[i,1]=0;
         *              playerScoreRed[i,2]=0;
         *              playerScoreRed[i,3]=0;
         *
         *              playerTagsRed[i]=playerTag;
         *              Debug.Log("Added player " + playerID + " on team " + playerTeam);
         *              done=true;
         *      }
         *      i++;
         * }*/

        while (i < 4 && done == false)
        {
            if (playerScoreBlue[4 * i] == playerID || playerScoreRed[4 * i] == playerID)
            {
                done = true;
            }

            if (playerScoreBlue[4 * i] == 0 && playerTeam == "Blue" && done == false)
            {
                playerScoreBlue[4 * i]     = playerID;
                playerScoreBlue[4 * i + 1] = 0;
                playerScoreBlue[4 * i + 2] = 0;
                playerScoreBlue[4 * i + 3] = 0;

                playerTagsBlue[i] = playerTag;
                Debug.Log("Added player " + playerID + " on team " + playerTeam);
                done = true;
            }
            if (playerScoreRed[4 * i] == 0 && playerTeam == "Red" && done == false)
            {
                playerScoreRed[4 * i]     = playerID;
                playerScoreRed[4 * i + 1] = 0;
                playerScoreRed[4 * i + 2] = 0;
                playerScoreRed[4 * i + 3] = 0;

                playerTagsRed[i] = playerTag;
                Debug.Log("Added player " + playerID + " on team " + playerTeam);
                done = true;
            }
            i++;
        }

        //if (photonView.isMine)
        //photonView.RPC("addOnBoard", PhotonTargets.Others, ident);
    }
Пример #27
0
 void Start()
 {
     pv         = PhotonView.Get(this);
     SpawnPoint = GameObject.Find("SpawnPoint").GetComponentsInChildren <Transform>();
 }
Пример #28
0
    /*---------------------------- UPDATE ----------------------------*/

    // Update is called once per frame
    void Update()
    {
        PhotonView photonView = PhotonView.Get(this);

        /*------------------------- VERIFYING SYNCHRONIZATION -------------*/
        //We check if we have the scores of everyone
        int numberOfScores = countPlayers();

        if (numberOfScores != PhotonNetwork.playerList.Length)        //We do not have all scores
        {
            if (updateCounter >= 2.0f)
            {
                int myID = photonView.owner.ID;

                photonView.RPC("updateMe", PhotonTargets.All, myID);
                updateCounter = 0f;
                Debug.Log("Requesting update");
            }
            else
            {
                updateCounter += Time.deltaTime;
            }
        }

        /*--------------------------------------------------------------------*/

        //When our playerCreator is created we add ourself on the scoreboards
        playerSpawn playSpawn = GetComponent <playerSpawn>();


        //While we're not on the scoreboard we try to be added
        if (addedOnBoard == false)
        {
            //We make a string out of our gamertag and playerID
            string myTag = PlayerPrefs.GetString("Gamertag");
            int    myID  = photonView.owner.ID;

            //If we have all the components we send the RPC
            if (myTeam == "Blue" || myTeam == "Red")
            {
                string tagTeamID = myID.ToString() + ";" + myTag + ";" + myTeam;

                if (PhotonNetwork.isMasterClient)
                {
                    photonView.RPC("addOnBoard", PhotonTargets.All, tagTeamID);
                }
                else
                {
                    photonView.RPC("addOnBoard", PhotonTargets.All, tagTeamID);
                    photonView.RPC("updateMe", PhotonTargets.All, myID);
                }

                /*if(photonView.isMine)
                 * {
                 *      addOnBoard(tagTeamID);
                 * }*/
                addedOnBoard = true;
            }
        }


        //Managing the kills

        //We update the last shot each frame
        foreach (Transform child in transform)
        {
            if (child.name != "globalHUD" && child.name != "scoreBoardUI" && child.name != "InGameMenu")
            {
                playerNetwork playSet = child.GetComponent <playerNetwork>();
                myLastShot = playSet.lastShot;
            }
        }

        //If we're killed we add the kill and update the score
        if (wasKilled)
        {
            int myID = photonView.owner.ID;
            if (myTeam == "Blue")
            {
                photonView.RPC("addRedKill", PhotonTargets.All, myLastShot);
                photonView.RPC("addBlueDeath", PhotonTargets.All, myID);
            }
            else
            {
                photonView.RPC("addBlueKill", PhotonTargets.All, myLastShot);
                photonView.RPC("addRedDeath", PhotonTargets.All, myID);
            }
            wasKilled = false;
        }

        /*--------------------------- SCOREBOARD ----------------------*/

        //We get the scoreboard object
        Transform scoreB = transform.Find("scoreBoardUI");

        //Drawing the score
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            drawTheScore = true;
        }
        if (Input.GetKeyUp(KeyCode.Tab))
        {
            drawTheScore = false;
        }

        if (photonView.isMine)
        {
            if (drawTheScore)            //If the player press tab we activate the board
            {
                scoreB.gameObject.active = true;
            }
            else
            {
                scoreB.gameObject.active = false;
            }
        }
        else
        {
            scoreB.gameObject.active = false;
        }
    }
Пример #29
0
    public void putPlayerNameOnScoreBoard(string name, int playerIndex)
    {
        PhotonView photonView = PhotonView.Get(this);

        photonView.RPC("PutPlayerNameOnScoreBoard_RPC", PhotonTargets.AllBufferedViaServer, PhotonNetwork.player.name, playerIndex);
    }
Пример #30
0
 private void Awake()
 {
     _photonView = PhotonView.Get(this);
 }