예제 #1
0
    //Gets the table cell which matches the current sector the agent is in
    private TableCell GetCell()
    {
        Point3    currentSector = Point3.DivideRound(AgentManager.instance.playerHead.position - AgentManager.instance.boundingBoxPivot, unitSize) - Point3.one;
        TableCell cell          = logBatch.table.Find(o => o.key.Equals(currentSector));

        if (cell != null)
        {
            return(cell);
        }

        return(FindClosestCell(currentSector));
    }
예제 #2
0
    //success value of each log section is calculated depending on their attributes and set
    private void SetSuccessValue()
    {
        foreach (LogSection section in logSections)
        {
            if (section.logLines.Count <= 1)
            {
                continue;
            }

            float time        = section.logLines[section.logLines.Count - 1].time - section.logLines[0].time;
            int   actionCount = 0;
            float distance    = 0;

            Vector3 oldPosition = Vector3.zero;

            foreach (LogLine line in section.logLines)
            {
                if (line.action == ActionEnum.PressLeft || line.action == ActionEnum.PressRight)
                {
                    actionCount++;
                }

                if (oldPosition == Vector3.zero)
                {
                    oldPosition = line.playerPosition.Vector3;
                }
                else
                {
                    distance   += Vector3.Distance(line.playerPosition.Vector3, oldPosition);
                    oldPosition = line.playerPosition.Vector3;
                }
            }

            if (actionCount > 0)
            {
                section.successValue = distance / (time * actionCount);
            }
            else
            {
                section.successValue = 0;
            }

            //set sector
            section.sector = Point3.DivideRound(section.logLines[0].playerPosition.Vector3 - section.logLines[0].cameraPosition.Vector3 - AgentManager.instance.boundingBoxPivot, AgentManager.instance.unitSize) - Point3.one;
        }
    }
예제 #3
0
    //logger method logs are grouped in log sections and all the body parts of the player is captured
    public void Logger(Vector3 targetPoint)
    {
        if (isRecording)
        {
            if (previousState == StateEnum.InAir && currentState == StateEnum.OnGround)
            {
                if (logSection != null)
                {
                    sessionLog.logSections.Add(logSection);
                }

                logSection        = new LogSection();
                logSection.sector = Point3.DivideRound(AgentManager.instance.playerHead.position - AgentManager.instance.boundingBoxPivot, unitSize) - Point3.one;
            }

            LogLine logLine = new LogLine();

            logLine.time   = Time.time;
            logLine.state  = currentState;
            logLine.action = currentAction;

            logLine.playerPosition = Point3.ToPoint(AgentManager.instance.player.position);

            logLine.cameraPosition = logLine.playerPosition - Point3.ToPoint(AgentManager.instance.playerHead.position);
            logLine.cameraRotation = Point3.ToPoint(AgentManager.instance.playerHead.rotation.eulerAngles);

            logLine.leftHandPosition = logLine.playerPosition - Point3.ToPoint(AgentManager.instance.leftHand.position);
            logLine.leftHandRotation = Point3.ToPoint(AgentManager.instance.leftHand.rotation.eulerAngles);

            logLine.rightHandPosition = logLine.playerPosition - Point3.ToPoint(AgentManager.instance.rightHand.position);
            logLine.rightHandRotation = Point3.ToPoint(AgentManager.instance.rightHand.rotation.eulerAngles);

            logLine.targetPoint = Point3.ToPoint(targetPoint);

            logSection.logLines.Add(logLine);

            previousState = currentState;
        }
    }