Пример #1
0
        public override void Initialize(
            GraphicsDeviceManager g, ContentManager c, SpriteBatch sb,
            int screenHeight, int screenWidth, Session s, Vector3 position)
        {
            base.Initialize(g, c, sb, screenHeight, screenWidth, s, position);
            primaryInput.Initialize(Position);
            foreach (InputDevice id in additionalInput)
            {
                id.Initialize(Position);
            }

            if (region.Shape == ShapeType.Hoop)
            {
                cursor = new Basketball(g, c, Position, Vector3.One, Color.Red);
            }
            else
            {
                cursor = new Ellipsoid(g, c, Position, Vector3.One, Color.Red);
            }

            cursor.Scale = new Vector3(0.02f, 0.02f, 0.02f);

            primaryInput.writeFields(output);
            primaryInput.Handling = inputHandling;
            foreach (InputDevice ID in additionalInput)
            {
                ID.writeFields(output);
                ID.Handling = inputHandling;
            }

            taskData = new TaskData();
            taskData.TaskName = this.Name;
            taskData.Metrics.primary = (int)performanceMetric;
            s.TaskDatas.Add(taskData);

            if ((endCondition.GetType() == typeof(TimeLimitEndCondition) &&  ((TimeLimitEndCondition)endCondition).Type == TimeLimitType.TimeInRegion) ||
                (endCondition.GetType() == typeof(TimeLimitEndCondition) && ((TimeLimitEndCondition)endCondition).Type == TimeLimitType.TimeOutRegion))
                output.addField("IsInRegion");
            output.addField("RegionX1");
            output.addField("RegionX2");
            output.addField("RegionY1");
            output.addField("RegionY2");
            output.addField("RegionZ1");
            output.addField("RegionZ2");

            output.writeHeader();
        }
Пример #2
0
        public override void Initialize(
            GraphicsDeviceManager g, ContentManager c, SpriteBatch sb,
            int screenHeight, int screenWidth, Session s, Vector3 position)
        {
            base.Initialize(g, c, sb, screenHeight, screenWidth, s, position);
            // determine shape size position on parameter type and repetition.
            int l, h;
            foreach (RegionParameter r in region.rParams.Values)
            {
                // update current position x,y,z
                if (r.SL_pos == SpecifierLabel.Static)
                    r.cPos = r.pos[1];
                else if (r.SL_pos == SpecifierLabel.Random)
                {
                    l = (int)((r.pos[0] + 1) * 100);
                    h = (int)((r.pos[1] + 1) * 100);
                    r.cPos = ((float)rand.Next(l, h) / 100) - 1;
                }
                else if (r.SL_pos == SpecifierLabel.Dynamic)
                {
                    if (currRep == 0)
                        r.cPos = r.pos[0];
                    else if (currRep < totalReps)
                        r.cPos += (r.pos[1] - r.pos[0])/(totalReps-1);
                }
                // update current size x,y,z
                if (r.SL_size == SpecifierLabel.Static)
                    r.cSize = r.size[1];
                else if (r.SL_size == SpecifierLabel.Random)
                {
                    l = (int)((r.size[0]) * 100);
                    h = (int)((r.size[1]) * 100);
                    r.cSize = ((float)rand.Next(l, h) / 100);
                }
                else if (r.SL_size == SpecifierLabel.Dynamic)
                {
                    if (currRep == 0)
                        r.cSize = r.size[0];
                    else if (currRep < totalReps)
                        r.cSize += (r.size[1] - r.size[0]) / (totalReps-1);
                }
                // make sure no region is partially outside the coordinate system
                if (region.Shape == ShapeType.Rectangle)
                {
                    if (r.cPos - r.cSize / 2 < -1)
                        r.cPos += (-1 - (r.cPos - r.cSize / 2));
                    else if (r.cPos + r.cSize / 2 > 1)
                        r.cPos -= (-1 + (r.cPos + r.cSize / 2));
                }
                this.swish = c.Load<SoundEffect>("Sounds\\bbswish");
            }

            if (region.Shape == ShapeType.Rectangle)
            {
                rectangle = new Cuboid(g,
                                       c,
                                       new Vector3(((RegionParameter)region.rParams[regPT.X]).cPos, ((RegionParameter)region.rParams[regPT.Y]).cPos, 0.0f),
                                       new Vector3(((RegionParameter)region.rParams[regPT.X]).cSize, ((RegionParameter)region.rParams[regPT.Y]).cSize, 0.0f),
                                       Color.DarkBlue);
            }
            else if (region.Shape == ShapeType.Ellipse)
            {
                ellipse = new Ellipsoid(g,
                                        c,
                                       new Vector3(((RegionParameter)region.rParams[regPT.X]).cPos, ((RegionParameter)region.rParams[regPT.Y]).cPos, 0.0f),
                                       new Vector3(((RegionParameter)region.rParams[regPT.X]).cSize/2, ((RegionParameter)region.rParams[regPT.Y]).cSize/2, 0.0f),
                                       Color.DarkBlue);
            }
            else if (region.Shape == ShapeType.Hoop)
            {
                hoop = new Hoop(g,
                                c,
                                new Vector3(((RegionParameter)region.rParams[regPT.X]).cPos, ((RegionParameter)region.rParams[regPT.Y]).cPos, 0.0f),
                                new Vector3(((RegionParameter)region.rParams[regPT.X]).cSize, ((RegionParameter)region.rParams[regPT.Y]).cSize, 0.0f),
                                Color.DarkBlue);
            }
        }