Пример #1
0
    // Update is called once per frame
    void Update()
    {
        // パーティクルをマウスカーソルに追従させる
        Vector3 mousePosition = Input.mousePosition;

        mousePosition.z = 30.0f;  // OverLay以外のCanvasより手前に移動させる
        mousePosition   = Camera.main.ScreenToWorldPoint(mousePosition);

        touch = TouchStateManagerScript.GetTouch();

        if (m_DragParticle != null)
        {
            m_DragParticle.transform.position = new Vector3(mousePosition.x, mousePosition.y, mousePosition.z);
        }
        //タッチされていたら
        if (touch)
        {
            // タッチ開始時
            if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Began)
            {
                m_ClickParticle.transform.position = mousePosition;

                m_ClickParticleSystem.Play();   // 1回再生(ParticleSystemのLoopingにチェックを入れていないため)
            }
            // タッチ終了
            else if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Ended)
            {
                // Particleの放出を停止する
                m_ClickParticleSystem.Stop();
                m_DragParticleSystem.Stop();

                DragFlag = false;
            }
            // タッチ中
            else if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Moved)
            {
                if (!DragFlag)
                {
                    m_DragParticleSystem.Play();    // ループ再生(Loopingにチェックが入っている)
                    //string scene_name = TouchStateManagerScript.GetCurrentSceneName();
                    if (script.GetCurrentSceneName() == "TITLE" ||
                        script.GetCurrentSceneName() == "SELECT STAGE")
                    {
                        audioSource.PlayOneShot(SE_awa);
                    }
                    DragFlag = true;
                }
            }
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        // パーティクルをマウスカーソルに追従させる
        Vector3 mousePosition = Input.mousePosition;

        mousePosition.z = 30.0f;  // Canvasより手前に移動させる
        mousePosition   = Camera.main.ScreenToWorldPoint(mousePosition);

        touch = TouchStateManagerScript.GetTouch();

        if (m_DragParticle != null)
        {
            m_DragParticle.transform.position = new Vector3(mousePosition.x, mousePosition.y, mousePosition.z);
        }
        //タッチされていたら
        if (touch)
        {
            // タッチ開始時
            if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Began)
            {
                Debug.Log("★を出すよ");
                m_ClickParticle.transform.position = mousePosition;
                m_ClickParticleSystem.Play();   // 1回再生(ParticleSystemのLoopingにチェックを入れていないため)
            }
            // タッチ終了
            else if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Ended)
            {
                Debug.Log("タッチエフェクト停止");
                // Particleの放出を停止する
                m_ClickParticleSystem.Stop();
                m_DragParticleSystem.Stop();

                DragFlag = false;
            }
            // タッチ中
            else if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Moved)
            {
                if (!DragFlag)
                {
                    Debug.Log("キラキラを出すよ");
                    m_DragParticleSystem.Play();    // ループ再生(Loopingにチェックが入っている)

                    DragFlag = true;
                }
            }
        }
    }
Пример #3
0
    //=========================
    // 更新処理
    //=========================
    void Update()
    {
        if (TouchStateManagerScript.GetTouch() == false && awa_Flag == true)
        {
            awa_Flag = false;
        }
        // タッチされている時
        if (managerScript.isRotate == false && TouchStateManagerScript.GetTouch())
        {
            Kuttuki_Flag = false;

            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (!(Physics.Raycast(ray, out hit, Mathf.Infinity, mask)))
            {
                if (!awa_Flag)
                {
                    audioSource.PlayOneShot(SE_awa);
                    awa_Flag = true;
                }
            }
            if (startObj == null)
            {
                // Rayが特定レイヤの物体(バイキン)に衝突している場合
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask))
                {
                    // 大バイキンにRayが衝突している時
                    if (hit.collider.gameObject.CompareTag("BigSlime") &&
                        isFusion == false)
                    {
                        Debug.Log("爆発");

                        touchFlg = true; Debug.Log("有効なタッチである");

                        // 処理内容はslimeControl.csのBigSlimeClickAct()の中
                        hit.collider.gameObject.GetComponent <slimeControl>().SlimeDestroy(new Vector3(0, 0, 0));
                        managerScript.CheckBubble();
                    }
                    // 小、中バイキンにRayがぶつかった時
                    else if (hit.collider.gameObject.CompareTag("MiddleSlimeTate") || hit.collider.gameObject.CompareTag("MiddleSlimeYoko") ||
                             hit.collider.gameObject.CompareTag("SmallSlime"))
                    {
                        isFusion    = true;
                        currentName = hit.collider.gameObject.tag;

                        // バイキンオブジェクトを格納
                        startObj = hit.collider.transform.parent.gameObject;
                        endObj   = hit.collider.transform.parent.gameObject;

                        // 削除対象オブジェクトリストの初期化
                        removableBaikinList = new List <GameObject>();

                        // 削除対象のオブジェクトを格納
                        PushToList(hit.collider.gameObject);

                        Debug.Log("削除対象追加");
                    }
                }
                else
                {
                }
            }
            //タッチ終了時
            else if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Ended)
            {
                int remove_cnt = removableBaikinList.Count;

                if (remove_cnt == 2)
                {
                    if (startObj.CompareTag("MiddleSlime"))
                    {
                        //CreateBigBubble();
                    }
                    //小バイキンが消された場合
                    else if (startObj.CompareTag("SmallSlime"))
                    {
                        //CreateMiddleBubble();
                    }

                    //GameObject.Destroy(startObj);
                    //GameObject.Destroy(endObj);

                    //startObj.GetComponent<slimeControl>().BubbleMove(Vector3.Normalize(startObj.transform.position - endObj.transform.position));
                }
                // 消す対象外の時
                else
                {
                    for (int i = 0; i < remove_cnt; i++)
                    {
                        removableBaikinList[i] = null;
                    }
                }

                // リスト内のバイキンを消す
                currentName = null;
                startObj    = null;
                endObj      = null;
            }
            // タッチ中
            else if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Moved && startObj != null)
            {
                // Rayが特定レイヤの物体(バイキン)に衝突している場合
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask))
                {
                    if (hit.collider != null)
                    {
                        GameObject hitObj = hit.collider.transform.parent.gameObject;

                        // 同じタグのブロックをクリック&endObjとは別オブジェクトである時
                        if (hitObj.tag == currentName && endObj != hitObj)
                        {
                            Debug.Log("同タグの別オブジェクトが選択された");
                            // 2つのオブジェクトの距離を取得
                            float distance = Vector2.Distance(hitObj.transform.position, endObj.transform.position);
                            isFusion = false;
                            if (distance <= MaxDistance)
                            {
                                Debug.Log("z値を取得し比較");
                                // zが同じであれば

                                if (((managerScript.GetNowFront() == (int)manager.Wall.Front) || (managerScript.GetNowFront() == (int)manager.Wall.Back)) &&
                                    Mathf.Floor(Mathf.Abs(startObj.transform.parent.position.z)) / (MaxDistance / 2) ==
                                    Mathf.Floor(Mathf.Abs(hitObj.transform.parent.position.z)) / (MaxDistance / 2)
                                    )
                                {
                                    DecideBubble(hitObj);
                                }
                                else if (((managerScript.GetNowFront() == (int)manager.Wall.Right) || (managerScript.GetNowFront() == (int)manager.Wall.Left)) &&
                                         Mathf.Floor(Mathf.Abs(startObj.transform.parent.position.x)) / (MaxDistance / 2) ==
                                         Mathf.Floor(Mathf.Abs(hitObj.transform.parent.position.x)) / (MaxDistance / 2))
                                {
                                    DecideBubble(hitObj);
                                }
                            }
                        }
                    }
                }
            }
        }

        if (touchFlg == true)
        {
            //ここに中小のバイキン削除、バイキン生成を移す
            touchNum++;
            managerScript.CheckBubble();
            touchFlg = false;
        }
    }
Пример #4
0
    //=========================
    // 更新処理
    //=========================
    void Update()
    {
        // タッチされている時
        if (managerScript.isRotate == false && TouchStateManagerScript.GetTouch())
        {
            Debug.Log("タッチ開始");
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (startObj == null)
            {
                // Rayが特定レイヤの物体(スライム)に衝突している場合
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask))
                {
                    // 大スライムにRayが衝突している時
                    if (hit.collider.gameObject.CompareTag("BigSlime"))
                    {
                        Debug.Log("爆発");

                        // 処理内容はslimeControl.csのBigSlimeClickAct()の中
                        hit.collider.gameObject.GetComponent <slimeControl>().SlimeDestroy(new Vector3(0, 0, 0));
                    }
                    // 小、中スライムにRayがぶつかった時
                    else if (hit.collider.gameObject.CompareTag("MiddleSlime") ||
                             hit.collider.gameObject.CompareTag("SmallSlime"))
                    {
                        currentName = hit.collider.gameObject.tag;

                        // スライムオブジェクトを格納
                        startObj = hit.collider.transform.parent.gameObject;
                        endObj   = hit.collider.transform.parent.gameObject;

                        // 削除対象オブジェクトリストの初期化
                        removableSlimeList = new List <GameObject>();

                        // 削除対象のオブジェクトを格納
                        PushToList(hit.collider.gameObject);

                        Debug.Log("削除対象追加");
                    }
                }
            }
            //タッチ終了時
            else if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Ended)
            {
                int remove_cnt = removableSlimeList.Count;

                if (remove_cnt == 2)
                {
                    //中スライムが消された場合
                    if (startObj.CompareTag("MiddleSlime"))
                    {
                        GameObject obj = (GameObject)Resources.Load("Prefab/Fields/FieldInBIg");
                        //プレハブを元に、インスタンスを生成
                        GameObject tmp = Instantiate(obj,
                                                     new Vector3
                                                     (
                                                         (int)(startObj.transform.position.x + endObj.transform.position.x) / 2,
                                                         (int)(startObj.transform.position.y + endObj.transform.position.y) / 2,
                                                         (int)(startObj.transform.position.z + endObj.transform.position.z) / 2
                                                     ),
                                                     Quaternion.Euler(CreateSlimeQuarternion()));
                        //生成したプレハブをFieldCenterに登録する。
                        tmp.transform.parent = GameObject.Find("FieldCenter").transform;
                        Debug.Log("終点側に大スライムを生成");
                    }
                    //小スライムが消された場合
                    else if (startObj.CompareTag("SmallSlime"))
                    {
                        GameObject obj = (GameObject)Resources.Load("Prefab/Fields/FieldInMid");
                        //プレハブを元に、インスタンスを生成
                        GameObject tmp = Instantiate(obj,
                                                     new Vector3
                                                     (
                                                         (int)(startObj.transform.position.x + endObj.transform.position.x) / 2,
                                                         (int)(startObj.transform.position.y + endObj.transform.position.y) / 2,
                                                         (int)(startObj.transform.position.z + endObj.transform.position.z) / 2
                                                     ),
                                                     Quaternion.Euler(CreateSlimeQuarternion()));
                        //生成したプレハブをFieldCenterに登録する。
                        tmp.transform.parent = GameObject.Find("FieldCenter").transform;
                        Debug.Log("終点側に中スライムを生成");
                    }

                    GameObject.Destroy(startObj);
                    GameObject.Destroy(endObj);
                    //          startObj.GetComponent<slimeControl>().DestroyAnimation(startObj.transform.position - endObj.transform.position);

                    // スコアと消えるときの音はここ↓※これは昔つくったやーつ

                    //scoreGUI.SendMessage("AddPoint", point * remove_cnt);
                    //efxSource.Play();
                }
                // 消す対象外の時
                else
                {
                    for (int i = 0; i < remove_cnt; i++)
                    {
                        removableSlimeList[i] = null;
                    }
                }

                // リスト内のバイキンを消す
                currentName = null;
                startObj    = null;
                endObj      = null;
            }
            // タッチ中
            else if (TouchStateManagerScript.GetTouchPhase() == TouchPhase.Moved && startObj != null)
            {
                // Rayが特定レイヤの物体(バイキン)に衝突している場合
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask))
                {
                    if (hit.collider != null)
                    {
                        GameObject hitObj = hit.collider.transform.parent.gameObject;

                        // 同じタグのブロックをクリック&endObjとは別オブジェクトである時
                        if (hitObj.tag == currentName && endObj != hitObj)
                        {
                            Debug.Log("同タグの別オブジェクトが選択された");
                            // 2つのオブジェクトの距離を取得
                            float distance = Vector2.Distance(hitObj.transform.position, endObj.transform.position);

                            if (distance <= MaxDistance)
                            {
                                Debug.Log("z値を取得し比較");
                                // zが同じであれば

                                if (Mathf.Floor(Mathf.Abs(startObj.transform.parent.position.z)) / (MaxDistance / 2) == Mathf.Floor(Mathf.Abs(hitObj.transform.parent.position.z)) / (MaxDistance / 2) &&
                                    startObj.transform.rotation.z == hitObj.transform.rotation.z)
                                {
                                    Debug.Log("削除します");

                                    // 削除対象のオブジェクトを格納
                                    endObj = hitObj;
                                    // 削除対象のオブジェクトを格納
                                    PushToList(hitObj);
                                }
                            }
                        }
                    }
                }
            }
        }
    }