示例#1
0
文件: BrickBoss.cs 项目: smhx/Spawn
 void Collided()
 {
     if (gameInit.Mode() == GameModes.HAZARD && hb.CurrentHazard())
     {
         gm.Kill();
     }
     timesHit++;
     if (brick == null)
     {
         Debug.LogError("BrickBoss::Collided: brick is null");
         return;
     }
     if (timesHit >= brick.timesToHit)
     {
         if (gameInit.Mode() == GameModes.HAZARD && hb.CurrentWarning())
         {
             hc.ResetTime();
         }
         Kill();
     }
     else
     {
         Audio.Instance.PlayBrickDamaged();
     }
 }
示例#2
0
    public bool Kill() {
		if (lives==0) {
			if (OnGameEnd != null)
				OnGameEnd ();
			dotCanBeClicked = false;

			return false;
		}

		--lives;
		lifeText.text = "x"+lives.ToString ();

		if (lives > 0) {
            if (gameInit.Mode() == GameModes.TIMED && timer.GetTime() <= 0)
            {
                timer.IncrementTimeBy((lives) * 20); //20 seconds per life
                lives = 1;
                lifeText.text = "x1";
                return false;
            }
			if (OnGameRevive != null) {
				OnGameRevive ();
				dotCanBeClicked = true;

				Audio.Instance.PlayRevive ();
			}
            return false;
		}
		

		if (watchedAdToRevive) {
			if (OnGameEnd != null)
				OnGameEnd ();
			dotCanBeClicked = false;


			DisplayEndScores();

			return true;
		
		} 

		watchedAdToRevive = true;

		if (OnDeathBeforeAd != null)
			OnDeathBeforeAd ();
		dotCanBeClicked = false;

		DisplayEndScores();

		return false;

    }
示例#3
0
    void Update()
    {
        if (!playing || gameInit.Mode() != GameModes.HAZARD)
        {
            return;
        }

        if (countDownTime - warningTime < time && time < countDownTime)
        {
            if (!hasWarned)
            {
                //choose brick
                chosenBrick = ObjectPooler.SharedInstance.GetRandomGameObject("Brick");
                if (chosenBrick == null)                  //no active bricks
                {
                    Debug.LogWarning("chosenBrick is null in HazardController");
                    time = 0f;
                }
                else
                {
                    hb = chosenBrick.GetComponent <HazardBrick>();
                    if (hb == null)
                    {
                        Debug.LogError("hb is null from get component!");
                    }
                    else
                    {
                        //set warning
                        hb.StartWarning();
                        hasWarned = true;
                    }
                }
            }
        }
        else if (time > countDownTime)
        {
            //make hazardous
            time      = 0f;
            hasWarned = false;
            if (hb == null)
            {
                Debug.LogError("hb is null!");
            }
            else
            {
                hb.StartHazard(duration);
            }
        }
        time += Time.deltaTime;
    }