Esempio n. 1
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);
                    }
                }
            }
        }
    }