/// <summary>
    /// プレーヤーが空中にいるか
    /// </summary>
    /// <returns>trueなら空中</returns>
    bool IsAir()
    {
        int layer = LayerName.GetObjectHitLayer();

        if (Physics.BoxCast(playerCenter, BoxRayScale, Vector3.down, new Quaternion(0, 0, 0, 0), YRaySize, layer, QueryTriggerInteraction.Ignore))
        {
            return(true);
        }

        return(false);
    }
    /// <summary>
    /// プレイヤーが移動できるかどうかの判定
    /// </summary>
    /// <returns>trueなら移動できる</returns>
    bool IsCanCove()
    {
        RaycastHit hit;

        if (Physics.BoxCast(playerCenter, BoxRayScale, new Vector3(dir, 0, 0), out hit, new Quaternion(0, 0, 0, 0), xRaySize, LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
        {
            Vector3 hitpos = hit.point;
            player.transform.position = new Vector3(hitpos.x + (playerXSize * -dir), transform.position.y, transform.position.z);
            return(true);
        }

        //第二
        if (Physics.CheckBox(playerCenter, BoxRayScale, new Quaternion(0, 0, 0, 0), LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
        {
            return(true);
        }

        return(true);
    }
Exemple #3
0
    protected override void EnemyUpdate()
    {
        base.EnemyUpdate();

        if (!fallOne)
        {
            if (!fall)
            {
                if (!Physics.BoxCast(enemyCenterPos, boxSize, Vector3.down, new Quaternion(0, 0, 0, 0), raySize, LayerName.GetWallObjectHitLayer()) && GetComponent <Rigidbody>().velocity.y < 0)
                {
                    Collider[] collid = Physics.OverlapBox(enemyCenterPos, boxSize, new Quaternion(0, 0, 0, 0), LayerMask.GetMask(LayerName.BLOCK), QueryTriggerInteraction.Ignore);
                    if (collid.Length == 0)
                    {
                        fall = true;
                    }
                }
            }
            else//落下
            {
                RaycastHit hit;

                Collider[] collid = Physics.OverlapBox(enemyCenterPos, boxSize, new Quaternion(0, 0, 0, 0), LayerMask.GetMask(LayerName.BLOCK), QueryTriggerInteraction.Ignore);

                bool collhit = false;
                if (collid.Length > 0)
                {
                    if ((collid[0].gameObject.layer & LayerName.GetWallObjectHitLayer()) != 0)
                    {
                        FallHitWall();
                    }
                    else
                    {
                        FallHitBlock(collid[0].gameObject);
                    }
                }
                if (!collhit && Physics.BoxCast(enemyCenterPos, boxSize, Vector3.down, out hit, new Quaternion(0, 0, 0, 0), raySize, LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
                {
                    if (hit.transform.CompareTag("wall") || hit.transform.CompareTag("endWall"))
                    {
                        FallHitWall();
                    }
                    else
                    {
                        FallHitBlock(hit.transform.gameObject);
                    }
                }
            }
        }
    }
 /// <summary>
 /// 天使のFixedUpdate
 /// </summary>
 protected override void EnemyUpdate()
 {
     if (down)//降下
     {
         if (Physics.BoxCast(enemyCenterPos, rayBoxSize, Vector3.down, new Quaternion(0, 0, 0, 0), downRaySize, LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
         {
             down          = false;
             downSizeCount = 0;
         }
         else
         {
             transform.position += Vector3.down * moveSpeed;
             downSizeCount      += moveSpeed;
             if (downSizeCount >= downSize)
             {
                 down          = false;
                 downSizeCount = 0;
             }
         }
     }
     else//左右移動
     {
         RaycastHit hit;
         if (Physics.BoxCast(enemyCenterPos, rayBoxSize, new Vector3(moveDir, 0, 0), out hit, new Quaternion(0, 0, 0, 0), raySize, LayerName.GetXMoveHitLayer(), QueryTriggerInteraction.Ignore))
         {
             if (hit.transform.CompareTag("enemy"))
             {
                 //反転
                 moveDir = -moveDir;
             }
             else if (hit.transform.CompareTag("wall") || hit.transform.CompareTag("blockObj"))
             {
                 //降下
                 down    = true;
                 moveDir = -moveDir;
             }
         }
         else
         {
             transform.position += new Vector3(moveSpeed * moveDir, 0, 0);
         }
     }
 }
    /// <summary>
    /// 達磨のFixedUpdate
    /// </summary>
    protected override void EnemyUpdate()
    {
        base.EnemyUpdate();
        if (jump && GetComponent <Rigidbody>().velocity.y < 0)
        {
            if (Physics.BoxCast(enemyCenterPos, grandChackBoxSize, Vector3.down, new Quaternion(0, 0, 0, 0), grandChackRaySize, LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
            {
                blockObjs[nnam] = Instantiate(jumpBlock, transform.position + Vector3.down * popPos, new Quaternion(0, 0, 0, 0), this.transform.parent);

                jump = false;
            }
        }
        for (int i = 0; i < blockObjs.Length; i++)
        {
            if (blockObjs[i] == null)
            {
                nnam = i;
                break;
            }
            else if (i == blockObjs.Length - 1)
            {
                jumpCount = jumpTime;
                nnam      = blockObjs.Length;
            }
        }
    }
Exemple #6
0
    protected override void EnemyUpdate()
    {
        base.EnemyUpdate();
        if (loopObj != null)
        {
            GetComponent <Rigidbody>().useGravity = false;
            GetComponent <Rigidbody>().velocity   = new Vector3(0, 0, 0);

            RaycastHit hit;
            if (BlockRayHit(enemyCenterPos, blockHitBoxScale, -rotateObj.transform.up, out hit))
            {
                loopObj = hit.transform.gameObject;

                transform.position += -rotateObj.transform.right * moveSpeed * moveDir;
                if (RotateRayHit(enemyCenterPos, rayBoxScale, -rotateObj.transform.right, out hit))
                {
                    loopObj  = hit.transform.gameObject;
                    moveNam += 4 - moveDir;
                    moveNam %= 4;
                    rotateObj.transform.eulerAngles = rotates[moveNam];

                    transform.position = hit.point + (rotateObj.transform.up * addP);

                    Debug.Log("壁移り");
                }
            }

            else
            {
                moveNam += 4 + moveDir;
                moveNam %= 4;
                rotateObj.transform.eulerAngles = rotates[moveNam];

                transform.position += -rotateObj.transform.right * moveSpeed * 3 * moveDir;
                if (BlockRayHit(enemyCenterPos, blockHitBoxScale, -rotateObj.transform.up, out hit))
                {
                    transform.position = hit.point + (rotateObj.transform.up * addP);
                    Debug.Log("壁回転 : 座標調整");
                    loopObj = hit.transform.gameObject;
                }
                else
                {
                    loopObj = null;
                }
                Debug.Log("壁回転");
            }
        }
        else
        {
            rotateObj.transform.eulerAngles       = rotates[0];
            GetComponent <Rigidbody>().useGravity = true;
            RaycastHit hit;

            if (Physics.BoxCast(enemyCenterPos + new Vector3(0, 0.1f, 0), rayBoxScale, Vector3.down, out hit, Quaternion.Euler(rotates[0]), blockHitRay, LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
            {
                if (hit.transform.CompareTag("wall") || (hit.transform.CompareTag("endWall")))
                {
                    if (Physics.BoxCast(enemyCenterPos, rayBoxScale, new Vector3(grMoveDir, 0, 0), Quaternion.Euler(rotates[0]), rotateRaySize, LayerName.GetXMoveHitLayer(), QueryTriggerInteraction.Ignore))
                    {
                        grMoveDir = -grMoveDir;
                    }
                    transform.position += new Vector3(grMoveDir * moveSpeed, 0, 0);
                }
                else
                {
                    loopObj = hit.transform.gameObject;
                    moveNam = 0;
                    GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
                    transform.position = hit.point + (rotateObj.transform.up * addP);
                }
            }
        }
    }