Пример #1
0
        public async Task <ActionResult> AddMissionAsync(Guid?id, Guid uMissionID)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Invalid User ID"));
            }

            var player = await db.Players.FirstOrDefaultAsync(p => p.uPlayerID == id);

            if (player == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "User Not Found: " + id.ToString()));
            }

            var mission = await db.Missions.FirstOrDefaultAsync(m => m.uMissionID == uMissionID);

            // Handles adding points to player and faction. Also maintains ranks.
            var bLeveledUp = await AddPointsToPlayerAsync(player, mission.iMissionPoints);



            // Add record of completing mission
            PlayerMission playerMission = new PlayerMission();

            playerMission.uMissionID       = uMissionID;
            playerMission.uPlayerID        = id.Value;
            playerMission.uPlayerMissionID = Guid.NewGuid();


            // Add completion achievement, if earned.
            bool bEarnedAchievement = false;
            var  completedMissions  = player.Missions.Count() + 1;

            var missionAchievement = await db.MissionAchievements.FirstOrDefaultAsync(ma => ma.iMissionCount == completedMissions);

            if (missionAchievement != null)
            {
                if (!player.Achievements.Any(pa => pa.uAchievementID == missionAchievement.uAchievementID))
                {
                    PlayerAchievements playerAchievement = new PlayerAchievements();
                    playerAchievement.uAchievementID       = missionAchievement.uAchievementID;
                    playerAchievement.uPlayerID            = id.Value;
                    playerAchievement.uPlayerAchievementID = Guid.NewGuid();

                    db.PlayerAchievements.Add(playerAchievement);
                    bEarnedAchievement = true;
                }
            }

            db.PlayerMissions.Add(playerMission);

            await db.SaveChangesAsync();

            if (bLeveledUp || bEarnedAchievement)
            {
                return(new RedirectResult(Url.Action("Details", "Players", new { @id = id, LeveledUp = bLeveledUp, EarnedAchievement = bEarnedAchievement ? (Guid?)missionAchievement.uAchievementID : null })));
            }

            return(RedirectToAction("Details", new { id = id }));
        }
    public void ReplacePlayerMission(PlayerMission newMisisonType)
    {
        var index     = GameComponentsLookup.PlayerMission;
        var component = CreateComponent <PlayerMissionComponent>(index);

        component.MisisonType = newMisisonType;
        ReplaceComponent(index, component);
    }
Пример #3
0
 public void SetLocalPlayerMission(PlayerMission mission)
 {
     MainPage.SetPlayerMission(_setting.PlayerMission.GetData(mission));
 }
Пример #4
0
 public static System.Collections.Generic.HashSet <GameEntity> GetEntitiesWithPlayerMission(this GameContext context, PlayerMission MisisonType)
 {
     return(((Entitas.EntityIndex <GameEntity, PlayerMission>)context.GetEntityIndex(Contexts.PlayerMission)).GetEntities(MisisonType));
 }
Пример #5
0
    public static void Export(BinaryWriter bw)
    {
        //if (PlayerFactory.mMainPlayer == null)
        //    return;

        PlayerMission pm      = MissionManager.Instance.m_PlayerMission;
        List <int>    tmpList = new List <int>();

        foreach (KeyValuePair <int, Dictionary <string, string> > ite in pm.m_MissionInfo)
        {
            if (!m_RandMisMap.ContainsKey(ite.Key))
            {
                continue;
            }

            tmpList.Add(ite.Key);
        }

        bw.Write(tmpList.Count);
        for (int i = 0; i < tmpList.Count; i++)
        {
            MissionCommonData data = MissionManager.GetMissionCommonData(tmpList[i]);
            if (data == null)
            {
                continue;
            }

            bw.Write(data.m_ID);
            bw.Write(data.m_MissionName);
            bw.Write(data.m_iNpc);
            bw.Write(data.m_iReplyNpc);
            bw.Write((int)data.m_Type);
            bw.Write(data.m_MaxNum);
            bw.Write(data.m_Description);
            bw.Write(data.m_TargetIDList.Count);
            for (int m = 0; m < data.m_TargetIDList.Count; m++)
            {
                bw.Write(data.m_TargetIDList[m]);
            }

            bw.Write(data.m_PlayerTalk.Length);
            for (int m = 0; m < data.m_PlayerTalk.Length; m++)
            {
                bw.Write(data.m_PlayerTalk[m]);
            }

            bw.Write(data.m_Get_DemandItem.Count);
            for (int m = 0; m < data.m_Get_DemandItem.Count; m++)
            {
                bw.Write(data.m_Get_DemandItem[m].id);
                bw.Write(data.m_Get_DemandItem[m].num);
            }

            bw.Write(data.m_Get_DeleteItem.Count);
            for (int m = 0; m < data.m_Get_DeleteItem.Count; m++)
            {
                bw.Write(data.m_Get_DeleteItem[m].id);
                bw.Write(data.m_Get_DeleteItem[m].num);
            }

            bw.Write(data.m_Get_MissionItem.Count);
            for (int m = 0; m < data.m_Get_MissionItem.Count; m++)
            {
                bw.Write(data.m_Get_MissionItem[m].id);
                bw.Write(data.m_Get_MissionItem[m].num);
            }

            bw.Write(data.m_Com_RewardItem.Count);
            for (int m = 0; m < data.m_Com_RewardItem.Count; m++)
            {
                bw.Write(data.m_Com_RewardItem[m].id);
                bw.Write(data.m_Com_RewardItem[m].num);
            }

            bw.Write(data.m_Com_SelRewardItem.Count);
            for (int m = 0; m < data.m_Com_SelRewardItem.Count; m++)
            {
                bw.Write(data.m_Com_SelRewardItem[m].id);
                bw.Write(data.m_Com_SelRewardItem[m].num);
            }

            bw.Write(data.m_Com_RemoveItem.Count);
            for (int m = 0; m < data.m_Com_RemoveItem.Count; m++)
            {
                bw.Write(data.m_Com_RemoveItem[m].id);
                bw.Write(data.m_Com_RemoveItem[m].num);
            }

            bw.Write(data.m_TalkOP.Count);
            for (int m = 0; m < data.m_TalkOP.Count; m++)
            {
                bw.Write(data.m_TalkOP[m]);
            }

            bw.Write(data.m_OPID.Count);
            for (int m = 0; m < data.m_OPID.Count; m++)
            {
                bw.Write(data.m_OPID[m]);
            }

            bw.Write(data.m_TalkIN.Count);
            for (int m = 0; m < data.m_TalkIN.Count; m++)
            {
                bw.Write(data.m_TalkIN[m]);
            }

            bw.Write(data.m_INID.Count);
            for (int m = 0; m < data.m_INID.Count; m++)
            {
                bw.Write(data.m_INID[m]);
            }

            bw.Write(data.m_TalkED.Count);
            for (int m = 0; m < data.m_TalkED.Count; m++)
            {
                bw.Write(data.m_TalkED[m]);
            }

            bw.Write(data.m_EDID.Count);
            for (int m = 0; m < data.m_EDID.Count; m++)
            {
                bw.Write(data.m_EDID[m]);
            }
        }
    }