コード例 #1
0
 public void OnWorkerEvent(Events.WorkerEvent e)
 {
     if (onWorkerEvent != null)
     {
         onWorkerEvent(e);
     }
 }
コード例 #2
0
    private void OnWorkerEvent(Events.WorkerEvent e)
    {
        if (e.workerEventType == Events.WorkerEventType.WorkerCreated)
        {
            GameObject worker = (GameObject)Instantiate(workerPrefab);
            worker.transform.parent = transform;

            WorkerController controller = worker.GetComponent <WorkerController>();
            if (controller == null)
            {
                Debug.LogError("Worker prefab does not contain worker controller!");
                Destroy(worker);
            }

            controller.worker = e.worker;
        }
        else if (e.workerEventType == Events.WorkerEventType.WorkerDestroyed)
        {
            // TODO: Destroy game object when worker destroyed.
            // TODO: Death animations?
        }
    }