浏览代码

Gameplay: Warriors now spawn in a ring, based on ID, instead of a random range.

/main
andytouch 5 年前
当前提交
2395a0e2
共有 2 个文件被更改,包括 27 次插入9 次删除
  1. 13
      InputSystem_Warriors_Project/Assets/Scenes/Scene_Example_Warriors.unity
  2. 23
      InputSystem_Warriors_Project/Assets/Scripts/GameManager.cs

13
InputSystem_Warriors_Project/Assets/Scenes/Scene_Example_Warriors.unity


- target: {fileID: 8145840457835498163, guid: 7040c04d00ad25e4cad0ba1b7d40c3c0,
type: 3}
propertyPath: m_LocalPosition.z
value: -3.22
value: -2.65
objectReference: {fileID: 0}
- target: {fileID: 8145840457835498163, guid: 7040c04d00ad25e4cad0ba1b7d40c3c0,
type: 3}

m_TimeSlicingMode: 0
m_Resolution: 128
m_UpdateFrequency: 0
m_BoxSize: {x: 10, y: 10, z: 10}
m_BoxSize: {x: 100, y: 100, z: 100}
m_BoxOffset: {x: 0, y: 0, z: 0}
m_NearClip: 0.3
m_FarClip: 1000

m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -32.013214}
m_AnchoredPosition: {x: 0, y: -32.013206}
m_SizeDelta: {x: -1, y: -64}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &782418258

spawnMultiplePlayers: 1
playerPrefab: {fileID: 8145840457835730771, guid: 7040c04d00ad25e4cad0ba1b7d40c3c0,
type: 3}
numberOfPlayers: 4
spawnArea: {x: 4, y: 0, z: 4}
numberOfPlayers: 10
spawnRingCenter: {fileID: 1568669756}
spawnRingRadius: 1.7
pauseMenu: {fileID: 1854239559}
--- !u!4 &1134540116
Transform:

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1568669755}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: -0.12, y: 0, z: -2.65}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1134540116}

23
InputSystem_Warriors_Project/Assets/Scripts/GameManager.cs


public bool spawnMultiplePlayers = false;
public GameObject playerPrefab;
public int numberOfPlayers;
public Vector3 spawnArea;
[Header("Spawn Ring Settings")]
public Transform spawnRingCenter;
public float spawnRingRadius;
//Spawned Players
private List<PlayerController> activePlayerControllers;

activePlayerControllers.Insert(i, spawnedPlayer.GetComponent<PlayerController>());
Vector3 randomSpawnPosition = new Vector3(Random.Range(-spawnArea.x, spawnArea.x), 0, Random.Range(-spawnArea.z, spawnArea.z));
spawnedPlayer.transform.position = randomSpawnPosition;
Vector3 spawnPosition = PositionInRing(i);
//Vector3 randomSpawnPosition = new Vector3(Random.Range(-spawnArea.x, spawnArea.x), 0, Random.Range(-spawnArea.z, spawnArea.z));
//spawnedPlayer.transform.position = randomSpawnPosition;
spawnedPlayer.transform.position = spawnPosition;
Quaternion randomSpawnRotation = Quaternion.Euler(new Vector3(0, Random.Range(0, 360), 0));
spawnedPlayer.transform.rotation = randomSpawnRotation;

public List<PlayerController> GetActivePlayerControllers()
{
return activePlayerControllers;
}
Vector3 PositionInRing(int positionID)
{
if(numberOfPlayers == 1)
return spawnRingCenter.position;
float angle = (positionID) * Mathf.PI * 2 / numberOfPlayers;
float x = Mathf.Cos(angle) * spawnRingRadius;
float z = Mathf.Sin(angle) * spawnRingRadius;
return spawnRingCenter.position + new Vector3(x, 0, z);
}
}
正在加载...
取消
保存