Beispiel #1
0
        // 직선 등속 이동
        protected override void MoveFrame()
        {
            float moveDistance = speed * Time.fixedDeltaTime;

            Vector2 moveVector = VEasyCalc.GetRotatedPosition(owner.moveDir, moveDistance);
            Vector2 v2Pos      = owner.transform.position;

            owner.transform.position = v2Pos + moveVector;
        }
Beispiel #2
0
        public override void PreFireProcess()
        {
            if (count == 1)
            {
                return;
            }

            float deltaDistance = length * (UnityEngine.Random.Range(0f, 1f) - 0.5f);

            deltaPos = VEasyCalc.GetRotatedPosition(direction, new Vector2(deltaDistance, 0f));
        }
Beispiel #3
0
        public override void PreFireProcess()
        {
            if (target != null)
            {
                targetPos = target.transform.position;
            }
            direction = VEasyCalc.GetDirection(position, targetPos);

            float deltaDistance = length * (UnityEngine.Random.Range(0f, 1f) - 0.5f);

            deltaPos = VEasyCalc.GetRotatedPosition(direction, new Vector2(deltaDistance, 0f));
        }
Beispiel #4
0
        // 목적과의 방향차이에 비례해서 선회
        protected override void MoveFrame()
        {
            float moveDistance = speed * Time.fixedDeltaTime;

            float dirToPlayer = VEasyCalc.GetDirection(owner.transform.position, targetPos);

            owner.moveDir = VEasyCalc.GetLerpDirection(
                owner.moveDir, dirToPlayer, turnFactor * Time.fixedDeltaTime);

            Vector2 moveVector = VEasyCalc.GetRotatedPosition(owner.moveDir, moveDistance);

            Vector2 v2Pos = owner.transform.position;

            owner.transform.position = v2Pos + moveVector;
        }
Beispiel #5
0
        protected override void ActionProcess(Trigger trigger)
        {
            Vector2 targetPos;
            float   targetDir;
            float   distance = 0f;

            Collidable col = trigger.owner.GetOperable <Collidable>();

            if (VEasyCalc.TryCast(trigger, out TrgCollision trgCol))
            {
                Actor target = trgCol.target;
                targetPos = target.transform.position;
                targetDir = VEasyCalc.GetDirection(trigger.owner, target);

                // TODO 유닛간 block 처리 구현
                // Contact, Raycast 등 활용?
            }
            else if (VEasyCalc.TryCast(trigger, out TrgBoundaryTouch trgBndTch))
            {
                targetPos = trgBndTch.targetPos;
                targetDir = trgBndTch.bounceTo;

                if (VEasyCalc.TryCast(col?.collider, out CircleCollider2D circleCol))
                {
                    distance = circleCol.radius;
                }
                // TODO box collider 처리
            }
            else if (VEasyCalc.TryCast(trigger, out TrgBoundaryOut regBndOut))
            {
                targetPos = regBndOut.targetPos;
                targetDir = regBndOut.bounceTo;

                if (VEasyCalc.TryCast(col?.collider, out CircleCollider2D circleCol))
                {
                    distance = circleCol.radius;
                }
            }
            else
            {
                return;
            }

            Vector2 delta = VEasyCalc.GetRotatedPosition(targetDir + 180f, distance);

            trigger.owner.transform.position = targetPos + delta;
        }
Beispiel #6
0
        public override void PreFireProcess()
        {
            if (count == 1)
            {
                return;
            }

            float fireIndex = (float)firedCount / (count - 1) - 0.5f;

            if (!isLeftToRight)
            {
                fireIndex = -fireIndex;
            }
            float deltaDistance = length * fireIndex;

            deltaPos = VEasyCalc.GetRotatedPosition(direction, new Vector2(deltaDistance, 0f));
        }