|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class PlayerSpawnPoint : MonoBehaviour {
|
|
|
|
|
|
|
|
public GameObject defaultPlayerPrefab;
|
|
|
|
public int playerNumber;
|
|
|
|
public Weapon startingWeapon;
|
|
|
|
|
|
|
|
void Awake(){
|
|
|
|
|
|
|
|
/*
|
|
|
|
//get selected player from character selection screen
|
|
|
|
if(GlobalGameSettings.Player1Prefab) {
|
|
|
|
loadPlayer(GlobalGameSettings.Player1Prefab);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
GameObject player = null;
|
|
|
|
//otherwise load default character
|
|
|
|
if (defaultPlayerPrefab) {
|
|
|
|
player = loadPlayer(defaultPlayerPrefab);
|
|
|
|
|
|
|
|
if (startingWeapon != null)
|
|
|
|
{
|
|
|
|
player.GetComponent<PlayerCombat>().equipWeapon(startingWeapon);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
Debug.Log("Please assign a default player prefab in the playerSpawnPoint");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//load a player prefab
|
|
|
|
GameObject loadPlayer(GameObject playerPrefab){
|
|
|
|
GameObject player = GameObject.Instantiate(playerPrefab) as GameObject;
|
|
|
|
player.transform.position = transform.position;
|
|
|
|
player.GetComponent<PlayerMovement>().playerNumber = playerNumber;
|
|
|
|
return player;
|
|
|
|
}
|
|
|
|
}
|