예제 #1
0
    public void GenerateBarrel(int difficulty)
    {
        List <System.Func <GameObject> > functionsList = new List <System.Func <GameObject> >();

        functionsList.Add(() => BarrelPresets.inst.InstantiateStepRotating(nextBarrelPosition, Quaternion.identity, difficulty, false));
        functionsList.Add(() => BarrelPresets.inst.InstantiatePathThreePointsVertical(nextBarrelPosition, Quaternion.identity, difficulty, false));
        functionsList.Add(() => BarrelPresets.inst.InstantiatePathSwingVertical(nextBarrelPosition, Quaternion.identity, difficulty, false));

        GameObject newBarrel = functionsList[Random.Range(0, functionsList.Count)]();

        //GameObject newBarrel = functionsList[0]();

        newBarrel.transform.parent = this.gameObject.transform;

        Barrel newBarrelScript = newBarrel.GetComponent <Barrel>();

        newBarrelScript.difficulty = difficulty;
        GameManager.inst.barrels.Add(newBarrel);

        nextBarrelPosition = newBarrelScript.NextBarrelPosition();
    }