コード例 #1
0
 void Update()
 {
     if (robotVision != null)
     {
         List <GameObject> objectsInFildOfVision = robotVision.getListOfElements();
         List <GameObject> objectsInSmellSense   = robotSmell.getListOfElements();
         List <GameObject> objectsInHearingSense = robotHearing.getListOfElements();
         List <GameObject> objectsInTasteSense   = robotTaste.getListOfElements();
         List <GameObject> objectsInTouchSense   = robotTouch.getListOfElements();
         List <GameObject> allObjectsInSenses    = objectsInFildOfVision.Union(objectsInSmellSense).ToList();
         allObjectsInSenses   = allObjectsInSenses.Union(objectsInHearingSense).ToList();
         allObjectsInSenses   = allObjectsInSenses.Union(objectsInTouchSense).ToList();
         allPerceivedElements = new HashSet <GameObject>(allObjectsInSenses);
         List <GameObject> auxGOLocations = new List <GameObject>(getElementsOfTagType(allObjectsInSenses, Constants.TAG_LOCATION));
         auxGOLocations.AddRange(locationsOnScene);
         objectsList = new List <GameObject>(getElementsOfTagType(allObjectsInSenses, Constants.TAG_OBJECT));
         switchsList = new List <GameObject>(getElementsOfTagType(allObjectsInSenses, Constants.TAG_SWITCH));
         //doorsList = new List<GameObject>(getElementsOfTagType(objectsInFildOfVision, Constants.TAG_DOOR));
         locationsList = new List <GameObject>(auxGOLocations);
     }
     if (commandsQueue.Count > 0 & manageExecution())
     {
         execute(commandsQueue.Dequeue());
     }
 }
コード例 #2
0
    /*void FixedUpdate () {
     *
     *  if (count % sensesRefreshRate == 0)
     *  {
     *      //Vision
     *      objectsInFildOfVision = vision.getListOfElements();
     *      //Hear
     *      soundsInHearing = hearing.getListOfElements();
     *      knowObjInHearing = objectsInFildOfVision.Intersect(soundsInHearing).ToList();
     *      foreach (GameObject obj in knowObjInHearing)
     *      {
     *          soundsInHearing.Remove(obj);
     *      }
     *      //Smell
     *      odorInSmell = smell.getListOfUnknowElements();
     *      //Touch
     *      knowObjInTouch = touch.getListOfKnowElements();
     *      touchInTouch = touch.getListOfUnknowElements();
     *
     *
     *      insertVision(objectsInFildOfVision);
     *  }
     *  if (count % triggerRefreshRate == 0)
     *  {
     *      knowObjInSmell = smell.getListOfKnowElements();
     *      //Taste
     *      objectsInTaste = taste.getListOfElements();
     *  }
     *  count++;
     * }*/

    void FixedUpdate()
    {
        if (getSensesCommand != null)
        {
            switch (getSensesCommand.getActionStateID())
            {
            case (int)GetSenses.Start:
                //if (count % sensesRefreshRate == 0){
                Debug.Log("Command>>> " + this.name + " command " + getSensesCommand.getId() + " Started!");
                //Vision
                objectsInFildOfVision = vision.getListOfElements();
                visionQueue           = new Queue <GameObject>(objectsInFildOfVision);

                //Hear
                soundsInHearing = hearing.getListOfElements();

                knowObjInHearing = objectsInFildOfVision.Intersect(soundsInHearing).ToList();
                hearKnowQueue    = new Queue <GameObject>(knowObjInHearing);
                foreach (GameObject obj in knowObjInHearing)
                {
                    soundsInHearing.Remove(obj);
                }
                hearUnkQueue = new Queue <GameObject>(soundsInHearing);
                //Smell
                odorInSmell   = smell.getListOfUnknowElements();
                smellUnkQueue = new Queue <GameObject>(odorInSmell);
                //Touch
                knowObjInTouch = touch.getListOfKnowElements();
                touchKnowQueue = new Queue <GameObject>(knowObjInTouch);
                //Unknow objects in touch
                touchInTouch  = touch.getListOfUnknowElements();
                touchUnkQueue = new Queue <GameObject>(touchInTouch);
                //objQueue = new Queue<GameObject>(objectsInFildOfVision.Union(soundsInHearing).Union(knowObjInHearing).Union(odorInSmell).Union(knowObjInTouch).Union(touchInTouch));
                int totalSize = visionQueue.Count + touchKnowQueue.Count + touchUnkQueue.Count + hearUnkQueue.Count +
                                hearKnowQueue.Count + smellUnkQueue.Count;
                batchSize = (int)Math.Ceiling((float)totalSize / sensesRefreshRate);
                //insertVision(objectsInFildOfVision);
                atDateTime = DateTime.Now;
                //}
                getSensesCommand.next();
                break;

            case (int)GetSenses.Position:

                for (int i = 0; i < batchSize; i++)
                {
                    if (visionQueue.Count > 0)
                    {
                        insertVision(visionQueue.Dequeue(), atDateTime);
                    }
                    else if (hearKnowQueue.Count > 0)
                    {
                        insertHearID(hearKnowQueue.Dequeue(), atDateTime);
                    }
                    else if (hearUnkQueue.Count > 0)
                    {
                        insertHearPos(hearUnkQueue.Dequeue(), atDateTime);
                    }
                    else if (touchKnowQueue.Count > 0)
                    {
                        insertTouchID(touchKnowQueue.Dequeue(), atDateTime);
                    }
                    else if (touchUnkQueue.Count > 0)
                    {
                        insertTouchPos(touchUnkQueue.Dequeue(), atDateTime);
                    }
                    else if (smellUnkQueue.Count > 0)
                    {
                        insertSmellPos(smellUnkQueue.Dequeue(), atDateTime);
                    }
                }
                if (count % triggerRefreshRate == 0)
                {
                    knowObjInSmell = smell.getListOfKnowElements();
                    foreach (GameObject goSmell in knowObjInSmell)
                    {
                        insertSmellID(goSmell, DateTime.Now);
                    }
                    //Taste
                    objectsInTaste = taste.getListOfElements();
                    foreach (GameObject goTaste in objectsInTaste)
                    {
                        insertTaste(goTaste, DateTime.Now);
                    }
                }
                count++;
                if (count % sensesRefreshRate == 0)
                {
                    count = 0;
                    getSensesCommand.success();
                    Debug.Log("Command>>> " + this.name + " command " + getSensesCommand.getId() + " Success!");
                }

                break;

            case (int)GetSenses.End:
                break;

            default:
                break;
            }
        }
    }
コード例 #3
0
    /*void FixedUpdate () {
     *
     *  if (count % sensesRefreshRate == 0)
     *  {
     *      //Vision
     *      objectsInFildOfVision = vision.getListOfElements();
     *      //Hear
     *      soundsInHearing = hearing.getListOfElements();
     *      knowObjInHearing = objectsInFildOfVision.Intersect(soundsInHearing).ToList();
     *      foreach (GameObject obj in knowObjInHearing)
     *      {
     *          soundsInHearing.Remove(obj);
     *      }
     *      //Smell
     *      odorInSmell = smell.getListOfUnknowElements();
     *      //Touch
     *      knowObjInTouch = touch.getListOfKnowElements();
     *      touchInTouch = touch.getListOfUnknowElements();
     *
     *
     *      insertVision(objectsInFildOfVision);
     *  }
     *  if (count % triggerRefreshRate == 0)
     *  {
     *      knowObjInSmell = smell.getListOfKnowElements();
     *      //Taste
     *      objectsInTaste = taste.getListOfElements();
     *  }
     *  count++;
     * }*/

    void FixedUpdate()
    {
        if (count % sensesRefreshRate == 0)
        {
            //Vision
            objectsInFildOfVision = vision.getListOfElements();
            visionQueue           = new Queue <GameObject>(objectsInFildOfVision);

            //Hear
            soundsInHearing = hearing.getListOfElements();

            knowObjInHearing = objectsInFildOfVision.Intersect(soundsInHearing).ToList();
            hearKnowQueue    = new Queue <GameObject>(knowObjInHearing);
            foreach (GameObject obj in knowObjInHearing)
            {
                soundsInHearing.Remove(obj);
            }
            hearUnkQueue = new Queue <GameObject>(soundsInHearing);
            //Smell
            odorInSmell   = smell.getListOfUnknowElements();
            smellUnkQueue = new Queue <GameObject>(odorInSmell);
            //Touch
            knowObjInTouch = touch.getListOfKnowElements();
            touchKnowQueue = new Queue <GameObject>(knowObjInTouch);
            //Unknow objects in touch
            touchInTouch  = touch.getListOfUnknowElements();
            touchUnkQueue = new Queue <GameObject>(touchInTouch);
            //objQueue = new Queue<GameObject>(objectsInFildOfVision.Union(soundsInHearing).Union(knowObjInHearing).Union(odorInSmell).Union(knowObjInTouch).Union(touchInTouch));
            int totalSize = visionQueue.Count + touchKnowQueue.Count + touchUnkQueue.Count + hearUnkQueue.Count +
                            hearKnowQueue.Count + smellUnkQueue.Count;
            batchSize = (int)Math.Ceiling((float)totalSize / sensesRefreshRate);
            //insertVision(objectsInFildOfVision);
            atDateTime = DateTime.Now;
        }
        for (int i = 0; i < batchSize; i++)
        {
            if (visionQueue.Count > 0)
            {
                insertVision(visionQueue.Dequeue(), atDateTime);
            }
            else if (hearKnowQueue.Count > 0)
            {
                insertHearID(hearKnowQueue.Dequeue(), atDateTime);
            }
            else if (hearUnkQueue.Count > 0)
            {
                insertHearPos(hearUnkQueue.Dequeue(), atDateTime);
            }
            else if (touchKnowQueue.Count > 0)
            {
                insertTouchID(touchKnowQueue.Dequeue(), atDateTime);
            }
            else if (touchUnkQueue.Count > 0)
            {
                insertTouchPos(touchUnkQueue.Dequeue(), atDateTime);
            }
            else if (smellUnkQueue.Count > 0)
            {
                insertSmellPos(smellUnkQueue.Dequeue(), atDateTime);
            }
        }
        if (count % triggerRefreshRate == 0)
        {
            knowObjInSmell = smell.getListOfKnowElements();
            foreach (GameObject goSmell in knowObjInSmell)
            {
                insertSmellID(goSmell, DateTime.Now);
            }
            //Taste
            objectsInTaste = taste.getListOfElements();
            foreach (GameObject goTaste in objectsInTaste)
            {
                insertTaste(goTaste, DateTime.Now);
            }
        }
        count++;
    }