예제 #1
0
파일: Manager.cs 프로젝트: c0deLab/RAiC
    private void Awake()
    {
        _brickManager = Bricks.GetComponent <BrickManager>();

        foreach (Transform drone in Drones)
        {
            var droneScript = drone.gameObject.GetComponent <Drone>();
            droneScript.manager = this;
            _drones.Add(droneScript);
        }

        Debug.Log($"Initialized {_drones.Count} drone(s)");

        foreach (Transform supplyTrans in Supplies)
        {
            var t = (from Transform supplyChild in supplyTrans
                     where _brickManager.GetTags().Contains(supplyChild.tag)
                     select supplyChild.tag).FirstOrDefault();
            if (t == null)
            {
                Debug.LogWarning($"There is no corresponding brick tag in Supply: {supplyTrans.name}");
                continue;
            }

            var supply = supplyTrans.GetComponent <Supply>();
            supply.type = t;
            if (!supplyTags.ContainsKey(t))
            {
                supplyTags.Add(t, new List <Supply>());
            }
            supplyTags[t].Add(supply);
            Debug.Log($"Initialized {supply.name}, type: {supply.type}");
        }

        if (supplyTags.Any(kvp => kvp.Value.Count == 0))
        {
            throw new Exception("No supply for certain brick type");
        }
    }