Esempio n. 1
0
        public EnemyBullet(Vector3 _pos, Sprite _spr, EnemyHead _head)
            : base(_pos, _spr, 1f, 1f, Vector2.One * 0.8f, Vector2.One * 0.25f, Vector2.Zero, 0.0f)
        {
            head = _head;

            Die();
            explode = false;

            AddTrig(new ColCircle(new Vector2(pos.X, pos.Y),
                                  Vector2.Zero,
                                  diam * 0.7f));
        }
Esempio n. 2
0
File: Editor.cs Progetto: Milun/VWA
        private void CreateActor(Vector2 _v)
        {
            Vector2 v = _v;

            Block block = null;

            // Spawn a block
            if (currentActorSelect.X == 0f && currentActorSelect.Y == 0f)
            {
                block = new BlockBurger(new Vector3(v.X, v.Y, 0f), sprBlock);
                rooms[currentRoom.X, currentRoom.Y].SetActor(new IntVector2D((int)v.X, (int)v.Y), block);
            }
            else if (currentActorSelect.X == 0f && currentActorSelect.Y == 1f)
            {
                block = new BlockTape(new Vector3(v.X, v.Y, 0f), sprBlockTape, sprBlockTapeSticker, actorMode % 4);
                rooms[currentRoom.X, currentRoom.Y].SetActor(new IntVector2D((int)v.X, (int)v.Y), block);
            }
            else if (currentActorSelect.X == 0f && currentActorSelect.Y == 2f)
            {
                block = new BlockDoom(new Vector3(v.X, v.Y, 0f), sprDoom);
                rooms[currentRoom.X, currentRoom.Y].SetActor(new IntVector2D((int)v.X, (int)v.Y), block);
            }

            if (Mouse.GetState().LeftButton == ButtonState.Released && block != null)
            {
                //rooms[currentRoom.X, currentRoom.Y].SetActor(new IntVector2D((int)v.X, (int)v.Y), block);

                placingActor = false;
                actorMode    = 0;
                return;
            }


            Enemy enemy = null;

            if (currentActorSelect.X == 2f && currentActorSelect.Y == 0f)
            {
                enemy = new EnemyStatue(new Vector3(v.X + 0.5f, v.Y + 1f, 0f), sprStatue, -1f, 1f);
            }
            else if (currentActorSelect.X == 2f && currentActorSelect.Y == 1f)
            {
                enemy = new EnemyStatue(new Vector3(v.X + 0.5f, v.Y, 0f), sprStatue, -1f, -1f);
            }
            else if (currentActorSelect.X == 1f && currentActorSelect.Y == 0f)
            {
                enemy = new EnemyHead(new Vector3(v.X + 1f, v.Y + 1f, 0f), sprHead, sprEarth, 1f);
            }

            if (enemy == null)
            {
                return;
            }

            enemy.DrawEditor();

            if (Mouse.GetState().LeftButton == ButtonState.Released)
            {
                rooms[currentRoom.X, currentRoom.Y].SetActor
                (
                    new IntVector2D((int)v.X, (int)(v.Y)), enemy
                );

                placingActor = false;
                actorMode    = 0;
                return;
            }
        }
Esempio n. 3
0
File: Room.cs Progetto: Milun/VWA
        public void LoadRoom(string filename, ref Sprite spr, ref Sprite _block)
        {
            //return;

            if (File.Exists(filename))
            {
                using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open)))
                {
                    tiles.Clear();

                    // Read how many tiles are in this room
                    int count = reader.ReadInt32();

                    // Read the tiles into the room
                    for (int i = 0; i < count; i++)
                    {
                        int   posX = reader.ReadInt32();
                        int   posY = reader.ReadInt32();
                        float offX = reader.ReadSingle();
                        float offY = reader.ReadSingle();
                        //int rotation = reader.ReadInt32();
                        //int color = reader.ReadInt32();

                        Tile tile = new Tile(spr,
                                             new Vector2(offX, offY),
                                             new Vector2(posX, posY));

                        tiles.Add(new IntVector2D(posX, posY), tile);
                    }

                    count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        // Need to read the type first.
                        int type = reader.ReadInt32();

                        // All actors have a position.
                        int posX = reader.ReadInt32();
                        int posY = reader.ReadInt32();

                        // Make block
                        if (type == 0)
                        {
                            Actor block = new BlockBurger(new Vector3(posX, posY, 0f), _block);
                            actors.Add(new IntVector2D(posX, posY), block);
                            continue;
                        }
                        else if (type == 3)
                        {
                            int   health = reader.ReadInt32();
                            Actor block  = new BlockTape(new Vector3(posX, posY, 0f), Editor.sprBlockTape, Editor.sprBlockTapeSticker, health);
                            actors.Add(new IntVector2D(posX, posY), block);
                            continue;
                        }
                        else if (type == 4)
                        {
                            Actor block = new BlockDoom(new Vector3(posX, posY, 0f), Editor.sprDoom);
                            actors.Add(new IntVector2D(posX, posY), block);
                            continue;
                        }

                        // Pretty much everything else reads the real position.
                        float X = reader.ReadSingle();
                        float Y = reader.ReadSingle();

                        bool  readFlipY  = false;
                        float writeFlipY = 1f;

                        switch (type)
                        {
                        // Statue
                        case 1:
                            readFlipY = reader.ReadBoolean();
                            if (readFlipY)
                            {
                                writeFlipY = -1f;
                            }

                            Actor statue = new EnemyStatue(new Vector3(X, Y, 0f), Editor.sprStatue, -1f, writeFlipY);
                            actors.Add(new IntVector2D(posX, posY), statue);
                            break;

                        // Head
                        case 2:
                            readFlipY = reader.ReadBoolean();
                            if (readFlipY)
                            {
                                writeFlipY = -1f;
                            }

                            Actor head = new EnemyHead(new Vector3(X, Y, 0f), Editor.sprHead, Editor.sprEarth, writeFlipY);
                            actors.Add(new IntVector2D(posX, posY), head);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }