/// <summary>
    /// ターゲッティング
    /// </summary>
    protected void Targeting()
    {
        if (targets.Count <= 0)
        {
            return;
        }

        //ターゲットの作るバウンディングボックスを求める
        Vector3 min, max, pos;

        min = max = pos = targets[0].transform.position;

        for (int i = 1; i < targets.Count; i++)
        {
            pos = targets[i].transform.position;
            //x
            if (min.x > pos.x)
            {
                min.x = pos.x;
            }
            else if (max.x < pos.x)
            {
                max.x = pos.x;
            }
            //y
            if (min.y > pos.y)
            {
                min.y = pos.y;
            }
            else if (max.y < pos.y)
            {
                max.y = pos.y;
            }
        }

        //カメラ位置
        Vector3 cameraPos;
        float   width = 0f, height = 0f;

        if (targets.Count == 1)
        {
            cameraPos = pos;
            width     = height = defaultSize;
        }
        else
        {
            width     = (max.x - min.x) * 0.5f;
            height    = (max.y - min.y) * 0.5f;
            cameraPos = new Vector3(min.x + width, min.y + height);
        }
        cameraPos.z = camera.transform.position.z;
        camera.transform.position = FuncBox.Vector3Lerp(camera.transform.position, cameraPos, 5 * Time.deltaTime);

        //カメラサイズ
        targetSize = (width < height ? height : width) * spacePar;
        if (targetSize < minSize)
        {
            targetSize = minSize;
        }
    }
Beispiel #2
0
 protected void Update()
 {
     if (flagRandom)
     {
         rotateVector = FuncBox.Vector3Lerp(rotateVector, targetAngle, t * Time.deltaTime);
     }
     transform.Rotate(rotateVector * rotatevelocity * Time.deltaTime);
 }
    public void Update()
    {
        //Indicatorを動かす
        Vector3 pos = Indicator.transform.position;

        pos = FuncBox.Vector3Lerp(pos, targetPos, lerpT * Time.deltaTime);
        Indicator.transform.position = pos;

        //時間の計測
        if (time <= returnPosTime)
        {
            time += Time.deltaTime;
            if (time > returnPosTime)
            {
                targetPos = defaultPos;
            }
        }
    }
Beispiel #4
0
    /// <summary>
    /// ターゲッティング
    /// </summary>
    protected void Targeting()
    {
        if (mainTarget == null)
        {
            return;
        }
        //カメラ位置
        Vector3 myPos     = mainTarget.transform.position;
        Vector3 cameraPos = new Vector3(myPos.x, myPos.y, camera.transform.position.z);

        camera.transform.position = FuncBox.Vector3Lerp(camera.transform.position, cameraPos, aimingLerp * Time.deltaTime);
        if (otherTargets.Count <= 0)
        {
            targetSize = minSize;
            return;
        }
        //メインから一番遠いターゲットを求める
        float   dis, maxDis = 0f;
        int     index = 0;
        Vector2 pos;

        for (int i = 0; i < otherTargets.Count; i++)
        {
            pos = otherTargets[i].transform.position;
            dis = Vector2.Distance(myPos, pos);
            if (maxDis < dis)
            {
                maxDis = dis;
                index  = i;
            }
        }
        //カメラサイズ
        Vector2 size = otherTargets[index].transform.position - myPos;

        size       = FuncBox.Vector3Abs(size);
        targetSize = (size.x < size.y ? size.y :size.x);
        //最小サイズ確認
        targetSize = (targetSize < minSize ? minSize : targetSize) * spacePer;
    }
Beispiel #5
0
 /// <summary>
 /// ブースト
 /// <para>通常、高速ブーストのフラグによって出力を変える</para>
 /// </summary>
 public void Boost()
 {
     if (BreakCheck())
     {
         return;
     }
     if (boostOutput <= 0f)
     {
         return;
     }
     if (flagBoost)
     {
         Vector3 v;                          //移動量
         float   e;                          //使用エネルギー(秒間)
         if (flagHighBoost)
         {
             v = transform.right * highBoostOutput * Time.deltaTime;
             e = highBoostEnergy * Time.deltaTime;
         }
         else
         {
             v = transform.right * boostOutput * Time.deltaTime;
             e = boostEnergy * Time.deltaTime;
         }
         //移動
         if (!AddVelocity(v, e))
         {
             //エネルギーが足りないのでエフェクトを非表示に
             IndicateBoostEffect(false);
             IndicateHighBoostEffect(false);
         }
     }
     else
     {
         //ブーストしてないなら慣性を掛ける
         rBody.velocity = FuncBox.Vector3Lerp(rBody.velocity, Vector3.zero, inertia * Time.deltaTime);
     }
 }
 /// <summary>
 /// 移動UI表示の更新
 /// </summary>
 public void UpdateMoveUI()
 {
     //座標
     targetPos = FuncBox.ViewPointTransform(mainCamera, player.transform.position, uiCamera);
     moveUIParent.transform.position = FuncBox.Vector3Lerp(moveUIParent.transform.position, targetPos, 0.5f);
 }
Beispiel #7
0
 protected void Update()
 {
     background.transform.localScale = FuncBox.Vector3Lerp(background.transform.localScale, targetSize, 0.5f);
     transform.localPosition         = FuncBox.Vector3Lerp(transform.localPosition, targetPos, 0.5f);
 }