Exemplo n.º 1
0
        public override SpaceShipControlInput GetConstrols()
        {
            SpaceShipControlInput input = new SpaceShipControlInput();

            input.LookAt = Target.AbsolutePosition;
            input.Thrust = 1;

            float dist = Owner.Distance(Target);

            Vector3 dir = Target.AbsolutePosition - Owner.AbsolutePosition;

            if (dir.LengthSquared > 0)
            {
                dir.Normalize();
                if ((float)Math.Acos(Vector3.Dot(dir, Owner.Direction)) < (float)Math.PI / 18 && dist < 2000)
                {
                    input.Fire1 = true;
                }
            }

            if (dist < 1000)
            {
                input.Strafe = 1;
                strafetime  += Root.Instance.TickDelta;
                if (strafetime > 10)
                {
                    Done     = true;
                    NextTask = new Retreat(Owner, Target);
                }
            }
            else
            {
                strafetime = 0;
            }

            if (dist < Owner.Radius * 3)
            {
                Done     = true;
                NextTask = new Retreat(Owner, Target);
            }
            return(input);
        }
Exemplo n.º 2
0
        public override SpaceShipControlInput GetConstrols()
        {
            SpaceShipControlInput input = new SpaceShipControlInput();

            input.LookAt = Target.AbsolutePosition;
            input.Thrust = 1;

            float dist = Owner.Distance(Target);

            Vector3 dir = Target.AbsolutePosition - Owner.AbsolutePosition;
            if (dir.LengthSquared > 0)
            {
                dir.Normalize();
                if ((float)Math.Acos(Vector3.Dot(dir, Owner.Direction)) < (float)Math.PI / 18 && dist < 2000)
                    input.Fire1 = true;
            }

            if (dist < 1000)
            {
                input.Strafe = 1;
                strafetime += Root.Instance.TickDelta;
                if (strafetime > 10)
                {
                    Done = true;
                    NextTask = new Retreat(Owner, Target);
                }
            }
            else
            {
                strafetime = 0;
            }

            if (dist < Owner.Radius * 3)
            {
                Done = true;
                NextTask = new Retreat(Owner, Target);
            }
            return input;
        }