void Start()
    {
        // Handle Level Generation
        levelManagement.generateLevel(Guid.NewGuid().ToString());

        //Spawn Players In

        List <int> playerIndexes = new List <int>();

        Debug.Log(SharedData.player1Joined);
        if (SharedData.player1Joined)
        {
            playerIndexes.Add(1);
        }
        if (SharedData.player2Joined)
        {
            playerIndexes.Add(2);
        }
        if (SharedData.player3Joined)
        {
            playerIndexes.Add(3);
        }
        if (SharedData.player4Joined)
        {
            playerIndexes.Add(4);
        }

        foreach (int index in playerIndexes)
        {
            Debug.Log(index);
            GameObject obj  = Instantiate(playerPrefab, levelManagement.GetGameObjectSpawnLocation(), Quaternion.identity);
            string     name = "Player " + index;
            Debug.Log(obj.transform.position);
            obj.GetComponent <PlayerMovement>().setChildTag(name);
            obj.GetComponent <PlayerInteraction>().tagSetup(index);
            obj.name = name;
            playerList[index - 1] = obj;
        }

        var values = Enum.GetValues(typeof(Item));

        foreach (Item item in values)
        {
            itemSpawner.SpawnItem(item, levelManagement.GetGameObjectSpawnLocation() + new Vector3(0, 1, 0));
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        movement.x = -Input.GetAxisRaw(verticalInputAxis);
        movement.z = -Input.GetAxisRaw(horizontalInputAxis);

        if (transform.position.y <= playerKillY)
        {
            rb.velocity        = Vector3.zero;
            transform.position = levelManagement.GetGameObjectSpawnLocation();
        }
    }