Exemple #1
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         player = GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerModel>();
         player.DamagePlayer(damage);
     }
 }
 void OnEnable()
 {
     _playerModel = (transform.parent != null) ? transform.parent.GetComponent<PlayerModel> () : null;
     if (_playerModel == null)
     {
         Debug.LogWarning("Weapon must be the child of a Player!");
         this.enabled = false;
     }
 }
    void Start()
    {
        zombie_On.SetActive (true);
        zombie_Off.SetActive (false);
        ghost_On.SetActive (false);
        ghost_Off.SetActive (true);

        zombie = GameObject.Find("ZombieController").GetComponent<PlayerModel>();
        ghost = GameObject.Find("GhostController").GetComponent<PlayerModel>();
    }
        public static bool isDungeonUnlocked(string name, PlayerModel pm)
        {
            switch (name)
            {
                case "Emergence Cavern B2":
                    return pm.isObjectiveCompleted(ObjectiveType.EmergenceCavernB2);
            }

            return true;
        }
 public GameModel(PlayerModel player)
 {
     _player = player;
     RxGameState = new ReactiveProperty<GameState>(GameState.WaitingToStart);
     _player.RxPlayerState
         .Where(x => x == PlayerModel.PlayerState.Dead)
         .Subscribe(x =>
         {
             RxGameState.Value = GameState.GameOver;
         });
 }
Exemple #6
0
 void FixedUpdate()
 {
     if (player == null) {
         player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerModel>();
     }
     health = player.playerStats.Health;
     //Debug.Log (health);
     scale = (health / 100);
     //Debug.Log (scale);
     rectTransform.localScale = new Vector3 (rectTransform.localScale.x, scale, rectTransform.localScale.z);
 }
 public void Draw_Player_Stats(PlayerModel player)
 {
     ZOutput.Print(playerCoord.Left, playerCoord.Top, Lang["Stats_Player"], Color.Red);
     CommonMethods.Draw_Stat(playerCoord, 1, Lang["Stats_Name"],		player.Name);
     CommonMethods.Draw_Stat(playerCoord, 2, Lang["Stats_ShipModel"],player.Ship.ModelName);
     CommonMethods.Draw_Stat(playerCoord, 3, Lang["Stats_ShipState"],ZIOX.Draw_State, player.CurrentHP, player.MaxHP);
     CommonMethods.Draw_Stat(playerCoord, 4, Lang["Stats_Attack"],	player.Attack);
     CommonMethods.Draw_Stat(playerCoord, 5, Lang["Stats_Defense"],	player.Defense);
     CommonMethods.Draw_Stat(playerCoord, 6, Lang["Stats_Missiles"],	ZIOX.Draw_State, player.CurrentMissiles, player.MaxMissiles);
     CommonMethods.Draw_Stat(playerCoord, 7, Lang["Stats_ECM"],		Lang["EquipmentState_" + player.ECM]);
 }
    public void Hit(PlayerModel player)
    {
        if (collided) return;

        var heading = transform.position - player.transform.position;

        AddImpact(heading, 8);

        var enemyModel = GetComponent<EnemyModel>();

        enemyModel.TakeDamage(player.Power);

        collided = true;
    }
    public void SetupGameView(GameView gameView)
    {
        LoadPlayer();

        this.gameView = gameView;
        player = new PlayerModel();
        InputManager.instance.onClickListener += OnClick;

        camObject = GameObject.Find(ElementType.MainCamera.ToString());


        if (anim == null)
        {
            anim = playerObject.GetComponent<Animation>();
        }
    }
        public static string completeObjective(PlayerModel pm, ObjectiveType objective)
        {
            if (!pm.isObjectiveCompleted(objective))
            {
                if (objective == ObjectiveType.EmergenceCavernAdditionalAdventurer)
                {
                    PlayerDataManager.addCharacter(pm);
                }
                pm.objectives.Add(new PlayerObjectiveModel()
                {
                    type = objective
                });
                return getCompletedText(objective);
            }

            return string.Empty;
        }
 public static void markCompletedObjectives(PlayerModel pm)
 {
     MapDataClasses.MapModel mm = pm.getActiveParty().location;
     if (mm != null)
     {
         foreach (MapDataClasses.MapEventModel mem in mm.eventCollection.getAll())
         {
             if (mem.rewardType == MapDataClasses.ClientEvent.RewardType.Objective)
             {
                 if (pm.isObjectiveCompleted(mem.eventData.objective))
                 {
                     mem.rewardType = MapDataClasses.ClientEvent.RewardType.CompletedObjective;
                 }
             }
         }
     }
 }
        public void Draw_NPC_Stats(NPC_Model npc, PlayerModel player)
        {
            ZOutput.Print(AreaRect.Left+2, AreaRect.Top+1, Lang["Stats_Enemy"], Color.Red);
            CommonMethods.Draw_Stat(enemyCoord, 1, Lang["Stats_Name"],		npc.Name);
            CommonMethods.Draw_Stat(enemyCoord, 2, Lang["Stats_ShipModel"],	npc.Ship.ModelName);

            if (player.Scanner == EquipmentState.Yes)
            {
                CommonMethods.Draw_Stat(enemyCoord, 3, Lang["Stats_ShipState"],	ZIOX.Draw_State, npc.CurrentHP, npc.MaxHP);
                CommonMethods.Draw_Stat(enemyCoord, 4, Lang["Stats_Attack"],	npc.Attack);
                CommonMethods.Draw_Stat(enemyCoord, 5, Lang["Stats_Defense"],	npc.Defense);
                CommonMethods.Draw_Stat(enemyCoord, 6, Lang["Stats_Missiles"],	ZIOX.Draw_State,	npc.CurrentMissiles, npc.MaxMissiles);
                CommonMethods.Draw_Stat(enemyCoord, 7, Lang["Stats_ECM"],		npc.IsRelevealedECM ? (Lang["EquipmentState_"] + npc.ECM) : Lang["Common_Unknown"]);
                if (npc.Bounty > 0)
                    CommonMethods.Draw_Stat(enemyCoord, 9, Lang["Stats_Bounty"],	ZIOX.Draw_Currency, npc.Bounty);
            }
        }
Exemple #13
0
 // Update is called once per frame
 void Update()
 {
     if (this.hitPoints <= 0) {
         Destroy (this.gameObject);
         _playerModel = GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerModel>();
         if(flyingEnemy){
         float newFlyingKills = _playerModel.playerStats.flyingKills + 1;
         _playerModel.playerStats.flyingKills = newFlyingKills;
         }
         if(acidEnemy){
             float newAcidKills= _playerModel.playerStats.acidKills + 1;
             _playerModel.playerStats.acidKills = newAcidKills;
         }
         if(speedEnemy){
             float newSpeedKills= _playerModel.playerStats.speedKills + 1;
             _playerModel.playerStats.flyingKills = newSpeedKills;
         }
     }
 }
Exemple #14
0
        public static Advert Create(AdvertType advertType, StarSystemModel starSystem, PlayerModel player, bool isMilitary)
        {
            if (advertType == AdvertType.BuyIllegal  &&  starSystem.IllegalGoods.Count == 0)
                advertType = AdvertType.PackageDelivery;

            var model = new Advert
                {
                    Type		= advertType,
                    Caption		= (isMilitary ? advertType.ToString() : "BBC_Advert" + advertType) + "Caption",
                    CallText	= (isMilitary ? advertType.ToString() : "BBC_Advert" + advertType) + "Text",
                    OwnerName	= isMilitary ? ZFrontier.Lang["MilitaryHQ_Officer"] : GameConfig.Get_NPC_Name(NPC_Type.Trader),
                };

            switch (advertType)
            {
                case AdvertType.PackageDelivery:	model.Mission = MissionModel.CreateRandom(MissionType.PackageDelivery);	break;
                case AdvertType.GoodsDelivery:		model.Mission = MissionModel.CreateRandom(MissionType.GoodsDelivery);	break;
                case AdvertType.Passenger:			model.Mission = MissionModel.CreateRandom(MissionType.Passenger);		break;
                case AdvertType.Assassination:		model.Mission = MissionModel.CreateRandom(MissionType.Assassination);	break;
                case AdvertType.Military_Delivery:		model.Mission = MissionModel.CreateRandom(MissionType.Military_Delivery,      true, starSystem.Allegiance);	break;
                case AdvertType.Military_Assassination:	model.Mission = MissionModel.CreateRandom(MissionType.Military_Assassination, true, starSystem.Allegiance);	break;
            }

            if (advertType == AdvertType.BuyIllegal)
            {
                var merch = starSystem.IllegalGoods.Get_Random();
                model.Merchandise = merch;
                model.IsTrap = RNG.GetDice() <= GameConfig.AdvertTrapChance;
                model.Price = GameConfig.Get_MerchPrice(starSystem.TechLevel, merch) + starSystem.PriceChanges[(int) (merch)];
                model.Price += RNG.GetNumber(1, GameConfig.AdvertIllegalPriceBonus);
            }
            else
            {
                model.Merchandise = model.Mission.GoodsToDeliver_Type;
                model.Price = model.Mission.RewardAmount;
            }

            return model;
        }
 // Sort delegate
 public static int DescendingKDR(PlayerModel lhs, PlayerModel rhs)
 {
     if (lhs == null) {
     return ((rhs == null) ? 0 : -1);
     } else if (rhs == null) {
     return ((lhs == null) ? 0 : 1);
     }
     double lKDR = (lhs.StatsVerified) ? lhs.KDR : lhs.KDRRound;
     double rKDR = (rhs.StatsVerified) ? rhs.KDR : rhs.KDRRound;
     if (lKDR < rKDR) return 1;
     if (lKDR > rKDR) return -1;
     return 0;
 }
Exemple #16
0
 private void Construct()
 {
     playerInstance   = new GameObject();
     playerController = playerInstance.AddComponent <PlayerController>();
     playerModel      = new PlayerModel(playerInstance, 1);
 }
Exemple #17
0
 public void GoToMenu()
 {
     StartCoroutine(FadeToScene("Menu"));
     PlayerModel.Save();
 }
 void Start()
 {
     this.playerModel = this.GetComponentInParent<PlayerModel>();
 }
        public static TaskDialogAbstract GetTask(TaskDialog taskDialog, int taskScore, PlayerModel player)
        {
            switch (taskDialog)
            {
            case TaskDialog.Bear:
                return(new BearTask(player.Name, player.Score));

            case TaskDialog.Make:
                return(new MakeTask(taskScore, player.Name, player.Score));

            case TaskDialog.RefuseFirstTime:
                return(new RefuseTask(taskScore));

            case TaskDialog.RefuseSecondTime:
                return(new RefuseAndMoveTask(player.Name, player.Score));

            default: throw new NotImplementedException();
            }
        }
 private bool IsRankDispersal(PlayerModel player)
 {
     if (player == null) return false;
     PerModeSettings perMode = GetPerModeSettings();
     if (perMode.DisperseEvenlyByRank == 0) return false;
     if (SameClanTagsForRankDispersal && CountMatchingTags(player, Scope.SameTeam) >= 2) {
     if (player.Rank >= perMode.DisperseEvenlyByRank) DebugWrite("^9Exempting player from rank dispersal, due to SameClanTagsForRankDispersal: ^b" + "^b" + player.FullName + "^n", 6);
     return false;
     }
     if (OnWhitelist && CheckWhitelist(player, WL_RANK)) return false; // special case for whitelist options
     return (player.Rank >= perMode.DisperseEvenlyByRank);
 }
Exemple #21
0
 public async Task AddPlayerAsync(PlayerModel player)
 {
     await _managerAccess.AddPlayerAsync(player);
 }
 private TimeSpan GetPlayerJoinedTimeSpan(PlayerModel player)
 {
     if (player != null) {
     return(DateTime.Now.Subtract(player.FirstSeenTimestamp));
     }
     return TimeSpan.FromMinutes(0);
 }
        private String ExtractTagOrFriendex(PlayerModel m)
        {
            /*
            For the swapper code, it is convenient to treat the Friend Index (Friendex) like a tag.
            The value of the index is formatted into a string "[x]", which should be impossible for real tags
            */
            if (m == null) return String.Empty;

            String tagOrFriendex = ExtractTag(m);
            if (KeepSquadsTogether || !KeepClanTagsInSameTeam) return tagOrFriendex;
            if (KeepFriendsInSameTeam && String.IsNullOrEmpty(tagOrFriendex) && m.Friendex != -1) {
            tagOrFriendex = String.Format("[{0}]", m.Friendex);
            //DebugScrambler("Using friendex ^b" + tagOrFriendex + "^n for ^b" + m.FullName);
            }
            return tagOrFriendex;
        }
Exemple #24
0
 private void Lynch(PlayerModel target)
 {
     Log.Write($"{target.Name} is dragged off by the mob and executed!");
     target.Kill();
 }
Exemple #25
0
 internal void OnPlayerEntered(PlayerModel player)
 {
     PlayerEntered?.Invoke(player, new EventArgs());
 }
Exemple #26
0
 public static void endNewbie(object[] objs, Action forceDo)
 {
     PlayerModel.getInstance().LeaveStandalone_CreateChar();
 }
 private int GetMoves(PlayerModel player)
 {
     if (player == null) return 0;
     return (player.MovesRound + player.MovesByMBRound);
 }
 // Sort delegate
 public static int DescendingKPM(PlayerModel lhs, PlayerModel rhs)
 {
     if (lhs == null) {
     return ((rhs == null) ? 0 : -1);
     } else if (rhs == null) {
     return ((lhs == null) ? 0 : 1);
     }
     double lKPM = (lhs.StatsVerified) ? lhs.KPM : lhs.KPMRound;
     double rKPM = (rhs.StatsVerified) ? rhs.KPM : rhs.KPMRound;
     if (lKPM < rKPM) return 1;
     if (lKPM > rKPM) return -1;
     return 0;
 }
 private bool IsDispersal(PlayerModel player, bool ignoreWhitelist)
 {
     if (player == null) return false;
     player.DispersalGroup = 0;
     PerModeSettings perMode = GetPerModeSettings();
     bool isDispersalByList = false;
     if (!perMode.EnableDisperseEvenlyList) return false;
     String extractedTag = ExtractTag(player);
     if (String.IsNullOrEmpty(extractedTag)) extractedTag = INVALID_NAME_TAG_GUID;
     String guid = (String.IsNullOrEmpty(player.EAGUID)) ? INVALID_NAME_TAG_GUID : player.EAGUID;
     if (fSettingDisperseEvenlyList.Count > 0) {
     if (fSettingDisperseEvenlyList.Contains(player.Name)
     || fSettingDisperseEvenlyList.Contains(guid)
     || fSettingDisperseEvenlyList.Contains(extractedTag)) {
     // Special case for whitelist options: clan tag on dispersal list, but Whitelist option enabled
     if (fSettingDisperseEvenlyList.Contains(extractedTag)
         && !fSettingDisperseEvenlyList.Contains(player.Name)
         && !fSettingDisperseEvenlyList.Contains(guid)
         && OnWhitelist
         && !ignoreWhitelist
         && CheckWhitelist(player, WL_DISPERSE)) {
         isDispersalByList = false;
     } else {
         isDispersalByList = true;
     }
     }
     }
     for (int i = 1; i <= 4; ++i) {
     if (!isDispersalByList && fDispersalGroups[i].Count > 0) {
     fDispersalGroups[i] = new List<String>(fDispersalGroups[i]);
     if (fDispersalGroups[i].Contains(player.Name)
     || fDispersalGroups[i].Contains(guid)
     || fDispersalGroups[i].Contains(extractedTag)) {
         // Special case for whitelist options: clan tag on dispersal list, but Whitelist option enabled
         if (fDispersalGroups[i].Contains(extractedTag)
             && !fDispersalGroups[i].Contains(player.Name)
             && !fDispersalGroups[i].Contains(guid)
             && OnWhitelist
             && !ignoreWhitelist
             && CheckWhitelist(player, WL_DISPERSE)) {
             isDispersalByList = false;
         } else {
             isDispersalByList = true;
             player.DispersalGroup = i;
         }
         break;
     }
     }
     }
     return (isDispersalByList);
 }
        // Sort delegate
        public static int DescendingPlayerRank(PlayerModel lhs, PlayerModel rhs)
        {
            if (lhs == null) {
            return ((rhs == null) ? 0 : -1);
            } else if (rhs == null) {
            return ((lhs == null) ? 0 : 1);
            }

            if (lhs.Rank < rhs.Rank) return 1;
            if (lhs.Rank > rhs.Rank) return -1;
            return 0;
        }
        private void ScrambleMove(PlayerModel clone, int where, bool logOnly)
        {
            int toSquad = 0;
            int toTeam = where;

            // Move to available squad
            if (!IsKnownPlayer(clone.Name)) return; // might have left
            String xt = ExtractTag(clone);
            String name = clone.Name;
            if (!String.IsNullOrEmpty(xt)) name = "[" + xt + "]" + name;
            toSquad = clone.ScrambledSquad;
            if (toSquad < 0 || toSquad > (SQUAD_NAMES.Length - 1)) {
            ConsoleDebug("ScrambleMove: why is ^b" + name + "^n scrambled to squad " + toSquad + "?");
            return;
            }
            if (toSquad == 0) {
            ConsoleDebug("ScrambleMove: why is ^b" + name + "^n scrambled to squad 0?");
            return;
            }
            if (clone.Team == toTeam && clone.Squad == toSquad) {
            ConsoleDebug("ScrambleMove: skipping scramble move of ^b" + clone.FullName + "^n, already in right team and squad");
            return;
            }

            // Do the move
            if (!EnableLoggingOnlyMode && !logOnly) {
            DebugScrambler("^1^bMOVE^n^0 ^b" + clone.FullName + "^n to " + GetTeamName(toTeam) + " team, squad " + SQUAD_NAMES[toSquad]);
            ServerCommand("admin.movePlayer", clone.Name, toTeam.ToString(), toSquad.ToString(), "false");
            Thread.Sleep(60);
            } else {
            DebugScrambler("^9(SIMULATED) ^1^bMOVE^n^0 ^b" + clone.FullName + "^n to " + GetTeamName(toTeam) + " team, squad " + SQUAD_NAMES[toSquad]);
            }

            // For debugging and since this is a clone model, update Team & Squad to reflect move
            clone.Team = toTeam;
            clone.Squad = toSquad;
        }
Exemple #32
0
 public void ResetStats()
 {
     PlayerModel.Reset();
 }
        private void SendBattlelogRequest(String name, String requestType, PlayerModel player)
        {
            try {
            String result = String.Empty;
            String err = String.Empty;

            if (player == null) player = GetPlayer(name);
            if (player == null) return;
            FetchInfo status = (requestType == "clanTag") ? player.TagFetchStatus : player.StatsFetchStatus;
            status.State = FetchState.Requesting;
            status.Since = DateTime.Now;
            status.RequestType = requestType;
            DebugFetch("Fetching from Battlelog " + requestType + "(^b" + name + "^n)");

            if (String.IsNullOrEmpty(player.PersonaId)) {
            // Get the main page
            bool ok = false;
            status.State = FetchState.Failed;
            if (!fIsEnabled) return;
            ok = FetchWebPage(ref result, "http://battlelog.battlefield.com/bf3/user/" + name);
            if (!fIsEnabled) return;

            if (!ok) return;

            // Extract the personaId
            MatchCollection pid = Regex.Matches(result, @"bf3/soldier/" + name + @"/stats/(\d+)(['""]|/\s*['""]|/[^/'""]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);

            foreach (Match match in pid) {
                if (match.Success && !Regex.Match(match.Groups[2].Value.Trim(), @"(ps3|xbox)", RegexOptions.IgnoreCase).Success) {
                    player.PersonaId = match.Groups[1].Value.Trim();
                    break;
                }
            }

            if (String.IsNullOrEmpty(player.PersonaId)) {
                DebugFetch("Request for ^b" + name +"^n failed, could not find persona-id!");
                status.State = FetchState.Failed;
                return;
            }
            }

            if (requestType == "clanTag") {
            // Extract the player tag
            Match tag = Regex.Match(result, player.PersonaId + @"/pc/[/'"">\s]+\[\s*([a-zA-Z0-9]+)\s*\]\s*" + name, RegexOptions.IgnoreCase | RegexOptions.Singleline); // Fixed #9
            //Match tag = Regex.Match(result, @"\[\s*([a-zA-Z0-9]+)\s*\]\s*" + name, RegexOptions.IgnoreCase | RegexOptions.Singleline);
            if (tag.Success) {
                Hashtable data = new Hashtable();
                data["clanTag"] = tag.Groups[1].Value;
                SetTag(player, data); // sets status.State
                DebugFetch("^4Battlelog tag updated: ^b" + player.FullName);
            } else {
                // No tag
                player.TagVerified = true;
                status.State = FetchState.Succeeded;
                DebugFetch("^4Battlelog says ^b" + player.Name + "^n has no tag");
            }
            } else if (requestType == "overview") {
            status.State = FetchState.Failed;
            if (!fIsEnabled || WhichBattlelogStats == BattlelogStats.ClanTagOnly) return;
            String furl = "http://battlelog.battlefield.com/bf3/overviewPopulateStats/" + player.PersonaId + "/bf3-us-assault/1/";
            if (FetchWebPage(ref result, furl)) {
                if (!fIsEnabled) return;

                Hashtable json = (Hashtable)JSON.JsonDecode(result);

                // verify we got a success message
                if (!CheckSuccess(json, out err)) {
                    DebugFetch("Request " + status.RequestType + "(^b" + name + "^n): " + err);
                    return;
                }

                // verify there is data structure
                Hashtable data = null;
                if (!json.ContainsKey("data") || (data = (Hashtable)json["data"]) == null) {
                    DebugFetch("Request " + status.RequestType + "(^b" + name + "^n): JSON response does not contain a data field (^4" + furl + "^0)");
                    return;
                }

                // verify there is stats structure
                Hashtable stats = null;
                if (!data.ContainsKey("overviewStats") || (stats = (Hashtable)data["overviewStats"]) == null) {
                    DebugFetch("Request " + status.RequestType + "(^b" + name + "^n): JSON response data does not contain overviewStats (^4" + furl + "^0)");
                    return;
                }

                // extract the fields from the stats
                SetStats(player, stats); // sets status.State
            }
            }
            } catch (Exception e) {
            ConsoleException(e);
            }
        }
 void Start()
 {
     this.controller = this.GetComponentInParent<CharacterController>();
     this.playerModel = this.GetComponentInParent<PlayerModel>();
 }
        private void SendBattlelogRequestBF4(String name, String requestType, PlayerModel player)
        {
            try {
            String result = String.Empty;
            String err = String.Empty;

            if (player == null) player = GetPlayer(name);
            if (player == null) return;

            FetchInfo status = (requestType == "clanTag") ? player.TagFetchStatus : player.StatsFetchStatus;
            status.State = FetchState.Requesting;
            status.Since = DateTime.Now;
            status.RequestType = requestType;
            DebugFetch("Fetching from Battlelog BF4 " + requestType + "(^b" + name + "^n)");

            if (String.IsNullOrEmpty(player.PersonaId)) {
            // Get the main page
            bool ok = false;
            status.State = FetchState.Failed;
            if (!fIsEnabled) return;
            ok = FetchWebPage(ref result, "http://battlelog.battlefield.com/bf4/user/" + name);
            if (!fIsEnabled) return;

            if (!ok) return;

            // Extract the personaId
            MatchCollection pid = Regex.Matches(result, @"bf4/soldier/" + name + @"/stats/(\d+)(['""]|/\s*['""]|/[^/'""]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);

            foreach (Match match in pid) {
                if (match.Success && !Regex.Match(match.Groups[2].Value.Trim(), @"(ps3|xbox)", RegexOptions.IgnoreCase).Success) {
                    player.PersonaId = match.Groups[1].Value.Trim();
                    break;
                }
            }

            if (String.IsNullOrEmpty(player.PersonaId)) {
                DebugFetch("Request for ^b" + name +"^n failed, could not find persona-id!");
                status.State = FetchState.Failed;
                return;
            }
            }

            if (requestType == "clanTag") {
            // Get the stats page
            bool ok = false;
            status.State = FetchState.Failed;
            if (!fIsEnabled) return;
            String bf4furl = "http://battlelog.battlefield.com/bf4/warsawoverviewpopulate/" + player.PersonaId + "/1/";
            ok = FetchWebPage(ref result, bf4furl);
            if (!fIsEnabled) return;
            if (!ok) return;

            // Get tag from json
            Hashtable jsonBF4 = (Hashtable)JSON.JsonDecode(result);

            // verify we got a success message
            if (!CheckSuccess(jsonBF4, out err)) {
                DebugFetch("Request " + status.RequestType + "(^b" + name + "^n): " + err);
                return;
            }

            // verify there is data structure
            Hashtable data = null;
            if (!jsonBF4.ContainsKey("data") || (data = (Hashtable)jsonBF4["data"]) == null) {
                DebugFetch("Request BF4 " + status.RequestType + "(^b" + name + "^n): JSON response does not contain a data field (^4" + bf4furl + "^0)");
                return;
            }

            // verify there is viewedPersonaInfo structure, okay if null!
            Hashtable info = null;
            if (!data.ContainsKey("viewedPersonaInfo") || (info = (Hashtable)data["viewedPersonaInfo"]) == null) {
                if (DebugLevel >= 7) DebugFetch("Request BF4" + status.RequestType + "(^b" + name + "^n): JSON response data does not contain viewedPersonaInfo (^4" + bf4furl + "^0)");
                // No tag
                player.Tag = String.Empty;
                player.TagVerified = true;
                status.State = FetchState.Succeeded;
                DebugFetch("^4Battlelog says ^b" + player.Name + "^n has no BF4 tag (no viewedPersonaInfo)");
                return;
            }

            // Extract the player tag
            String bf4Tag = String.Empty;
            if (!info.ContainsKey("tag") || String.IsNullOrEmpty(bf4Tag = (String)info["tag"])) {
                // No tag
                player.Tag = String.Empty;
                player.TagVerified = true;
                status.State = FetchState.Succeeded;
                DebugFetch("^4Battlelog says ^b" + player.Name + "^n has no BF4 tag");
            } else {
                Hashtable tmp = new Hashtable();
                tmp["clanTag"] = bf4Tag;
                SetTag(player, tmp); // sets status.State
                DebugFetch("^4Battlelog BF4 tag updated: ^b" + player.FullName);
            }
            } else if (requestType == "overview") {
            //DebugFetch("Stats fetch not supported for BF4 yet: " + player.Name);
            status.State = FetchState.Failed;
            if (!fIsEnabled || WhichBattlelogStats == BattlelogStats.ClanTagOnly) return;
            String furl = "http://battlelog.battlefield.com/bf4/warsawoverviewpopulate/" + player.PersonaId + "/1/";
            if (FetchWebPage(ref result, furl)) {
                if (!fIsEnabled) return;

                Hashtable json = (Hashtable)JSON.JsonDecode(result);

                // verify we got a success message
                if (!CheckSuccess(json, out err)) {
                    DebugFetch("Request " + status.RequestType + "(^b" + name + "^n): " + err);
                    return;
                }

                // verify there is data structure
                Hashtable data = null;
                if (!json.ContainsKey("data") || (data = (Hashtable)json["data"]) == null) {
                    DebugFetch("Request " + status.RequestType + "(^b" + name + "^n): JSON response does not contain a data field (^4" + furl + "^0)");
                    return;
                }

                // verify there is stats structure
                Hashtable stats = null;
                if (!data.ContainsKey("overviewStats") || (stats = (Hashtable)data["overviewStats"]) == null) {
                    DebugFetch("Request " + status.RequestType + "(^b" + name + "^n): JSON response data does not contain overviewStats (^4" + furl + "^0)");
                    return;
                }

                // extract the fields from the stats
                SetStats(player, stats); // sets status.State
            }
            }
            } catch (Exception e) {
            ConsoleException(e);
            }
        }
 private void OnStartButton()
 {
     PlayerModel.SaveFirstOpenApp();
     SceneManager.LoadSceneAsync("MenuScene");
 }
        private void SetStats(PlayerModel player, Hashtable stats)
        {
            player.StatsFetchStatus.State = FetchState.Failed;
            if (stats == null) {
            ConsoleDebug("SetStats ^b" + player.Name + "^n stats = null");
            return;
            }

            Dictionary<String,double> propValues = new Dictionary<String,double>();
            propValues["kdRatio"] = -1;
            propValues["timePlayed"] = -1;
            propValues["kills"] = -1;
            propValues["scorePerMinute"] = -1;
            propValues["deaths"] = -1;
            propValues["rsDeaths"] = -1;
            propValues["rsKills"] = -1;
            propValues["rsScore"] = -1;
            propValues["rsTimePlayed"] = -1;

            foreach (DictionaryEntry entry in stats) {
            try {
            if (entry.Key == null) continue;
            String entryKey = (String)(entry.Key.ToString());

            // skip entries we are not interested in
            if (!propValues.ContainsKey(entryKey)) continue;
            if (entry.Value == null) continue;

            String entryValue = (String)(entry.Value.ToString());

            double dValue = -1;
            if (!String.IsNullOrEmpty(entryValue)) Double.TryParse(entryValue, out dValue);
            propValues[entryKey] = (Double.IsNaN(dValue)) ? -1 : dValue;
            } catch (Exception) {}
            }

            // Now set the player values, starting with AllTime
            double allTimeMinutes = Math.Max(1, propValues["timePlayed"] / 60);
            double kills = propValues["kills"];
            kills = (kills < 1) ? 0 : kills;
            double deaths = propValues["deaths"];
            deaths = (deaths < 1) ? 1 : deaths;
            double kdr = propValues["kdRatio"];
            if (kdr < 0) {
            kdr = kills / deaths;
            }

            player.KDR = kdr;
            player.SPM = propValues["scorePerMinute"];
            player.KPM = propValues["kills"] / allTimeMinutes;

            // Using Reset?
            String type = "All-Time";
            if (WhichBattlelogStats == BattlelogStats.Reset && propValues["rsTimePlayed"] > 0) {
            type = "Reset";
            double resetMinutes = Math.Max(1, propValues["rsTimePlayed"] / 60);
            double resetKDR = propValues["rsKills"] / Math.Max(1, propValues["rsDeaths"]);
            if (resetKDR > 0) player.KDR = resetKDR;
            double resetSPM = propValues["rsScore"] / resetMinutes;
            if (resetSPM > 0) player.SPM = resetSPM;
            double resetKPM = propValues["rsKills"] / resetMinutes;
            if (resetKPM > 0) player.KPM = resetKPM;
            }
            player.StatsFetchStatus.State = FetchState.Succeeded;
            player.StatsVerified = true;
            String msg = type + " [bKDR:" + player.KDR.ToString("F2") + ", bSPM:" + player.SPM.ToString("F0") + ", bKPM:" + player.KPM.ToString("F1") + "]";
            String ver = (fGameVersion == GameVersion.BF4) ? "BF4" : "BF3";
            DebugFetch("^4Player " + ver + " stats updated ^0^b" + player.Name + "^n, " + msg);
        }
Exemple #38
0
 public VillagerRole(PlayerModel player) : base(player)
 {
 }
    protected override void OpenScreen()
    {
        var model = MainModel.Instance;
        _timeToMove = Time.time + maxTimeToMove;

        // Create a player selection for each Active player
        if (_playerPrefab == null)
        {
            _playerPrefab = transform.root.FindChild("Players").FindChild("PlayerPrefab").gameObject;
            _playerPrefab.SetActive(false);
        }

        if (model.AvailablePlayers.Count != model.PlayerDataModel.AvailablePlayers.Count)
        {
            foreach (var playerData in model.PlayerDataModel.AvailablePlayers)
            {
                if (!model.AvailablePlayers.Any(p => p.PlayerData == playerData))
                {

                    var playerModel = new PlayerModel();
                    model.AvailablePlayers.Add(playerModel);

                    var playerGameObject = (Instantiate(_playerPrefab.transform) as Transform).gameObject;
                    playerGameObject.transform.parent = _playerPrefab.transform.parent;
                    playerGameObject.SetActive(true);
                    playerGameObject.GetComponent<PlayerView>().PlayerViewModel = new PlayerViewModel(playerModel);

                    playerModel.GameObject = playerGameObject;
                    playerModel.PlayerData = playerData;

                    playerModel.GameObject.transform.localPosition = new Vector3(-1000, 0, 0);
                }
            }
        }

        // Enable selection
        foreach (var p in model.AvailablePlayers)
        {
            var pLocal = p;

            pLocal.SelectCallback = () =>
            {
                //if (model.ActivePlayer != pLocal)
                //{
                model.ActivePlayer.ShouldShowSelectionBox = false;
                model.ActivePlayer.PlayerState = PlayerState.Hurt;
                model.ActivePlayer = pLocal;
                model.ActivePlayer.ShouldShowSelectionBox = true;
                model.ActivePlayer.PlayerState = PlayerState.Happy;
                //}

                _forwardButton.SetActive(true);
            };
        }

        // Move players to good position
        PositionPlayers(model.AvailablePlayers);

        // Auto select
        var autoSelect = false;

        if (autoSelect)
        {
            if (MainModel.Instance.ActivePlayer != null)
            {
                _forwardButton.SetActive(true);
            }

            if (model.ActivePlayer == null)
            {
                model.ActivePlayer = model.AvailablePlayers[0];
            }

            model.ActivePlayer.ShouldShowSelectionBox = true;
        }
        else
        {
            _forwardButton.SetActive(false);
        }
    }
Exemple #40
0
 public void QuestAccepted()
 {
     PlayerModel.AddActiveQuest(questName);
     questAccepted = true;
 }
 public override void Update(GameTime gameTime, CharactorSelectDatas data)
 {
     if (!data.getModel(playerID).Equals(model))
     {
         model = data.getModel(playerID);
     }
     model.ChangeMotion(DropFight.ModelUtils.PlayerModel.ModelAnimation.WALK);
     model.Update(gameTime);
     isConflict = data.getConflict(playerID);
 }
 private void OnTutorialButton()
 {
     PlayerModel.SaveFirstOpenApp();
     SceneManager.LoadSceneAsync("TutorialScene");
 }