private void EventEnterChannel() { EventDropShade(transform.localPosition, Utility.InverseDirection(direction)); transform.SetParent(transform.parent.parent); transform.SetAsLastSibling(); Vector3 worldPosition = GetComponent <RectTransform>().localPosition; position = Utility.WorldToArrayPosition(gameManager.loadedLevel, worldPosition, direction); if (position.x < 0 || position.x >= gameManager.loadedLevel.size.x || position.y < 0 || position.y >= gameManager.loadedLevel.size.y || currentChannel.GetComponent <BehaviourChannel>().isRotating) { Debug.LogError("Cause:\nOut of map bounds"); EventDeath(); return; } else { currentChannel = gameManager.loadedLevel.channels[(int)position.y, (int)position.x].GetComponent <BehaviourChannel>(); currentChannel.GetComponent <BehaviourChannel>().EventPlacedShade(this); int channelID = currentChannel.GetComponent <BehaviourChannel>().channelID; int channelOrientation = currentChannel.GetComponent <BehaviourChannel>().GetOrientation(); bool[] paths = Utility.InnateChannels(channelID, channelOrientation); if (!paths[Utility.InverseDirection(direction)]) { Debug.LogError("Cause:\nNo receipient channel"); EventDeath(); return; } transform.SetParent(currentChannel.transform); transform.parent.transform.SetAsLastSibling(); currentChannel.EventEnteredChannel(this); EventDropShade(transform.localPosition, direction); } }
public void Start() { frozen = true; currentChannel = GetCurrentChannel(); moveScale = new Vector3(gameManager.loadedLevel.channelSize * thinkInterval * ballSpeed, gameManager.loadedLevel.channelSize * thinkInterval * ballSpeed, 0); elapsed = 0; sum = 0; }
public int[,,] GetMap() { int[,,] map = new int[(int)size.y, (int)size.x, 3]; for (var y = 0; y < (int)size.y; y++) { for (var x = 0; x < (int)size.x; x++) { BehaviourChannel channel = channels[y, x].GetComponent <BehaviourChannel>(); int[] data = channel.GetData(); map[y, x, 0] = data[0]; map[y, x, 1] = data[1]; map[y, x, 2] = data[2]; } } return(map); }
private BehaviourChannel GetCurrentChannel() { BehaviourChannel channel = gameManager.loadedLevel.channels[Mathf.RoundToInt(position.y), Mathf.RoundToInt(position.x)].GetComponent <BehaviourChannel>(); return(channel); }