示例#1
0
    private List <Vertex> dijkstraPath(Vertex enemyV, Vertex playerV)
    {
        Algorithem    dijksta = new Algorithem();
        List <Vertex> temp    = m_Grid.Generate();
        List <Vertex> list    = dijksta.computePaths(temp, enemyV);

        return(dijksta.getShortestPath(playerV, list));
    }
示例#2
0
    // Use this for initialization
    IEnumerator Start()
    {
        yield return(0);

        waveNum          = 1;
        spawnSpeed       = 2 - waveNum * 0.1f;
        timeBetweenWaves = 1.0f;
        gameScene        = GameApp.GetInstance().GetGameScene();
        //GameApp.GetInstance().GetGameScene().ArenaTrigger = this;

        Algorithem <EnemySpawnScript> .RandomSort(spawns);

        GameApp.GetInstance().GetGameScene().RefreshWoodBoxes();
        waveStartTime = Time.time;
    }
示例#3
0
    // Use this for initialization
    public void Start()
    {
        //! for test
        GameApp.GetInstance().Init();
        GameApp.GetInstance().GetGameState().ClearState();
        GameApp.GetInstance().GetGameState().InitWeapons();


        FlurryTAd.ShowTAd(false);
        startTime = Time.time;

        for (int i = 0; i < MAP_COUNT; i++)
        {
            infection[i] = i;
        }

        if (GameApp.GetInstance().GetGameState().LevelNum == 1)
        {
            infection[1] = -1;
            infection[2] = -1;
            infection[3] = -1;
        }
        else
        {
            //Random.seed = GameApp.GetInstance().GetGameState().LevelNum;
            Algorithem <int> .RandomSort(infection);

            int infectionNum = Random.Range(1, 3);
            if (infectionNum == 2)
            {
                infection[1] = -1;
                infection[2] = -1;
                infection[3] = -1;
            }
            else if (infectionNum == 1)
            {
                infection[2] = -1;
                infection[3] = -1;
            }
        }


        //int Random.Range(0, 2);

        Init();
        //StartCoroutine("Init");
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (Time.time - lastUpdateTime < spawnSpeed)
        {
            return;
        }
        lastUpdateTime = Time.time;



        if (currentSpawnIndex == spawns.Length)
        {
            //Debug.Log(GameApp.GetInstance().GetGameScene().GetEnemies().Count);
            int enemyLeft = GameApp.GetInstance().GetGameScene().GetEnemies().Count;

            /*     Next Wave Condition:
             *     1. All enemies killed in the wave.
             *     2. Only less than 5 enemies left and you played too long (more than 2 minutes)
             *
             *
             */


            if (enemyLeft == 0 || (Time.time - waveStartTime > 2 * 60 && enemyLeft < 5))
            {
                waveNum++;
                currentSpawnIndex = 0;
                float difficultyFactor = ((float)(waveNum - 1)) / 10.0f;
                //GameApp.GetInstance().GetGameScene().UpdateDifficultyLevel(difficultyFactor);
                waveEndTime = Time.time;

                Algorithem <EnemySpawnScript> .RandomSort(spawns);

                GameApp.GetInstance().GetGameScene().RefreshWoodBoxes();
                spawnSpeed = 2 - waveNum * 0.1f;
                if (spawnSpeed < 0.5f)
                {
                    spawnSpeed = 0.5f;
                }
                Debug.Log("Wave " + waveNum);
            }
        }
        else
        {
            if (Time.time - waveEndTime > timeBetweenWaves)
            {
                if (currentSpawnIndex == 0)
                {
                    waveStartTime = Time.time;
                }

                EnemySpawnScript es = spawns[currentSpawnIndex];
                if ((waveNum % es.onlySpawnEvery) == 0 && (waveNum >= es.onlySpawnFromRound))
                {
                    es.Spawn(1);
                }

                currentSpawnIndex++;
            }
        }
    }