Beispiel #1
0
    void Update()
    {
        GameObject     playfield = GameObject.Find("Horizontal Playfield");
        RestrictScript field     = playfield.GetComponent <RestrictScript>();

        Vector3 clampedPosition = transform.position;

        clampedPosition.x  = Mathf.Clamp(transform.position.x, field.minX, field.maxX);
        clampedPosition.y  = Mathf.Clamp(transform.position.y, field.minY, field.maxY);
        transform.position = clampedPosition;

        GameObject  clock = GameObject.Find("Timer");
        TimerScript t     = clock.GetComponent <TimerScript>();

        time = t.timer;
        if (time >= loadTime)
        {
            gameObject.GetComponent <SpriteRenderer>().enabled = true;
            GetComponent <CircleCollider2D>().enabled          = true;
        }

        GameObject  player = GameObject.Find("Steve_Square");
        ScoreScript steve  = player.GetComponent <ScoreScript>();

        if (steve.score == 3)
        {
            gameObject.GetComponent <SpriteRenderer>().enabled = false;
            gameObject.GetComponent <SlowBalls>().enabled      = false; //change the green portion between <> to current script name
        }

        HealthScript health = player.GetComponent <HealthScript>();

        if (health.hp <= 1)
        {
            gameObject.GetComponent <SpriteRenderer>().enabled = false;
            gameObject.GetComponent <SlowBalls>().enabled      = false; //change the green portion between <> to current script name
        }

        if (t.timer >= t.limit)
        {
            gameObject.GetComponent <SpriteRenderer>().enabled = false;
            gameObject.GetComponent <SlowBalls>().enabled      = false; //change the green portion between <> to current script name
        }
    }
Beispiel #2
0
    void Update()
    {
        if (canMove)
        {
            GameObject     playfield = GameObject.Find("Horizontal Playfield");
            RestrictScript field     = playfield.GetComponent <RestrictScript>();

            if (speedy == true)
            {
                float inputX = Input.GetAxis("Horizontal");
                float inputY = Input.GetAxis("Vertical");
                setDirection(inputX, inputY);

                movement = new Vector3(fast.x * inputX, fast.y * inputY, 0);
            }

            if (slowly == true)
            {
                float inputX = Input.GetAxis("Horizontal");
                float inputY = Input.GetAxis("Vertical");
                setDirection(inputX, inputY);

                movement = new Vector3(slow.x * inputX, slow.y * inputY, 0);
            }

            if (speedy != true && slowly != true)
            {
                float inputX = Input.GetAxis("Horizontal");
                float inputY = Input.GetAxis("Vertical");
                setDirection(inputX, inputY);

                movement = new Vector3(speed.x * inputX, speed.y * inputY, 0);
            }

            movement *= Time.deltaTime;
            transform.Translate(movement);

            Vector3 clampedPosition = transform.position;
            clampedPosition.x  = Mathf.Clamp(transform.position.x, field.minX + 1.3f, field.maxX - 1.3f);
            clampedPosition.y  = Mathf.Clamp(transform.position.y, field.minY + 1.60f, field.maxY - 1.05f);
            transform.position = clampedPosition;
        }

        GameObject  player = GameObject.Find("Steve_Square");
        ScoreScript steve  = player.GetComponent <ScoreScript>();

        if (steve.score == 3)
        {
            gameObject.GetComponent <SpriteRenderer>().enabled = false;
            gameObject.GetComponent <SteveScript>().enabled    = false;
        }

        HealthScript health = player.GetComponent <HealthScript>();

        if (health.hp <= 1)
        {
            gameObject.GetComponent <SpriteRenderer>().enabled = false;
            gameObject.GetComponent <SteveScript>().enabled    = false;
        }

        GameObject  clock = GameObject.Find("Timer");
        TimerScript t     = clock.GetComponent <TimerScript>();

        if (t.timer >= t.limit)
        {
            gameObject.GetComponent <SpriteRenderer>().enabled = false;
            gameObject.GetComponent <SteveScript>().enabled    = false;
        }
    }