Exemple #1
0
    // ================================================ helper
    // Evaluates the tasks. Carry out the task for each survivor
    void evaluateTasks()
    {
        _reports = new List <Report>();
        //Evaluate each task
        for (int s = 0; s < _shelter.NumberOfSurvivors; s++)
        {
            ArrayList rtmp;
            //carry out the task
            switch (_shelter._survivors [s].AssignedTask)
            {
            case Survivor.task.Scout:
                rtmp = (_shelter._survivors [s].Scout(_shelter));
                if (rtmp != null)
                {
                    foreach (Report r in rtmp)
                    {
                        _reports.Add(r);
                    }
                }
                break;

            case Survivor.task.Heal:
                _reports.Add(_shelter._survivors [s].Heal(_shelter));
                break;

            case Survivor.task.Defend:
                _reports.Add(_shelter._survivors [s].Defend(_shelter));
                break;

            case Survivor.task.Scavenge:
                _reports.Add(_shelter._survivors [s].Scavenge(_shelter));
                break;

            case Survivor.task.Execute:
                _reports.Add(_shelter.Execute(_shelter._survivors[s]));
                break;

            case Survivor.task.Evict:
                _reports.Add(_shelter.Evict(_shelter._survivors[s]));
                break;

            case Survivor.task.Raiding:
                if (_gameWorld.ExistVisibleShelters() == true)
                {
                    _reports.Add(_shelter._survivors [s].Raid(_shelter));
                }
                else
                {
                    rtmp = (_shelter._survivors [s].Scout(_shelter));
                    if (rtmp != null)
                    {
                        foreach (Report r in rtmp)
                        {
                            _reports.Add(r);
                        }
                    }
                }
                break;

            case Survivor.task.Unassigned:
                goto case Survivor.task.Resting;

            case Survivor.task.Resting:


                Report rTmp = _shelter._survivors [s].Rest(_shelter);

                //Debug.Log ("rTmp Message:" + rTmp.GetMessage());

                _reports.Add(rTmp);
                break;
            }             // end of switch

            if (_shelter._survivors [s] != null)
            {
                // increase survivor status
                _shelter._survivors [s].Exhaust();
                _reports.Add(_shelter._survivors [s].Eat(_shelter));
                _shelter._survivors [s].ConsumeMedicine(_shelter);
            }
        }


        ArrayList tReports = _gameWorld.CalculateShelterLocation();

        foreach (Report r in tReports)
        {
            _reports.Add(r);
        }

        // update report from gameworld
        ArrayList rt = _gameWorld.NewDay();

        foreach (Report r in rt)
        {
            _reports.Add(r);
        }

        // player update
        _shelter.playerEat();

        _reports.Add(_shelter.GetEatingReport());
        _reports.Add(_shelter.GetMedicineConsumptionReport());

#if debug
        //print the reports
        foreach (Report r in _reports)
        {
            try{
                Debug.Log("130 [reports]:" + r.GetMessage());
            }
            catch {
                Debug.LogError("134 reports are invalid");
            }
        }
#endif

        // pass report
        _rh.PassReports(_reports);

        // reset report
        //_reports = new List<Report> ();
    }