Ejemplo n.º 1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         if (canOpenMenu)
         {
             canOpenMenu = false;
             //Bottom
             if (direction == 1)
             {
                 moveCamera.Move(0f, -18f);
                 nextPos = new Vector3(0, -teleport, 0);
                 player.transform.position += nextPos;
                 OpenCardSelect();
             }
             //Top
             else if (direction == 2)
             {
                 moveCamera.Move(0f, 18);
                 nextPos = new Vector3(0, teleport, 0);
                 player.transform.position += nextPos;
                 OpenCardSelect();
             }
             //Left
             else if (direction == 3)
             {
                 moveCamera.Move(-30f, 0f);
                 nextPos = new Vector3(-teleport, 0, 0);
                 player.transform.position += nextPos;
                 OpenCardSelect();
             }
             //Right
             else if (direction == 4)
             {
                 moveCamera.Move(30f, 0f);
                 nextPos = new Vector3(teleport, 0, 0);
                 player.transform.position += nextPos;
                 OpenCardSelect();
             }
         }
     }
 }
Ejemplo n.º 2
0
    /*
     * Starts moving the camera by invoking the move-method on the camera.
     * @param   context The information provided by the triggering event. This is a vector2, calculated by the buttons pressed and the corresponding axis.
     * W- and S-keys determine the y-Axis, while A- and D-keys determine the x-Axis.
     */
    public void MoveCamera(InputAction.CallbackContext context)
    {
        // Nullchecking for the MoveCamera-Component on the main-Camera-Gameobject.
        MoveCamera temp = _camera.go.GetComponent <MoveCamera>();

        if (temp)
        {
            Vector3 tempVec = context.ReadValue <Vector2>();
            temp.Move(tempVec);
        }
    }
Ejemplo n.º 3
0
 private void OnMouseDown()
 {
     if (Input.GetMouseButtonDown(0))
     {
         foreach (GameObject obj in others)
         {
             obj.SetActive(false);
         }
         moveCam.Move(position);
         anim.SetTrigger("Play");
         Destroy(GetComponent <Collider2D>());
         Destroy(this);
     }
 }
Ejemplo n.º 4
0
    public void StartGame()
    {
        StartCoroutine(Camera.Move());

        for (int i = 0; i < DisappearObjects.Length; i++)
        {
            DisappearObjects[i].SetTrigger("Exit");
        }

        if (GameProcesses.IsGame)
        {
            MenuPanel.SetActive(false);
        }
    }
Ejemplo n.º 5
0
    void Update()
    {
        if (stageIndex != FindObjectOfType <StageHelper>().stageIndex)
        {
            NextStage();
        }
        switch (stageIndex)
        {
        //猫猫兔兔上车
        case 1:
            if (!finished)
            {
                moveCam.Move(new Vector3(0, -10.8f, -10));
                finished = true;
            }
            break;

        //上车后
        case 2:
            if (!finished)
            {
                Items[0].GetComponent <Collider2D>().enabled = true;
                finished = true;
            }
            break;

        //白天对话
        case 3:
            if (!finished)
            {
                Items[0].GetComponent <Collider2D>().enabled = false;
                alpha += Time.deltaTime * 3 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                bubbles[0].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                bubbles[1].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                if (alpha == 1)
                {
                    Items[0].GetComponent <Collider2D>().enabled = true;
                    finished = true;
                }
            }
            break;

        //黄昏
        case 4:
            if (!finished)
            {
                Destroy(Items[1]);
                Items[2].SetActive(true);
                finished = true;
            }
            break;

        //黄昏对话
        case 5:
            if (!finished)
            {
                Items[0].GetComponent <Collider2D>().enabled = false;
                alpha += Time.deltaTime * 3 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                bubbles[2].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                bubbles[3].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                if (alpha == 1)
                {
                    Items[0].GetComponent <Collider2D>().enabled = true;
                    finished = true;
                }
            }
            break;

        //夜晚
        case 6:
            if (!finished)
            {
                Destroy(Items[2]);
                Items[3].SetActive(true);
                finished = true;
            }
            break;

        //夜晚对话
        case 7:
            if (!finished)
            {
                Items[0].GetComponent <Collider2D>().enabled = false;
                alpha += Time.deltaTime * 3 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                bubbles[4].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                bubbles[5].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                if (alpha == 1)
                {
                    Items[0].GetComponent <Collider2D>().enabled = true;
                    finished = true;
                }
            }
            break;

        //公车开过
        case 8:
            if (!finished)
            {
                Items[0].GetComponent <Collider2D>().enabled = false;
                Items[4].transform.position += new Vector3(Time.deltaTime * 15, 0, 0);
                if (Items[4].transform.position.x > 0.45f)
                {
                    Destroy(Items[5]);
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    finished = true;
                }
            }
            break;

        //公车离开屏幕
        case 9:
            if (!finished)
            {
                Items[4].transform.position += new Vector3(Time.deltaTime * 15, 0, 0);
                if (Items[4].transform.position.x > 30)
                {
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    finished = true;
                }
            }
            break;

        //站牌
        case 10:
            if (!finished)
            {
                Items[6].GetComponent <Animator>().SetTrigger("Play");
                finished = true;
            }
            break;

        //移动镜头到2-3-3
        case 11:
            if (!finished)
            {
                moveCam.Move(new Vector3(0, -21.6f, 0));
                finished = true;
            }
            break;

        //移动镜头到2-3-3
        case 12:
            if (!finished)
            {
                Items[10].GetComponent <Collider2D>().enabled = true;
                finished = true;
            }
            break;

        //递锤子
        case 13:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer > 1)
                {
                    alpha += Time.deltaTime * 3 * .3f;
                    alpha  = Mathf.Clamp(alpha, 0, 1);
                    Items[7].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1 - alpha);
                    Items[9].GetComponent <Image>().color          = new Color(1, 1, 1, alpha);
                    if (alpha == 1)
                    {
                        Items[8].SetActive(true);
                        finished = true;
                    }
                }
            }
            break;
        }
    }
Ejemplo n.º 6
0
    void Update()
    {
        if (stageIndex != FindObjectOfType <StageHelper>().stageIndex)
        {
            NextStage();
        }
        switch (stageIndex)
        {
        //地铁进站
        case 1:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer > trainLoopTime)
                {
                    //进站停车
                    Items[0].GetComponent <Animator>().SetBool("Loop", false);
                    finished = true;
                }
            }
            break;

        //猫猫上车
        case 2:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer > gateOpenTime)
                {
                    Items[2].GetComponent <Animator>().SetTrigger("Open");
                    Items[1].GetComponent <Cat1>().enabled = true;
                    finished = true;
                }
            }
            break;

        //上车后
        case 3:
            if (!finished)
            {
                alpha  = Mathf.Clamp(alpha, 0, 1);
                alpha -= Time.deltaTime * fadeSpeed;
                Items[1].GetComponentInChildren <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                Items[2].GetComponent <Animator>().SetTrigger("Close");
                Items[0].GetComponent <Animator>().SetBool("Loop", true);
                timer += Time.deltaTime;
                if (timer > 3.0f)
                {
                    moveCam.Move(new Vector3(0, -10.8f, -10));
                    alpha    = 0;
                    finished = true;
                }
            }
            break;

        //切换到火车内时
        case 4:
            if (!finished)
            {
                Items[6].GetComponent <NamePlate>().enabled  = true;
                Items[7].GetComponent <NamePlate>().enabled  = true;
                Items[15].GetComponent <NamePlate>().enabled = true;
                finished = true;
            }
            break;

        //名牌切到徐家汇后
        case 5:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer > 1.0f)
                {
                    moveCam.Move(new Vector3(0, -21.6f, -10));
                    finished = true;
                }
            }
            break;

        //切换到下车分镜时
        case 6:
            if (!finished)
            {
                Items[3].GetComponent <Animator>().enabled = true;
                finished = true;
            }
            break;

        //地铁进站时
        case 7:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer > trainLoopTime)
                {
                    //进站停车
                    Items[3].GetComponent <Animator>().SetBool("Loop", false);
                    finished = true;
                }
            }
            break;

        //地铁开门
        case 8:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer > gateOpenTime)
                {
                    Items[4].GetComponent <Animator>().SetTrigger("Open");
                    Items[5].GetComponent <Cat1>().enabled       = true;
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    alpha    = 0;
                    finished = true;
                }
            }
            break;

        //猫猫走出来
        case 9:
            if (!finished)
            {
                timer += Time.deltaTime;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                alpha += Time.deltaTime * fadeSpeed;
                Items[5].GetComponentInChildren <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                if (timer > gateOpenTime)
                {
                    alpha    = 1;
                    finished = true;
                }
            }
            break;

        //切分镜到出地铁站
        case 10:
            if (!finished)
            {
                timer += Time.deltaTime;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                alpha -= Time.deltaTime * fadeSpeed * 0.5f;
                Items[5].GetComponentInChildren <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                if (timer > 1.0f)
                {
                    moveCam.Move(new Vector3(0, -32.4f, -10));
                    finished = true;
                }
            }
            break;

        //扒拉人群
        case 11:
            if (!finished)
            {
                Items[8].GetComponent <DragPeople1>().enabled    = true;
                Items[13].GetComponent <DragPeople1>().enabled   = true;
                Items[8].GetComponent <BoxCollider2D>().enabled  = true;
                Items[13].GetComponent <BoxCollider2D>().enabled = true;
                if (PeopleCount == 4)
                {
                    Items[9].GetComponent <DragPeople1>().enabled    = true;
                    Items[12].GetComponent <DragPeople1>().enabled   = true;
                    Items[9].GetComponent <BoxCollider2D>().enabled  = true;
                    Items[12].GetComponent <BoxCollider2D>().enabled = true;
                }
                if (PeopleCount == 2)
                {
                    Items[10].GetComponent <DragPeople1>().enabled   = true;
                    Items[11].GetComponent <DragPeople1>().enabled   = true;
                    Items[10].GetComponent <BoxCollider2D>().enabled = true;
                    Items[11].GetComponent <BoxCollider2D>().enabled = true;
                }
                if (PeopleCount == 0)
                {
                    moveCam.Move(new Vector3(0, -43.2f, -10));
                    finished = true;
                }
            }
            break;

        //看见狗狗
        case 12:
            //播片就完事了
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer > 2.0f)
                {
                    moveCam.Move(new Vector3(0, -54.0f, -10));
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    alpha    = 0;
                    finished = true;
                }
            }
            break;

        case 13:
            //出现片头
            if (!finished)
            {
                timer += Time.deltaTime;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                alpha += Time.deltaTime * fadeSpeed * .3f;
                Items[14].GetComponent <Image>().color = new Color(1, 0, 0, alpha);
                if (timer > 1.5f)
                {
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    finished = true;
                }
            }
            break;

        case 14:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer >= 2.0f)
                {
                    SceneManager.LoadScene(2);
                    finished = true;
                }
            }
            break;

        default: break;
        }
    }
Ejemplo n.º 7
0
    void Update()
    {
        if (stageIndex != FindObjectOfType <StageHelper>().stageIndex)
        {
            NextStage();
        }
        switch (stageIndex)
        {
        //切屏到电脑交互界面时
        case 1:
            if (!finished)
            {
                if (goodCount == 2)
                {
                    Items[0].SetActive(true);
                }
                if (goodCount == 1)
                {
                    Items[0].GetComponent <Animator>().SetBool("Change1", true);
                }
                if (goodCount == 0)
                {
                    Items[0].GetComponent <Animator>().SetBool("Change2", true);
                }
                if (goodCount + badCount == 0)
                {
                    moveCam.Move(new Vector3(0, -32.4f, -10));
                    Destroy(Items[4]);
                    Destroy(Items[5]);
                    finished = true;
                }
            }
            break;

        case 2:
            //猫猫看向兔兔镜头开始移动
            if (!finished)
            {
                Items[1].transform.position = Vector3.MoveTowards
                                                  (Items[1].transform.position, new Vector3(6.5f, -32.4f, 0), 3 * Time.deltaTime);
                Items[2].GetComponent <Animator>().SetBool("Turn", true);
                if (Items[1].transform.position == new Vector3(6.5f, -32.4f, 0))
                {
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    Items[3].GetComponent <Animator>().SetBool("Turn", true);
                    timer = 0;
                    Destroy(Items[6]);
                    finished = true;
                }
            }
            break;

        case 3:
            //猫猫兔兔互看+傻笑
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer >= 1.0f)
                {
                    Items[2].GetComponent <Animator>().SetTrigger("Change");
                    Items[3].GetComponent <Animator>().SetTrigger("Change");
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    finished = true;
                }
            }
            break;

        case 4:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer >= 2.0f)
                {
                    SceneManager.LoadScene(3);
                    finished = true;
                }
            }
            break;

        default: break;
        }
    }
Ejemplo n.º 8
0
    void Update()
    {
        if (stageIndex != FindObjectOfType <StageHelper>().stageIndex)
        {
            NextStage();
        }
        switch (stageIndex)
        {
        //标题
        case 0:
            if (!finished)
            {
                alpha += Time.deltaTime * 3 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                Items[0].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1 - alpha);
                if (alpha == 1)
                {
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    finished = true;
                }
            }
            break;

        //显示兔兔跟猫猫
        case 1:
            if (!finished)
            {
                alpha += Time.deltaTime * 5 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                Items[1].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                timer += Time.deltaTime;
                if (timer > 1.2f && alpha == 1)
                {
                    moveCam.Move(new Vector3(0, 5, -10));
                    finished = true;
                }
            }
            break;

        //显示气泡
        case 2:
            if (!finished)
            {
                alpha += Time.deltaTime * 3 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                Items[2].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                Items[3].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                Items[4].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                Items[5].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                Items[6].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                foreach (SpriteRenderer sr in bubbles)
                {
                    sr.color = new Color(1, 1, 1, alpha);
                }
                if (alpha == 1)
                {
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    finished = true;
                }
            }
            break;

        //打开碰撞体
        case 3:
            if (!finished)
            {
                Items[2].GetComponent <Collider2D>().enabled = true;
                Items[3].GetComponent <Collider2D>().enabled = true;
                Items[4].GetComponent <Collider2D>().enabled = true;
                FindObjectOfType <StageHelper>().stageIndex += 1;
                finished = true;
            }
            break;

        //三个场景结束
        case 13:
            if (!finished)
            {
                alpha += Time.deltaTime * 3 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                foreach (SpriteRenderer sr in bubbles)
                {
                    sr.color = new Color(1, 1, 1, 1 - alpha);
                }
                if (alpha == 1)
                {
                    moveCam.Move(new Vector3(0, 0, -10));
                    finished = true;
                }
            }
            break;

        case 14:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer >= 2.0f)
                {
                    SceneManager.LoadScene(6);
                    finished = true;
                }
            }
            break;
        }
    }
Ejemplo n.º 9
0
    void Update()
    {
        if (stageIndex != FindObjectOfType <StageHelper>().stageIndex)
        {
            NextStage();
        }
        switch (stageIndex)
        {
        //接起电话时
        case 1:
            if (!finished)
            {
                Items[0].GetComponent <Animator>().SetBool("Calling", true);
                finished = true;
            }
            break;

        //妈妈出现时
        case 2:
            if (!finished)
            {
                Items[1].gameObject.SetActive(true);
                FindObjectOfType <StageHelper>().stageIndex += 1;
                finished = true;
            }
            break;

        //通话中
        case 3:
            if (!finished)
            {
                if (IconCount == 0)
                {
                    Destroy(Items[1]);
                    Items[2].gameObject.SetActive(true);
                    Items[3].GetComponent <Animator>().SetTrigger("Change");
                    IconCount = 3;
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    finished = true;
                }
            }
            break;

        //第二轮表情
        case 4:
            if (!finished)
            {
                if (IconCount == 0)
                {
                    Items[3].GetComponent <Animator>().SetTrigger("Change");
                    Items[4].GetComponent <Animator>().SetTrigger("Change");
                    Items[0].GetComponent <Animator>().SetBool("Calling", false);
                    finished = true;
                }
            }
            break;

        //挂电话后
        case 5:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer > 1.5f)
                {
                    moveCam.Move(new Vector3(0, -10.8f, -10));
                    finished = true;
                }
            }
            break;

        //切到门铃分镜
        case 6:
            if (!finished)
            {
                Items[5].GetComponent <DogPaw>().enabled = true;
                finished = true;
            }
            break;

        //狗狗按上门铃
        case 7:
            if (!finished)
            {
                Items[6].GetComponent <Animator>().SetTrigger("Change");
                moveCam.Move(new Vector3(0, -21.6f, -10));
                finished = true;
            }
            break;

        //猫猫去开门
        case 8:
            if (!finished)
            {
                Items[8].GetComponent <OpenDoor>().enabled = true;
                finished = true;
            }
            break;

        //开门时
        case 9:
            if (!finished)
            {
                Items[7].GetComponent <Animator>().SetTrigger("Change");
                finished = true;
            }
            break;

        //开门后
        case 10:
            if (!finished)
            {
                moveCam.Move(new Vector3(0, -32.4f, -10));
                finished = true;
            }
            break;

        case 11:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer >= 2.0f)
                {
                    SceneManager.LoadScene(5);
                    finished = true;
                }
            }
            break;

        default: break;
        }
    }
Ejemplo n.º 10
0
    void Update()
    {
        if (stageIndex != FindObjectOfType <StageHelper>().stageIndex)
        {
            NextStage();
        }
        switch (stageIndex)
        {
        //播放日历动画
        case 1:
            if (!finished)
            {
                Items[0].GetComponent <Animator>().SetTrigger("Play");
                finished = true;
            }
            break;

        //移动镜头到第二分镜
        case 2:
            if (!finished)
            {
                moveCam.Move(new Vector3(0, -10.8f, 0));
                finished = true;
            }
            break;

        //允许摄像机滚动
        case 3:
            if (!finished)
            {
                moveCam.GetComponent <DragCamera>().enabled = true;
                finished = true;
            }
            break;

        //关闭摄像机滚动
        case 4:
            if (!finished)
            {
                moveCam.GetComponent <DragCamera>().enabled  = false;
                Items[1].GetComponent <Collider2D>().enabled = true;
                finished = true;
            }
            break;

        //点击事件1
        case 5:
            if (!finished)
            {
                Items[1].GetComponent <Collider2D>().enabled = false;
                Items[2].SetActive(true);
                alpha += Time.deltaTime * 3 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                Items[2].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                if (alpha == 1)
                {
                    Items[4].GetComponent <Collider2D>().enabled = true;
                    FindObjectOfType <StageHelper>().stageIndex += 1;
                    finished = true;
                }
            }
            break;

        //点击事件2
        case 7:
            if (!finished)
            {
                Items[3].SetActive(true);
                alpha += Time.deltaTime * 3 * .3f;
                alpha  = Mathf.Clamp(alpha, 0, 1);
                Items[3].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
                if (alpha == 1)
                {
                    moveCam.Move(new Vector3(0, -75.6f, -10));
                    finished = true;
                }
            }
            break;

        case 9:
            if (!finished)
            {
                moveCam.Move(new Vector3(0, -88, 0));
                finished = true;
            }
            break;

        case 10:
            if (!finished)
            {
                timer += Time.deltaTime;
                if (timer >= 2.0f)
                {
                    SceneManager.LoadScene(7);
                    finished = true;
                }
            }
            break;
        }
    }