Exemplo n.º 1
0
    void SpawnFly()
    {
        Vector4 flyZone = new Vector4();

        flyZone.x = screenSize.x - (screenSize.x - screenSize.z) * 0.03f;
        flyZone.y = screenSize.y - (screenSize.y - screenSize.w) * 0.2f;
        flyZone.z = screenSize.z + (screenSize.x - screenSize.z) * 0.2f;
        flyZone.w = screenSize.w + (screenSize.y - screenSize.w) * 0.2f;
        for (int j = 0; j < curentLevel.flyDefList.Count; j++)
        {
            for (int i = 0; i < (curentLevel.flyDefList[j] as FlyDef).nbFly; i++)
            {
                Vector3    spawnPosition = new Vector3(Random.Range(flyZone.z, flyZone.x), Random.Range(flyZone.w, flyZone.y), 0.0f);
                Quaternion spawnRotation = Quaternion.identity;
                GameObject temp          = Instantiate(Resources.Load((curentLevel.flyDefList[j] as FlyDef).type), spawnPosition, spawnRotation) as GameObject;
                temp.name = "Fly" + flyTab.Count;
                IFlyable component = (IFlyable)temp.GetComponent(typeof(IFlyable));
                component.SetId(flyTab.Count);
                component.Init(flyZone, (curentLevel.flyDefList[j] as FlyDef).velocidadMax, (curentLevel.flyDefList[j] as FlyDef).maxAngle);
                component.SetControler(gameObject);
                if ((curentLevel.flyDefList[j] as FlyDef).CompoDef.Count > 0)
                {
                    for (int k = 0; k < (curentLevel.flyDefList[j] as FlyDef).CompoDef.Count; k++)
                    {
                        CompoDef compD = (curentLevel.flyDefList[j] as FlyDef).CompoDef[k] as CompoDef;
                        switch (compD.type)
                        {
                        case "Animator":
                            Debug.Log(compD.name.ToString() + "  " + compD.val.ToString());
                            temp.GetComponent <Animator>().SetBool((compD.name), compD.val);
                            break;
                        }
                    }
                }
                flyTab.Add(temp);
            }
        }
    }
Exemplo n.º 2
0
    void addEnemies()
    {
        Vector4 flyZoneE = new Vector4();

        flyZoneE.x = screenSize.x - (screenSize.x - screenSize.z) * 0.03f;
        flyZoneE.y = screenSize.y - (screenSize.y - screenSize.w) * 0.2f;
        flyZoneE.z = screenSize.x - (screenSize.x - screenSize.z) * 0.3f;
        flyZoneE.w = screenSize.w + (screenSize.y - screenSize.w) * 0.2f;
        Quaternion spawnRotation = Quaternion.identity;
        EnemieD    tempEnemie;

        for (int k = 0; k < currentWave.enemieList.Count; k++)
        {
            tempEnemie = currentWave.enemieList[k] as EnemieD;
            for (int j = 0; j < tempEnemie.nb; j++)
            {
                Vector3    spawnPosition = new Vector3(Random.Range(flyZoneE.z, flyZoneE.x), Random.Range(flyZoneE.w, flyZoneE.y), 0.0f);
                GameObject temp          = Instantiate(Resources.Load(tempEnemie.type), spawnPosition, spawnRotation) as GameObject;
                IFlyable   component     = (IFlyable)temp.GetComponent(typeof(IFlyable));
                component.SetId(j);
                component.SetControler(gameObject);
                component.Init(flyZoneE, 0, 0);
                component.type = "Enemie";
                enemieTab.Add(temp);
            }
        }
        if (curentLevel.waveList.Count > (currentWaveId + 1))
        {
            currentWaveId += 1;
            Debug.Log(curentLevel.waveList.Count + "  " + currentWaveId);
            currentWave = curentLevel.waveList [currentWaveId] as Wave;
        }
        else
        {
            noMoreWave = true;
        }
    }