void Start() { m_theghosts = GameObject.FindObjectsOfType <TrapPlayerController>(); m_trapmanager = GameObject.FindObjectOfType <TrapManager>(); Debug.Log(m_trapplayerindex); m_theghosts[m_trapplayerindex].m_selectedtrap = m_trapplayerindex; m_trapmanager.GetTrap(m_selectedtrap).UseThisTrap(true); }
void Update() { if (Input.GetKeyDown(player_nexttrapkey)) { int newtrapindex = m_trapmanager.GetNextTrap(m_selectedtrap); if (newtrapindex != m_selectedtrap) { m_trapmanager.GetTrap(m_selectedtrap).UseThisTrap(false); m_trapmanager.GetTrap(newtrapindex).UseThisTrap(true); m_selectedtrap = newtrapindex; } } if (Input.GetKeyDown(player_previoustrapkey)) { int newtrapindex = m_trapmanager.GetPreviousTrap(m_selectedtrap); if (newtrapindex != m_selectedtrap) { m_trapmanager.GetTrap(m_selectedtrap).UseThisTrap(false); m_trapmanager.GetTrap(newtrapindex).UseThisTrap(true); m_selectedtrap = newtrapindex; } } transform.position = m_activationposition[m_selectedtrap].position; if (m_trapmanager.GetTrap(m_selectedtrap).PlayerMayPress()) { if (Input.GetKeyDown(player_activatetrapkey)) { m_trapmanager.ActivateTrap(m_selectedtrap); } } }