Esempio n. 1
0
        public override void Tick(float dtime)
        {
            SpaceShipControlInput input = GetControls();

            if (input == null)
            {
                return;
            }

            if (Target.ControlsJamed)
            {
                Target.ThrustPower = 0;
                Target.StrafePower = 0;
                Vector3 tmp = Target.Position;
                tmp.Y = 0;
                TargetActor.Position = tmp;
            }
            else
            {
                Target.ThrustPower = input.Thrust;
                Target.StrafePower = input.Strafe;

                if (input.NextWeapon)
                {
                    Target.NextWeapon();
                }
                if (input.PreviousWeapon)
                {
                    Target.PreviousWeapon();
                }

                if (input.Fire1)
                {
                    Target.Fire();
                }
                if (input.Fire2)
                {
                    Target.Fire(1);
                }
                if (input.Select)
                {
                    Target.Computer.TargetNearestToCursor(input.LookAt);
                }
                //for (int i = 0; i < Target.Slots.Length; ++i)
                {
                    if (input.CycleWeapon >= 0 && input.CycleWeapon < Target.Slots.Length)
                    {
                        Target.CycleWeapon(input.CycleWeapon);
                    }
                }
                //float cos = Target.GetCosDirection(input.LookAt);
                Target.RotationPower = GetRotation(input);
                //Cheetah.Console.WriteLine(Target.RotationPower.ToString());
            }
        }
Esempio n. 2
0
        public virtual float GetRotation(SpaceShipControlInput input)
        {
            float cos = Target.GetCosDirection(input.LookAt);
            float f   = -Math.Max(Math.Min(cos * 3, 1.0f), -1.0f);

            if (float.IsNaN(f))
            {
                throw new Exception("NaN");
            }
            return(f);
        }
Esempio n. 3
0
 public override float GetRotation(SpaceShipControlInput input)
 {
     if (MouseLook)
     {
         return(base.GetRotation(input));
     }
     else
     {
         return(Rotate.GetAxisPosition());
     }
 }
Esempio n. 4
0
        protected override SpaceShipControlInput GetControls()
        {
            SpaceShipControlInput input = new SpaceShipControlInput();

            input.Fire1  = Fire.GetButtonState();
            input.Fire2  = FireSecondary.GetButtonState();
            input.LookAt = Cursor.Position;
            input.Strafe = Strafe.GetAxisPosition();
            input.Thrust = Thrust.GetAxisPosition();
            input.Select = Select.GetButtonState();
            for (int i = 0; i < Cycle.Length; ++i)
            {
                if (Cycle[i].GetButtonState())
                {
                    input.CycleWeapon = i;
                }
            }
            input.NextWeapon     = NextWeapon.GetButtonState();
            input.PreviousWeapon = PreviousWeapon.GetButtonState();
            return(input);
        }
Esempio n. 5
0
 public virtual float GetRotation(SpaceShipControlInput input)
 {
     float cos = Target.GetCosDirection(input.LookAt);
     float f = -Math.Max(Math.Min(cos * 3, 1.0f), -1.0f);
     if (float.IsNaN(f))
         throw new Exception("NaN");
     return f;
 }
Esempio n. 6
0
 protected override SpaceShipControlInput GetControls()
 {
     SpaceShipControlInput input = new SpaceShipControlInput();
     input.Fire1 = Fire.GetButtonState();
     input.Fire2 = FireSecondary.GetButtonState();
     input.LookAt = Cursor.Position;
     input.Strafe = Strafe.GetAxisPosition();
     input.Thrust = Thrust.GetAxisPosition();
     input.Select = Select.GetButtonState();
     for (int i = 0; i < Cycle.Length; ++i)
     {
         if(Cycle[i].GetButtonState())
         {
             input.CycleWeapon = i;
         }
     }
     input.NextWeapon = NextWeapon.GetButtonState();
     input.PreviousWeapon = PreviousWeapon.GetButtonState();
     return input;
 }
Esempio n. 7
0
 public override float GetRotation(SpaceShipControlInput input)
 {
     if (MouseLook)
         return base.GetRotation(input);
     else
         return Rotate.GetAxisPosition();
 }
Esempio n. 8
0
        public override SpaceShipControlInput GetConstrols()
        {
            SpaceShipControlInput input = new SpaceShipControlInput();

            return input;
        }
Esempio n. 9
0
        public override SpaceShipControlInput GetConstrols()
        {
            SpaceShipControlInput input = new SpaceShipControlInput();
            input.LookAt = 2 * Owner.AbsolutePosition - Target.AbsolutePosition;
            input.Thrust = 1;

            return input;
        }
Esempio n. 10
0
        public override SpaceShipControlInput GetConstrols()
        {
            SpaceShipControlInput input = new SpaceShipControlInput();

            input.LookAt = Target;

            Vector3 dir = Target - Owner.AbsolutePosition;
            float dist = dir.Length;
            if (dist > lastdist)
            {
                stop = true;
                lastdist = float.PositiveInfinity;
            }

            if (Owner.Speed.Length < 1)
                stop = false;

            input.Strafe = stop?0:Math.Sign(Owner.GetCosDirection(Target));

            input.Thrust = stop?0:Math.Min((dist*dist)/(500.0f*500.0f),1.0f);

            if (dist < 200)
                Done = true;

            return input;
        }
Esempio n. 11
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;
        }