Beispiel #1
0
        public virtual void Fire(Actor ss, Slot s)
        {
            CurrentReloadTime = 0;


            Projectile p = (Projectile)Root.Instance.Factory.CreateInstance(ProjectileType);
            if (p.NoReplication || Root.Instance.IsAuthoritive)
            {
                p.Target = ss.Computer.Target;

                Matrix4 ship = ss.Matrix;
                Matrix4 slot = s.Matrix;
                Matrix4 combined = slot * ship;
                Vector3 x, y, z;
                Matrix4Extensions.ExtractBasis(combined, out x, out y, out z);

                p.Position = Matrix4Extensions.ExtractTranslation(combined);
                p.Orientation = Matrix4Extensions.ExtractRotation(combined);
                //p.localspeed=new Vector3(0,0,ExitingSpeed);
                p.Speed = z * ExitingSpeed;
                p.Source = ss;
                Root.Instance.Scene.Spawn(p);

                if (FireSound != null)
                    p.PlaySound(FireSound, false);
            }
            //else p.Kill=true;
        }
Beispiel #2
0
 public Computer(Actor owner)
 {
     Owner = owner;
 }
Beispiel #3
0
 public ActorBaseControl(Actor target)
 {
     TargetActor = target;
 }
Beispiel #4
0
        public override void Fire(Actor ss, Slot s)
        {
            base.Fire(ss, s);

            AmmoSource.Unload(AmmoType, 1);
        }
Beispiel #5
0
        public override void Fire(Actor ss, Slot s)
        {
            base.Fire(ss, s);

            EnergySource.CurrentEnergy -= EnergyPerShot;
        }
Beispiel #6
0
 public void TargetNext()
 {
     IList<Actor> actors = Root.Instance.Scene.FindEntitiesByType<Actor>();
     foreach (Actor a in actors)
     {
         if (a != Owner && !a.Kill)
         {
             Target = (Actor)a;
             //System.Console.WriteLine("Computer aquired target: " + Target.ToString());
             break;
         }
     }
 }
Beispiel #7
0
 public Follow(SpaceShip owner, Actor target)
     : base(owner)
 {
     Target = target;
 }
Beispiel #8
0
 public DestroyObjective(string text,Actor[] targets)
     : base(text)
 {
     Targets = targets;
 }
Beispiel #9
0
 public EscortObjective(string text,Actor[] targets)
     : base(text)
 {
     Targets = targets;
 }
Beispiel #10
0
 public RendevouzObjective(string text, Actor[] targets)
     : base(text)
 {
     Targets = targets;
 }
Beispiel #11
0
 public override void ActorDestroy(Actor killer, Actor victim, Projectile p)
 {
     System.Console.WriteLine("actor destroyed.");
     if (!GameOver)
         PlayerKill(killer != null ? killer.Owner as Player : null, victim.Owner as Player, p);
 }
Beispiel #12
0
        void UpdateInfo(ActorInfoWindow info, Actor actor)
        {
            if (info == null)
                return;

            if (actor != null && !actor.Kill)
            {
                info.Visible = true;
                Actor t = actor;

                float[] f = Root.Instance.UserInterface.Renderer.GetRasterPosition(Vector3Extensions.ToFloats(t.SmoothPosition));
                Vector2 v = new Vector2(f[0],f[1]);
                v.Y = Root.Instance.UserInterface.Renderer.Size.Y - v.Y;
                info.Position = new Vector2((int)(v.X + 0.5f), (int)(v.Y + 0.5f));

                if (t.Shield != null)
                    info.ShieldBar.Value = t.Shield.CurrentCharge / t.Shield.MaxEnergy;
                else
                    info.ShieldBar.Value = 0;
                if (t.Hull != null)
                    info.HitpointBar.Value = t.Hull.CurrentHitpoints / t.Hull.MaxHitpoints;
                else
                    info.HitpointBar.Value = 0;

                if (t.Battery != null)
                    info.EneryBar.Value = t.Battery.CurrentCharge;
                else
                    info.EneryBar.Value = 0;

                /*
                if (t is SpaceShip)
                {
                    SpaceShip s = (SpaceShip)t;
                    info.EneryBar.Value = s.Battery.CurrentCharge;
                }
                else
                    info.EneryBar.Value = 0;
                */

                if (actor.Owner != null)
                {
                    info.Name.Caption = actor.Owner.Name;
                    if (actor.Owner is Player && ((Player)actor.Owner).Team >= 0)
                        info.Name.TextColor = Team.Colors[((Player)actor.Owner).Team];
                    else
                        info.Name.TextColor = new Color4f(1, 1, 1, 1);
                }
                else
                {
                    info.Name.TextColor = new Color4f(1, 1, 1, 1);
                    info.Name.Caption = actor.Name;
                }

            }
            else
                info.Visible = false;
        }
Beispiel #13
0
 public bool Transfer(Actor a)
 {
     if (a.Inventory != null && Items != null)
     {
         foreach (KeyValuePair<Type, int> kv in Items)
         {
             Cheetah.Console.WriteLine("transfering " + kv.Value.ToString() + " " + kv.Key.Name + " to " + a.ToString());
             a.Inventory.Load(kv.Key, kv.Value);
         }
         return true;
     }
     return false;
 }
Beispiel #14
0
 public Retreat(SpaceShip owner, Actor target)
     : base(owner)
 {
     Target = target;
 }
Beispiel #15
0
        public void TargetNearest(Predicate<Actor> pred)
        {
            float distnow = float.PositiveInfinity;

            IList<Actor> actors = Root.Instance.Scene.FindEntitiesByType<Actor>();
            foreach (Actor a in actors)
            {
                if (a != Owner && !a.Kill && pred(a))
                {
                    float dist = (((Node)a).AbsolutePosition - Owner.AbsolutePosition).Length;
                    if (dist < distnow)
                    {
                        Target = (Actor)a;
                        distnow = dist;
                    }
                }
            }
        }
Beispiel #16
0
 public CaptureObjective(string text, Actor[] targets)
     : base(text)
 {
     Targets = targets;
 }
Beispiel #17
0
        public void TargetNearestToCursor(Vector3 c)
        {
            float distnow = float.PositiveInfinity;

            IList<Actor> actors = Root.Instance.Scene.FindEntitiesByType<Actor>();
            foreach (Actor a in actors)
            {
                if (a != Owner && !a.Kill)
                {
                    float dist = (((Node)a).AbsolutePosition - c).Length;
                    if (dist < distnow)
                    {
                        Target = (Actor)a;
                        distnow = dist;
                    }
                }
            }

            /*foreach (KeyValuePair<int, Entity> de in Root.Instance.Scene.ClientList)
            {
                if (de.Value is Actor && de.Value != Owner && !de.Value.Kill)
                {
                    float dist = (((Node)de.Value).AbsolutePosition - c).Length;
                    if (dist < distnow)
                    {
                        Target = (Actor)de.Value;
                        distnow = dist;
                    }
                }
            }*/
            //if (Target != null)
            //    System.Console.WriteLine("Computer aquired target: " + Target.ToString());
        }
Beispiel #18
0
 public virtual void ActorDestroy(Actor killer, Actor victim, Projectile p)
 {
 }
Beispiel #19
0
        /*
        public TargetInfo Scan()
        {
            if(Target==null)
                return null;

            TargetInfo ti = new TargetInfo();
            ti.Dist = (Owner.AbsolutePosition - Target.AbsolutePosition).Length;

        }*/
        public void Tick(float dtime)
        {
            //if (Target == null)
            //    TargetNext();
            if (Target != null && Target.Kill)
            {
                System.Console.WriteLine("Computer lost target: " + Target.ToString());
                Target = null;
            }

            //if (TextMonitor == null)
            //   throw new Exception();
        }
Beispiel #20
0
 public Attack(SpaceShip owner, Actor target)
     : base(owner)
 {
     Target = target;
 }