Exemplo 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());
            }
        }
Exemplo 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);
        }
Exemplo n.º 3
0
 public override float GetRotation(SpaceShipControlInput input)
 {
     if (MouseLook)
     {
         return(base.GetRotation(input));
     }
     else
     {
         return(Rotate.GetAxisPosition());
     }
 }
Exemplo 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);
        }
Exemplo 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;
 }
Exemplo 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;
 }
Exemplo n.º 7
0
 public override float GetRotation(SpaceShipControlInput input)
 {
     if (MouseLook)
         return base.GetRotation(input);
     else
         return Rotate.GetAxisPosition();
 }
Exemplo n.º 8
0
        public override SpaceShipControlInput GetConstrols()
        {
            SpaceShipControlInput input = new SpaceShipControlInput();

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

            return input;
        }
Exemplo 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;
        }
Exemplo 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;
        }