Exemplo n.º 1
0
    void SpawnPlayers()
    {
        for (int spawns = 0; spawns < spawnPoints.Length; spawns++)
        {
            GameObject newPlayer = potentialCharacters[wantedCharacter];
            TwoDimensionalCharacterController thisChar = newPlayer.GetComponent <TwoDimensionalCharacterController>();
            //If the player is player one, set the axes that it can use and store it for later

            //Create an information packet and set all relevant variables needed.
            SpawningInformation thisSpawningInformation = new SpawningInformation();
            thisSpawningInformation.characterToSpawn = charactersInGame[spawns] = newPlayer;
            thisSpawningInformation.spawnpoint       = spawnPoints[spawns];

            if (spawns == 0)
            {
                thisChar.inputSettings.HORIZONTAL_INPUT = "Horizontal";
                thisChar.inputSettings.VERTICAL_INPUT   = "Vertical";
                thisChar.inputSettings.DASH_INPUT       = "gp_P1A";
                thisChar.inputSettings.PROJECTILE_INPUT = /*"gp_P1X"*/ "q";
                thisChar.inputSettings.SUPER_INPUT      = "gp_P1Y";
            }
            else
            {
                thisChar.inputSettings.HORIZONTAL_INPUT = "gp_P2LSX";
                thisChar.inputSettings.VERTICAL_INPUT   = "gp_P2LSY";
                thisChar.inputSettings.DASH_INPUT       = "gp_P2A";
                thisChar.inputSettings.PROJECTILE_INPUT = /* "gp_P2X"*/ "e";
                thisChar.inputSettings.SUPER_INPUT      = "gp_P2Y";
            }

            //Invoke the event necessary to spawn each character.
            EventManager.instance.OnSpawnCharacter.Invoke(thisSpawningInformation);
            //Set max values of each bar
            uiElements.playerHPBar[spawns].maxValue    = charactersInGame[spawns].GetComponent <HealthComponent>().maximumHealth;
            uiElements.playerSuperBar[spawns].maxValue = charactersInGame[spawns].GetComponent <TwoDimensionalCharacterController>().combatSettings.maxSuper;
        }
    }
Exemplo n.º 2
0
 void CreateCharacter(SpawningInformation information)
 {
     //Instantiate the character
     Instantiate(information.characterToSpawn, information.spawnpoint.transform.position, information.spawnpoint.transform.rotation);
 }