Exemplo n.º 1
0
    public void RegisterWorker(AIProjectWorker worker)
    {
        worker.SetProject(this);
        assignedWorkers.Add(worker);

        OnNewWorker(worker);
    }
Exemplo n.º 2
0
    public override void FinishedWork(AIProjectWork work, AIProjectWorker worker)
    {
        GameManager.pointObjectManager.EraseObject(work.cubePoint);
        RemoveMineralFromDivision(((MiningWork)work).pointValue);
        base.FinishedWork(work, worker);
        WorldInterface.RequestPointDataRelated(work.cubePoint, 2.0f, DeliverPointValue);

        if (workQueue.Count==0)
        {
            PendingOfflineTimer = 5.0f;
            DebugOutput.Shout("Pending Offlining Mining Project in " + PendingOfflineTimer.ToString()+" seconds");
            TimerSystem.AddSimpleUpdate(UpdateOfflineTimer);
        }
    }
Exemplo n.º 3
0
 public virtual void FindWorkForWorker(AIProjectWorker worker)
 {
     AIProjectWork closestWork = null;
     float closestDistance = float.MaxValue;
     for(int i = 0;i < workQueue.Count;i++)
     {
         if(workQueue[i].assignedWorker == null)
         {
             float sqrdistance = (workQueue[i].cubePoint-worker.transform.position).sqrMagnitude;
             if( sqrdistance < closestDistance)
             {
                 closestDistance = sqrdistance;
                 closestWork = workQueue[i];
             }
         }
     }
     if (closestWork != null)
     {
         worker.SetActiveWork(closestWork);
         return;
     }
 }
Exemplo n.º 4
0
    public virtual void FinishedWork(AIProjectWork work,AIProjectWorker worker)
    {
        workQueue.Remove(work);

        FindWorkForWorker(worker);
    }
Exemplo n.º 5
0
    public static void RegisterWorker(AIProjectWorker worker)
    {
        //worker.SetProject(GetProjectByDistance(worker));

        if (idleWorkers == null)
        {
            idleWorkers = new List<AIProjectWorker>();
        }
        idleWorkers.Add(worker);
        if (projectsDictionary != null)
        {
            if (projectsDictionary.Keys.Count > 0)
            {
                ParseWorkers();
            }
        }
    }
Exemplo n.º 6
0
    public static AIProject GetProjectByDistance(AIProjectWorker worker)
    {
        for(int i = 0 ; i < worker.typeData.workTypeIDs.Count;i++)
        {
            List<AIProject> projects = getProjects(worker.typeData.workTypeIDs[i]);
            if(projects != null)
            {
                AIProject closestProject = null;
                float distanceToClosest = float.MaxValue;
                for(int j = 0;j < projects.Count;j++)
                {
                    if (projects[j].needWorker())
                    {
                        float sqrdistance = (worker.transform.position - projects[j].position).sqrMagnitude;
                        if (sqrdistance < distanceToClosest)
                        {
                            closestProject = projects[j];
                            distanceToClosest = sqrdistance;
                        }
                    }

                }
                if (closestProject != null)
                {
                    return closestProject;
                }
            }

        }
        return null;
    }
Exemplo n.º 7
0
 protected virtual void OnNewWorker(AIProjectWorker worker)
 {
     FindWorkForWorker(worker);
 }
Exemplo n.º 8
0
    protected override void OnNewWorker(AIProjectWorker worker)
    {
        DebugOutput.Shout("We have a new Worker for this project");

        base.OnNewWorker(worker);
    }