public static FranceUnitController Create(Global.WallHorizontalType franceType)
    {
        string prefabPath = PREFAB_PATH_1;

        if (franceType == Global.WallHorizontalType.FRANCE_1)
        {
            prefabPath = PREFAB_PATH_1;
        }
        else if (franceType == Global.WallHorizontalType.FRANCE_2)
        {
            prefabPath = PREFAB_PATH_2;
        }

        GameObject           go     = Instantiate(Resources.Load(prefabPath)) as GameObject;
        FranceUnitController script = go.GetComponent <FranceUnitController>();

        return(script);
    }
Exemple #2
0
    //单格栅栏
    private void CreateFrance1()
    {
        //1.确定数目
        int num = this.GetRateNum(franceNum, franceNumRate);

        GGDebug.Log("==================单格栅栏===================" + num);
        //2.确定位置
        List <int> francePos = new List <int>();

        for (int i = 0; i < num; i++)
        {
            while (true)
            {
                int  randPos = Random.Range(1, 5);
                bool isSame  = false;
                for (int j = 0; j < francePos.Count; j++)
                {
                    if (francePos[j] == randPos)
                    {
                        isSame = true;
                        break;
                    }
                }

                if (!isSame)
                {
                    francePos.Add(randPos);
                    break;
                }
            }
        }
        //3.添加GameObject
        for (int i = 0; i < francePos.Count; i++)
        {
            FranceUnitController script = FranceUnitController.Create(Global.WallHorizontalType.FRANCE_1);
            this.AddWallUnit(script.gameObject, this.GetWallPos(fFrancePosX[i] - 1));
        }

        this.loopIndexNum++;
        this.curCreateWallIndex++;
        this.JudgeIsNewFullWall();
    }