Beispiel #1
0
        public static Vector2 GetRotatedPosition(float degrees, Vector2 pos)
        {
            float prevDegrees = VEasyCalc.GetDirection(new Vector2(0f, 0f), pos);

            float distance = Vector2.Distance(new Vector2(0f, 0f), pos);

            return(GetRotatedPosition(prevDegrees + degrees, distance));
        }
Beispiel #2
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 #3
0
        public override void PreFireProcess()
        {
            if (target == null && owner != null)
            {
                target = owner.GetOperable <Targetable>().target;
            }

            if (target != null)
            {
                targetPos = target.transform.position;
            }
            direction = VEasyCalc.GetDirection(position, targetPos);
        }
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
        public override void PreFireProcess()
        {
            if (target == null && owner != null)
            {
                target = owner.GetOperable <Targetable>().target;
            }

            if (target != null)
            {
                targetPos = target.transform.position;
            }
            direction = VEasyCalc.GetDirection(position, targetPos);

            fireAngle = angle * (UnityEngine.Random.Range(0f, 1f) - 0.5f);
        }
Beispiel #6
0
        protected override void ActionProcess(Trigger trigger)
        {
            if (VEasyCalc.TryCast(trigger, out TrgCollision trgCol))
            {
                if (trgCol.target != null)
                {
                    target.moveDir = VEasyCalc.GetDirection(trgCol.target, target);
                }
            }
            else
            {
                target.moveDir += 180f;
            }

            GameManager.Instance.StartCoroutine(DecelerationProcess(trigger));
        }
Beispiel #7
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 #8
0
        private void FixedUpdate()
        {
            if (state == false)
            {
                return;
            }

            if (enableTargetUpdate)
            {
                TargetUpdate();
            }

            if (target != null)
            {
                owner.targetDir = VEasyCalc.GetDirection(owner, target);
            }
        }
Beispiel #9
0
 protected override void ActionProcess(Trigger trigger)
 {
     from.targetDir = VEasyCalc.GetDirection(from, to);
 }
Beispiel #10
0
        protected override void ActionProcess(Trigger trigger)
        {
            Vector2 mouseWorldPos = VEasyCalc.ScreenToWorldPos(Input.mousePosition);

            target.targetDir = VEasyCalc.GetDirection(target.transform.position, mouseWorldPos);
        }