Ejemplo n.º 1
0
        private void server_CreateNewTarget()
        {
            lastTarget = targets[currentTarget].gameObject;

            int nextTarget = currentTarget + 8;

            if (experiment.Trial.TrialNro % 2 == 1)
            {
                nextTarget++;
            }
            nextTarget = nextTarget % targets.Count;

            bool doneAllDists  = true;
            bool doneAllWidths = true;


            foreach (bool done in doneDistances)
            {
                if (!done)
                {
                    doneAllDists = false;
                }
            }

            foreach (bool done in doneWidths)
            {
                if (!done)
                {
                    doneAllWidths = false;
                }
            }


            experiment.Trial.TrialNro++;
            if (experiment.Trial.TrialNro == NumberOfTrials)
            {
                if (doneAllWidths && doneAllDists)//&& doneZones[1] && doneZones[2]) //all zones are done, experiment finishes
                {
                    nextTarget = -1;

                    all_SetTargetAndTrial(-1, -1);
                    if (Network.isServer)
                    {
                        //if (Network.isClient || Network.isServer)
                        networkView.RPC("all_SetTargetAndTrial", RPCMode.Others, -1, -1);
                    }

                    GameObject osStart1 = TargetSet;
                    GameObject osEnd1   = TargetSet;
                    all_SynchOffScreenTargets(osStart1.name, osEnd1.name);
                    if (Network.isServer)
                    {
                        //if (Network.isClient || Network.isServer)
                        networkView.RPC("all_SynchOffScreenTargets", RPCMode.Others, osStart1.name, osEnd1.name);
                    }

                    Screen.lockCursor = false;

                    return;
                }
                else
                {
                    // Change width, reset distances
                    if (doneAllDists && !doneAllWidths)
                    {
                        TargetWidths newWidth = (TargetWidths)UnityEngine.Random.Range(0, doneWidths.Length);
                        while (doneWidths[(int)newWidth])
                        {
                            newWidth = (TargetWidths)UnityEngine.Random.Range(0, doneWidths.Length);
                        }

                        all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), newWidth.ToString(), TargetDistance.ToString());
                        if (Network.isClient || Network.isServer)
                        {
                            networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), newWidth.ToString(), TargetDistance.ToString());
                        }
                        doneWidths[(int)newWidth] = true;

                        for (int dist = 0; dist < doneDistances.Length; dist++)
                        {
                            doneDistances[dist] = false;

                            // Do not do distances that will put targets out of view in view based.
                            if (RefFrame == ReferenceFrame.View && dist > 1)
                            {
                                doneDistances[dist] = true;
                            }
                            // Do not do distances that are all in view
                            else if (RefFrame == ReferenceFrame.Body && dist < 2)
                            {
                                doneDistances[dist] = true;
                            }
                        }
                    }
                    // Change distance keep width
                    else
                    {
                        TargetDistances newDistance = (TargetDistances)UnityEngine.Random.Range(0, doneDistances.Length);
                        while (doneDistances[(int)newDistance])
                        {
                            newDistance = (TargetDistances)UnityEngine.Random.Range(0, doneDistances.Length);
                        }

                        all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), newDistance.ToString());
                        if (Network.isClient || Network.isServer)
                        {
                            networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), newDistance.ToString());
                        }
                        doneDistances[(int)newDistance] = true;
                    }
                }

                nextTarget = UnityEngine.Random.Range(0, targets.Count);
                experiment.Trial.TrialNro = 0;
            }

            all_SetTargetAndTrial(nextTarget, experiment.Trial.TrialNro);
            if (Network.isServer)
            {
                //if (Network.isClient || Network.isServer)
                networkView.RPC("all_SetTargetAndTrial", RPCMode.Others, nextTarget, experiment.Trial.TrialNro);
            }

            //creates the offscreen targeting objects
            GameObject osStart2 = lastTarget;
            GameObject osEnd2   = targets[currentTarget].gameObject;

            all_SynchOffScreenTargets(osStart2.name, osEnd2.name);
            if (Network.isServer)
            {
                //if (Network.isClient || Network.isServer)
                networkView.RPC("all_SynchOffScreenTargets", RPCMode.Others, osStart2.name, osEnd2.name);
            }
        }
Ejemplo n.º 2
0
        private void server_StartExperiment()
        {
            //Unhighlights everything
            for (int index = 0; index < targets.Count; index++)
            {
                targets[index].Highlighted = false;
            }

            //resets the zones to false
            for (int zone = 0; zone < doneZones.Length; zone++)
            {
                doneZones[zone] = false;
            }

            //reset widths to false
            for (int width = 0; width < doneWidths.Length; width++)
            {
                doneWidths[width] = false;
            }

            //reset distances to false
            for (int dist = 0; dist < doneDistances.Length; dist++)
            {
                doneDistances[dist] = false;

                // Do not do distances that will put targets out of view in view based.
                if (RefFrame == ReferenceFrame.View && dist > 1)
                {
                    doneDistances[dist] = true;
                }
                // Do not do distances that are all in view
                else if (RefFrame == ReferenceFrame.Body && dist < 2)
                {
                    doneDistances[dist] = true;
                }
            }

            //determines the initial zone (fixed to control for purposes of ring experiment)
            DistanceZones newZone = DistanceZones.Control;
            //determines initial width
            TargetWidths newWidth = (TargetWidths)UnityEngine.Random.Range(0, doneWidths.Length);

            while (doneWidths[(int)newWidth])
            {
                newWidth = (TargetWidths)UnityEngine.Random.Range(0, doneWidths.Length);
            }
            //determines initial distance
            TargetDistances newDistance = (TargetDistances)UnityEngine.Random.Range(0, doneDistances.Length);

            while (doneDistances[(int)newDistance])
            {
                newDistance = (TargetDistances)UnityEngine.Random.Range(0, doneDistances.Length);
            }

            all_UpdateReferenceFrame(newZone.ToString(), RefFrame.ToString(), newWidth.ToString(), newDistance.ToString());
            if (Network.isClient || Network.isServer)
            {
                networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, newZone.ToString(), RefFrame.ToString(), newWidth.ToString(), newDistance.ToString());
            }
            doneZones[(int)newZone]         = true;
            doneWidths[(int)newWidth]       = true;
            doneDistances[(int)newDistance] = true;

            //Creates the trial tracking objects
            int nextTarget = UnityEngine.Random.Range(0, targets.Count);

            all_SetTargetAndTrial(nextTarget, 0);
            if (Network.isServer)
            {
                //if (Network.isClient || Network.isServer)
                networkView.RPC("all_SetTargetAndTrial", RPCMode.Others, nextTarget, experiment.Trial.TrialNro);
            }

            lastTarget = TargetSet;

            //creates the offscreen targeting objects
            GameObject osStart = GetInteractionZoneGO();
            GameObject osEnd   = targets[currentTarget].gameObject;

            all_SynchOffScreenTargets(osStart.name, osEnd.name);
            if (Network.isServer)
            {
                //if (Network.isClient || Network.isServer)
                networkView.RPC("all_SynchOffScreenTargets", RPCMode.Others, osStart.name, osEnd.name);
            }
        }