public List<Player> ReadPlayers()
 {
     List<Player> players = new List<Player>();
     try
     {
         conn.Open();
         SqlCommand sqlcmd = new SqlCommand("ReadPlayers", conn);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         DataTable table = new DataTable();
         SqlDataAdapter adapter = new SqlDataAdapter(sqlcmd);
         adapter.Fill(table);
         SqlDataReader reader = sqlcmd.ExecuteReader();
         reader.Read();
         foreach (DataRow row in table.Rows)
         {
             Player player = new Player(row["Name"].ToString());
             player.CurrentHitPoints = int.Parse(row["currentHitPoints"].ToString());
             player.MaximumHitPoints = int.Parse(row["maximumHitPoints"].ToString());
             player.Level = byte.Parse(row["Level"].ToString());
             player.ExperiencePoints = int.Parse(row["experiencePoints"].ToString());
             player.Gold = int.Parse(row["gold"].ToString());
             players.Add(player);
         }
         conn.Close();
         return players;
     }
     catch (Exception)
     {
         throw new ArgumentException("LoadPlayers failed");
     }
 }
Exemple #2
0
    public void Put(int index)
    {
        var result = Controller.putStone(cells, next, index);

        cells = result.Item1;
        next  = result.Item2;

        over = Controller.judge(cells);
    }
Exemple #3
0
 /// <summary>
 /// 加载保存的玩家对象
 /// </summary>
 /// <returns>加载成功的对象,null为失败了</returns>
 public Player LoadPlayer()
 {
     if (PlayerPrefs.HasKey("Player")) {
         var json = PlayerPrefs.GetString("Player");
         player = Player.LoadFromJson(json);
         return player;
     } else {
         return null;
     }
 }
    GameObject GetErrorBoxes(Model.Player player)
    {
        switch (player)
        {
        case Model.Player.Eyes: return(m_endSection.transform.Find("EyesErrorBoxes").gameObject);

        case Model.Player.Hands: return(m_endSection.transform.Find("HandsErrorBoxes").gameObject);

        case Model.Player.Ears: return(m_endSection.transform.Find("EarsErrorBoxes").gameObject);

        case Model.Player.Mouth: return(m_endSection.transform.Find("MouthErrorBoxes").gameObject);

        default: throw new System.ArgumentException();
        }
    }
    GameObject GetCardBlock(Model.Player player)
    {
        switch (player)
        {
        case Model.Player.Eyes: return(m_shuffleSection.transform.Find("EyesCardBlock").gameObject);

        case Model.Player.Hands: return(m_shuffleSection.transform.Find("HandsCardBlock").gameObject);

        case Model.Player.Ears: return(m_shuffleSection.transform.Find("EarsCardBlock").gameObject);

        case Model.Player.Mouth: return(m_shuffleSection.transform.Find("MouthCardBlock").gameObject);

        default: throw new System.ArgumentException();
        }
    }
        public Gameplay()
        {
            InitializeComponent();

            using (SoundPlayer player = new SoundPlayer(@"..\..\Audio\theme.wav"))
            {
                player.Play();
            }

            List<InventoryItem> pInventory = new List<InventoryItem>();
            List<PlayerQuest> pQuest = new List<PlayerQuest>();

            pInventory.Add(new InventoryItem(new Longsword(1), 1));

            _player = new Player("Sorrow Woodentears");
            lblHitPoints.Content = _player.CurrentHitPoints.ToString();
            lblGold.Content = _player.Gold.ToString();
            lblExperience.Content = _player.ExperiencePoints.ToString();
            lblLevel.Content = _player.Level.ToString();
            lblName.Content = _player.Name;

            // Map Examples... we need to code this better. Inherit a baselocation, and have several .cs files with locations?
            // Also have random areas, where it takes X number of travels to get by.
            Location home = new Location(1, "Your house", "You really need to clean up the place.");
            Location townSquare = new Location(2, "Town square", "You see a fountain.");
            Location wilderness = new Location(3, "The Wilderness", "Nothing to be seen anywhere.");
            Location oldForest = new Location(4, "Old Forest", "This place is dark and creepy...");
            Location theTemple = new Location(5, "Dark Temple", "An eerie sound comes from the temple.");
            Location smallLake = new Location(6, "A Lake", "You feel like you are being watched.");

            // Link the locations together
            home.LocationToNorth = townSquare;
            townSquare.LocationToSouth = home;
            townSquare.LocationToNorth = wilderness;
            townSquare.LocationToWest = oldForest;
            wilderness.LocationToSouth = townSquare;
            oldForest.LocationToEast = townSquare;
            oldForest.LocationToNorth = theTemple;
            oldForest.LocationToWest = smallLake;
            theTemple.LocationToSouth = oldForest;
            smallLake.LocationToEast = oldForest;

            MoveTo(home);

            _player.CurrentLocation = home;
            _player.Inventory = pInventory;
        }
 public void UpdatePlayer(Player player)
 {
     try
     {
         SqlCommand sqlcmd = new SqlCommand("UpdatePlayer", conn);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.Parameters.Add(new SqlParameter("@name", player.Name));
         sqlcmd.Parameters.Add(new SqlParameter("@currenthitpoints", player.CurrentHitPoints));
         sqlcmd.Parameters.Add(new SqlParameter("@maximumhitpoints", player.MaximumHitPoints));
         sqlcmd.Parameters.Add(new SqlParameter("@level", player.Level));
         sqlcmd.Parameters.Add(new SqlParameter("@experiencepoints", player.ExperiencePoints));
         sqlcmd.Parameters.Add(new SqlParameter("@gold", player.Gold));
         conn.Open();
         sqlcmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception)
     {
         throw new ArgumentException("UpdatePlayer failed");
     }
 }
 public void DeletePlayer(Player player)
 {
     data.DeletePlayer(player);
 }
 public void UpdatePlayer(Player player)
 {
     data.UpdatePlayer(player);
 }
 public void CreateNewPlayer(string name)
 {
     player = new Player(name);
     data.CreateNewPlayer(player);
     players.Add(player);
 }
Exemple #11
0
        /// <summary>
        /// 从数据生成玩家对象
        /// </summary>
        /// <param name="data">数据类</param>
        /// <returns></returns>
        public static Player LoadFromData(PlayerData data)
        {
            var player = new Player();
            player.name = data.Name;
            player.growth = data.Growth;
            player.experience = data.Experience;
            player.Level = data.Level;
            player.Strength = data.Strength;
            player.Agility = data.Agility;
            player.Intelligence = data.Intelligence;
            player.currentHP = data.CurrentHP;
            player.deck = data.Deck;
            player.skills = data.Skills;

            return player;
        }
 public void DeletePlayer(Player player)
 {
     try
     {
         SqlCommand sqlcmd = new SqlCommand("DeletePlayer", conn);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.Parameters.Add(new SqlParameter("@name", player.Name));
         conn.Open();
         sqlcmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception)
     {
         throw new ArgumentException("DeletePlayer failed");
     }
 }
Exemple #13
0
 public void Init(int id, Player player)
 {
     _id = id;
     _player = player;
 }
Exemple #14
0
 private void LoadParty(Player player)
 {
     var player1 = _game.Content.Load<BattleObject>(@"BattleXML/Character1");
     _playerParty.Add(player1);
 }