Example #1
0
 //動く床のプレイヤーの動き
 private void PlayerWallMove()
 {
     if (moveWall != null)
     {
         WallAbility wa = moveWall.GetComponent <WallAbility>();
         if (wa.abilityNumber == 8)
         {
             MoveWall mw = moveWall.GetComponent <MoveWall>();
             mw.Move(gameObject, mw.speedX, mw.speedY);
         }
         else if (wa.abilityNumber == 9)
         {
             StageDate.Instance.SetData(SceneManager.GetActiveScene().name);
             fade.StartFadeIn("GameOver", false);
         }
         else
         {
         }
     }
 }
Example #2
0
    //判定を見るよう
    private void vecTest()
    {
        //コンポーネント取得
        wa = hitObject.GetComponent <WallAbility>();
        float x = hitPoint.x;
        float y = hitPoint.y;

        x *= 10;
        y *= 10;
        x  = Mathf.Floor(x) / 10;
        y  = Mathf.Floor(y) / 10;



        Debug.Log(wa.Width(true));
        Debug.Log(wa.Width(false));
        Debug.Log(wa.Height(true));
        Debug.Log(wa.Height(false));
        Debug.Log(hitPoint);
    }
Example #3
0
    //リスタート用
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.CompareTag("Wall") && currentPlayerState == PlayerState.Attack)
        {
            wa = col.gameObject.GetComponent <WallAbility>();
            switch (wa.abilityNumber)
            {
            case 3:    //滑る床
                SripAction(col.gameObject);
                break;

            case 4:    //とげ
                restratFlag = true;
                Instantiate(sperkEffect, effectPos2.transform.position, transform.rotation);
                StartCoroutine("ThornTime");
                break;

            case 5:    //斜めの反射
                SkewRefrect(col.gameObject);
                break;

            case 9:    //デスエリア
                StageDate.Instance.SetData(SceneManager.GetActiveScene().name);
                fade.StartFadeIn("GameOver", false);
                break;

            default:
                break;
            }
        }
        //EnemyTrigger場合
        //アタック(移動中に当たると)タイマー増加
        if (col.gameObject.CompareTag("Enemy"))
        {
            // ComboStart();
        }
    }
Example #4
0
    //動く床の判定
    private void coltest()
    {
        //コンポーネント取得
        wa = hitObject.GetComponent <WallAbility>();
        ////どの位置にあたったか判定し回転する
        float[]  posi  = new float[4];
        string[] num   = new string[4];
        Vector3  plPos = gameObject.transform.position;

        //各面の中心点のの距離を格納
        //posi[0] = Mathf.Floor(Vector3.Distance(hitPoint, wa.HeightPos(true)) *100) / 100;
        //posi[1] = Mathf.Floor(Vector3.Distance(hitPoint, wa.HeightPos(false)) * 100) / 100;
        //posi[2] = Mathf.Floor(Vector3.Distance(hitPoint, wa.WidthPos(true)) * 100) / 100;
        //posi[3] = Mathf.Floor(Vector3.Distance(hitPoint, wa.WidthPos(false)) * 100) / 100;

        posi[0] = Mathf.Floor(Vector3.Distance(plPos, wa.HeightPos(true)) * 100) / 100;
        posi[1] = Mathf.Floor(Vector3.Distance(plPos, wa.HeightPos(false)) * 100) / 100;
        posi[2] = Mathf.Floor(Vector3.Distance(plPos, wa.WidthPos(true)) * 100) / 100;
        posi[3] = Mathf.Floor(Vector3.Distance(plPos, wa.WidthPos(false)) * 100) / 100;
        //格納した値を短い順にする
        var list = new List <float>();

        list.AddRange(posi);
        list.Sort();

        //どこの面が短いか順番を決める
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                if (list[i] == posi[j])
                {
                    if (i > 0)
                    {
                        if (num[i - 1] != j.ToString())
                        {
                            num[i] = j.ToString();
                            break;
                        }
                    }
                    else
                    {
                        num[i] = j.ToString();
                        break;
                    }
                }
            }
        }

        //リストに沿って飛ぶ方向を決める
        bool go = false;
        int  f  = 0;

        while (!go)
        {
            switch (num[f])
            {
            case "0":
                if (wa.colObjs[0] == null)
                {
                    //中の番号を取得
                    int a = int.Parse(num[f + 1]);
                    if (list[f] == list[f + 1] && wa.colObjs[a] == null)
                    {
                        if (a == 2)
                        {
                            playerRot = Vector3.forward * 315;
                            // Debug.Log("上to右");
                        }
                        if (a == 3)
                        {
                            playerRot = Vector3.forward * 45;
                            //   Debug.Log("上to左");
                        }
                    }
                    else
                    {
                        //  Debug.Log("上");
                        playerRot = Vector3.forward * 0;
                    }
                    go = true;
                }
                else
                {
                    //  Debug.Log("上だけど無理");
                    f++;
                }
                break;

            case "1":
                if (wa.colObjs[1] == null)
                {
                    int a = int.Parse(num[f + 1]);
                    if (list[f] == list[f + 1] && wa.colObjs[a] == null)
                    {
                        // Debug.Log("したと左右");
                        if (a == 2)    //右
                        {
                            playerRot = Vector3.forward * 225;
                            //    Debug.Log("したと右");
                        }
                        if (a == 3)    //左
                        {
                            playerRot = Vector3.forward * 135;
                            //    Debug.Log("したと左");
                        }
                    }
                    else
                    {
                        //   Debug.Log("した");
                        playerRot = Vector3.forward * 180;
                    }
                    go = true;
                }
                else
                {
                    //  Debug.Log("下だけど無理");
                    f++;
                }
                break;

            case "2":
                if (wa.colObjs[2] == null)
                {
                    int a = int.Parse(num[f + 1]);
                    if (list[f] == list[f + 1] && wa.colObjs[a] == null)
                    {
                        //Debug.Log("右to上下");
                        if (a == 0)    //上
                        {
                            playerRot = Vector3.forward * 315;
                            Debug.Log("右to上");
                        }
                        if (a == 1)    //下
                        {
                            playerRot = Vector3.forward * 225;
                            //  Debug.Log("右to下");
                        }
                    }
                    else
                    {
                        //  Debug.Log("右");
                        playerRot = Vector3.forward * 270;
                    }
                    go = true;
                }
                else
                {
                    //  Debug.Log("右だけど無理");
                    f++;
                }
                break;

            case "3":

                if (wa.colObjs[3] == null)
                {
                    int a = int.Parse(num[f + 1]);
                    if (list[f] == list[f + 1] && wa.colObjs[a] == null)
                    {
                        //  Debug.Log("左と上下");
                        if (a == 0)    //上
                        {
                            playerRot = Vector3.forward * 45;
                            // Debug.Log("左と上");
                        }
                        if (a == 1)    //下
                        {
                            playerRot = Vector3.forward * 135;
                            //   Debug.Log("左と下");
                        }
                    }
                    else
                    {
                        //   Debug.Log("左");
                        playerRot = Vector3.forward * 90;
                    }
                    go = true;
                }
                else
                {
                    //  Debug.Log("左だけど無理");
                    f++;
                }
                break;
            }
        }
        //Debug.Log(list[f] + ":  " + posi[0] + "," + posi[1] + "," + posi[2] + "," + posi[3]);
        //Debug.Log(num[f] + ":  " + num[0] + "," + num[1] + "," + num[2] + "," + num[3]);
        //Debug.Log(wa.Width(true));
        //Debug.Log(wa.Width(false));
        //Debug.Log(wa.Height(true));
        //Debug.Log(wa.Height(false));
        //Debug.Log(hitPoint);
        wallNum = wa.abilityNumber;
    }
Example #5
0
    //回転の判定
    private void test()
    {
        //コンポーネント取得
        wa = hitObject.GetComponent <WallAbility>();
        float x = hitPoint.x;
        float y = hitPoint.y;

        x *= 10;
        y *= 10;

        x = Mathf.Floor(x) / 10;
        y = Mathf.Floor(y) / 10;


        //どの位置にあたったか判定し回転する
        if (y == wa.Height(true) || y + 0.1f == wa.Height(true) || y - 0.1f == wa.Height(true))
        {
            if (wa.colObjs[0] == null)
            {
                playerRot = Vector3.forward * 0;
                //Debug.Log("UP");
            }
            else
            {
                //  Debug.Log("UPだけどむり");
                coltest();
            }
        }
        else if (y == wa.Height(false) || y + 0.1f == wa.Height(false) || y - 0.1f == wa.Height(false))
        {
            if (wa.colObjs[1] == null)
            {
                playerRot = Vector3.forward * 180;
                //   Debug.Log("Down");
            }
            else
            {
                // Debug.Log("Downだけどむり");
                coltest();
            }
        }
        else if (x == wa.Width(true) || x + 0.1f == wa.Width(true) || x - 0.1f == wa.Width(true))
        {
            if (wa.colObjs[2] == null)
            {
                playerRot = Vector3.forward * 270;
                //  Debug.Log("right");
            }
            else
            {
                // Debug.Log("rightだけど無理");
                coltest();
            }
        }
        else if (x == wa.Width(false) || x + 0.1f == wa.Width(false) || x - 0.1f == wa.Width(false))
        {
            if (wa.colObjs[3] == null)
            {
                playerRot = Vector3.forward * 90;
                //  Debug.Log("left");
            }
            else
            {
                //  Debug.Log("leftだけど無理");
                coltest();
            }
        }
        else
        {
            //  Debug.Log("何も該当していない");
            coltest();
        }
        wallNum = wa.abilityNumber;
    }
Example #6
0
    //壁との当たり判定
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.CompareTag("Wall") && currentPlayerState == PlayerState.Attack)
        {
            if (!colFlag)
            {
                // Debug.Log("当たった");
                colFlag = true;
                if (hitObject != col.gameObject)
                {
                    hitObject = col.gameObject;
                    foreach (ContactPoint point in col.contacts)
                    {
                        hitPoint = point.point;
                    }
                    //  Debug.Log("違うオブジェ");
                    coltest();
                }

                jumpFlag           = false;
                playerRig.velocity = Vector3.zero;

                switch (wallNum)
                {
                case 0:    //着地
                    // Debug.Log("tyakuti");
                    ReflectActionCount();
                    break;

                case 1:    //沼の床
                    gameObject.transform.localRotation = Quaternion.Euler(0, 0, 0);
                    gameObject.transform.Rotate(playerRot);
                    jumpSpeed = jumpDefalut;
                    SetAngle();
                    currentPlayerState = PlayerState.Normal;
                    break;

                case 2:    //反射
                    //Debug.Log("hannsya");
                    ReflectAction();
                    break;

                case 4:    //とげ
                    restratFlag = true;
                    Instantiate(sperkEffect, effectPos2.transform.position, transform.rotation);
                    ReflectAction();
                    StartCoroutine("ThornTime");
                    break;

                case 6:    //斜め着地左
                    currentPlayerState = PlayerState.Normal;
                    SkewBlockLeft(col.gameObject);
                    break;

                case 7:    //斜め着地右
                    currentPlayerState = PlayerState.Normal;
                    SkewBlockRight(col.gameObject);
                    break;

                case 8:    //動く床
                    ReflectMoveActionCount(col.gameObject);
                    break;

                case 10:
                    ReflectActionCount();
                    break;

                default:
                    break;
                }
            }
        }
        //EnemyCollision場合
        //アタック(移動中に当たると)タイマー増加
        if (col.gameObject.CompareTag("Enemy"))
        {
            //   ComboStart();
        }
        if (col.gameObject.CompareTag("Wall"))
        {
            wa = col.gameObject.GetComponent <WallAbility>();
            switch (wa.abilityNumber)
            {
            case 9:    //デスエリア
                StageDate.Instance.SetData(SceneManager.GetActiveScene().name);
                fade.StartFadeIn("GameOver", false);
                break;

            default:
                break;
            }
        }
        if (col.gameObject.CompareTag("ChaseEnemy"))
        {
            StageDate.Instance.SetData(SceneManager.GetActiveScene().name);
            fade.StartFadeIn("GameOver", false);
        }
    }