Пример #1
0
    public PlayerConnectionObject GetPlayerConnectionObjectFromController(PlayerController playerController)
    {
        //Finding all player objects and connections
        GameObject[] playerControllers = GetAllPlayerObjects();
        GameObject[] playerConnections = GetAllPlayerConnectionObjects();

        //Find id of passed in player controller in array
        int connectionID = 0;

        for (int i = 0; i < playerControllers.Length; i++)
        {
            //If equal
            if (playerController == playerControllers[i])
            {
                //Set id and break out of loop
                connectionID = i;
                break;
            }
        }

        //Get item within array and return
        PlayerConnectionObject connection = playerConnections[connectionID].GetComponent <PlayerConnectionObject>();

        return(connection);
    }
Пример #2
0
    public override void tick()
    {
        if (isComplete)
        {
            return;
        }
        base.tick();

        bool allDied = true;

        foreach (GameObject p in players)
        {
            if (!p)
            {
                continue;
            }
            PlayerConnectionObject pco = p.GetComponent <PlayerConnectionObject>();
            if (!pco)
            {
                continue;
            }
            PlayerData pd = p.GetComponent <PlayerData>();

            if (pd.roundDeathCount <= 0)
            {
                allDied = false;
            }
        }
        if (allDied)
        {
            questCompleted();
        }

        checkAndAddEnemies();
    }
Пример #3
0
    void Start()
    {
        PCO = GetComponentInParent <PlayerConnectionObject>();
        transform.SetParent(null);

        //transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
    }
Пример #4
0
    public override void questCompleted()
    {
        foreach (GameObject p in players)
        {
            if (!p)
            {
                Debug.Log("null player found");
                continue;
            }
            PlayerConnectionObject pco = p.GetComponent <PlayerConnectionObject>();
            if (!pco)
            {
                Debug.Log("pco not found");
                continue;
            }
            PlayerData pd = p.GetComponent <PlayerData>();//pco exists so this should

            if (pd.roundDeathCount <= 0)
            {
                winners.Add(p);
            }
        }


        base.questCompleted();
    }
Пример #5
0
 private void Start()
 {
     PCO = GetComponent <PlayerConnectionObject>();
     this.currentHealth   = this.maxHealth;
     this.initialPosition = this.transform.position;
     PD = GetComponent <PlayerData>();
 }
    void Clock()
    {
        //Time calculations
        float currentHours   = 24.0f * currentTimeOfDay;
        float currentMinutes = 60 * (currentHours - Mathf.Floor(currentHours));

        //If new hour
        if (lastHour != hours)
        {
            Temperature();
            WindSpeed();
            WindAngle();
            lastHour = hours;

            //Update environment
            PlayerConnectionObject host = networkUtils.GetHostPlayerConnectionObject();
            if (host != null)
            {
                host.CmdUpdateEnvironment();
            }
        }

        minutes = Mathf.FloorToInt(currentMinutes);
        hours   = Mathf.FloorToInt(currentHours);
    }
    // Use this for initialization
    void Start()
    {
        thisPlayerConnectionObject = GetComponentInParent <PlayerConnectionObject>();
        playerDistanceSlider       = GetComponent <Slider>();

        RegisterCurrentPlayerGameObject();
        RegisterOpponentPlayerGameObject();
    }
Пример #8
0
 private void Start()
 {
     PCO    = GetComponentInParent <PlayerConnectionObject>();
     active = PCO.active;
     if (active)
     {
         // print("pick up stuff script active");
     }
 }
Пример #9
0
    public void CmdAddLocalAuthority(GameObject go)
    {
        GameObject             goClient = NetworkServer.FindLocalObject(go.GetComponent <NetworkIdentity>().netId);
        NetworkIdentity        ni       = goClient.GetComponent <NetworkIdentity>();
        PlayerConnectionObject pcu      = this.transform.GetComponent <PlayerUnit>().ConnectionObject.GetComponent <PlayerConnectionObject>();

        ni.AssignClientAuthority(pcu.connectionToClient);
        Debug.Log("add authority");
    }
Пример #10
0
 private void Start()
 {
     parentCO = GetComponentInParent <PlayerConnectionObject>();
     active   = parentCO.active;
     if (active)
     {
         //  print("script active");
     }
 }
Пример #11
0
    //Function to update flash light battery across the network.
    public void UpdateFlashLightBattery()
    {
        PlayerConnectionObject host = netUtils.GetHostPlayerConnectionObject();

        if (host != null)
        {
            host.CmdUpdateFlashLightBattery(flashLightBattery, flashLightMaxBattery);
        }
    }
Пример #12
0
    //Function to update flash light status across the network.
    public void UpdateFlashLightStatus()
    {
        PlayerConnectionObject host = netUtils.GetHostPlayerConnectionObject();

        if (host != null)
        {
            host.CmdUpdateFlashLightStatus(flashLightStatus);
        }
    }
Пример #13
0
    private void Start()
    {
        PCO = GetComponent <PlayerConnectionObject>();
        PRD = GetComponent <PlayerReceiveDamage>();

        if (isServer && playerName == "default")
        {
            playerName = "player " + new System.Random().Next(1, 100);
        }
    }
Пример #14
0
    //Function to apply attributes across the network
    void UpdateAttributes()
    {
        //Get host
        PlayerConnectionObject host = netUtils.GetHostPlayerConnectionObject();

        if (host != null)
        {
            //run command on host
            host.CmdUpdatePlayerAttributes(health, maxHealth, stamina, maxStamina);
        }
    }
Пример #15
0
    //Function to update the skill points across the network.
    void UpdateSkillPoints()
    {
        //Apply skills
        ApplySkills();
        //Update skill points
        PlayerConnectionObject host = netUtils.GetHostPlayerConnectionObject();

        if (host != null)
        {
            host.CmdUpdatePlayerSkillPoints();
        }
    }
Пример #16
0
    private void Start()
    {
        PCO              = GetComponentInParent <PlayerConnectionObject>();
        PD               = GetComponentInParent <PlayerData>();
        active           = PCO.active;
        originalRotation = sword.transform.localRotation;

        if (active)
        {
            if (!PCO || !PD)
            {
                Debug.Log("sword couldn't find it's own PCO/PD");
            }
        }
    }
Пример #17
0
    private void OnPlayerDisconnected(NetworkIdentity player)
    {
        Debug.Log("player disconnected");
        PlayerConnectionObject PCO = player.GetComponent <PlayerConnectionObject>();

        if (PCO)
        {
            string disconnectMessage = "Player: ";
            disconnectMessage += PCO.PlayerName + ", has dissconnected";
            TextManager.instance.displayMessageToAll(disconnectMessage, 5);
        }
        else
        {
            Debug.Log("cant find PCO componenet");
        }
    }
Пример #18
0
    public void RpcDisplayGreenMessageToPlayer(GameObject PCOGO, string m)
    {
        if (!PCOGO.GetComponent <NetworkIdentity>().isLocalPlayer)
        {
            return;
        }
        //found target Player object
        PlayerConnectionObject PCO = PCOGO.GetComponent <PlayerConnectionObject>();

        if (!PCO)
        {
            Debug.Log("couldn't find PCO");
            return;
        }

        StartCoroutine(displayGreenMessage(m, 6f));
    }
Пример #19
0
 // Update is called once per frame
 void Update()
 {
     if (targetToMatch)
     {
         transform.rotation = targetToMatch.transform.rotation;
         Debug.Log("rotation = " + targetToMatch.transform.rotation);
         Debug.Log("rotation2 = " + transform.rotation);
     }
     else
     {
         PlayerConnectionObject PCO = GetComponentInParent <PlayerConnectionObject>();
         if (PCO && PCO.playerBoundingCollider)
         {
             targetToMatch = PCO.playerBoundingCollider.gameObject;
         }
     }
 }
Пример #20
0
    private void respawnAllPlayers()
    {
        foreach (GameObject p in GM.players)
        {
            if (!p)
            {
                continue;
            }
            PlayerConnectionObject PCO = p.GetComponent <PlayerConnectionObject>();
            if (!PCO || !PCO.PC)
            {
                continue;
            }

            Vector3 randomPosition = getRandomPositionAboveMap();
            PCO.PC.RpcTeleportObject(randomPosition);
        }
    }
Пример #21
0
 //Function to return the host player, mainly used for command access
 public PlayerConnectionObject GetHostPlayerConnectionObject()
 {
     //Get all players
     GameObject[] playerConnections = GetAllPlayerConnectionObjects();
     //Loop over them
     for (int i = 0; i < playerConnections.Length; i++)
     {
         //Get player connection object
         PlayerConnectionObject playerObject = playerConnections[i].GetComponent <PlayerConnectionObject>();
         //If this is the local player
         if (playerObject.isLocalPlayer == true)
         {
             //returns playerobject;
             return(playerObject);
         }
     }
     return(null);
 }
    public override void OnStartAuthority()
    {
        base.OnStartAuthority();
        ConvertOtherPlayerRigsToRemote();

        Camera[] cameras = GetComponentsInChildren <Camera>(true);
        foreach (Camera cam in cameras)
        {
            cam.enabled = true;
        }

        PlayerConnectionObject[] connections = FindObjectsOfType <PlayerConnectionObject>();
        foreach (PlayerConnectionObject connection in connections)
        {
            if (connection.isLocalPlayer)
            {
                _connection = connection;
                break;
            }
        }

                #if Int_SteamVR
        SteamVR_Camera steamCam = GetComponentInChildren <SteamVR_Camera>();
        if (steamCam != null)
        {
            steamCam.enabled = true;
        }
                #endif

        VRInput[] inputs = GetComponentsInChildren <VRInput>(true);
        foreach (VRInput input in inputs)
        {
            InputReceivedForwarder forwarder = input.gameObject.AddComponent <InputReceivedForwarder>();
            forwarder.networkRig = this;
            if (input.LeftHand)
            {
                leftHand = input.gameObject;
            }
            else
            {
                rightHand = input.gameObject;
            }
        }
    }
Пример #23
0
 // Update is called once per frame
 void Update()
 {
     if (targetToMatch)
     {
         transform.position = new Vector3(targetToMatch.transform.position.x, targetToMatch.transform.position.y, 5f);
         // transform.rotation = targetToMatch.transform.rotation;
     }
     else
     {
         if (PCO)
         {
             if (PCO.playerBoundingCollider)
             {
                 targetToMatch = PCO.playerBoundingCollider.gameObject;
             }
         }
         else
         {
             PCO = GetComponentInParent <PlayerConnectionObject>();
         }
     }
 }
    void RpcResetPlayerConnection()
    {
        //Reset position to 0, 0, 0
        transform.position = new Vector3(0, 0, 0);
        //Reset rotation to 0, 0, 0
        transform.rotation = Quaternion.identity;

        GameObject[] playerConnectionObjects = netUtils.GetAllPlayerConnectionObjects();
        GameObject[] playerObjects           = netUtils.GetAllPlayerObjects();

        //For every player connection
        for (int i = 0; i < playerConnectionObjects.Length; i++)
        {
            //Link connection object to player object
            PlayerConnectionObject playerConnection = playerConnectionObjects[i].GetComponent <PlayerConnectionObject>();
            playerConnection.playerGameObject = playerObjects[i];
            if (playerConnection.isLocalPlayer == true)
            {
                playerConnection.Resync();
            }
        }
    }
Пример #25
0
 void Start()
 {
     parentPCO          = transform.parent.GetComponent <PlayerConnectionObject>();
     CameraComponenet   = GetComponent <Camera>();
     startingCameraSize = CameraComponenet.orthographicSize;
 }
Пример #26
0
 void Start()
 {
     selectWeapon();
     parentPCO = transform.parent.GetComponent <PlayerConnectionObject>();
 }
Пример #27
0
 private void Start()
 {
     PCO    = GetComponentInParent <PlayerConnectionObject>();
     active = PCO.active;
 }