Inheritance: MonoBehaviour
Exemplo n.º 1
0
 void FindSpawner()
 {
     if (this.spawnPlayers == null)
     {
         this.spawnPlayers = GameObject.FindGameObjectWithTag("PlayerSpawner").GetComponent <SpawnPlayers>();
     }
 }
Exemplo n.º 2
0
    public void SpawnMyPlayer()
    {
        //OnGUI ();

        if (spawnSpots == null)
        {
            Debug.LogError("No Spawns");
            return;
        }

        SpawnPlayers mySpawn = spawnSpots [teamId];

        GameObject myPlayer = (GameObject)PhotonNetwork.Instantiate("Player", mySpawn.transform.position, mySpawn.transform.rotation, 0);

        mapCamera.enabled = false;



        myPlayer.GetComponent <MoveCamera> ().enabled = true;
        myPlayer.GetComponent <Grounded> ().enabled   = true;
        myPlayer.transform.FindChild("Main Camera").gameObject.SetActive(true);
        myPlayer.GetComponent <Crosshair> ().enabled       = true;
        myPlayer.GetComponent <MyPlayerHealth> ().enabled  = true;
        myPlayer.GetComponentInChildren <Pause> ().enabled = true;
        myPlayer.GetComponent <Inv> ().enabled             = true;
        myPlayer.GetComponent <Equipped> ().enabled        = true;
        myPlayer.GetComponent <Zoom> ().enabled            = true;
        myPlayer.GetComponent <Jump> ().enabled            = true;
        myPlayer.GetComponent <Scoreboard> ().enabled      = true;
        //myPlayer.GetComponentInChildren<Respawn> ().enabled = true;
    }
Exemplo n.º 3
0
 void Init()
 {
     Instance = this;
     _tmp = _SpawnPoints.Length + 1;
     _SpawnPoints = GameObject.FindWithTag("Respawn").GetComponentsInChildren<Transform>();
     _HeaderWayPoints = GameObject.FindWithTag("Waypoints");
     if (_Spawn) AddList();
 }
Exemplo n.º 4
0
 public void OnDestroy()
 {
     if (Network.isServer && this.dead)
     {
         Vector3 vector3  = base.transform.position;
         Vector3 vector31 = base.transform.rotation.eulerAngles;
         SpawnPlayers.die(vector3, (int)vector31.y, base.GetComponent <Clothes>().face, base.GetComponent <Clothes>().hair, base.GetComponent <Clothes>().skinColor, base.GetComponent <Clothes>().hairColor);
     }
 }
Exemplo n.º 5
0
    private void NextRace()
    {
        AudioManager.instance.Play("Next Race");

        SelectionManager.CleanUpSelectionManager();
        SpawnRacers.CleanUpSpawnRacers();
        SpawnPlayers.CleanUpSpawnPlayers();

        GameSettings.NavigationMode = 0;

        SceneManager.LoadScene("2 Meadows");
    }
Exemplo n.º 6
0
    private void QuitToMainMenu()
    {
        AudioManager.instance.Play("Cancel");

        SelectionManager.CleanUpSelectionManager();
        SpawnRacers.CleanUpSpawnRacers();
        SpawnPlayers.CleanUpSpawnPlayers();
        ResultsManager.CleanUpResultsManager();
        ResultsManager.initializedScores = false;

        SceneManager.LoadScene("1 Main Menu");
    }
Exemplo n.º 7
0
    //Sets the index of the spawn point used by the player. Used to determine turn order
    private void FindSpawnPoint()
    {
        SpawnPlayers spawner = GameObject.FindGameObjectWithTag("PauseMenu").GetComponentInChildren <SpawnPlayers>();

        foreach (SpawnPoint point in spawner.spawnPoints)
        {
            if (gameObject.transform.position == point.transform.position)
            {
                spawnPoint = spawner.spawnPoints.IndexOf(point);
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     CurrState = State.Intro;
     _allChildrenTransformsPositions = new List <Vector3>();
     _spawnscript = Spawn.GetComponent <SpawnPlayers>();
     // _resetButton.interactable = false;
     ControlsPanel = GameObject.Find("Controls");
     _fast         = false;
     if (FastForwardButtonIcon != null)
     {
         FastForwardButtonIcon.GetComponent <Image>().sprite = slowSpeedIcon;
     }
     _startCameraPos       = CameraMovement.Instance.gameObject.transform.localPosition;
     _startCameraRot       = CameraMovement.Instance.gameObject.transform.localRotation;
     _startCameraParentRot = CameraMovement.Instance.gameObject.transform.parent.rotation;
     _elapsedSlerp         = 0;
 }
Exemplo n.º 9
0
 public void onReady()
 {
     SpawnPlayers.tool  = this;
     SpawnPlayers.model = GameObject.Find(Application.loadedLevelName).transform.FindChild("players").gameObject;
     if (!Network.isServer)
     {
         base.Invoke("spawn", 0.25f);
     }
     else if (ServerSettings.dedicated)
     {
         GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("Prefabs/Game/dedicated"), Vector3.zero, Quaternion.identity);
         gameObject.name             = "dedicated";
         gameObject.transform.parent = SpawnPlayers.model.transform;
     }
     else
     {
         base.Invoke("spawn", 0.25f);
     }
 }
Exemplo n.º 10
0
    // Use this for initialization
    void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.GetComponent <SpawnPlayers>());
        }
        else
        {
            _instance = this;
        }



        if (_playerPrefab == null)
        {
            _playerPrefab = Resources.Load("Prefabs/PlayerMain") as GameObject;
        }


        if (_playerPrefab == null)
        {
            Debug.LogError("PlayerPrefab not found or assigned");

            return;
        }

        _players = new GameObject[_maxPlayers];

        _controllersInUse = new bool[_maxPlayers];

        for (int i = 0; i < _maxPlayers; i++)
        {
            SpawnPlayer();
        }


        for (int i = 0; i < _playersToSpawn; i++)
        {
            ActivatePlayerSpawnPoint();
        }
    }
Exemplo n.º 11
0
    public void loadPositionFromSerial(NetworkPlayer player, string serial)
    {
        if (serial != string.Empty)
        {
            string[] strArrays = Packer.unpack(serial, ';');
            Vector3  vector3   = new Vector3(float.Parse(strArrays[0]), float.Parse(strArrays[1]), float.Parse(strArrays[2]));

            DedicatedServer.CheckPlayer(player, "SpawnPlayers.cs @loadPositionFromSerial");

            if (player != Network.player)
            {
                base.networkView.RPC("tellPosition", player, new object[] { vector3, float.Parse(strArrays[3]) });
            }
            else
            {
                this.tellPosition(vector3, float.Parse(strArrays[3]));
            }
        }
        else
        {
            Transform spawnPoint = SpawnPlayers.getSpawnPoint(player, true);
            if (player != Network.player)
            {
                NetworkView networkView = base.networkView;
                object[]    objArray    = new object[] { spawnPoint.position, null };
                Vector3     vector31    = spawnPoint.rotation.eulerAngles;
                objArray[1] = vector31.y + 90f;
                networkView.RPC("tellPosition", player, objArray);
            }
            else
            {
                Vector3 vector32 = spawnPoint.position;
                Vector3 vector33 = spawnPoint.rotation.eulerAngles;
                this.tellPosition(vector32, vector33.y + 90f);
            }
        }
    }
Exemplo n.º 12
0
    public void askRespawn(bool bed)
    {
        if (this.dead)
        {
            Vector3 vector3  = base.transform.position;
            Vector3 vector31 = base.transform.rotation.eulerAngles;
            SpawnPlayers.die(vector3, (int)vector31.y, base.GetComponent <Clothes>().face, base.GetComponent <Clothes>().hair, base.GetComponent <Clothes>().skinColor, base.GetComponent <Clothes>().hairColor);
            this.health          = 100;
            this.food            = 100;
            this.water           = 100;
            this.sickness        = 100;
            this.bleeding        = false;
            this.startedBleeding = Single.MaxValue;
            this.startedBones    = Single.MaxValue;
            this.bones           = false;
            this.dead            = false;
            this.death           = string.Empty;
            base.GetComponent <Inventory>().load();
            base.GetComponent <Clothes>().load();
            base.GetComponent <Skills>().load();

            // TODO: this is temporary fix!!
            this.loadAllVitalityFromSerial(String.Empty);
            base.GetComponent <Player>().owner.spawned = Time.realtimeSinceStartup;
            if (bed && Time.realtimeSinceStartup - this.lastDied < 20f && NetworkUserList.users.Count > 1 && ServerSettings.pvp)
            {
                bed = false;
            }
            Transform   spawnPoint  = SpawnPlayers.getSpawnPoint(base.networkView.owner, bed);
            NetworkView networkView = base.networkView;
            object[]    objArray    = new object[] { spawnPoint.position, null };
            Vector3     vector32    = spawnPoint.rotation.eulerAngles;
            objArray[1] = Quaternion.Euler(0f, vector32.y + 90f, 0f);
            networkView.RPC("tellStatePosition", RPCMode.All, objArray);
        }
    }
Exemplo n.º 13
0
 void Awake()
 {
     instance = this;
 }