Exemplo n.º 1
0
    void Create()
    {
        GameObject g = GameObject.Instantiate(Resources.Load("Construct/" + n + "_2") as GameObject, v, Quaternion.identity);

        construct = g.GetComponent <UnitConstruct>();

        construct._property.colorTeam = controller.team;
        construct.SetColorTeam();

        switch (n)
        {
        case "Farm":
            controller.farmConstructs.Add(construct.GetComponent <FarmConstruct>());
            break;

        case "Barracks":
            controller.barracksConstructs.Add(construct.GetComponent <BarracksConstruct>());
            break;

        case "Archer Range":
            controller.archerRangeConstructs.Add(construct.GetComponent <ArcherRangeConstruct>());
            break;
        }
    }
Exemplo n.º 2
0
    IEnumerator CreateCo()
    {
        List <UnitSoldier> soldiers = new List <UnitSoldier>();

        int a = amountCreate;

        switch (typeWave)
        {
        case TypeWave.Default:
            break;

        case TypeWave.Random:
            a = Random.Range(amountR.x, amountR.y);
            break;
        }

        for (int i = 0; i < a; i++)
        {
            switch (nameCreate)
            {
            case "Archerman":

                if (controller.archerRangeConstructs.Count > 0)
                {
                    if (!constructToCreate)
                    {
                        if (controller.archerRangeConstructs.Count > 0)
                        {
                            constructToCreate = controller.archerRangeConstructs[0];
                        }
                    }

                    ArcherRangeConstruct archerRange = constructToCreate.GetComponent <ArcherRangeConstruct>();

                    yield return(new WaitUntil(() => { return (archerRange.createArcherman.t <= 0 ? true : false); }));

                    archerRange.createArcherman.StartCreate();

                    GameObject g = GameObject.Instantiate(Resources.Load("Soldier/" + nameCreate) as GameObject,
                                                          constructToCreate.posToCreateSoldier.position, Quaternion.identity);

                    Vector3 vMove = new Vector3();
                    vMove.x = Random.Range(-1f, 1f);
                    vMove.z = Random.Range(0, -2f);

                    g.GetComponent <UnitSoldier>().SetMove(g.transform.position + vMove);

                    g.GetComponent <UnitSoldier>()._property.colorTeam = controller.team;
                    g.GetComponent <UnitSoldier>().SetColorTeam();

                    soldiers.Add(g.GetComponent <UnitSoldier>());

                    SetTime();
                }
                break;

            case "Spearman":
                if (controller.barracksConstructs.Count > 0)
                {
                    BarracksConstruct barracks = constructToCreate.GetComponent <BarracksConstruct>();

                    yield return(new WaitUntil(() => { return (barracks.createSpearman.t <= 0 ? true : false); }));

                    barracks.createSpearman.StartCreate();

                    GameObject g2 = GameObject.Instantiate(Resources.Load("Soldier/" + nameCreate) as GameObject,
                                                           constructToCreate.posToCreateSoldier.position, Quaternion.identity);
                    g2.GetComponent <UnitSoldier>()._property.colorTeam = controller.team;
                    g2.GetComponent <UnitSoldier>().SetColorTeam();

                    soldiers.Add(g2.GetComponent <UnitSoldier>());

                    SetTime();
                }
                break;
            }
        }

        foreach (var item in soldiers)
        {
            item.GetComponent <UnitSoldier>().SetMove(vAttack);
            item.GetComponent <UnitSoldier>().mission  = Mission.Move;
            item.GetComponent <UnitSoldier>().vMission = vAttack;
        }
    }