Example #1
0
File: Movements.cs Project: UDK/SoV
        public static void CircleAroundTarget(GameObject self, GameObject target, SpaceShipContainer container)
        {
            var distance = Vector2.Distance(
                container.Homing.transform.position,
                self.transform.position);

            if (distance > container.SightDist)
            {
                Movements.HeadToTarget(self, container.Homing, container);
                return;
            }
            Movements.MoveByCircle(self, container.Homing, container);
        }
Example #2
0
File: Attacks.cs Project: UDK/SoV
        public static Action Back(
            GameObject self,
            SpaceShipContainer container) =>
        () =>
        {
            Vector3 toTarget = (container.Target.transform.position - self.transform.position).normalized;
            var     dot      = Vector3.Dot(
                self.transform.right,
                toTarget);

            foreach (var weapon in container.Weapons)
            {
                weapon.Attack(container.Target, container.AllianceGuid);
            }
            var distance = Vector2.Distance(
                container.Target.transform.position,
                self.transform.position);

            if (dot < -0.60 &&
                distance > container.AttackDistance * 2)
            {
                container.StateMachine.Push(
                    ShipStates.Moving);
            }
            else if (dot < 0)
            {
                if (dot < -0.5)
                {
                    Movements.MoveByCircle(self, container.Target, container);
                }
                container.MovementBehaviour.SmoothlySetVelocity(
                    container.MovementBehaviour.Velocity.normalized *
                    container.MovementBehaviour.MaxVelocity);
            }
            else
            {
                Movements.MoveByCircle(self, container.Target, container);
            }

            Rotations.RotateBySpeed(self, container);
        };
Example #3
0
File: Attacks.cs Project: UDK/SoV
        public static Action CircleAround(
            GameObject self,
            SpaceShipContainer container) =>
        () =>
        {
            foreach (var weapon in container.Weapons)
            {
                weapon.Attack(container.Target, container.AllianceGuid);
            }

            var distance = Vector2.Distance(
                container.Target.transform.position,
                self.transform.position);
            if (distance > container.AttackDistance)
            {
                container.StateMachine.Push(
                    ShipStates.Moving);
                return;
            }

            Movements.MoveByCircle(self, container.Target, container);
            Rotations.RotateBySpeed(self, container);
        };