Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (mTarget == null)
        {
            return;
        }

        if (!mTarget.IsLive())
        {
            mTarget = null;
            Destroy(gameObject);
            return;
        }

        Vector3 pos = mTarget.GetPos() * CGameScaller.GetInstance().GetScale();// - CGameManager.GetInstance().GetPos();

        pos -= CGameManager.GetInstance().GetPos();

        pos.x *= 1.0f / 20.0f;
        pos.y *= 1.0f / 20.0f;

        if (pos.x < -50.0f || pos.x > 50.0f || pos.y < -50.0f || pos.y > 50.0f)
        {
            EnableImage(false);
        }
        else
        {
            SetPos(pos.x, pos.y);
            EnableImage(true);
        }
    }
Beispiel #2
0
    //대상 추적하기
    void SearchTarget()
    {
        MoveUnit();

        //추적할 대상이 없음
        CUnit enemy = CGameManager.GetInstance().GetEnemy(this);

        if (enemy == null || !enemy.IsLive())
        {
            if (mTarget == null)
            {
                SetStatus(UNIT_STATUS.US_MOVE);
            }
            else
            {
                if (mTarget.GetDistanceSq(this) > (mSight * mSight))
                {
                    mTarget = null;
                    SetStatus(UNIT_STATUS.US_MOVE);
                }
                else
                {
                    SetStatus(UNIT_STATUS.US_TRACE);
                }
            }

            return;
        }

        //대상이 있으면 추적으로 설정하기
        mTarget = enemy;

        if (mTarget.GetDistanceSq(this) > (mSight * mSight))
        {
            mTarget = null;
            SetStatus(UNIT_STATUS.US_MOVE);
        }
        else
        {
            mTargetPos = mTarget.GetPos();

            mMoveDirection = mTargetPos - GetPos();
            mMoveDirection.Normalize();

            SetStatus(UNIT_STATUS.US_MOVE_TARGET);
        }
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        if (mTarget.GetStatus() == CUnit.UNIT_STATUS.US_DYING)
        {
            Destroy(gameObject);
            return;
        }

        Vector3 pos = mTarget.GetPos() * CGameScaller.GetInstance().GetScale();

        pos  -= CGameManager.GetInstance().GetPos();
        pos.z = 1.0f;

        pos   *= 1.0f / CUIManager.GetInstance().GetScaleFactor();
        pos.y += 25;

        SetPos(pos.x, pos.y);

        SetValue(mTarget.GetHpPercent());
    }
Beispiel #4
0
    //unit과 현재 유닛간의 거리의 제곱을 얻기
    public float GetDistanceSq(CUnit unit)
    {
        Vector3 v = unit.GetPos() - GetPos();

        return((v.x * v.x) + (v.y * v.y));
    }