Пример #1
0
        public NPC(Game game, Ship Ship, VertexScreen Vertex)
            : base(game)
        {
            this.Ship = Ship;
            this.Ship.CurrentVertex = Vertex;
            Ship.CurrentVertex.Ships.Add(Ship);

            GeneralManager.NPCs.Add(this);
        }
Пример #2
0
        public Vertex(Game game, Vector2 Pos, Texture2D Tex, VertexScreen Parent)
            : base(game)
        {
            this.Position = Pos;
            this.Tex = Tex;
            this.Rect = new Rectangle((int)(Pos.X), (int)(Pos.Y), (int)Tex.Width, (int)Tex.Height);
            spriteBatch = Renderer.Singleton.batch;
            Connections = new List<Vertex>();

            this.Parent = Parent;
        }
Пример #3
0
        public object Clone()
        {
            VertexScreen Tmp = new VertexScreen(Game, Vertex.Position, this.Tex);
            Tmp.Components = this.Components;
            Tmp.Ships = this.Ships;
            Tmp.Size = this.Size;
            Tmp.Vertex = this.Vertex;
            Tmp.Backgrounds = this.Backgrounds;

            return Tmp as object;
        }
Пример #4
0
 public void DetectCollisions(VertexScreen V, Ship Owner)
 {
     foreach (Bullet B in Bullets)
     {
         foreach (Ship S in V.Ships)
         {
             if (S.Hull.Mask.CheckCollision(B.Position + Owner.Position - S.Position + S.OutsideView.FrameSize/2) && Owner != S)
             {
                 B.CurrentLife = B.LifeTime;
                 S.HitPoints -= Damage;
                 S.CurrentVertex.Effect.Parameters["BloomIntensity"].SetValue(1.5f);
             }
         }
     }
 }
Пример #5
0
        public static VertexScreen CreateVertex(Game game, Vector2 Pos1, Texture2D Tex)
        {
            VertexScreen Tmp = new VertexScreen(game, Pos1, Tex);
            //Tmp.Background = Renderer.Singleton.Background;
            //Tmp.BackgroundScale = new Vector2(1.3f, 1.4f);

            Background Background1 = new Background();
            Background1.Tex = Renderer.Singleton.Background;
            Background1.Scale= new Vector2(1.3f, 1.4f);
            Background1.Color = Color.Gray;
            Tmp.Backgrounds.Add(Background1);

            Background Background2 = new Background();
            Background2.Tex = Renderer.Textures["Background_Clouds_1"];
            Background2.Scale = new Vector2(2.5f, 2.5f);
            Background2.Color = Color.White;
            Tmp.Backgrounds.Add(Background2);

            Background Background3 = new Background();
            Background3.Tex = Renderer.Textures["Background_Clouds_2"];
            Background3.Scale = new Vector2(3.5f, 3.5f);
            Background3.Color = Color.White;
            Tmp.Backgrounds.Add(Background3);

            foreach(VertexComponent C in GenerateAsteroidField(game, Vector2.One * Tmp.Size))
            {
                Tmp.Components.Add(C);
            }

            if (GeneralManager.Singleton.GetRandom() % 3 == 0)
            {
                SpaceStationComponent Station = new SpaceStationComponent(game);
                Station.Initialize();
                Station.Position = new Vector2(GeneralManager.Singleton.GetRandom() % 3000 + 1000, GeneralManager.Singleton.GetRandom() % 3000 + 1000);

                if (GeneralManager.Singleton.GetRandom() % 2 == 0) Station.TradeOptions.AddBuyOption(new BuyOption(new Engine(game), 50));
                if (GeneralManager.Singleton.GetRandom() % 2 == 0) Station.TradeOptions.AddBuyOption(new BuyOption(new Generator(game), 150));
                if (GeneralManager.Singleton.GetRandom() % 2 == 0) Station.TradeOptions.AddSellOption(new SellOption(new Engine(game), 60));
                if (GeneralManager.Singleton.GetRandom() % 2 == 0) Station.TradeOptions.AddSellOption(new SellOption(new Generator(game), 180));

                Tmp.Components.Add(Station);
            }

            var ItemToAdd = Tmp.Clone();

            return ItemToAdd as VertexScreen;
        }
Пример #6
0
 public NPC_Pirate1(Game game, Ship Ship, VertexScreen Vertex)
     : base(game, Ship, Vertex)
 {
     this.AI = new AgresiveAI(game);
     this.AI.Initialize(Ship);
 }
Пример #7
0
        public override void Update(GameTime gameTime)
        {
            foreach (Slot S in Hull.Slots)
            {
                if (S.Component != null)
                {
                    if (S.Component is Weapon)
                    {

                        Weapon Weapon = (S.Component as Weapon);
                        Weapon.Update(gameTime);
                        Weapon.DetectCollisions(this.CurrentVertex, this);

                        if (Weapon.ShootAnim.CurrentFrame > 0)
                        {
                            Weapon.ShootAnim.Update(gameTime);
                        }

                    }
                    else if (S.Component is MiningLaser)
                    {
                        (S.Component as MiningLaser).Update(gameTime, DrawPosition);
                    }
                    else
                    {
                        S.Component.Update(gameTime);
                    }
                }
            }

            switch (State)
            {
                case ShipState.InVertex:

                    Position += Speed;
                    if (AccelerationPercent > 0)
                    {
                        Speed += GeneralManager.Singleton.GetVectorFromAngle(- Angle + (float)Math.PI * 0.5f) * GetSpeed * AccelerationPercent;
                    }

                    if (Speed.Length() > GetMaxSpeed * AccelerationPercent)
                    {
                        Speed.Normalize();
                        Speed *= GetMaxSpeed * AccelerationPercent;
                    }

                    OutsideView.Position = DrawPosition;
                    if (OutsideColor != null)
                    {
                        OutsideColor.Position = DrawPosition;
                    }
                    InsideView.Update(gameTime);
                    OutsideView.Update(gameTime);
                    if (OutsideColor != null)
                    {
                        OutsideColor.Update(gameTime);
                    }
                    break;

                case ShipState.Travelling:
                    TimeToArrival -= HyperspaceSpeed;
                    if (TimeToArrival <= 0)
                    {
                        GeneralManager.SoundManager.PlaySound("DroppHSpace");
                        CurrentVertex = DestinationVertex;
                        CurrentVertex.Ships.Add(this);
                        State = ShipState.InVertex;
                    }
                    break;
            }

            SetEngineEmmiters();
            // ====================== HP HAndling ======

            if (HitPoints < 0)
            {
                HitPoints = 0;
                this.Hull.Wreck.Position = this.Position;
                this.Hull.Wreck.Angle = this.Angle;
                CurrentVertex.Components.Add(this.Hull.Wreck);
                CurrentVertex.Ships.Remove(this);
                CurrentVertex.Effect.Parameters["BloomIntensity"].SetValue(1000f);
            }

            //=-===============================
            /*
            if (Angle < Math.PI * 2)
            {
                Angle += (float)Math.PI * 2f;
            }
            if (Angle > Math.PI * 2)
            {
                Angle -= (float)Math.PI * 2f;
            }*/

            //Sound
            EngineSound.Volume = AccelerationPercent;
            //===

            base.Update(gameTime);
        }
Пример #8
0
 public void FlyTo(VertexScreen V)
 {
     if (CurrentVertex != null)
     {
         GeneralManager.SoundManager.PlaySound("Jump");
         GeneralManager.SoundManager.PlaySound("WarpJump");
         State = ShipState.Travelling;
         CurrentVertex.Ships.Remove(this);
         CurrentVertex = null;
         DestinationVertex = V;
         TimeToArrival = 10000.0f;
     }
 }