Пример #1
0
    /// <summary>
    /// Removes the objective from the list.
    /// By default also removes any child objectives.
    /// </summary>
    /// <returns><c>true</c>, if objective was removed, <c>false</c> otherwise.</returns>
    /// <param name="obj">Objective.</param>
    /// <param name="removeChildren">If true, also remove all child objectives.</param>
    public static bool RemoveObjective(objective obj, bool removeChildren = true)
    {
        if (IsObjectivePresent(obj))
        {
            int index = objList.list.IndexOf(obj);
            if (removeChildren)
            {
                List <string> childrenIds = obj.childIds;
                foreach (string id in childrenIds)
                {
                    objective child = GetObjective(id);
                    if (child != null)
                    {
                        RemoveObjective(child);
                    }
                }
            }

            /* Not sure whether to add this part. Leave commented out for now.
             * if (obj.parentId != null) {
             *      objective parentObj = GetObjective (obj.parentId);
             *      if (parentObj != null) {
             *              parentObj.childIds.Remove (obj.id);
             *      }
             * }
             */
            objList.list.RemoveAt(index);
            return(true);
        }
        else
        {
            Debug.Log("Objective " + obj.title + " Not Found");
            return(false);
        }
    }
Пример #2
0
 // if MakeChild fails, it simply returns the original objective and logs an error
 public objective MakeChild(objective child)
 {
     if (serialNumber != 0 && child.serialNumber != 0)
     {
         int numberOfGrandChildren = child.childObjectives.Count; // a child objective may have grandchildren
         if (numberOfGrandChildren == 0)                          // if no grandchildren pass null as childObjectives of child
         {
             childObjectives.Add(new objective(child.title, child.description, child.completionLevel, child.hint, null, serialNumber, lastIndex));
             lastIndex++;
         }
         else // else get the list of child's child objectives and pass it as grandChildObjectives
         {
             objective[] grandChildObjectives = new objective[numberOfGrandChildren];
             for (int i = 0; i < numberOfGrandChildren; i++)
             {
                 grandChildObjectives[i] = child.GetChild(i);
             }
             // grandChildObjectives will now be re-passed as childObjectives of the child in the constructor of "objective", which calls MakeChild again
             // and gets the children of the grandchildren recursively till it hits null
             childObjectives.Add(new objective(child.title, child.description, child.completionLevel, child.hint, grandChildObjectives, serialNumber, lastIndex));
             lastIndex++;
         }
         return(GetChild(lastIndex - 2)); // returns the child created so functions can be chained
     }
     else
     {
         ErrorLogger.Log();
         return(this);
     }
 }
Пример #3
0
        private static void GetObjectives(IReadOnlyList <DataTable> sheets, personnel_master personnel, IObjectSpace objectSpace)
        {
            for (int objInx = 0; objInx < sheets[2].Rows.Count; objInx++)
            {
                if (sheets[2].Rows[objInx][0].ToString() == "Appraisee: Describe your overall performance over the past year")
                {
                    objInx++;
                    personnel.emp_past_year_description_appraisee = sheets[2].Rows[objInx][0].ToString();
                    objInx += 12;
                    if (TryParse(sheets[2].Rows[objInx][9].ToString(), out short empRating))
                    {
                        personnel.emp_rating = empRating;
                    }
                    objInx += 13;
                    personnel.manager_past_year_description_appraisee = sheets[2].Rows[objInx][0].ToString();
                    objInx += 12;
                    if (TryParse(sheets[2].Rows[objInx][9].ToString(), out short managerRating))
                    {
                        personnel.manager_rating = managerRating;
                    }
                    objInx += 12;
                    personnel.appraisee_comments = sheets[2].Rows[objInx][0].ToString();

                    break;
                }
                if (sheets[2].Rows[objInx][0].ToString() != "Objective")
                {
                    continue;
                }
                objInx++;
                while (sheets[2].Rows[objInx][0].ToString().Trim() == string.Empty)
                {
                    objInx++;
                }
                //if (sheets[2].Rows[objInx + 1][0].ToString().Trim() == string.Empty)
                //    continue;
                //objInx++;
                objective obv = objectSpace.CreateObject <objective>();
                obv.objective1       = sheets[2].Rows[objInx][0].ToString();
                obv.personnel_id     = personnel;
                obv.base_start_point = sheets[2].Rows[objInx][6].ToString();
                obv.method_actions   = sheets[2].Rows[objInx][9].ToString();
                if (TryParse(sheets[2].Rows[objInx][14].ToString(), out double weight))
                {
                    obv.weight = weight;
                }
                if (DateTime.TryParse(sheets[2].Rows[objInx][15].ToString(), out DateTime timeInCurrentRole))
                {
                    obv.timing_to_complete = timeInCurrentRole;
                }
                if (TryParse(sheets[2].Rows[objInx][16].ToString(), out short rating))
                {
                    obv.rating = rating;
                }
                objInx += 7;
                obv.employee_comment = sheets[2].Rows[objInx][0].ToString();
                obv.manager_comment  = sheets[2].Rows[objInx][6].ToString();
            }
        }
    public override void Initialize()
    {
        targets        = GetComponents <RayPerceptionSensorComponent3D>()[1];
        obstacles      = GetComponents <RayPerceptionSensorComponent3D>()[0];
        movementScript = GetComponent <Movement>();

        objectiveScirpt = mainObj.GetComponent <objective>();
        Debug.Log(targets.SensorName);
        Debug.Log(obstacles.SensorName);
    }
Пример #5
0
    public objective GetObjectiveWithSerial(int serialNumber)
    {
        string    serialNumberString  = serialNumber.ToString();
        objective objectiveWithSerial = objectiveList[charToInt(serialNumberString[0]) - 1];

        if (serialNumberString.Length > 1)
        {
            objectiveWithSerial = objectiveWithSerial.GetChildWithSerial(serialNumber);
        }
        return(objectiveWithSerial);
    }
Пример #6
0
    public objective GetChildWithSerial(int serialNumber)
    {
        string    serialNumberString     = serialNumber.ToString();
        objective currentObjectiveGotten = GetChild(getIndex(serialNumberString, 1));

        for (int i = 2; i < serialNumberString.Length; i++)
        {
            currentObjectiveGotten = currentObjectiveGotten.GetChild(getIndex(serialNumberString, i));
        }
        return(currentObjectiveGotten);
    }
Пример #7
0
 /// <summary>
 /// Removes the objective with specified id from the list.
 /// </summary>
 /// <returns><c>true</c>, if objective was removed, <c>false</c> otherwise.</returns>
 /// <param name="id">Objective id.</param>
 /// <param name="removeChildren">If true, also remove all child objectives.</param>
 public static bool RemoveObjective(string id, bool removeChildren = true)
 {
     if (IsObjectivePresent(id))
     {
         objective toRemove = GetObjective(id);
         return(RemoveObjective(toRemove, removeChildren));
     }
     else
     {
         Debug.Log("Objective with ID: " + id + " Not Found");
         return(false);
     }
 }
Пример #8
0
 /// <summary>
 /// Adds the objective to the list.
 /// </summary>
 /// <returns><c>true</c>, if objective was added, <c>false</c> otherwise.</returns>
 /// <param name="obj">Objective to add.</param>
 /// <param name="avoidRepeats">If true, will not add objective if its already added.</param>
 public static bool AddObjective(objective obj, bool avoidRepeats = true)
 {
     if (avoidRepeats && IsObjectivePresent(obj))
     {
         Debug.Log("Objective already present");
         return(false);
     }
     try {
         objList.list.Add(obj);
         AppendToParent(obj);
         return(true);
     } catch (Exception e) {
         Debug.LogError(e.Message);
         return(false);
     }
 }
Пример #9
0
    public static void AppendToParent(objective obj)
    {
        if (obj.parentId == null || obj.parentId == "")
        {
            return;
        }
        objective parent = GetObjective(obj.parentId);

        if (parent != null)
        {
            if (parent.childIds == null)
            {
                parent.childIds = new List <string> ();
            }
            if (!parent.childIds.Contains(obj.id))
            {
                parent.childIds.Add(obj.id);
            }
        }
    }
        public static Decision check_columns(int[,] matrix, objective c)
        {
            Decision        ret       = new Decision(0, 0, 999);
            List <Decision> tmp       = new List <Decision>();
            List <Decision> decisions = new List <Decision>();

            for (int j = 0; j < matrix.GetUpperBound(0) + 1; j++)
            {
                for (int i = 0; i < matrix.GetUpperBound(1) + 1; i++)
                {
                    tmp.Add(new Decision(i, j, matrix[i, j]));
                }
                //Select first from list sorted ASCENDING == SMALLEST value
                if (c == objective.max)
                {
                    decisions.Add(tmp.OrderBy(item => item.value).First());
                }
                //Select first from list sorted DESCENDING == BIGGEST value
                if (c == objective.min)
                {
                    decisions.Add(tmp.OrderByDescending(item => item.value).First());
                }
                tmp.Clear();
            }
            //Select first from list sorted ASCENDING == SMALLEST value
            if (c == objective.min)
            {
                ret = decisions.OrderBy(item => item.value).First();
            }
            //Select first from list sorted DESCENDING == BIGGEST value
            if (c == objective.max)
            {
                ret = decisions.OrderByDescending(item => item.value).First();
            }
            return(ret);
        }
Пример #11
0
 public objective InsertTree(int index, objective mainObjective)
 {
     // todo: change all the serial numbers of succeeding objectives
     objectiveList.Insert(index, mainObjective);
     return(objectiveList[index]);
 }
Пример #12
0
 public objective AddTree(objective mainObjective)
 {
     // todo: create serial numbers upon adding
     objectiveList.Add(mainObjective);
     return(objectiveList[objectiveList.Count - 1]);
 }
Пример #13
0
 /// <summary>
 /// Determines if the specified objective is present in the list.
 /// </summary>
 /// <returns><c>true</c> if is objective present the list, <c>false</c> otherwise.</returns>
 /// <param name="obj">Objective.</param>
 public static bool IsObjectivePresent(objective obj)
 {
     return(objList.list.Contains(obj));
 }