This simple chat example showcases the use of RPC targets and targetting certain players via RPCs.
Inheritance: Photon.MonoBehaviour
コード例 #1
0
ファイル: PrisonTrigger.cs プロジェクト: seazth/overlaw
 public void OnTriggerEnter(Collider other)
 {
     if (other.transform.tag == forTaggedGO)
     {
         PhotonPlayer player = other.GetComponent <PhotonView>().owner;
         if (player != null &&
             other.GetComponent <PhotonView>().isMine &&
             player.GetAttribute <bool>(PlayerAttributes.HASSPAWNED, false) &&
             player.GetPlayerState() == PlayerState.inGame)
         {
             int tid = player.getTeamID();
             if (tid == 1 || tid == 2)
             {
                 playerInZone.Add(player);
                 countsHasChanged = true;
                 player.SetAttribute(PlayerAttributes.INPRISONZONE, true);
             }
             if (tid == 1 && player.GetAttribute <bool>(PlayerAttributes.ISCAPTURED, false))
             {
                 player.SetAttribute(PlayerAttributes.ISCAPTURED, false);
                 ChatVik.SendRoomMessage(player.NickName + " s'est évadé de prison !");
             }
         }
     }
 }
コード例 #2
0
    void Start()
    {
        myPhotonView = gameObject.GetComponent <PhotonView> ();

        GameObject[] players = GameObject.FindGameObjectsWithTag("Other");


        animation [punch1Animation.name].AddMixingTransform(torso);
        animation [punch2Animation.name].AddMixingTransform(torso);
        animation [punch3Animation.name].AddMixingTransform(torso);
        animation [hit1Animation.name].AddMixingTransform(torso);

        animation [hit1Animation.name].layer   = 90;
        animation [punch1Animation.name].layer = 55;
        animation [punch2Animation.name].layer = 55;
        animation [punch3Animation.name].layer = 55;
        animation [jumpAnimation.name].layer   = 40;

        animation [runAnimation.name].wrapMode   = WrapMode.Loop;         // set the animation to loop ..
        animation [deathAnimation.name].wrapMode = WrapMode.ClampForever; // set the animation to loop ..

        //|inov| get chat script and store it for future use
        CHATScript = GameObject.Find("GameManager").GetComponent <ChatVik> ();

        if (myPhotonView.isMine)
        {
            //|inov| sets local variable myName to this users name for future use
            myName = PhotonNetwork.playerName;
            //|inov| sends my local name to all other players
            myPhotonView.RPC("setNameGlobal", PhotonTargets.All, myName);
        }
    }
コード例 #3
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
    /// <summary>
    /// Coroutine de jeu : Fincalisation d'un round avec changement de camps des joueurs
    /// </summary>
    /// <param name="winnerTeamId"></param>
    /// <returns></returns>
    IEnumerator FinalizeRound(int winnerTeamId)
    {
        // INIT DES VARIABLES DE NOUVEAU ROUND
        InitRoomAttributes(false);
        PhotonNetwork.room.SetRoomState(GameState.isRoundFinishing); // au cas ou
        PhotonNetwork.room.SetAttribute(RoomAttributes.PLAYERSCANSPAWN, false);
        SetImmobilizeAll(true);

        //DESTRUCTION DES POINTS DE PASSAGES VOLEURS
        DestroyThiefZones();

        //SETUP WINNER PANEL
        if (winnerTeamId != 0 && PhotonNetwork.room.GetTeamAttribute(winnerTeamId, TeamAttributes.ROUNDSWON, 0) == 3)
        {
            StartCoroutine(FinalizeGame(winnerTeamId));
            yield break;
        }

        //RESET DU SCORE DES EQUIPES
        PhotonNetwork.room.SetTeamAttribute(1, TeamAttributes.SCORE, 0);
        PhotonNetwork.room.SetTeamAttribute(2, TeamAttributes.SCORE, 0);

        // AFFICHE L'EQUIPE GAGNANTE
        photonView.RPC("rpc_callWinner", PhotonTargets.All, new object[] { winnerTeamId, false });

        // COMPTE A REBOURG AVANT LE DEBUT DU ROUND
        int timeRoundPreparation = PhotonNetwork.ServerTimestamp;

        foreach (PhotonPlayer p in PhotonNetwork.playerList)
        {
            InitPlayerAttributes(p, false);
        }
        ChatVik.SendRoomMessage("Revert teams in " + (durationRoundFinalize / 1000) + "sec");

        while (PhotonNetwork.ServerTimestamp - timeRoundPreparation < durationRoundFinalize)
        {
            yield return(new WaitForSeconds(1f));

            int time = durationRoundFinalize / 1000 - (PhotonNetwork.ServerTimestamp - timeRoundPreparation - 1000) / 1000;
            if (time == 15 || time == 10 || time <= 5)
            {
                ChatVik.SendRoomMessage("Revert teams in " + time + "sec");
            }
        }

        //CHANGEMENT DES CAMPS
        ChangeTeamSides();

        // CHECK FINAL : IL Y A ASSEZ DE JOUEUR POUR JOUER
        if (PhotonNetwork.playerList.Count(s => s.getTeamID() == 1) < 1 &&
            PhotonNetwork.playerList.Count(s => s.getTeamID() == 2) < 1)
        {
            ChatVik.SendRoomMessage("There is no players in both team ! Restart Warmup ...");
            StartCoroutine(WarmUp());
            yield break;
        }

        // INIT DES JOUEURS AU ROUND
        PhotonNetwork.room.SetRoomState(GameState.BeginningRound);
    }
コード例 #4
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
    void OnJoinedRoom()
    {
        ChatVik.SendRoomMessage(PhotonNetwork.player.NickName + " enter the game");
        InitPlayerAttributes(PhotonNetwork.player, false);

        PhotonNetwork.player.SetAttribute(PlayerAttributes.TEAM, 0);
        InvokeRepeating("RefreshGameBoard", 0f, 1f);
    }
コード例 #5
0
 /// <summary>
 /// Si le joueur est frappé par une balles : on l'immobilise
 /// </summary>
 /// <param name="collision"></param>
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Ball" && photonView.owner != null)
     {
         GetComponent <PhotonView>().RPC("rpc_immobilize", PhotonTargets.All);
         ChatVik.SendRoomMessage(collision.gameObject.GetComponent <PhotonView>().owner.NickName + " knocked out " + photonView.owner.NickName);
     }
 }
コード例 #6
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
    void Update()
    {
        if (!PhotonNetwork.inRoom)
        {
            return;
        }

        //MISE A JOUR AFFICHAGE DU STATUS DE CONNECTION A LA ROOM
        text_Gamestatus.text = (PhotonNetwork.room.GetRoomState()).ToString();

        if (PhotonNetwork.room.GetAttribute(RoomAttributes.PLAYERSCANSPAWN, false) &&
            PhotonNetwork.player.getTeamID() != 0 &&
            !PhotonNetwork.player.GetAttribute(PlayerAttributes.HASSPAWNED, false))
        {
            SpawnMyAvatar();
        }

        // ON CHECK LA PRESENCE D'UN MASTER PLAYER // UNIQUEMENT SI CE N'EST PAS EN COURS // REVIENS A : PhotonNetwork.isNonMasterClientInRoom
        if (!PhotonNetwork.playerList.AsEnumerable().Any(a => a.isGameOwner()) && !PhotonNetwork.room.GetAttribute(RoomAttributes.CHANGEINGMASTER, false))
        {
            // ON LOCK LA METHODE POUR EVITER QUE TOUT LES JOUEURS CHANGENT L'HOST !
            PhotonNetwork.room.SetAttribute(RoomAttributes.CHANGEINGMASTER, true);
            //On le designe automatiquement par le premier joueur de la liste
            PhotonNetwork.SetMasterClient(PhotonNetwork.playerList[0]);
            // ON DELOCK
            PhotonNetwork.room.SetAttribute(RoomAttributes.CHANGEINGMASTER, false);
        }

        // CONTROLLER DE STATUT DE JEU = GEREE PAR LE PLAYERMASTER
        if (PhotonNetwork.player.isGameOwner())
        {
            if (PhotonNetwork.room.GetRoomState() == GameState.isWaitingNewGame)
            {
                ChatVik.SendRoomMessage("Warmup : Waiting " + minPlayers + " players minimum to start game");
                StartCoroutine(WarmUp());
            }
            else if (PhotonNetwork.room.GetRoomState() == GameState.BeginningRound)
            {
                StartCoroutine(PrepareRound());
            }
            else if (PhotonNetwork.room.GetRoomState() == GameState.RoundRunning)
            {
                ManageWaypoints();
                UpdateGameInfos();
            }
        }

        //FONCTION DE DEBUG POUR FAIRE RESPAWN LE JOUEUR
        if (Input.GetKeyDown(KeyCode.F10))
        {
            photonView.RPC("rpc_UnspawnPlayerAvatar", PhotonTargets.All, new object[] { PhotonNetwork.player });
        }
        UpdateTimer();
    }
コード例 #7
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
    /// <summary>
    /// Coroutine de jeu : Preparation au lancement d'une nouvelle session de jeu
    /// </summary>
    /// <returns></returns>
    IEnumerator PrepareRound()
    {
        // INIT DES VARIABLES DE NOUVEAU ROUND
        InitRoomAttributes(false);
        PhotonNetwork.room.SetRoomState(GameState.PrepareRound); // au cas ou
        PhotonNetwork.room.SetAttribute(RoomAttributes.PLAYERSCANSPAWN, true);
        SetImmobilizeAll(true);
        max_Zones = System.Math.Max(3, PhotonNetwork.playerList.Count(w => (w.getTeamID() == 1) && w.GetAttribute(PlayerAttributes.HASSPAWNED, false)) + 1);
        print("max_Zones:" + max_Zones);
        //DEPOP DES JOUEURS
        foreach (PhotonPlayer p in PhotonNetwork.playerList.Where(w => (w.getTeamID() == 1 || w.getTeamID() == 2) && w.GetAttribute(PlayerAttributes.HASSPAWNED, false)))
        {
            call_UnspawnPlayerAvatar(p);
        }

        // COMPTE A REBOURG AVANT LE DEBUT DU ROUND
        int timeRoundPreparation = PhotonNetwork.ServerTimestamp;

        foreach (PhotonPlayer p in PhotonNetwork.playerList)
        {
            InitPlayerAttributes(p, true);
        }
        ChatVik.SendRoomMessage("New round begin in " + (durationRoundFinalize / 1000) + "sec");

        while (PhotonNetwork.ServerTimestamp - timeRoundPreparation < durationRoundFinalize)
        {
            yield return(new WaitForSeconds(1f));

            int time = durationRoundFinalize / 1000 - (PhotonNetwork.ServerTimestamp - timeRoundPreparation - 1000) / 1000;
            if (time == 15 || time == 10 || time <= 5)
            {
                ChatVik.SendRoomMessage("New round begin in " + time + "sec");
            }
        }

        // CHECK FINAL : IL Y A ASSEZ DE JOUEUR POUR JOUER
        if (PhotonNetwork.playerList.Count(s => s.getTeamID() == 1) < 1 &&
            PhotonNetwork.playerList.Count(s => s.getTeamID() == 2) < 1)
        {
            ChatVik.SendRoomMessage("There is no players in both team ! Restart Warmup ...");
            StartCoroutine(WarmUp());
            yield break;
        }

        // INIT DES JOUEURS AU ROUND
        PhotonNetwork.room.SetAttribute(RoomAttributes.PLAYERSCANSPAWN, false);
        print(durationRound);
        PhotonNetwork.room.SetAttribute(RoomAttributes.TIMEROUNDSTARTED, PhotonNetwork.ServerTimestamp);
        PhotonNetwork.room.SetRoomState(GameState.RoundRunning);
        PhotonNetwork.room.SetAttribute(RoomAttributes.ROUNDNUMBER, PhotonNetwork.room.GetAttribute(RoomAttributes.ROUNDNUMBER, 0) + 1);
        ChatVik.SendRoomMessage("New round : " + PhotonNetwork.room.GetAttribute(RoomAttributes.ROUNDNUMBER, 0));
        SetImmobilizeAll(false);
    }
コード例 #8
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
    /// <summary>
    /// Mettre un joueur en status "prêt"
    /// </summary>
    public void switchReadyState()
    {
        if (!PhotonNetwork.inRoom &&
            !PhotonNetwork.player.GetAttribute(PlayerAttributes.HASSPAWNED, false) &&
            PhotonNetwork.player.GetPlayerState() != PlayerState.inGame)
        {
            return;
        }
        bool newVal = !PhotonNetwork.player.GetAttribute <bool>(PlayerAttributes.ISREADY, false);

        PhotonNetwork.player.SetAttribute(PlayerAttributes.ISREADY, newVal);
        ChatVik.SendRoomMessage(PhotonNetwork.player.NickName + " is now " + (newVal ? "ready" : "not ready"));
        UpdateReadyBtnState();
    }
コード例 #9
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
    //============================================================================================//

    /// <summary>
    /// Cette méthode vérifie l'état de jeu dans une session en cours.
    /// </summary>
    public void UpdateGameInfos()
    {
        // UPDATE DE LA PARTIE UNIQUEMENT POUR LE MASTERPLAYER
        if (!(PhotonNetwork.player.isGameOwner() && PhotonNetwork.room.GetRoomState() == GameState.RoundRunning))
        {
            return;
        }
        // ON CHECK SI LE TIMER EST ATTEInt OU TOUT LES THIEFS SONT CAPTUREE
        if (PhotonNetwork.playerList.Where(s => s.getTeamID() == 1 && s.GetAttribute(PlayerAttributes.HASSPAWNED, false)).All(s => s.GetAttribute(PlayerAttributes.ISCAPTURED, false)))
        {
            PhotonNetwork.room.SetAttribute(RoomAttributes.ALLTHIEFCATCHED, true);
            ChatVik.SendRoomMessage("COPS CATCH ALL THIEVES AND WIN THE ROUND");
            PhotonNetwork.room.SetTeamAttribute(2, TeamAttributes.ROUNDSWON, PhotonNetwork.room.GetTeamAttribute(2, TeamAttributes.ROUNDSWON, 0) + 1);
            foreach (PhotonPlayer p in PhotonNetwork.playerList.Where(s => s.getTeamID() == 1 || s.getTeamID() == 2))
            {
                p.SetAttribute(PlayerAttributes.ISIMMOBILIZED, true);
            }
            StartCoroutine(FinalizeRound(2));
        }
        else if (PhotonNetwork.ServerTimestamp - PhotonNetwork.room.GetAttribute(RoomAttributes.TIMEROUNDSTARTED, PhotonNetwork.ServerTimestamp) > durationRound)
        {
            int tid_winner = CalculateScores();
            switch (tid_winner)
            {
            case 1:
                ChatVik.SendRoomMessage("THIEVES WIN THE ROUND");
                PhotonNetwork.room.SetTeamAttribute(tid_winner, TeamAttributes.ROUNDSWON, PhotonNetwork.room.GetTeamAttribute(1, TeamAttributes.ROUNDSWON, 0) + 1);
                break;

            case 2:
                ChatVik.SendRoomMessage("COPS WIN THE ROUND");
                PhotonNetwork.room.SetTeamAttribute(tid_winner, TeamAttributes.ROUNDSWON, PhotonNetwork.room.GetTeamAttribute(1, TeamAttributes.ROUNDSWON, 0) + 1);
                break;

            case 0:
                ChatVik.SendRoomMessage("DRAW !");
                break;
            }

            foreach (PhotonPlayer p in PhotonNetwork.playerList.Where(s => s.getTeamID() == 1 || s.getTeamID() == 2))
            {
                p.SetAttribute(PlayerAttributes.ISIMMOBILIZED, true);
            }
            StartCoroutine(FinalizeRound(tid_winner));
        }
    }
コード例 #10
0
    private string fileName; //file name for the chat log

    //public Texture2D chatBG;

    void Awake()
    {
        GameObject SpawnManager = GameObject.Find("Code");

        manager = SpawnManager.GetComponent <GameManagerVik>();


        var dt        = DateTime.Now;
        var timeStamp = String.Format("{0:hh-mm-ss-yyyy-MM-dd}", dt);

        //Access the initial chatlog to see if it is empty
        path     = Application.dataPath;
        fileName = "/ChatLog " + timeStamp + ".txt";
        path     = Application.dataPath + fileName;

        SP = this;
    }
コード例 #11
0
    /// <summary>
    /// On capture un voleur si il se trouve dans la ligne de mire du joueur et que celui ci reste appuyé sur E.
    /// </summary>
    /// <param name="thiefTarget"></param>
    /// <param name="t_thief"></param>
    /// <returns></returns>
    IEnumerator catchThief(PhotonPlayer thiefTarget, Transform t_thief)
    {
        isCapturingThief = true;
        float timeCatching = Time.timeSinceLevelLoad;
        bool  waitCatching = true;

        while (waitCatching && isCapturingThief)
        {
            yield return(new WaitForSeconds(0.5f));

            RaycastHit hitInfo = new RaycastHit();
            bool       hit     = Physics.Raycast(
                transform.forward * 0.3f + transform.position
                , transform.forward
                , out hitInfo
                , 1.2f
                , LayerMask.GetMask("NetEntity"));
            if (Input.GetKey(KeyCode.E) && hit && hitInfo.transform == t_thief)
            {
                if (Time.timeSinceLevelLoad - timeCatching > durationCatch)
                {
                    waitCatching = false;
                }
            }
            else
            {
                isCapturingThief = false;
                yield break;
            }
        }
        if (isCapturingThief)
        {
            if (PhotonNetwork.room.GetRoomState() == GameState.RoundRunning)
            {
                PhotonNetwork.player.AddPlayerScore(CapturePoint);
                PhotonNetwork.player.AddPlayerCaptureScore(1);
                PhotonNetwork.room.AddTeamScore(PhotonNetwork.player.getTeamID(), CapturePoint);
            }

            ChatVik.SendRoomMessage(PhotonNetwork.player.NickName + " has captured " + thiefTarget.NickName);
            thiefTarget.SetAttribute(PlayerAttributes.ISCAPTURED, true);
            t_thief.GetComponent <PhotonView>().RPC("rpc_capture", PhotonTargets.All);
            isCapturingThief = false;
        }
    }
コード例 #12
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
    /// <summary>
    /// Coroutine de jeu : Finalisation d'un match avec une équipe gagnante
    /// </summary>
    /// <param name="winnerTeamId"></param>
    /// <returns></returns>
    IEnumerator FinalizeGame(int winnerTeamId)
    {
        // INIT DES VARIABLES DE NOUVEAU ROUND
        InitRoomAttributes(false);
        PhotonNetwork.room.SetRoomState(GameState.isGameFinishing); // au cas ou
        PhotonNetwork.room.SetAttribute(RoomAttributes.PLAYERSCANSPAWN, false);
        SetImmobilizeAll(true);

        //AFFICHAGE WINNER
        ChatVik.SendRoomMessage("TEAM " + (winnerTeamId == 2 ? "COPS" : "THIEVES") + " WIN THE GAME");
        photonView.RPC("rpc_callWinner", PhotonTargets.All, new object[] { winnerTeamId, true });


        // COMPTE A REBOURG AVANT LE DEBUT DU ROUND
        int timeRoundPreparation = PhotonNetwork.ServerTimestamp;

        foreach (PhotonPlayer p in PhotonNetwork.playerList)
        {
            InitPlayerAttributes(p, false);
        }
        ChatVik.SendRoomMessage("Restart Game in " + (durationRoundFinalize / 1000) + "sec");

        while (PhotonNetwork.ServerTimestamp - timeRoundPreparation < durationRoundFinalize)
        {
            yield return(new WaitForSeconds(1f));

            int time = durationRoundFinalize / 1000 - (PhotonNetwork.ServerTimestamp - timeRoundPreparation - 1000) / 1000;
            if (time == 15 || time == 10 || time <= 5)
            {
                ChatVik.SendRoomMessage("Restart Game in " + time + "sec");
            }
        }

        //DEPOP DES JOUEURS
        foreach (PhotonPlayer p in PhotonNetwork.playerList.Where(w => (w.getTeamID() == 1 || w.getTeamID() == 2) && w.GetAttribute(PlayerAttributes.HASSPAWNED, false)))
        {
            call_UnspawnPlayerAvatar(p);
        }
        PhotonNetwork.room.SetRoomState(GameState.isWaitingNewGame);
    }
コード例 #13
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
    /// <summary>
    /// Faire apparaitre le joueur au point de spawn d'équipe choisit.
    /// </summary>
    public void SpawnMyAvatar()
    {
        if (!PhotonNetwork.inRoom || PhotonNetwork.player.GetAttribute <bool>(PlayerAttributes.HASSPAWNED, false))
        {
            return;
        }

        //bugfix
        ResetCameraTransform();
        //PhotonNetwork.DestroyPlayerObjects(PhotonNetwork.player);
        DestroyPlayerCharacters(PhotonNetwork.player);

        // CREATE AVATAR
        GameObject playerChar;
        Vector2    randpos = UnityEngine.Random.insideUnitCircle * 5f;

        if (PhotonNetwork.player.getTeamID() == 1 || PhotonNetwork.player.getTeamID() == 2)
        {
            playerChar = PhotonNetwork.Instantiate(this.playerprefabname_overlaw, getTeams[PhotonNetwork.player.getTeamID()].TeamSpawnLocation + new Vector3(randpos.x, 0f, randpos.y), Quaternion.identity, 0);
        }
        else
        {
            PhotonNetwork.player.SetAttribute(PlayerAttributes.TEAM, 3);
            playerChar = PhotonNetwork.Instantiate(this.spectatorPrefabName, getTeams[PhotonNetwork.player.getTeamID()].TeamSpawnLocation + new Vector3(randpos.x, 0f, randpos.y), Quaternion.identity, 0);
        }
        PhotonNetwork.player.SetAttribute(PlayerAttributes.HASSPAWNED, true);
        PhotonNetwork.player.SetPlayerState(PlayerState.inGame);

        //SETUP CAMERA
        playerChar.GetComponent <MNG_CameraController>().camera = Camera.main;
        Camera.main.transform.parent           = playerChar.transform;
        Camera.main.transform.localPosition    = new Vector3(0, 0, 0);
        Camera.main.transform.localEulerAngles = new Vector3(0, 0, 0);
        //LOCKING MOUSE
        MNG_MainMenu.captureMouse = true;
        ChatVik.SendRoomMessage(PhotonNetwork.player.NickName + " has spawn as " + getTeams[PhotonNetwork.player.getTeamID()].TeamName);
    }
コード例 #14
0
    /// <summary>
    /// Ici on check les touches pressés si le joeuur n'est pas immobilisé
    /// </summary>
    void Update()
    // Handle rotation here to ensure smooth application.
    {
        if (!photonView.isMine)
        {
            return;
        }


        if (!PhotonNetwork.player.GetAttribute(PlayerAttributes.ISIMMOBILIZED, false)) // immobilization gestion
        {
            if (Input.GetMouseButtonDown(0) &&
                Time.timeSinceLevelLoad - timeCantPunch > durationCantPunch &&
                !_climbing &&
                !_isPrepareToThrow)    // you can only give a slap when you're a thief
            {
                timeCantPunch = Time.timeSinceLevelLoad;
                CTRL_Animation.call_anim_trigger("Punch", layer: 1);

                RaycastHit hitInfo = new RaycastHit();
                bool       hit     = Physics.Raycast(transform.forward * 0.3f + transform.position, transform.forward, out hitInfo, 1.2f, LayerMask.GetMask("NetEntity"));
                if (hit && hitInfo.transform.gameObject.tag == "Player")
                {
                    hitInfo.transform.GetComponent <PhotonView>().RPC("rpc_immobilize", PhotonTargets.All);
                    ChatVik.SendRoomMessage(photonView.owner.NickName + " kick the ass of " + hitInfo.transform.GetComponent <PhotonView>());
                }
            }

            if (Input.GetMouseButton(1) &&
                Time.timeSinceLevelLoad - timeCantShoot > durationCantShoot &&
                !_isPrepareToThrow &&
                !_climbing)     // you can only throw a ball when you're a cop

            {
                timeHoldingShoot = Time.timeSinceLevelLoad;
                StartCoroutine(prepareToThrow());
            }

            if (Input.GetKeyDown(KeyCode.E) &&
                PhotonNetwork.player.getTeamID() == 2 &&
                !isCapturingThief &&
                !_climbing)    // you can only capture when you're a cop

            {
                RaycastHit hitInfo = new RaycastHit();
                bool       hit     = Physics.Raycast(transform.forward * 0.3f + transform.position, transform.forward, out hitInfo, 1.2f, LayerMask.GetMask("NetEntity"));
                if (hit && hitInfo.transform.gameObject.tag == "Player")
                {
                    PhotonPlayer thiefInCatch = hitInfo.transform.GetComponent <PhotonView>().owner;
                    if (thiefInCatch != null && thiefInCatch.getTeamID() == 1)
                    {
                        StartCoroutine(catchThief(thiefInCatch, hitInfo.transform));
                    }
                }
            }


            if (Input.GetButtonDown("Jump") &&
                (grounded || (_climbing)))
            // Handle jumping
            {
                target.AddForce(jumpforce * target.transform.up + target.velocity.normalized * directionalJumpFactor, ForceMode.VelocityChange);
                onJump();
                if (_climbing)
                {
                    CTRL_Animation.call_anim_trigger("ClimbUp", "ClimbUp", layer: 2);
                }
                else
                {
                    CTRL_Animation.call_anim_trigger("Jump");
                }
                timeCantClimbGrab = Time.timeSinceLevelLoad;
                _climbing         = false;
            }
            else if (Input.GetKeyDown(KeyCode.LeftControl) &&
                     _climbing)
            // Handle releasing
            {
                CTRL_Animation.call_anim_trigger("Jump");
                _climbing         = false;
                timeCantClimbGrab = Time.timeSinceLevelLoad;
                target.AddForce(target.transform.up * -0.1f, ForceMode.VelocityChange);
            }
            else if (Input.GetKey(KeyCode.LeftControl) &&
                     !_climbing &&
                     Time.timeSinceLevelLoad - timeCantClimbGrab > durationCantClimbGrab)
            // Handle climbing
            {
                bool canclimb = Physics.CheckSphere(target.transform.position + target.transform.up * checkclimbtop + target.transform.forward * checkclimbforward, 0.2f, groundLayers);

                if (canclimb)
                {
                    CTRL_Animation.call_anim_trigger("Climb", layer: 2);
                    _climbing = true;
                }
            }
        }
    }
コード例 #15
0
ファイル: ChatVik.cs プロジェクト: nguyensitien/SGICollab
    //public Texture2D chatBG;
    void Awake()
    {
        GameObject SpawnManager = GameObject.Find("Code");
        manager = SpawnManager.GetComponent<GameManagerVik>();

        var dt = DateTime.Now;
        var timeStamp = String.Format("{0:hh-mm-ss-yyyy-MM-dd}", dt);

        //Access the initial chatlog to see if it is empty
        path = Application.dataPath;
        fileName = "/ChatLog " + timeStamp + ".txt";
        path = Application.dataPath +fileName;

        SP = this;
    }
コード例 #16
0
ファイル: ChatVik.cs プロジェクト: jiangkuo888/ORP_beta
 void Awake()
 {
     playerTexture = null;
     SP = this;
 }
コード例 #17
0
ファイル: move.cs プロジェクト: BlackW0lf/source
    void Start()
    {
        myPhotonView = gameObject.GetComponent<PhotonView> ();

        GameObject[] players = GameObject.FindGameObjectsWithTag ("Other");

        animation [punch1Animation.name].AddMixingTransform (torso);
        animation [punch2Animation.name].AddMixingTransform (torso);
        animation [punch3Animation.name].AddMixingTransform (torso);
        animation [hit1Animation.name].AddMixingTransform (torso);

        animation [hit1Animation.name].layer = 90;
        animation [punch1Animation.name].layer = 55;
        animation [punch2Animation.name].layer = 55;
        animation [punch3Animation.name].layer = 55;
        animation [jumpAnimation.name].layer = 40;

        animation [runAnimation.name].wrapMode = WrapMode.Loop;// set the animation to loop ..
        animation [deathAnimation.name].wrapMode = WrapMode.ClampForever;// set the animation to loop ..

        //|inov| get chat script and store it for future use
        CHATScript = GameObject.Find ("GameManager").GetComponent<ChatVik> ();

        if (myPhotonView.isMine) {
            //|inov| sets local variable myName to this users name for future use
            myName = PhotonNetwork.playerName;
            //|inov| sends my local name to all other players
            myPhotonView.RPC ("setNameGlobal", PhotonTargets.All, myName);
        }
    }
コード例 #18
0
ファイル: ChatVik.cs プロジェクト: unityosgt/source
 void Awake()
 {
     SP = this;
 }
コード例 #19
0
ファイル: MNG_GameManager.cs プロジェクト: seazth/overlaw
 void OnLeftRoom()
 {
     ChatVik.SendRoomMessage(PhotonNetwork.player.NickName + " leave the game");
     PhotonNetwork.player.SetAttribute(PlayerAttributes.TEAM, 0);
     InitPlayerAttributes(PhotonNetwork.player, false);
 }
コード例 #20
0
ファイル: ChatVik.cs プロジェクト: nguyensitien/SGICollab
 public void Reset()
 {
     SP = this;
 }
コード例 #21
0
 public void Reset()
 {
     SP = this;
 }
コード例 #22
0
ファイル: ChatVik.cs プロジェクト: joel-agora/VideoChat
 void Awake()
 {
     SP = this;
 }