void Start() { if (MonAgent.GetMonPrefab() == null) { enabled = false; return; } currentChannelPositions = new List <int>(); segments = new List <GameObject>(); shotsFired = new List <GameObject>(); shotChannels = new List <int>(); damagingShotChannels = new List <int>(); Reset(); }
public void Reset() { int randomValue = Mathf.FloorToInt(Random.value * 3f); switch (randomValue) { case 0: numSegments = 1; shotSpeedPercent = 2f; break; case 1: numSegments = 2; shotSpeedPercent = 1f; break; case 2: numSegments = 4; shotSpeedPercent = 0.5f; break; } currentChannelPositions.Clear(); for (int i = 0; i < segments.Count; i++) { Destroy(segments[i]); } segments.Clear(); StopCoroutine("RunShotsFired"); DestroyShotsFired(); for (int i = 0; i < numSegments; i++) { if (numSegments == 4 && i > 1) { currentChannelPositions.Add((BoardAgent.NumChannels / 2 + (i - 3) * (isDefender ? 1 : -1))); segments.Add(Instantiate(MonAgent.GetMonPrefab(), BoardAgent.ChannelPositionToScreenPosition(currentChannelPositions[i], isDefender) + Vector3.up * BoardAgent.ChannelWidth * (isDefender ? 1f : -1f), rotation) as GameObject); } else { currentChannelPositions.Add((BoardAgent.NumChannels / 2 + (i - 1) * (isDefender ? 1 : -1))); segments.Add(Instantiate(MonAgent.GetMonPrefab(), BoardAgent.ChannelPositionToScreenPosition(currentChannelPositions[i], isDefender), rotation) as GameObject); } segments[i].transform.parent = transform; segments[i].transform.localScale = Vector3.one * BoardAgent.ChannelWidth * 0.75f; } }