Exemple #1
0
 public void CopyFrom(PlayerGameData otherPlayerGameData)
 {
     Name = otherPlayerGameData.Name;
     Gold = otherPlayerGameData.Gold;
     PlayerStats.CopyFrom(otherPlayerGameData.PlayerStats);
     SlavesOwned = new List<Slave>(otherPlayerGameData.SlavesOwned);
 }
Exemple #2
0
    void Update()
    {
        //update remote character: body position, body rotation, head rotation, looking direction, animation state

        //if nothing new, skip update
        if (!isNeedUpdate())
        {
            return;
        }
//		ConsoleLog.SLog ("[" + playerNum + "] Update () " + (int)Time.realtimeSinceStartup);

        remotePlayerData = MultiplayerController.instance.latestPlayerDatas[playerNum];

        //body position
        Vector3 velocity = Vector3.zero;

        transform.position = Vector3.SmoothDamp(
            transform.position,
            remotePlayerData.position,
            ref velocity,
            MultiplayerController.instance.timeBetweenBroadcast * 0.9f
            );

        //body rotation
        float degreePerSec = 0f;

        transform.rotation = Quaternion.Euler(
            0,
            Mathf.SmoothDampAngle(
                transform.rotation.eulerAngles.y,
                remotePlayerData.rotation.eulerAngles.y,
                ref degreePerSec,
                MultiplayerController.instance.timeBetweenBroadcast * 0.9f
                ),
            0
            );

        //animation state
        if (anim.GetInteger("AnimNum") != remotePlayerData.animState)
        {
//			ConsoleLog.SLog ("AnimNum change: change animation (" +
//				anim.GetInteger ("AnimNum") + ", " + remotePlayerData.animState
//			);

            anim.SetInteger("AnimNum", remotePlayerData.animState);
            anim.SetTrigger("NewAnimation");
        }

        MultiplayerController.instance.hasNewPlayerDatas [playerNum] = false;
        MultiplayerController.instance.updatedLastFrame [playerNum]  = true;
    }
Exemple #3
0
    public void Refresh(PlayerGameData playerGameData)
    {
        float healthPercent = (float)(playerGameData.Health) / (float)(playerGameData.ShipRef.MaxHealth);
        float armorPercent  = (float)(playerGameData.Armor) / (float)(playerGameData.ShipRef.MaxArmor);
        float expPercent    = (float)(ExperienceConst.ExpNeededForLevel(playerGameData.Level)) / (float)(ExperienceConst.ExpNeededForLevel(playerGameData.Level + 1));

        ArmorPercent.text  = string.Format("{0}%", (int)(armorPercent * 100));
        HealthPercent.text = string.Format("{0}%", (int)(healthPercent * 100));
        ExpPercent.text    = string.Format("{0}%", (int)(expPercent * 100));

        Level.text = string.Format("Ship level {0}", playerGameData.Level);

        HealthBar.fillAmount     = healthPercent;
        ArmorBar.fillAmount      = armorPercent;
        ExperienceBar.fillAmount = expPercent;
    }
Exemple #4
0
 public void InitPlayerGameData(Player player)
 {
     _player           = player;
     _ship             = player.PlayerSelects.SelectedShip;
     _unlockedShipData = player.GetUnlockedShipByID(_ship.Id);
     _playerGameData   = new PlayerGameData()
     {
         UnlockedShipData = _unlockedShipData,
         Armor            = _unlockedShipData.Armor,
         Health           = _unlockedShipData.Health,
         Experience       = _unlockedShipData.Experience,
         Level            = _unlockedShipData.Level,
         ShipRef          = _ship
     };
     StaticTagFinder.GameUI.UiShipBars.Init(this);
     RefreshUi();
 }
        public Boolean InsertPlayerGameData(PlayerGameData pgd, int playerID)
        {
            //TODO: The team information needs to be in here

            SqlCommand verifyCmd = MyConnection.CreateCommand();

            verifyCmd.CommandText = "SELECT * FROM PlayerGame WHERE Player = @PlayerID AND Game = @GameID";
            verifyCmd.Parameters.AddWithValue("@PlayerID", pgd.player);
            verifyCmd.Parameters.AddWithValue("@GameID", pgd.game);
            MyConnection.Open();
            SqlDataReader reader  = verifyCmd.ExecuteReader();
            bool          hasRows = reader.HasRows;

            MyConnection.Close();
            int returnVal = 0;

            if (!hasRows)
            {
                SqlCommand cmd = MyConnection.CreateCommand();

                cmd.CommandText = "INSERT INTO PlayerGame(Played, Goals, Assists, Conceded, PenSave, PenMiss, Yellow, Red, Saves, Bonus, OwnGoal, Total, Game, Player, Team, NetTransfer, EASport, Value, CleanSheets) VALUES (@Played, @Goals, @Assists, @Conceded, @PenSave, @PenMiss, @Yellow, @Red, @Saves, @Bonus, @OwnGoal, @Total, @Game, @Player, @Team, @NetTransfer, @EASport, @Value, @CleanSheets)";
                cmd.Parameters.Add(new SqlParameter("@Played", pgd.played));
                cmd.Parameters.Add(new SqlParameter("@Goals", pgd.goals));
                cmd.Parameters.Add(new SqlParameter("@Assists", pgd.assist));
                cmd.Parameters.Add(new SqlParameter("@Conceded", pgd.conceded));
                cmd.Parameters.Add(new SqlParameter("@PenSave", pgd.pensave));
                cmd.Parameters.Add(new SqlParameter("@PenMiss", pgd.penmiss));
                cmd.Parameters.Add(new SqlParameter("@Yellow", pgd.yellow));
                cmd.Parameters.Add(new SqlParameter("@Red", pgd.red));
                cmd.Parameters.Add(new SqlParameter("@Saves", pgd.saves));
                cmd.Parameters.Add(new SqlParameter("@Bonus", pgd.bonus));
                cmd.Parameters.Add(new SqlParameter("@OwnGoal", pgd.ownGoal));
                cmd.Parameters.Add(new SqlParameter("@Total", pgd.total));
                cmd.Parameters.Add(new SqlParameter("@Game", pgd.game));
                cmd.Parameters.Add(new SqlParameter("@Player", playerID));
                cmd.Parameters.Add(new SqlParameter("@Team", pgd.team)); //TODO: Fix with actual Team
                cmd.Parameters.AddWithValue("@NetTransfer", pgd.transfer);
                cmd.Parameters.AddWithValue("@EASport", pgd.EAsports);
                cmd.Parameters.AddWithValue("@Value", pgd.value);
                cmd.Parameters.AddWithValue("@CleanSheets", pgd.cleansheets);
                MyConnection.Open();
                returnVal = cmd.ExecuteNonQuery();
                MyConnection.Close();
            }
            return(returnVal != 0);
        }
Exemple #6
0
        private void RunPlayer(int FLID)
        {
            WebRequest request = WebRequest.Create("http://fantasy.premierleague.com/web/api/elements/" + FLID + "/");

            request.Method = "GET";
            Stream response = request.GetResponse().GetResponseStream();

            StreamReader responseReader = new StreamReader(response);
            String       responseString = responseReader.ReadToEnd();

            XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(responseString, "PlayerData");

            Player p = DataAccess.Instance.GetPlayer(FLID);

            if (p != null)
            { // We know this player, lets update
                //Get the gameweek data
                XmlNode historyList = doc.GetElementsByTagName("fixture_history")[0];
                foreach (XmlNode node in historyList.ChildNodes)
                {
                    //child child #1 is gameweek
                    int jsonGameweek;
                    if (int.TryParse(node.ChildNodes[1].InnerText, out jsonGameweek))
                    {
                        if (jsonGameweek == GameWeek)
                        {
                            PlayerGameData.InsertGameData(node, p);
                        }
                    }
                }
                p.Price     = double.Parse(doc.GetElementsByTagName("now_cost")[0].InnerText) / 10.0;
                p.FirstName = doc.GetElementsByTagName("first_name")[0].InnerText;
                p.Active    = doc.GetElementsByTagName("status")[0].InnerText != "a" ? false : true;
                p.PhotoURL  = doc.GetElementsByTagName("photo_mobile_url")[0].InnerText;
                p.Position  = (Player.Positions)Enum.Parse(typeof(Player.Positions), doc.GetElementsByTagName("type_name")[0].InnerText);
                p.Update();
            }
            else
            {
                //this is a new Player
                string Name   = doc.GetElementsByTagName("web_name")[0].InnerText;
                string TeamID = (new Team(doc.GetElementsByTagName("team_name")[0].InnerText)).teamID.ToString();
                DataAccess.Instance.InsertPlayer(Name, TeamID, FLID);
                this.RunPlayer(FLID);
            }
        }
Exemple #7
0
    public static PlayerGameData ToObject(string json, out bool isSuccess, out Exception exception)
    {
        try
        {
            PlayerGameData data = JsonConvert.DeserializeObject <PlayerGameData>(json, serializerSettings);
            isSuccess = true;
            exception = null;

            return(data);
        }
        catch (Exception catchedException)
        {
            Debug.LogError($"Неуспешная попытка десериализации: {catchedException.Message}");

            isSuccess = false;
            exception = catchedException;

            return(null);
        }
    }
Exemple #8
0
 private protected override void WriteToStorage(PlayerGameData data)
 {
     SaveAndEncryptData(data);
 }
Exemple #9
0
 public PlayerAnsweredCorrectlyEventArgs(User player, PlayerGameData playerData)
 {
     Player     = player;
     PlayerData = playerData;
 }
Exemple #10
0
 public void Teardown()
 {
     playerGameData = null;
 }
Exemple #11
0
 public void Setup()
 {
     playerGameData = CreateTestPlayerGameData();
 }
Exemple #12
0
        // Create a player game data object
        public static PlayerGameData CreateTestPlayerGameData()
        {
            PlayerGameData gameData = new PlayerGameData();

            return(gameData);
        }
 public void PlayerAnsweredCorrectly(User player, PlayerGameData playerData)
 {
     PlayerAnsweredCorrectlyEvent?.Invoke(this, new PlayerAnsweredCorrectlyEventArgs(player, playerData));
 }
Exemple #14
0
 private protected abstract void WriteToStorage(PlayerGameData data);
Exemple #15
0
 void IModelInteraction.SetData(PlayerGameData data)
 {
     this.data = data;
 }
Exemple #16
0
 public DataSetter(PlayerGameData data)
 {
     statsSetter           = new StatsSetter(data.Stats);
     inGamePurchasesSetter = new InGamePurchasesSetter(data.InGamePurchases);
 }
Exemple #17
0
 private protected override void WriteToStorage(PlayerGameData data)
 {
     CreateSavedGame(data);
 }
Exemple #18
0
 public void CopyFrom(PlayerGameData otherPlayerGameData)
 {
     Name = otherPlayerGameData.Name;
     Gold = otherPlayerGameData.Gold;
     PlayerStats.CopyFrom(otherPlayerGameData.PlayerStats);
 }
        private PlayerGameData Map(string playerId, PlayerStats stats, Dictionary <string, Player> playerMap, Dictionary <string, Team> teamMap)
        {
            var player = playerMap[playerId];

            try
            {
                var position = GetNFLPosition(player.PrimaryPositionId);
                var team     = teamMap[player.TeamId];

                var res = new PlayerGameData
                {
                    Player = new NFLPlayer
                    {
                        DisplayName = player.DisplayName,
                        FirstName   = player.FirstName,
                        LastName    = player.LastName,
                        NFLPosition = position,
                        NFLTeamCode = team.Abbreviation,
                        YahooId     = player.PlayerId
                    },
                    Passing     = new Dictionary <PassingStat, int>(),
                    Receiving   = new Dictionary <ReceivingStat, int>(),
                    Rushing     = new Dictionary <RushingStat, int>(),
                    Kicking     = new Dictionary <KickingStat, int>(),
                    KickReturns = new Dictionary <KickReturnsStat, int>()
                };

                var returnTDStats = new[] { "nfl.stat_type.507", "nfl.stat_type.513" };

                var variationId = "nfl.stat_variation.2";
                foreach (var stat in stats[variationId])
                {
                    decimal value;
                    if (decimal.TryParse(stat.Value, out value))
                    {
                        var intValue = Convert.ToInt32(value);

                        if (returnTDStats.Contains(stat.Key))
                        {
                            if (res.KickReturns.ContainsKey(KickReturnsStat.TD))
                            {
                                res.KickReturns[KickReturnsStat.TD] += intValue;
                            }
                            else
                            {
                                res.KickReturns[KickReturnsStat.TD] = intValue;
                            }
                        }
                        else
                        {
                            var map = GetStatMap(stat.Key);
                            if (map.Passing.HasValue)
                            {
                                res.Passing[map.Passing.Value] = intValue;
                            }
                            if (map.Rushing.HasValue)
                            {
                                res.Rushing[map.Rushing.Value] = intValue;
                            }
                            if (map.Receiving.HasValue)
                            {
                                res.Receiving[map.Receiving.Value] = intValue;
                            }
                            if (map.Kicking.HasValue)
                            {
                                res.Kicking[map.Kicking.Value] = intValue;
                            }
                            if (map.Kicking.HasValue)
                            {
                                res.Kicking[map.Kicking.Value] = intValue;
                            }
                        }
                    }
                }

                return(res);
            } catch (Exception x)
            {
                throw new Exception($"Error processing player: {player.DisplayName}", x);
            }
        }
	void Update () {
		//update remote character: body position, body rotation, head rotation, looking direction, animation state

		//if nothing new, skip update
		if(!isNeedUpdate()) return;
//		ConsoleLog.SLog ("[" + playerNum + "] Update () " + (int)Time.realtimeSinceStartup);

		remotePlayerData = MultiplayerController.instance.latestPlayerDatas[playerNum];

		//body position
		Vector3 velocity = Vector3.zero;
		transform.position = Vector3.SmoothDamp (
			transform.position,
			remotePlayerData.position,
			ref velocity,
			MultiplayerController.instance.timeBetweenBroadcast * 0.9f
		);

		//body rotation
		float degreePerSec = 0f;
		transform.rotation = Quaternion.Euler (
			0,
			Mathf.SmoothDampAngle (
				transform.rotation.eulerAngles.y,
				remotePlayerData.rotation.eulerAngles.y,
				ref degreePerSec,
				MultiplayerController.instance.timeBetweenBroadcast * 0.9f
			),
			0
		);

		//animation state
		if (anim.GetInteger ("AnimNum") != remotePlayerData.animState) {
//			ConsoleLog.SLog ("AnimNum change: change animation (" +
//				anim.GetInteger ("AnimNum") + ", " + remotePlayerData.animState
//			);

			anim.SetInteger ("AnimNum", remotePlayerData.animState);
			anim.SetTrigger ("NewAnimation");
		}

		MultiplayerController.instance.hasNewPlayerDatas [playerNum] = false;
		MultiplayerController.instance.updatedLastFrame [playerNum] = true;
	}
Exemple #21
0
 public DataModel()
 {
     data       = PlayerGameData.CreateDataWithDefaultValues();
     dataSetter = new DataSetter(data);
 }
Exemple #22
0
 public GameData()
 {
     ScreenContextStackGameData = new ScreenContextStackGameData();
     PlayerGameData             = new PlayerGameData();
     WorldGameData = new WorldGameData();
 }
Exemple #23
0
 public override void WriteAllData(PlayerGameData data)
 {
     Array.ForEach(storages, storage => storage.WriteAllData(data));
 }
Exemple #24
0
 public abstract void WriteAllData(PlayerGameData data);