Exemplo n.º 1
0
        public static bool LoadGame(GameState state)
        {
            if (!File.Exists(FILENAME)) return false;
            bool sucessfulLoad = false;

            using (StreamReader reader = new StreamReader(FILENAME))
            {
                String st;

                while ((st = reader.ReadLine()) != null)
                {
                    if (st.StartsWith("[GameState]"))
                    {
                        state.ParseSaveString(st);
                    }
                    else if (st.StartsWith("[Accordian]"))
                    {
                        state.SetPlayer(Accordian.ParseSaveString(st));
                        sucessfulLoad = true;
                    }
                    else if (st.StartsWith("[Note]"))
                    {
                        state.AddNote(Note.ParseSaveString(st));
                    }
                    else if (st.StartsWith("[Banjo]"))
                    {
                        state.AddBanjo(Banjo.ParseSaveString(st, state.GetPlayer()));
                    }
                }
                reader.Close();
            }
            File.Delete(FILENAME);
            return sucessfulLoad;
        }
Exemplo n.º 2
0
        public static bool SaveGame(GameState state)
        {
            if (!Directory.Exists(PATH)) Directory.CreateDirectory(PATH);

            using (StreamWriter writer = new StreamWriter(FILENAME))
            {

                writer.WriteLine(state.ToSaveString());
                writer.WriteLine(state.GetPlayer().ToSaveString());

                foreach (Note n in state.GetNotes())
                {
                    writer.WriteLine(n.ToSaveString());
                }

                foreach (Banjo b in state.GetBanjos())
                {
                    writer.WriteLine(b.ToSaveString());
                }

                writer.Close();
            }
            return true;
        }
Exemplo n.º 3
0
 public AttractState(ACWGame game, MainMenuState menu)
 {
     this.game = game;
     this.mainMenu = menu;
     gameState = new GameState(true);
 }
Exemplo n.º 4
0
 public Banjo(int x, int y, Accordian player, BanjoType type, GameState state = null)
 {
     Init(x, y);
     Init(type, player, state);
 }
Exemplo n.º 5
0
 public void Init(BanjoType type, Accordian player, GameState state = null)
 {
     if (type == BanjoType.Standard)
     {
         this.yVel = ACWGame.HEIGHT / 3;
         ai = new StandardBanjoAI();
     }
     else if (type == BanjoType.Hunter)
     {
         this.ai = new HunterBanjoAI(player);
     }
     else if (type == BanjoType.DeadlyStrummer)
     {
         this.hp = 2;
         this.xVel = ACWGame.WIDTH / 2.8;
         this.yVel = ACWGame.HEIGHT / 4;
         this.ai = new DeadlyStrummerAI(player, state);
     }
     this.state = state;
     this.type = type;
 }
Exemplo n.º 6
0
 public DeadlyStrummerAI(Accordian player, GameState state)
 {
     this.player = player;
     mtp = new MoveToPlayerAI(player);
     this.state = state;
 }
Exemplo n.º 7
0
        public void UpdateAutoPlay(GameTime dt, GameState state)
        {
            double dx = 0;
            if (targetEntity != null)
            {
                targetDX = (int)(targetEntity.x - targetOldX);
                targetOldX = (int)targetEntity.x;

                dx = targetEntity.x - targetEntity.w / 2 - x + (targetEntity.type == Banjo.BanjoType.Standard ? (targetDX > 0 ? -40 : 40) : 0);
            }
            else
            {
                dx = ACWGame.WIDTH / 2 - x;
            }

            if (dx > 0) dx = 1;
            else dx = -1;

            x += dt.ElapsedGameTime.TotalSeconds * xVel * dx;

            Shoot(dt, state);
            UpdateAndValidateRect();
        }
Exemplo n.º 8
0
        public void Update(GameTime dt, GameState state)
        {
            if (!dead)
            {
                if (ACWGame.gameKeys[(int)ACWGame.KeyMap.W].down || ACWGame.gameKeys[(int)ACWGame.KeyMap.Up].down)
                {
                    y -= (yVel * dt.ElapsedGameTime.TotalSeconds);
                }
                if (ACWGame.gameKeys[(int)ACWGame.KeyMap.S].down || ACWGame.gameKeys[(int)ACWGame.KeyMap.Down].down)
                {
                    y += (yVel * dt.ElapsedGameTime.TotalSeconds);
                }
                if (ACWGame.gameKeys[(int)ACWGame.KeyMap.A].down || ACWGame.gameKeys[(int)ACWGame.KeyMap.Left].down)
                {
                    x -= (xVel * dt.ElapsedGameTime.TotalSeconds);
                }
                if (ACWGame.gameKeys[(int)ACWGame.KeyMap.D].down || ACWGame.gameKeys[(int)ACWGame.KeyMap.Right].down)
                {
                    x += (xVel * dt.ElapsedGameTime.TotalSeconds);
                }

                x += (xVel * dt.ElapsedGameTime.TotalSeconds * ACWGame.gamepad.ThumbSticks.Left.X);
                y -= (yVel * dt.ElapsedGameTime.TotalSeconds * ACWGame.gamepad.ThumbSticks.Left.Y);

                if (canShoot)
                {
                    Shoot(dt, state);
                }

                UpdateAndValidateRect();
            }
            else
            {
                if (!showExplosion) return;
                explosion.Update(dt);
                if (explosion.finished) remove = true;
            }
        }
Exemplo n.º 9
0
 public void Shoot(GameTime dt, GameState state)
 {
     shotTimer -= dt.ElapsedGameTime.TotalSeconds;
     if (shotTimer <= 0 && ((ACWGame.gamepad.Triggers.Right >= 0.4f || ACWGame.gameKeys[(int)ACWGame.KeyMap.Fire].down) || autoPlay))
     {
         state.AddNote(new Note(x + (w / 2), y, 0, -200, true));
         shotTimer = shotDelay;
         if(ACWGame.SOUND_ENABLED)ResourceManager.shoot.Play();
     }
 }