Example #1
0
    public void Die()
    {
        EnemyIndexManager.LogPlayerDeath(mostRecentAttackerFilename);
        GameEvent death = new GameEvent("game_over");

        EventManager.Instance().RaiseEvent(death);
    }
Example #2
0
 void BonusWaveUpdate()
 {
     if (!bonusGoing)
     {
         if (delayTimer.TimeElapsedSecs() >= 4f)
         {
             bonusGoing = true;
             bonusTimer.Restart();
         }
     }
     else
     {
         foreach (GameObject enemy in bonusWave.GetEnemies())
         {
             if (enemy == null)
             {
                 continue;
             }
             Enemy e = enemy.GetComponent <Enemy> ();
             if (e.GetSpawnTime() - ZoneWarning.HEAD_START * 1000 < bonusTimer.TimeElapsedMillis() &&
                 !e.HasWarned())
             {
                 e.Warn();
                 GameEvent warning = new GameEvent("warning");
                 warning.addArgument(e);
                 EventManager.Instance().RaiseEvent(warning);
             }
             if (e.GetSpawnTime() < bonusTimer.TimeElapsedMillis() && !e.spawned)
             {
                 enemy.SetActive(true);
                 e.StartMoving();
                 EnemyIndexManager.LogEnemyAppearance(e.GetSrcFileName());
                 //handle junior
                 if (e is Junior)
                 {
                     int   bonusWaveNumber = 1;                       //change this later when we have multiple bonus waves
                     float extraShielding  = bonusWaveNumber * Junior.extraShieldPerWave;
                     e.GetShield().SetAllShieldHP(e.GetShield().GetBaseHP() + extraShielding);
                 }
             }
         }
         //check if the wave's over
         if (bonusWave.IsEverythingDead())
         {
             waveProgress.Restart();
             onBreather = true;
             BonusWaveStart();
         }
     }
 }
 public static void LogEnemyAppearance(string enemyfile)
 {
     EnemyIndexManager.IncrementEnemyLogStat(enemyfile, "timesSeen");
     Debug.Log(enemyfile);
 }
 public static void LogEnemyDeath(string enemyfile)
 {
     interestedWaveManager.guysKilled++;
     EnemyIndexManager.IncrementEnemyLogStat(enemyfile, "timesKilled");
     EnemyIndexManager.IncrementTotalsLogStat("totalKills");
 }
 public static void LogPlayerDeath(string enemyfile)
 {
     EnemyIndexManager.IncrementEnemyLogStat(enemyfile, "timesKilledBy");
     EnemyIndexManager.IncrementTotalsLogStat("totalDeaths");
 }
 public static void LogHitByEnemy(string enemyfile)
 {
     EnemyIndexManager.IncrementEnemyLogStat(enemyfile, "timesHitBy");
     EnemyIndexManager.IncrementTotalsLogStat("totalHitBy");
 }
Example #7
0
    public void RealDie()
    {
        RectTransform rt = (RectTransform)transform;

        if (hp <= 0)
        {
            System.Random r   = new System.Random();
            float         rng = (float)r.NextDouble() * 100;                       //random float between 0 and 100
            if (this.impactTime < TrackController.NORMAL_SPEED + NORMALNESS_RANGE &&
                this.impactTime > TrackController.NORMAL_SPEED - NORMALNESS_RANGE) //is "normal speed"
            //Debug.Log ("normal speed enemy died");
            {
                if (rng < medDropRate)
                {
                    DropPiece();
                }
            }
            else if (this.impactTime >= TrackController.NORMAL_SPEED + NORMALNESS_RANGE)                 //is "slow"
            //Debug.Log("slow enemy died");
            {
                float distanceFromCenter = Mathf.Sqrt((rt.anchoredPosition.x) * (rt.anchoredPosition.x) + (rt.anchoredPosition.y) * (rt.anchoredPosition.y));
                if (distanceFromCenter > Dial.middle_radius)                   //died in outer ring
                {
                    if (rng < highDropRate)
                    {
                        DropPiece();
                    }
                }
                else if (distanceFromCenter > Dial.inner_radius)                     //died in middle ring
                {
                    if (rng < medDropRate)
                    {
                        DropPiece();
                    }
                }
                else                     //died in inner ring
                {
                    if (rng < lowDropRate)
                    {
                        DropPiece();
                    }
                }
            }
            else                 //is "fast"
                                 //Debug.Log("fast enemy died");
            {
                float distanceFromCenter = Mathf.Sqrt((rt.anchoredPosition.x) * (rt.anchoredPosition.x) + (rt.anchoredPosition.y) * (rt.anchoredPosition.y));
                if (distanceFromCenter > Dial.middle_radius)                   //died in outer ring
                {
                    if (rng < lowDropRate)
                    {
                        DropPiece();
                    }
                }
                else if (distanceFromCenter > Dial.inner_radius)                     //died in middle ring
                {
                    if (rng < medDropRate)
                    {
                        DropPiece();
                    }
                }
                else                     //died in inner ring
                {
                    if (rng < highDropRate)
                    {
                        DropPiece();
                    }
                }
            }
            EnemyIndexManager.LogEnemyDeath(srcFileName);
        }
        else
        {
            EnemyIndexManager.LogHitByEnemy(srcFileName);
        }
        //TODO:put yourself in the missedwave queue
        foreach (TipOfTheSpear tots in partners)
        {
            Destroy(tots.gameObject);
        }
        Destroy(this.gameObject);
    }
Example #8
0
    public virtual void Die()
    {
        dead = true;
        //put more dying functionality here
        System.Random r   = new System.Random();
        float         rng = (float)r.NextDouble() * 100; //random float between 0 and 100


        if (hp <= 0.0f)
        {
            dialCon.IncreaseSuperPercent();
            if (this.impactTime < TrackController.NORMAL_SPEED + NORMALNESS_RANGE &&
                this.impactTime > TrackController.NORMAL_SPEED - NORMALNESS_RANGE)                  //is "normal speed"
            //Debug.Log ("normal speed enemy died");
            {
                if (rng <= medDropRate)
                {
                    DropPiece();
                }
            }
            else if (this.impactTime >= TrackController.NORMAL_SPEED + NORMALNESS_RANGE)                 //is "slow"
            //Debug.Log("slow enemy died");
            {
                float distanceFromCenter = Mathf.Sqrt((rt.anchoredPosition.x) * (rt.anchoredPosition.x) + (rt.anchoredPosition.y) * (rt.anchoredPosition.y));
                if (distanceFromCenter > Dial.middle_radius)                   //died in outer ring
                {
                    if (rng <= highDropRate)
                    {
                        DropPiece();
                    }
                }
                else if (distanceFromCenter > Dial.inner_radius)                     //died in middle ring
                {
                    if (rng <= medDropRate)
                    {
                        DropPiece();
                    }
                }
                else                     //died in inner ring
                {
                    if (rng <= lowDropRate)
                    {
                        DropPiece();
                    }
                }
            }
            else                 //is "fast"
                                 //Debug.Log("fast enemy died");
            {
                float distanceFromCenter = Mathf.Sqrt((rt.anchoredPosition.x) * (rt.anchoredPosition.x) + (rt.anchoredPosition.y) * (rt.anchoredPosition.y));
                if (distanceFromCenter > Dial.middle_radius)                   //died in outer ring
                {
                    if (rng <= lowDropRate)
                    {
                        DropPiece();
                    }
                }
                else if (distanceFromCenter > Dial.inner_radius)                     //died in middle ring
                {
                    if (rng <= medDropRate)
                    {
                        DropPiece();
                    }
                }
                else                     //died in inner ring
                {
                    if (rng <= highDropRate)
                    {
                        DropPiece();
                    }
                }
            }
            EnemyIndexManager.LogEnemyDeath(srcFileName);
        }
        else
        {
            EnemyIndexManager.LogHitByEnemy(srcFileName);
        }
        Destroy(this.gameObject);
    }
Example #9
0
    public void Update()
    {
        if (Pause.paused)
        {
            return;
        }

        if (bonusWaveIsHappening)
        {
            BonusWaveUpdate();
            return;
        }
        if (!onBreather)
        {
            //Debug.Log("not on breather");
            //List<GameObject> spawnedThisCycle = new List<GameObject> ();
            foreach (GameObject enemy in activeWave.GetEnemies())
            {
                if (enemy == null)
                {
                    continue;
                }
                Enemy e = enemy.GetComponent <Enemy> ();
                if (e.GetSpawnTime() - ZoneWarning.HEAD_START * 1000 < waveProgress.TimeElapsedMillis() &&
                    !e.HasWarned())
                {
                    e.Warn();
                    GameEvent warning = new GameEvent("warning");
                    warning.addArgument(e);
                    EventManager.Instance().RaiseEvent(warning);
                }
                if (e.GetSpawnTime() < waveProgress.TimeElapsedMillis() && !e.spawned)
                {
                    //spawnedThisCycle.Add (enemy);
                    enemy.SetActive(true);
                    e.StartMoving();
                    EnemyIndexManager.LogEnemyAppearance(e.GetSrcFileName());
                }
            }
            //foreach (GameObject spawned in spawnedThisCycle) {
            //	activeWave.RemoveEnemy (spawned);
            //}
            if (activeWave.IsEverythingDead())
            {
                waveProgress.Restart();
                KillCountBox.KillDisplay(guysKilled, enemycount, false);
                onBreather = true;
                if (activeWaveIndex + 2 <= waves.Count)
                {
                    WaveMessageBox.StandardWarning(activeWaveIndex + 2);
                }
            }
        }
        else
        {
            //Debug.Log("on breather");
            if (waveProgress.TimeElapsedSecs() > BREATHER_SECONDS)
            {
                onBreather = false;
                activeWaveIndex++;
                if (activeWaveIndex < waves.Count)
                {
                    activeWave = waves [activeWaveIndex];
                }
                else
                {
                    //Debug.Log(activeWaveIndex + " >= " + waves.Count);
                    BonusWaveStart();
                }
                waveProgress.Restart();
                if (activeWaveIndex == 5)
                {
                    //spawn late-spawning bosses
                    if (bosscode == 1)
                    {
                        GameObject boss = GameObject.Instantiate(Resources.Load("Prefabs/MainCanvas/SwarmMaster")) as GameObject;
                        boss.transform.SetParent(Dial.unmaskedLayer, false);
                    }
                    if (bosscode == 4)
                    {
                        GameObject boss = GameObject.Instantiate(Resources.Load("Prefabs/MainCanvas/Skizzard")) as GameObject;
                        boss.transform.SetParent(Dial.unmaskedLayer, false);
                    }
                }
            }
            return;
        }
    }