Exemplo n.º 1
0
    //获取空闲的防守点
    private Transform GetFreeDefendPosition()
    {
        Transform        res    = null;
        List <Transform> points = defendPoint.GetDefendPoint();

        foreach (Transform point in points)
        {
            if (soldiersList.ContainsValue(point) == false)
            {
                res = point;
                break;
            }
        }
        return(res);
    }
Exemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        BuildingPlace buildingPlace = GetComponentInParent <BuildingPlace>();

        defendPoint     = buildingPlace.GetComponentInChildren <DefendPoint>();
        coolDownCounter = coolDown;
        //升级当前已生成的士兵
        foreach (Transform point in defendPoint.GetDefendPoint())
        {
            //如果防守点已经有士兵
            AIBehavior soldier = point.GetComponentInChildren <AIBehavior>();
            if (soldier != null)
            {
                //在相同的坐标上生成新的
                Spawn(soldier.transform, point);
                //摧毁之前的士兵
                Destroy(soldier.gameObject);
            }
        }
    }