//	public ITracker GetCurrentController()
//	{
//		return current;
//	}
//	public void SetCurrentController (ITracker t)
//	{
//		if (t != null)
//			Controller.SetTracker (t);
//	}
    public void SwitchControllers()
    {
        List <ITracker> trackers = ControllerHandler.GetTrackers();

        current = null;

        int me = -1;

        for (int i = 0; i < trackers.Count; i++)
        {
            if (Controller.GetTracker() == trackers[i])
            {
                me = i;
                break;
            }
        }
        for (int i = 1; i < trackers.Count; i++)
        {
            if (trackers[(me + i) % trackers.Count].gameObject != gameObject)
            {
                Debug.LogWarning("Reached this even if the compiler said we can't");
                current = trackers[(me + i) % trackers.Count];
                break;
            }
        }

        if (current != null)
        {
            MessageSystem.Line.Main.AddMessage(new MessageSystem.Message("" + Controller.name + " set to " + current.name, 0.5f));
            Controller.SetTracker(current);
        }
        ControllerSwitched();
    }
Exemplo n.º 2
0
    public void SwitchControllers()
    {
        //get list of trackers
        List <ITracker> trackers = ControllerHandler.GetTrackers();

        ITracker newTracker = null;

        //find the first on after the current tracker
        int currentIndex = -1;

        for (int i = 0; i < trackers.Count; i++)
        {
            if (Controller.GetRealPositionTracker() == trackers[i])
            {
                currentIndex = i;
                break;
            }
        }

        newTracker = trackers[(currentIndex + 1) % trackers.Count];

        if (newTracker != null)
        {
            //show message
            MessageSystem.Line.Main.AddMessage(new MessageSystem.Message("" + Controller.name + " set to " + newTracker.name, 0.5f));
            //set new tracker
            Controller.SetRealPositionTracker(newTracker);
        }
    }