Esempio n. 1
0
    //Overload function to check if a specific need is on the list
    public SurvivalTask needOnList(SurvivalTask task)
    {
        int count = survivalTasks.Count;

        for (int i = 0; i < count; i++)
        {
            if (survivalTasks[i].need == task.need)
            {
                return(survivalTasks[i]);
            }
        }
        return(new SurvivalTask(SurvivalNeeds.Empty, 10));
    }
Esempio n. 2
0
    protected List <SurvivalTask> survivalTasks;             //Holds a list of all the tasks of basic survival needs, filtered by importance

    //Adds an item to the survivalTasks, to remove an item set remove to TRUE
    public void addSurvivalNeed(SurvivalTask task, bool remove)
    {
        int count = survivalTasks.Count;        //Local storage for number of survival tasks

        //Remove if already contained
        for (int i = 0; i < count; i++)
        {
            if (survivalTasks[i].need == task.need)
            {
                survivalTasks.RemoveAt(i);
            }
        }
        //If the user is intending to add the task
        if (!remove)
        {
            //Check if it is empty, then just add it
            if (count == 0)
            {
                survivalTasks.Add(task);
            }
            //Add task in correct place
            for (int i = 0; i < count; i++)
            {
                //If the priorities are equal, prioritise by survivalNeed order (lowest number more important)
                if (survivalTasks[i].priority == task.priority)
                {
                    if ((int)survivalTasks[i].need < (int)task.need)
                    {
                        survivalTasks.Insert(i, task);
                        i = count + 1;
                    }
                }
                //Add task if it is more important, (lower priority number)
                else if (survivalTasks[i].priority > task.priority)
                {
                    survivalTasks.Insert(i, task);
                    i = count + 1;
                }
                //Should the end of the tasks list be reached add it at the end due to it being of the least importance
                else if (i == count - 1)
                {
                    survivalTasks.Add(task);
                }
            }
        }
    }
Esempio n. 3
0
    //Checks if any of the needs has passed any thresholds
    public override void checkSurvivalNeeds()
    {
        if (sleep <= 90.0f)
        {
            if (sleep <= 85.0f)
            {
                if (sleep <= 79.0f)
                {
                    if (sleep <= 70.0f)
                    {
                        if (sleep <= 55.0f)
                        {
                            if (sleep <= 50.0f)
                            {
                                if (sleep <= 35.0f)
                                {
                                    if (sleep <= 0.0f)
                                    {
                                        // DEATH!!!! KILL PLAYER
                                    }
                                    else
                                    {
                                        SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Sleep, 1);
                                        addSurvivalNeed(newTask, false);
                                    }
                                }
                                else
                                {
                                    SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Sleep, 2);
                                    addSurvivalNeed(newTask, false);
                                }
                            }
                            else
                            {
                                SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Sleep, 3);
                                addSurvivalNeed(newTask, false);
                            }
                        }
                        else
                        {
                            SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Sleep, 4);
                            addSurvivalNeed(newTask, false);
                        }
                    }
                    else
                    {
                        SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Sleep, 5);
                        addSurvivalNeed(newTask, false);
                    }
                }
                else
                {
                    SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Sleep, 6);
                    addSurvivalNeed(newTask, false);
                }
            }
            else
            {
                SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Sleep, 7);
                addSurvivalNeed(newTask, true);
            }
        }

        //Update Hydration
        if (hydration <= 95.0f)
        {
            if (hydration <= 74.0f)
            {
                if (hydration <= 66.0f)
                {
                    if (hydration <= 33.0f)
                    {
                        if (hydration <= 0.0f)
                        {
                            //death
                        }
                        else
                        {
                            SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Water, 1);
                            addSurvivalNeed(newTask, false);
                        }
                    }
                    else
                    {
                        SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Water, 2);
                        addSurvivalNeed(newTask, false);
                    }
                }
                else
                {
                    SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Water, 3);
                    addSurvivalNeed(newTask, false);
                }
            }
            else
            {
                SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Water, 4);
                addSurvivalNeed(newTask, false);
            }
        }
        else
        {
            SurvivalTask newTask = new SurvivalTask(SurvivalNeeds.Water, 4);
            addSurvivalNeed(newTask, true);
        }
    }