示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("TestScene"))
        {
            if (!LoadedScene)
            {
                Cursor.visible   = false;
                Cursor.lockState = CursorLockMode.Locked;
                LoadedScene      = true;
            }

            if (OverlayActive.IsOverlayActive())
            {
                Cursor.visible   = true;
                Cursor.lockState = cursorLockMode;
            }
            else
            {
                Cursor.visible   = false;
                Cursor.lockState = CursorLockMode.Locked;
            }
        }
        else
        {
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.None;
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (isLocalPlayer)
        {
            OnOverlayActive(!OverlayActive.IsOverlayActive());

            if (GetComponent <Health>().currentHealth <= 0.0f && isDead == false)
            {
                Die();
            }
            else if (isDead)
            {
                //GetComponent<Rigidbody>().AddForce(0, -500, 0);
                //**Dropping Down code****/
                this.gameObject.transform.position += Vector3.down * 2;
                this.gameObject.transform.Rotate(0, 0, 5);
                //************************/
                if (killerName != "")
                {
                    if (killerName != this.name)
                    {
                        GetComponent <PlayerSetup>().GetPlayerUI().GetRespawnScreen().SetKillerText(killerName);
                    }
                    else
                    {
                        GetComponent <PlayerSetup>().GetPlayerUI().GetRespawnScreen().SetKillerText("Myself");
                    }
                }

                respawnTimer -= Time.deltaTime;
                GetComponent <PlayerSetup>().GetPlayerUI().GetRespawnScreen().SetRespawnTimerText(((int)respawnTimer).ToString());

                if (respawnTimer <= 1f)
                {
                    Respawn();
                }
            }

            // For testing
            if (Input.GetKeyDown(KeyCode.K))
            {
                GetComponent <Health>().currentHealth = 0;
                killerName = this.gameObject.name;
            }

            updateInterval += Time.deltaTime;
            if (updateInterval > 0.11f)
            {
                CmdSync(isDead, hasRespawned);
            }
        }
        else
        {
            isDead       = real_isDead;
            hasRespawned = real_hasRespawned;
            RemotePlayerDead();
        }
    }
示例#3
0
    void Start()
    {
        NetworkManager.singleton.GetComponent <MatchTimer>().enabled = true;
        OverlayActive.SetOverlayActive(false);

        //PauseMenu.isOn = false;

#if !UNITY_ANDROID
        joystick.SetActive(false);
        pauseButton.SetActive(false);
        scoreboardButton.SetActive(false);
#else
        joystick.SetActive(true);
        pauseButton.SetActive(true);
        scoreboardButton.SetActive(true);
#endif
    }
示例#4
0
	// Use this for initialization
	void Start () 
    {
        player = NetworkManager.singleton.playerPrefab;

        OverlayActive.SetOverlayActive(true);

        // Stop rendering stuff
        //player.GetComponent<Renderer>().enabled = false;

        //GameObject.Find("skydome").SetActive(false);
        //GameObject.Find("MapGenerator").SetActive(false);
        //GameObject.Find("Terrain").SetActive(false);
        //GameObject.Find("WorldSpawner").SetActive(false);
        //GameObject.Find("HealthBarManager").SetActive(false);

        // Set winner/loser text
        playersGO = GameObject.FindGameObjectsWithTag("Player");
        if (playersGO.Length > 1)
        {
            for (int i = 0; i < playersGO.Length - 1; ++i)
            {
                if (playersGO[i].GetComponent<Player>().GetKills() > playersGO[i + 1].GetComponent<Player>().GetKills())
                    matchWinner = playersGO[i];
                else if (playersGO[i].GetComponent<Player>().GetKills() < playersGO[i + 1].GetComponent<Player>().GetKills())
                    matchWinner = playersGO[i + 1];
                else
                    matchWinner = null;
            }
        }
        else
        {
            matchWinner = player;
        }

        if (matchWinner == player)
            matchWinnerText.text = "Winner";
        else if (matchWinner != null)
            matchWinnerText.text = "Loser";
        else
            matchWinnerText.text = "Neutral";
	}
示例#5
0
    void Update()
    {
        if (!playerScript.isLocalPlayer || OverlayActive.IsOverlayActive())
        {
            return;
        }

        //Debug.Log(playerScript.name);

        // Rotate
        //UpdatePitch();
        //UpdateYaw();

        // Update rotation values
        float playerPitch = playerScript.GetPitch();
        float playerYaw   = playerScript.GetYaw();

        if (this.pitch != playerPitch)
        {
            if (this.pitch < playerPitch)
            {
                this.pitch += (playerPitch - this.pitch) * changeSpeed * Time.deltaTime;
                if (this.pitch > playerPitch)
                {
                    this.pitch = playerPitch;
                }
            }
            else
            {
                this.pitch -= (this.pitch - playerPitch) * changeSpeed * Time.deltaTime;
                if (this.pitch < playerPitch)
                {
                    this.pitch = playerPitch;
                }
            }
        }
        if (this.yaw != playerYaw)
        {
            if (this.yaw < playerYaw)
            {
                this.yaw += (playerYaw - this.yaw) * changeSpeed * Time.deltaTime;
                if (this.yaw > playerYaw)
                {
                    this.yaw = playerYaw;
                }
            }
            else
            {
                this.yaw -= (this.yaw - playerYaw) * changeSpeed * Time.deltaTime;
                if (this.yaw < playerYaw)
                {
                    this.yaw = playerYaw;
                }
            }
        }
        //this.pitch = playerScript.GetPitch();
        //this.yaw = playerScript.GetYaw();

        this.roll = playerScript.GetRoll();

        // rotate player
        //player.transform.eulerAngles = new Vector3(-pitch, yaw, -yaw * 0.5f);

        // move camera
        this.transform.position = player.transform.position;
        this.transform.Translate(positionOffset);
        //Quaternion destRotate = Quaternion.Euler(-playerPitch + 30f, playerYaw, roll);
        ////Vector3 destination = player.transform.position + positionOffset;
        //Vector3 destination = positionOffset;
        //destination = destRotate * destination + player.transform.position;
        //Vector3 moveDir = (destination - this.transform.position).normalized;
        //this.transform.position += moveDir * Time.deltaTime * 500f;
        //
        //Vector3 dist = destination - this.transform.position;
        //double cosOfAngle = (moveDir.x * dist.x + moveDir.y * dist.y + moveDir.z * dist.z);
        //if (cosOfAngle < 0)     // -ve, parallel & opp direction
        //{
        //    this.transform.position = destination;
        //}

        // rotate camera
        this.transform.eulerAngles = new Vector3(-pitch + cameraPitchOffset, yaw, roll);

        // rotate up vector
        //float playerRoll = playerScript.GetRoll();
        //this.transform.up = new Vector3(playerRoll, 0f, 0f);
        //Vector3 right = Vector3.Cross(playerScript.GetView(), this.transform.up);
        //right.y = 0f;
        //right.Normalize();
        //this.transform.up = Vector3.Cross(right, playerScript.GetView());

        // rotate view vector
        //Quaternion rotation = Quaternion.Euler(-pitch, yaw, 0f);
        //playerScript.SetView(new Vector3(0, 0, 1));
        //playerScript.SetView(rotation * playerScript.GetView());

        // change target
        Quaternion euler = Quaternion.Euler(-pitch + cameraPitchOffset, yaw, 0f);

        cameraDir = euler * new Vector3(0, 0, 1);
        target.transform.position = this.transform.position + 1000f * cameraDir;
    }
示例#6
0
 public void SetInactive()
 {
     OverlayActive.SetOverlayActive(false);
 }
示例#7
0
 public void SetActive()
 {
     OverlayActive.SetOverlayActive(true);
 }
示例#8
0
 public void ToggleRespawnScreen()
 {
     respawnScreen.SetActive(!respawnScreen.activeSelf);
     OverlayActive.SetOverlayActive(!OverlayActive.IsOverlayActive());
 }
示例#9
0
 public void TogglePauseMenu()
 {
     pauseMenu.SetActive(!pauseMenu.activeSelf);
     OverlayActive.SetOverlayActive(!OverlayActive.IsOverlayActive());
     //PauseMenu.isOn = pauseMenu.activeSelf;
 }