示例#1
0
 void MakeInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#2
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        // Debug.Log(hitInfo.name);
        DestroyOffscreen enemy = hitInfo.GetComponent <DestroyOffscreen>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
        }
    }
示例#3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log("OnCollisionEnter");//Debug.Log ("HHHHHH");
        //Destroy(other.gameObject);
        if (this.ActiveMode == true){
            if ((other.gameObject.tag != "Player") && (other.gameObject.tag != "Drop"  )){
                obstacle = other.gameObject.GetComponent<DestroyOffscreen> ();
                obstacle.OnOutOfBounds();
            }

        }
    }
示例#4
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        // Debug.Log(hitInfo.name);
        DestroyOffscreen enemy = hitInfo.GetComponent <DestroyOffscreen>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
        }

        // Instantiate(impactEffect, transform.position, transform.rotation);

        GameObjetcUtil.Destroy(gameObject);
    }
示例#5
0
    void ResetGame()
    {
        spawner.active = true;

        //create player and set spawn height
        player = GameObjectUtility.Instantiate(playerPrefab, new Vector3(0f, (Screen.height / PixelPerfectCamera.pixelsToUnits) / 2 + 100.0f, 0f));
        //Get component for destroyOffscreen
        DestroyOffscreen playerDestroyScript = player.GetComponent <DestroyOffscreen>();

        //hook up destroyOffscreen delegate to execute OnPlayerKilled when called
        playerDestroyScript.DestroyCallback += OnPlayerKilled;

        gameStarted = true;

        continueText.canvasRenderer.SetAlpha(0f);
        timeElapsed  = 0f;
        beatBestTime = false;
    }
示例#6
0
    void OnPlayerKilled()
    {
        spawner.active = false;
        //Get component for destroyOffscreen
        DestroyOffscreen playerDestroyScript = player.GetComponent <DestroyOffscreen>();

        //unlink delegate for garbage caller
        playerDestroyScript.DestroyCallback -= OnPlayerKilled;

        //reset velocity of player
        player.GetComponent <Rigidbody2D>().velocity = Vector2.zero;

        timeManager.ManipulateTime(0f, 5.5f);
        gameStarted = false;

        continueText.text = "PRESS ANY BUTTON TO RESTART";

        if (timeElapsed > bestTime)
        {
            bestTime = timeElapsed;
            PlayerPrefs.SetFloat("BestTime", bestTime);
            beatBestTime = true;
        }
    }
示例#7
0
 private void Awake()
 {
     _destroyOffscreen = GetComponent <DestroyOffscreen>();
 }