コード例 #1
0
    // Use this for initialization
    void Awake()
    {
        LevelEndManager.levelExitEvent += Reset;

        if (FindObjectOfType <PlayerSelectionContainer>() == null)
        {
            editorSpawner.SetActive(true);
            gamePadDevices = new List <InputDevice>();
            GetGamePadDevices();
            playerSelectionContainer = editorSpawner.GetComponent <PlayerSelectionContainer>();
            if (playerSelectionContainer != null)
            {
                if (chosenPlayerIndices.Length > 0 && chosenPlayerIndices.Length != controllerNumber.Length)
                {
                    Debug.Log("Much to learn you still have padawan!");
                }
                else
                {
                    for (int i = 0; i < chosenPlayerIndices.Length; i++)
                    {
                        if (controllerNumber[i] == Controllers.Keyboard)
                        {
                            playerSelectionContainer.playerInputDevices[i] = keyboardDevice;
                        }
                        else if (controllerNumber[i] == Controllers.None)
                        {
                            playerSelectionContainer.playerInputDevices[i] = InputDevice.Null;
                        }
                        else
                        {
                            if ((int)controllerNumber[i] < gamePadDevices.Count)
                            {
                                playerSelectionContainer.playerInputDevices[i] = gamePadDevices[(int)controllerNumber[i]];
                            }
                            else
                            {
                                if (gamePadDevices.Count > 0)
                                {
                                    playerSelectionContainer.playerInputDevices[i] = gamePadDevices[gamePadDevices.Count - 1];
                                }
                                else
                                {
                                    playerSelectionContainer.playerInputDevices[i] = keyboardDevice;
                                }
                            }
                        }

                        playerSelectionContainer.playerActive[i]        = true;
                        playerSelectionContainer.playerPrefabIndices[i] = (int)chosenPlayerIndices[i];
                    }
                    editorSpawner.tag = "GlobalScripts";
                }
            }
        }
        else
        {
            Destroy(this.gameObject);
        }
    }
コード例 #2
0
    private void GatherNeededReferences()
    {
        //getting all the character menu manager scripts
        GameObject[]         go = GameObject.FindGameObjectsWithTag("CharacterMenuManager");
        CharacterMenuManager characterMenuManager;

        if (go != null)
        {
            for (int i = 0; i < go.Length; i++)
            {
                characterMenuManager = go[i].GetComponent <CharacterMenuManager>();
                characterMenuManager.SetMenuInputActive(false);
                slots.Add(new SlotContainer(characterMenuManager, null));
            }
            SortSlots();
        }
        else
        {
            Debug.LogError("No CharacterMenuManager found!");
        }


        //getting the player selection container
        GameObject g1 = GameObject.FindGameObjectWithTag("GlobalScripts");

        if (g1 != null)
        {
            playerSelectionContainer = g1.GetComponent <PlayerSelectionContainer>();
            if (playerSelectionContainer == null)
            {
                Debug.LogError("No PlayerSelectionContainer found!");
            }
        }
        else
        {
            Debug.LogError("No Global Scripts GameObject found!");
        }

        //getting the character selection helper
        GameObject g2 = GameObject.FindGameObjectWithTag("CharacterMenuHelper");

        if (g2 != null)
        {
            characterSelectionHelper = g2.GetComponent <CharacterSelectionHelper>();
            if (characterSelectionHelper == null)
            {
                Debug.LogError("Chracter Selection Helper is null!");
            }
        }
        else
        {
            Debug.LogError("No Character Selection GameObject found!");
        }
    }
コード例 #3
0
    private void SaveLevelIntoSelectionContainer()
    {
        PlayerSelectionContainer container = GameObject.FindGameObjectWithTag("GlobalScripts").GetComponent <PlayerSelectionContainer>();

        if (container != null)
        {
            container.levelName = levelNameForPlayerContainer;
        }
        else
        {
            Debug.LogError("No selection container was found!");
        }
    }
コード例 #4
0
    private void Start()
    {
        playerActions = PlayerControlActions.CreateWithGamePadBindings();
        gameObject.transform.position = startPosition;

        gradient = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>().GetComponent <GradientImageEffect>();

        menuManager         = GetComponentInChildren <AbstractMenuManager>();
        menuManager.enabled = false;
        menuManager.SetMenuInputActive(false);

        LevelEndManager.levelExitEvent += DeRegister;

        playerActionList = new List <PlayerControlActions>();
        GameObject g = GameObject.FindGameObjectWithTag("GlobalScripts");

        if (g != null)
        {
            playerSelectionContainer = g.GetComponent <PlayerSelectionContainer>();
            if (playerSelectionContainer != null)
            {
                for (int i = 0; i < playerSelectionContainer.playerInputDevices.Length; i++)
                {
                    if (playerSelectionContainer.playerInputDevices[i] != null)
                    {
                        PlayerControlActions p = PlayerControlActions.CreateWithGamePadBindings();
                        p.Device = playerSelectionContainer.playerInputDevices[i];
                        playerActionList.Add(p);
                    }
                }
            }
        }


        steamManager = SteamManager.Instance;
        if (steamManager != null)
        {
            steamManager.OnOverlayActivated += OnOverlayActivated;
        }

        PlayerManager.AllPlayersDeadEventHandler += () => {
            gameEnded = true;
        };
    }
コード例 #5
0
    private void GetLevelName()
    {
        GameObject g = GameObject.FindGameObjectWithTag("GlobalScripts");

        if (g != null)
        {
            playerSelectionContainer = g.GetComponent <PlayerSelectionContainer>();
            if (playerSelectionContainer != null)
            {
                levelName = playerSelectionContainer.levelName;
            }
            else
            {
                Debug.LogError("No Player Selection Container Component found!");
            }
        }
        else
        {
            Debug.LogError("No Global Scripts Gameobject found!");
        }
    }
コード例 #6
0
    private void Start()
    {
        //If there are more spawn points, choose the first one.
        if (spawnPosition == null && GameObject.FindGameObjectsWithTag("PlayerSpawn").Length > 0)
        {
            spawnPosition = GameObject.FindGameObjectsWithTag("PlayerSpawn")[0].transform;
        }

        playerSlot = new bool[4];


        rumbleManager = RumbleManager.Instance;
        if (rumbleManager == null)
        {
            Debug.LogError("Rumblemanager is null");
        }

        GameObject g = GameObject.FindGameObjectWithTag("GlobalScripts");

        if (g != null)
        {
            playerSelectionInformation = g.GetComponent <PlayerSelectionContainer>();
            if (playerSelectionInformation != null)
            {
                //Assign the used slots
                if (playerSelectionInformation != null)
                {
                    for (int i = 0; i < playerSlot.Length; i++)
                    {
                        GameObject prefab;

                        if (playerSelectionInformation.playerActive[i])
                        {
                            playerSlot[i] = true;
                            prefab        = Instantiate(playerSelectionInformation.playerPrefabs[playerSelectionInformation.playerPrefabIndices[i]]) as GameObject;
                            prefab.GetComponent <NavMeshAgent>().enabled = false;
                            prefab.transform.position = spawnPosition.position;
                            prefab.GetComponent <BasePlayer>().InputDevice   = playerSelectionInformation.playerInputDevices[i];
                            prefab.GetComponent <BasePlayer>().RumbleManager = rumbleManager;
                            prefab.GetComponent <NavMeshAgent>().enabled     = true;
                            OnPlayerJoined();
                        }
                        else
                        {
                            playerSlot[i] = false;
                        }
                    }
                }
            }
            else
            {
                Debug.LogError("No Player Selection Container found!");
            }
        }
        else
        {
            Debug.Log("No Global Scripts GameObject found");
        }



        playTime    = new TimeUtil();
        startTime   = 0f;
        measureTime = true;

        // start session
        DataCollector.instance.startSession();
        TrackControllerTypes();
    }
コード例 #7
0
    private void Start()
    {
        PlayerSelectionContainer playerInfos = GameObject.FindObjectOfType <PlayerSelectionContainer>();

        playerInfos.ResetPlayers();
    }