GameOver() публичный статический Метод

public static GameOver ( ) : void
Результат void
Пример #1
0
 void OnMouseDown()
 {
     if (gameHandler.isGameActive)
     {
         Destroy(gameObject);
         gameHandler.UpdateScore(pointValue);
         Instantiate(explosionParticle, transform.position, explosionParticle.transform.rotation);
         if (this.CompareTag("Bad_Object"))
         {
             gameHandler.GameOver();
         }
     }
 }
Пример #2
0
    void Start()
    {
        for (int x = 0; x < objectGrid.Length; x++)
        {
            int posx = (int)x / 4;
            int posy = (int)x % 4;

            if (objectGrid[x])
            {
                //Vector3 pos = new Vector3(posx*grid.squareWidth-2*grid.squareWidth, posy*grid.squareHeight-grid.squareHeight,0);
                Vector3    pos = new Vector3(posx * grid.squareWidth - grid.squareWidth, posy * grid.squareHeight - grid.squareHeight, 0);
                GameObject obj = Instantiate(innerBlock, Vector3.zero, Quaternion.identity);
                //
                obj.transform.SetParent(transform);
                obj.transform.localPosition = pos;
                //
                Image image = obj.GetComponent <Image>();
                image.sprite = blockSprite;
                obj.GetComponent <RectTransform>().sizeDelta = new Vector2(grid.squareWidth, grid.squareHeight);
            }
        }

        if (!IsValidBlockPosition())
        {
            game.GameOver();
        }
    }
Пример #3
0
    // kaycak bloğa karar ver, input al, input varsa ona göre haraket et
    private void Update()
    {
        if (game.game == GameHandler.GameState.Start)
        {
            if (Mathf.Approximately(platfotmTiles[blockToSlide].transform.position.x, 0f))
            {
                blockToSlide = (blockToSlide + 1 < platfotmTiles.Count) ? blockToSlide += 1 : blockToSlide = 0;
            }

            ınput.directionGetter();

            if (ınput.directions.Count != 0)
            {
                ınput.dirr = ınput.directions.Dequeue();
                if (ınput.dirr == InputManager.direction.right)
                {
                    if (Mathf.Approximately(platfotmTiles[blockToSlide].transform.position.x, BlockPos[1]))
                    {
                        platfotmTiles[blockToSlide].transform.position = new Vector2(platfotmTiles[blockToSlide].transform.position.x - 1.5f, platfotmTiles[blockToSlide].transform.position.y);
                    }
                    else
                    {
                        game.GameOver();
                        StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockFallAnimation>().Fall(new Vector2(-1f, 0)));
                        var uı = (UIHandler)FindObjectOfType(typeof(UIHandler));
                        uı.GameOver();
                    }
                }
                else if (ınput.dirr == InputManager.direction.left)
                {
                    if (Mathf.Approximately(platfotmTiles[blockToSlide].transform.position.x, BlockPos[0]))
                    {
                        platfotmTiles[blockToSlide].transform.position = new Vector2(platfotmTiles[blockToSlide].transform.position.x + 1.5f, platfotmTiles[blockToSlide].transform.position.y);
                    }
                    else
                    {
                        game.GameOver();
                        StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockFallAnimation>().Fall(new Vector2(1f, 0)));
                        var uı = (UIHandler)FindObjectOfType(typeof(UIHandler));
                        uı.GameOver();
                    }
                }
            }
        }
    }
Пример #4
0
    private IEnumerator GameOverSequence()
    {
        transform.position = _playerHoldingArea;
        _gameHandler.UpdateGameSpeed(0);
        if (!_data.StoryData.EventCompleted(StoryEventID.FirstDeath))
        {
            yield return(_data.StoryData.StartCoroutine("TriggerEventCoroutine", StoryEventID.FirstDeath));
        }
        yield return(new WaitForSeconds(1f));

        _gameHandler.GameOver();
    }
Пример #5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Gem"))
        {
            collision.gameObject.SetActive(false);
            gameHandler.addGem();
        }

        if (collision.CompareTag("Cherry"))
        {
            collision.gameObject.SetActive(false);
            gameHandler.addCherry();
        }

        if (collision.CompareTag("Parchment"))
        {
            collision.gameObject.SetActive(false);
            gameHandler.addParchment();
        }

        if (collision.CompareTag("NextLevelCollider"))
        {
            gameHandler.LoadNextLevel();
        }

        if (collision.CompareTag("BottomLimitDeath"))
        {
            gameHandler.GameOver();
        }


        if (collision.CompareTag("Enemy"))
        {
            if (collision is CircleCollider2D)
            {
                if (!isInvincible)
                {
                    animator.SetTrigger("TookDamage");
                    Vector2 pushDirection = (transform.position - collision.transform.position).normalized;
                    GetComponent <Rigidbody2D>().AddForce(pushDirection * tookDamageThrust, ForceMode2D.Impulse);
                    gameHandler.takeDamage();

                    StartCoroutine(BecomeInvincible());
                }
            }
            else if (collision is BoxCollider2D)
            {
                collision.GetComponent <Enemy>().TakeDamage();
                GetComponent <Rigidbody2D>().AddForce(transform.up * thrust, ForceMode2D.Impulse);
            }
        }
    }
Пример #6
0
    // Start is called before the first frame update
    private void OnTriggerEnter2D(Collider2D collision)
    {
        switch (collision.gameObject.tag)
        {
        case "Food":
            gameHandler.Eat();
            break;

        case "Tail":
            print("Morreu");
            gameHandler.GameOver();
            break;
        }
    }
Пример #7
0
    private void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);
            touchPosition   = Camera.main.ScreenToWorldPoint(touch.position);
            touchPosition.z = 0;
            direction       = (touchPosition - transform.position);
            rb.velocity     = new Vector2(direction.x, direction.y) * moveSpeed;

            if (touch.phase == TouchPhase.Ended)
            {
                rb.velocity = Vector2.zero;
            }
        }

        if (playerHealth <= 0)
        {
            GameHandler.GameOver();
        }
    }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        //get player movement
        float hori = Input.GetAxis(player_name + "_hori");
        float vert = Input.GetAxis(player_name + "_vert");

        //contrain rotation (if angular vel is greater than max allowed set to max angular vel else add torque)
        if (Mathf.Abs(rigidbody2D.angularVelocity) > maxRotSpeed)
        {
            rigidbody2D.angularVelocity = Mathf.Sign(rigidbody2D.rotation) * maxRotSpeed;
        }
        else
        {
            rigidbody2D.AddTorque(-hori * rotationSpeed * (8 - tailLength) / 1.4f);
        }

        //add vel
        rigidbody2D.velocity = transform.right * vert * speed;

        rigidbody2D.mass = Settings.playerMass * (8 - tailLength);

        if (Input.GetButton(player_name + "_dash"))
        {
            decayCost = Settings.drainSpeedPerDashTrail;
            dash      = true;
            speed     = Settings.playerDashSpeed;
        }
        else
        {
            dash      = false;
            speed     = Settings.playerSpeed;
            decayCost = Settings.drainSpeedPerTrail;
        }

        if (!dash && speedup && speedupEnd < Time.time)
        {
            speedup = false;
            speed   = Settings.playerSpeed;
        }

        if (slowed && slowEnd < Time.time)
        {
            slowed = false;
            speed  = Settings.playerSpeed;
        }


        //check distance to last placed trail if greater then a set value then instantiate a new
        float dist = Vector3.Distance(lastPlacedTrailPos, transform.position);

        if (dist > distBetweenTrails && fillAmount > 0)
        {
            Transform t = joints[0].transform;

            if (dash)
            {
                instantTrail(t, new Vector3(Random.Range(-2f, 2f), Random.Range(-2f, 2f), 0));
                instantTrail(t, new Vector3(Random.Range(-2f, 2f), Random.Range(-2f, 2f), 0));
                instantTrail(t, new Vector3(Random.Range(-2f, 2f), Random.Range(-2f, 2f), 0));
                fillAmount -= decayCost;
            }
            else
            {
                instantTrail(t);
                fillAmount -= decayCost;
            }
            lastPlacedTrailPos = sponge.transform.position;
        }



        calcFill();

        if (fillAmount < 0)
        {
            gh.GameOver(player_name);
        }
    }
Пример #9
0
    private void MoveTile()
    {
        if (platfotmTiles[blockToSlide].GetComponent <Block>().type == BlockData.blockType.normal)
        {
            if (ınput.dirr == InputManager.direction.right)
            {
                if (Mathf.Approximately(platfotmTiles[blockToSlide].transform.position.x, BlockPos[1])) // if pressed right and next tile is on right
                {
                    explosionParticleSystem.Explode(platfotmTiles[blockToSlide].transform.position);

                    StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockAnimation>().MoveTile(0));
                    blockToSlide = (blockToSlide + 1 < platfotmTiles.Count) ? blockToSlide += 1 : blockToSlide = 0;
                    point++;
                    uI.SetPoint(point);

                    platfotmTiles [blockToSlide].gameObject.SetActive(false);                      // blow up the block
                    //platfotmTiles[blockToSlide].transform.position = new Vector2(platfotmTiles[blockToSlide].transform.position.x - distBetweenBlock, platfotmTiles[blockToSlide].transform.position.y);
                }
                else // if pressed Right but tile is on left
                {
                    game.GameOver();
                    StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockAnimation>().Fall(new Vector2(-1f, 0)));

                    uI.GameOver();
                }
            }
            else if (ınput.dirr == InputManager.direction.left)
            {
                if (Mathf.Approximately(platfotmTiles[blockToSlide].transform.position.x, BlockPos[0])) // if pressed left and tile is on left
                {
                    explosionParticleSystem.Explode(platfotmTiles[blockToSlide].transform.position);

                    StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockAnimation>().MoveTile(0));
                    blockToSlide = (blockToSlide + 1 < platfotmTiles.Count) ? blockToSlide += 1 : blockToSlide = 0;
                    point++;
                    uI.SetPoint(point);

                    platfotmTiles [blockToSlide].gameObject.SetActive(false);                       // blow up the block
                    //platfotmTiles[blockToSlide].transform.position = new Vector2(platfotmTiles[blockToSlide].transform.position.x + distBetweenBlock, platfotmTiles[blockToSlide].transform.position.y);
                }
                else // if pressed left but tile is on right
                {
                    game.GameOver();
                    StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockAnimation>().Fall(new Vector2(1f, 0)));

                    uI.GameOver();
                }
            }
        }
        else // if block is reverse
        {
            if (ınput.dirr == InputManager.direction.right)
            {
                if (Mathf.Approximately(platfotmTiles[blockToSlide].transform.position.x, BlockPos[0])) // if pressed right tile is on left
                {
                    explosionParticleSystem.Explode(platfotmTiles[blockToSlide].transform.position);

                    StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockAnimation>().MoveTile(0));
                    blockToSlide = (blockToSlide + 1 < platfotmTiles.Count) ? blockToSlide += 1 : blockToSlide = 0;
                    point++;
                    uI.SetPoint(point);

                    platfotmTiles [blockToSlide].gameObject.SetActive(false);                      // blow up the block
                    //platfotmTiles[blockToSlide].transform.position = new Vector2(platfotmTiles[blockToSlide].transform.position.x + distBetweenBlock, platfotmTiles[blockToSlide].transform.position.y);
                }
                else // if pressed right but reverse worng
                {
                    game.GameOver();
                    StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockAnimation>().Fall(new Vector2(1f, 0)));

                    uI.GameOver();
                }
            }
            else if (ınput.dirr == InputManager.direction.left) // if pressed left tile is on right
            {
                if (Mathf.Approximately(platfotmTiles[blockToSlide].transform.position.x, BlockPos[1]))
                {
                    explosionParticleSystem.Explode(platfotmTiles[blockToSlide].transform.position);

                    StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockAnimation>().MoveTile(0));
                    blockToSlide = (blockToSlide + 1 < platfotmTiles.Count) ? blockToSlide += 1 : blockToSlide = 0;
                    point++;
                    uI.SetPoint(point);

                    platfotmTiles [blockToSlide].gameObject.SetActive(false);                      // blow up the block
                    //platfotmTiles[blockToSlide].transform.position = new Vector2(platfotmTiles[blockToSlide].transform.position.x - distBetweenBlock, platfotmTiles[blockToSlide].transform.position.y);
                }
                else // if pressed left but reverse worng
                {
                    game.GameOver();
                    StartCoroutine(platfotmTiles[blockToSlide].GetComponent <BlockAnimation>().Fall(new Vector2(-1f, 0)));

                    uI.GameOver();
                }
            }
        }
    }