示例#1
0
文件: BrickBoss.cs 项目: smhx/Spawn
 void Awake()
 {
     PScolor  = standardPS.colorOverLifetime;
     tracker  = GameObject.FindWithTag("CollisionTracker").GetComponent <CollisionTracker> ();
     sr       = GetComponent <SpriteRenderer>();
     spawner  = GameObject.FindWithTag("BrickSpawner").GetComponent <BrickSpawner> ();
     gameInit = GameObject.FindWithTag("GameInitializer").GetComponent <GameInitializer> ();
     hb       = GetComponent <HazardBrick>();
     gm       = GameObject.FindWithTag("GameManager").GetComponent <GameSceneManager>();
     hc       = GameObject.FindWithTag("HazardController").GetComponent <HazardController>();
 }
示例#2
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;
    }