Beispiel #1
0
        public override void Update(Dwarf d, float dt)
        {
            if (_currentTask == null)
            {
                _prevTask = _currentTask;
                _currentTask = TaskManager.GetTask(d);
                if (_currentTask == null)
                    return;
                _currentBehavior = _currentTask.ActivateBehavior(d);
            }

            _currentBehavior.Execute(d, dt);
            if (_currentBehavior.State == TaskState.Success)
            {
                DwarfConsole.WriteLine("Task: " + _currentTask.ToString() + " is success " + _currentTask.Id, ConsoleColor.Gray);
                //TaskManager.PrintOutTasks();
                TaskManager.FinishTask(_currentTask);
                Stop();
                Update(d, dt);
                d.PersonalSkiped();
            }
            else if (_currentBehavior.State == TaskState.Fail)
            {
                //DwarfConsole.WriteLine("Task failed: " + _currentTask.TaskType, ConsoleColor.Red);

                TaskManager.TaskFailed(_currentTask);
                Stop();
                Update(d, dt);
            }
            else if (_currentBehavior.State == TaskState.SmallFail)
            {
                DwarfConsole.WriteLine("Task small failed: " + _currentTask.TaskType + " - ", ConsoleColor.Magenta);
                TaskManager.TaskSmallFail(_currentTask);
                Stop();
                Update(d, dt);
            }
            else if (_currentBehavior.State == TaskState.Absolete)
            {
                TaskManager.TaskAbsolete(_currentTask);
                Stop();
                Update(d, dt);
            }
            else if (_currentBehavior.State == TaskState.PersonalSuccess)
            {
                DwarfConsole.WriteLine("Task: " + _currentTask.ToString() + " is success", ConsoleColor.DarkCyan);
                Stop();
                Update(d, dt);
            }
            else if (_currentBehavior.State == TaskState.PersonalFail)
            {
                d.SkipPersonal();
                Stop();
            }
            else if (_currentBehavior.State == TaskState.PersonalFailTryTaskAgain)
            {
                // Restart task
                _currentBehavior = _currentTask.ActivateBehavior(d);
            }
            else if (_currentBehavior.State == TaskState.PersonalFailTryBehaviorAgain)
            {

            }
        }