Esempio n. 1
0
        public override void Construct(Vector3 spawnPosition, float rotation, CampaignSection section)
        {
            base.Construct(spawnPosition, rotation, section);

            this._state     = AlienState.ALIVE;
            this._livestate = LiveState.ROAMING;
            this._health    = 250;

            this._mesh       = new SkinnedMesh();
            this._mesh.Model = AssetLoader.mdl_alien4;

            this._aplayer = new DurationBasedAnimator(_mesh.SkinningData, _mesh.SkinningData.AnimationClips["Take 001"], null);

            this._aplayer.AddAnimationPackage = AssetLoader.ani_alien4;
            this._aplayer.StartClip(Animation_States.moving);

            this.VerticalOffset = new Vector3(0, 0.8f, 0);
            this.ScaleMatrix    = Matrix.CreateScale(0.6f);

            UpdateAnimations(0);
            UpdateMajorTransform();

            Globals.gameInstance.sceneGraph.Setup(_mesh);
            this._modelReceipt = Globals.gameInstance.sceneGraph.Add(_mesh);

            _collisionRectangle = new RectangleF(
                _position.X - bBWidth,
                _position.Z - bBWidth, bBWidth * 2, bBWidth * 2);
        }
Esempio n. 2
0
 public virtual void Construct(Vector3 spawnPosition, float rotation, CampaignSection section)
 {
     this._mustBeDeleted = false;
     this._position      = spawnPosition;
     this._rotation      = rotation;
     this._section       = section;
 }
Esempio n. 3
0
        // spawn N of the given alien in the given section
        public static void Spawn(int n, CampaignSection s)
        {
            Vector3    r;
            RectangleF rr;

            while (n > 0)
            {
                r = new Vector3(
                    (float)Globals.random.NextDouble() * 30 + s.Index * 32 + 1,
                    0,
                    (float)Globals.random.NextDouble() * 30 + 1
                    );
                rr = new RectangleF(r.X - 0.5f, r.Z - 0.5f, 1.0f, 1.0f);
                // check collision
                if (Globals.gameInstance.cellCollider.RectangleCollides(rr))
                {
                    continue;
                }
                if (s.CollideAliens(rr))
                {
                    continue;
                }

                AlienType a = new AlienType();
                a.Construct(r, (float)Globals.random.NextDouble() * MathHelper.TwoPi, s);
                s.AddAlienToPopulation(a);

                n--;
            }
        }
Esempio n. 4
0
 public Alien4(Vector3 spawnPosition, CampaignSection section)
 {
     Construct(spawnPosition, (float)Globals.random.NextDouble() * MathHelper.TwoPi, section);
 }
Esempio n. 5
0
        public static void SpawnEntities(int id, Vector3 corigin, int index)
        {
            CampaignSection csection = new CampaignSection(index, corigin);

            Texture2D t = AssetLoader.tex_section_ent[id];

            Color[] colours = new Color[96 * 96];
            t.GetData <Color>(colours);

            for (int y = 0; y < 32; y++)
            {
                for (int x = 0; x < 32; x++)
                {
                    int pixelX     = x * 3;
                    int pixelY     = y * 3;
                    int pixelIndex = pixelY * 96 + pixelX;


                    Color   c      = colours[pixelIndex];
                    Vector3 center = corigin + new Vector3(0.5f + x, 0, 0.5f + y);


                    if (c == Color.Black || c == Color.Blue)
                    {
                        Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true);
                    }
                    else if (c == Color.Yellow)
                    {
                        csection.AddOverheadLight(SpawnOverheadLight(center));
                    }
                    else if (c == Color.Red)
                    {
                        SpawnFilingCabinet(center, colours, pixelX, pixelY);
                    }
                    else if (c == PureGreen)
                    {
                        int pi2 = (pixelY + 1) * 96 + pixelX + 1;

                        Color cc = colours[pi2];
                        if (cc == PureGreen)
                        {
                            csection.SetDoor(new Door(center));
                        }
                    }
                    else if (c == Color.DarkMagenta)
                    {
                        int pi2 = (pixelY + 2) * 96 + pixelX + 1;

                        if (colours[pi2] != Color.DarkMagenta)
                        {
                            Mesh m = new Mesh();
                            m.Model = AssetLoader.mdl_desk;
                            m.SetInstancingEnabled(true);
                            m.Transform = Matrix.CreateRotationY(MathHelper.ToRadians(0)) * Matrix.CreateTranslation(center + new Vector3(0, 0, 0.5f));

                            Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true);
                            Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z + 1, true);

                            Globals.gameInstance.sceneGraph.Setup(m);
                            Globals.gameInstance.sceneGraph.Add(m);
                        }

                        int pi3 = (pixelY + 1) * 96 + pixelX + 2;

                        if (colours[pi3] != Color.DarkMagenta)
                        {
                            Mesh m = new Mesh();
                            m.Model = AssetLoader.mdl_desk;
                            m.SetInstancingEnabled(true);
                            m.Transform = Matrix.CreateRotationY(MathHelper.ToRadians(90)) * Matrix.CreateTranslation(center + new Vector3(0.5f, 0, 0));

                            Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true);
                            Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z + 1, true);

                            Globals.gameInstance.sceneGraph.Setup(m);
                            Globals.gameInstance.sceneGraph.Add(m);
                        }
                    }
                    else if (c == Color.Turquoise)
                    {
                        float a = GetAngleToAWall(colours, pixelX, pixelY);
                        Mesh  m = new Mesh();
                        m.Model = AssetLoader.mdl_pipe;
                        m.SetInstancingEnabled(true);
                        m.Transform = Matrix.CreateRotationY(MathHelper.ToRadians(a)) * Matrix.CreateTranslation(center);

                        Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true);

                        Globals.gameInstance.sceneGraph.Setup(m);
                        Globals.gameInstance.sceneGraph.Add(m);
                    }
                    else if (c == Color.Tan)
                    {
                        csection.SetWeaponDepot(new WeaponDepot(center, Globals.random.Next(3) + 1));
                    }
                    else if (c == Color.SteelBlue)
                    {
                        Globals.gameInstance.campaignManager.SetTeleport(new Teleporter(center));
                    }
                }
            }

            Globals.gameInstance.campaignManager.AddSection(csection);
        }