Exemplo n.º 1
0
    /// <summary>
    /// 骸骨のFixedUpdate
    /// </summary>
    protected override void EnemyUpdate()
    {
        if (notMoveCounter <= notMoveCount)
        {
            GetComponent <Rigidbody>().position = Vector3.MoveTowards(transform.position, targetCoordinate, moveSpeed);
            if (GetComponent <Rigidbody>().position == targetCoordinate)
            {
                snam            += addAngle;
                cnam            += addAngle;
                targetCoordinate = center + (new Vector3(Mathf.Sin(snam), Mathf.Cos(snam), 0)) * radius;
            }
            Debug.DrawRay(transform.position, (targetCoordinate - transform.position).normalized, Color.red, 0.1f);

            int layer = LayerName.GetMaltMoveHitLayer();
            if (Physics.BoxCast(enemyCenterPos, reverseBoxSize, targetCoordinate - transform.position, new Quaternion(0, 0, 0, 0), reverseRaySize, layer, QueryTriggerInteraction.Ignore))
            {
                addAngle         = -addAngle;
                snam            += addAngle;
                cnam            += addAngle;
                targetCoordinate = center + (new Vector3(Mathf.Sin(snam), Mathf.Cos(snam), 0)) * radius;
                if (notMoveCounter++ >= notMoveCount)
                {
                    GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
                }
            }
            else
            {
                notMoveCounter = 0;
            }
            SetRotate();
        }
    }
Exemplo n.º 2
0
 protected override void EnemyUpdate()
 {
     transform.position = Vector3.MoveTowards(transform.position, targetPos[moveNam], movePower);
     if (transform.position == targetPos[moveNam])
     {
         reachingPos();
     }
     if (hitReturn)
     {
         int layer = LayerName.GetMaltMoveHitLayer();
         if (Physics.BoxCast(transform.position, hitBoxSize, targetPos[moveNam] - transform.position, new Quaternion(0, 0, 0, 0), hitReturnRaySize, layer, QueryTriggerInteraction.Ignore))
         {
             moveDir *= -1;
             addMoveNam(moveDir);
         }
     }
 }
Exemplo n.º 3
0
    protected override void EnemyUpdate()
    {
        Vector3 moveVDir = new Vector3(0, 0, 0);

        switch (moveDir)
        {
        case MoveDir.Up:
            moveVDir.Set(0, 1, 0);
            break;

        case MoveDir.Right:
            moveVDir.Set(1, 0, 0);

            break;

        case MoveDir.Down:
            moveVDir.Set(0, -1, 0);

            break;

        case MoveDir.Left:
            moveVDir.Set(-1, 0, 0);
            break;
        }

        if (moveCount > 0)
        {
            moveCount--;
            int layer = LayerName.GetMaltMoveHitLayer();
            if (Physics.BoxCast(enemyCenterPos, boxSize, moveVDir, new Quaternion(0, 0, 0, 0), boxRaySize, layer, QueryTriggerInteraction.Ignore))
            {
                turn();
            }
        }
        else
        {
            turn();
        }

        transform.position += (moveVDir * moveSpeed);
    }
Exemplo n.º 4
0
    private void FixedUpdate()
    {
        if (!IsWallHit())
        {
            SetColliderCenter();


            RaycastHit hit;
            if (Physics.BoxCast(enemyCenterPos, boxRaySize, moveDir, out hit, new Quaternion(0, 0, 0, 0), raySize, LayerName.GetMaltMoveHitLayer(), QueryTriggerInteraction.Ignore))
            {
                moveDir = Vector3.Reflect(this.moveDir, hit.normal);
                Debug.DrawRay(hit.point, moveDir, Color.green, 2);
            }
            transform.position += moveDir.normalized * moveSpeed;
            cangeScaleObj.transform.localScale = baseSize + Vector3.one * ((1 + Mathf.Sin(sinCount)) * sinSize);
            sinCount += sinSpeed;
        }
    }