Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("KeyItem"))
        {
            portal.SetActive(true);
        }

        else if (collision.CompareTag("Portal"))
        {
            portal.GetComponent <AudioSource>().Play();
            gameObject.GetComponent <Collider2D>().enabled = false;
            fadeImage.PublicFadeOut();
        }

        else if (collision.CompareTag("enemy") || collision.CompareTag("EnemyBullet"))
        {
            hitSound.Play();
            transform.position = new Vector2(-7, -8);
            portal.SetActive(false);
            if (spawnedKey == null)
            {
                spawnedKey = Instantiate(key_prefab, new Vector2(0, 0), Quaternion.identity);
            }
            else
            {
                Destroy(spawnedKey);
                spawnedKey = Instantiate(key_prefab, new Vector2(0, 0), Quaternion.identity);
            }
        }
    }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.gameObject.tag == "Player")
        {
            if (twe.readyToNextstage)
            {
                enter.Play();
                StartCoroutine(MoveTo(coll.gameObject, twe.gateSpawnpoint.transform.position));
                fadeImage.PublicFadeOut();
                return;
            }


            if (twe.isTried3times == false)
            {
                reject.Play();
                coll.gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector2(-2500.0f, 1000f));
                count++;
            }
            if (count >= 2)
            {
                twe.isTried3times = true;
            }
        }
    }
 public void clearStage()
 {
     isStageCleared = true;
     Destroy(spawned_ball);
     spawned_player.GetComponent<Rigidbody2D>().gravityScale = 0.0f;
     StartCoroutine(MoveTo(spawned_player.gameObject, Gate_spawnPoint.transform.position));
     fadeImage.PublicFadeOut();
 }
Esempio n. 4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // 코인을 획득한 경우.
        if (collision.CompareTag("Coin"))
        {
            Coin.instance.GetCoin(collision.gameObject);
        }

        // Portal에 들어간 경우 다음 스테이지(윈도우95) 씬 로드.
        else if (collision.CompareTag("Portal"))
        {
            canMove      = false;
            coll.enabled = false;

            levelCompleted.Play();
            fadeImage.PublicFadeOut();
        }

        // Ghost와 부딪힌 경우.
        else if (collision.CompareTag("Ghost"))
        {
            Ghost ghostScript = collision.GetComponent <Ghost>();

            // Ghost를 잡을 수 없는 경우 게임을 재시작한다.
            if (ghostScript.curState != Ghost.State.CONFUSED)
            {
                audioSource.clip = dieSound;
                audioSource.Play();

                // Player의 위치, Ghost의 위치, 코인 & 아이템을 전부 초기 상태로 복원한다.
                canMove      = false;
                coll.enabled = false;
                Invoke("Restart", 0.2f);
            }

            // Ghost를 잡을 수 있는 경우 Ghost는 감옥으로 보내진다.
            else
            {
                audioSource.clip = catchEnemySound;
                audioSource.Play();

                ghostScript.SetState(Ghost.State.GOPRISON);
            }
        }

        // 아이템을 획득한 경우.
        else if (collision.CompareTag("Item"))
        {
            collision.gameObject.SetActive(false);

            // Ghost의 속도를 늦추었다가 3초 뒤에 원래대로 되돌린다.
            GhostManager.instance.SetConfused();
            GhostManager.instance.CancelInvoke();
            GhostManager.instance.Invoke("RevertConfused", 3);
        }
    }
Esempio n. 5
0
    private void EnterIP()
    {
        string input = inputField.GetComponent <InputField>().text;

        if (input.Equals(rightIP))
        {
            audioSource.Play();
            fade.PublicFadeOut();
        }
    }
Esempio n. 6
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("clock")) //시계가 닿으면
        {
            itemGet.Play();
            Debug.Log("시계");
            timerController.MinusTime();
            Destroy(collision.gameObject);
        }

        if (collision.CompareTag("word")) //단어가 닿으면
        {
            hitSound.Play();
            Debug.Log("게임 오버");
            timerController.ResetTime();                                          //시간 다시
            transform.position = new Vector3(-8.4f, -4.7f, 0);                    //플레이어 위치 다시

            GameObject[] destroyWord = GameObject.FindGameObjectsWithTag("word"); //단어 없애기
            foreach (GameObject destroy1 in destroyWord)
            {
                Destroy(destroy1);
            }

            GameObject[] destroyClock = GameObject.FindGameObjectsWithTag("clock"); //시계 없애기
            foreach (GameObject destroy2 in destroyClock)
            {
                Destroy(destroy2);
            }

            GameObject door = GameObject.FindWithTag("door");
            if (door != null)
            {
                Destroy(door);
            }
        }

        if (collision.CompareTag("door")) //문에 닿으면
        {
            if (flag <= 0)
            {
                levelCompleted.Play();
                isEnded = true;
                Debug.Log("다음 스테이지");
                GameObject[] words = GameObject.FindGameObjectsWithTag("word");
                foreach (var word in words)
                {
                    word.GetComponent <TextController>().isEnded = true;
                }
                fade.PublicFadeOut();
                flag++;
            }
        }
    }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        if (FadeImage.isOuted)
        {
            MoveScene.instance.WarpScene9();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (spriteIndex >= sprites.Length)
            {
                fadeImage.PublicFadeOut();
            }
            currentSprite.sprite = sprites[spriteIndex];
            spriteIndex++;
        }
    }
Esempio n. 8
0
    void Update()
    {
        if (FadeImage.isOuted)
        {
            MoveScene.instance.WarpScene8(); //씬 0으로 복귀, 수정필요
        }
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Debug.DrawRay(ray.origin, ray.direction * 10, Color.blue, 3.5f);
            RaycastHit2D hit = Physics2D.Raycast(ray.origin, Vector3.zero);

            if (hit.transform != null)
            {
                if (hit.transform.CompareTag("search"))
                {
                    fadeImage.PublicFadeOut();
                }
            }
        }
    }