private void updateSampling(float delta) { timeCounter += delta; float interval = 1.0f / SampleRate; if(timeCounter > interval) { timeCounter -= interval; //tracks movement and direction if(firstTimeSample || Vector3.Distance(lastSamplePos,PlayerObject.Position) >= SampleDiff) { MovementAction mAction = new MovementAction(); mAction.Record(PlayerObject.Position); ActionTracker.TrackAction(mAction); lastSamplePos = PlayerObject.Position; } if(firstTimeSample || Vector3.Distance(lastSampleDir,PlayerObject.DirectionAngle) >= SampleDiff) { LookAction lAction = new LookAction(); lAction.Record(PlayerObject.DirectionAngle); ActionTracker.TrackAction(lAction); lastSampleDir = PlayerObject.DirectionAngle; } if(firstTimeSample) firstTimeSample = false; } }
/// <summary> /// Create an action from a string line /// </summary> public static Action Create(string line) { Action.ActionTypes actionType = (Action.ActionTypes)int.Parse(line.Substring (0, line.IndexOf (','))); switch(actionType) { case Action.ActionTypes.Movement: MovementAction mAction = new MovementAction(); mAction.Load(line); return mAction; break; case Action.ActionTypes.Look: LookAction lAction = new LookAction(); lAction.Load(line); return lAction; break; case Action.ActionTypes.Interact: InteractAction iAction = new InteractAction(); iAction.Load(line); return iAction; break; case Action.ActionTypes.TextInfo: TextInfoAction tAction = new TextInfoAction(); tAction.Load(line); return tAction; break; case Action.ActionTypes.Teleport: TeleportAction tlAction = new TeleportAction(); tlAction.Load(line); return tlAction; break; default: return null; break; } }