public void ProcessControlCommand(ServerAction controlCommand)
        {
            errorMessage       = "";
            errorCode          = ServerActionErrorCode.Undefined;
            collisionsInAction = new List <string>();

            lastAction        = controlCommand.action;
            lastActionSuccess = false;
            lastPosition      = new Vector3(transform.position.x, transform.position.y, transform.position.z);
            System.Reflection.MethodInfo method = this.GetType().GetMethod(controlCommand.action);
            this.actionComplete = false;

            try
            {
                if (method == null)
                {
                    errorMessage = "Invalid action: " + controlCommand.action;
                    errorCode    = ServerActionErrorCode.InvalidAction;
                    Debug.LogError(errorMessage);
                    actionFinished(false);
                }
                else
                {
                    method.Invoke(this, new object[] { controlCommand });
                }
            }
            catch (Exception e)
            {
                Debug.LogError("caught error with invoke");
                Debug.LogError(e);

                errorMessage += e.ToString();
                actionFinished(false);
            }
        }
Example #2
0
 //iterates to next allowed downward horizon angle for AgentCamera (max 60 degrees down)
 public virtual void LookDown(ServerAction response)
 {
     if (currentHorizonAngleIndex() > 0)
     {
         float targetHorizon = horizonAngles[currentHorizonAngleIndex() - 1];
         m_Camera.transform.localEulerAngles = new Vector3(targetHorizon, 0.0f, 0.0f);
         actionFinished(true);
     }
     else
     {
         errorMessage = "can't LookDown below the min horizon angle";
         Debug.Log(errorMessage);
         errorCode = ServerActionErrorCode.LookDownCantExceedMin;
         actionFinished(false);
     }
 }
Example #3
0
        //iterates to next allowed upward horizon angle for agent camera (max 30 degrees up)
        public virtual void LookUp(ServerAction controlCommand)
        {
            if (currentHorizonAngleIndex() < horizonAngles.Length - 1)
            {
                float targetHorizon = horizonAngles[currentHorizonAngleIndex() + 1];
                m_Camera.transform.localEulerAngles = new Vector3(targetHorizon, 0.0f, 0.0f);
                actionFinished(true);
            }

            else
            {
                errorMessage = "can't LookUp beyond the max horizon angle";
                Debug.Log(errorMessage);
                errorCode = ServerActionErrorCode.LookUpCantExceedMax;
                actionFinished(false);
            }
        }