void AcceptAllMission()
    {
        if (Singleton <ObjManager> .Instance.MainPlayer.IsInJianYu())
        {
            Singleton <ObjManager> .Instance.MainPlayer.SendNoticMsg(false, "#{2216}");

            return;
        }

        int nMaxKinds = DailyMissionData.MAX_DAILYMISSION_KINDS;

        for (int i = 0; i < nMaxKinds; i++)
        {
            DailyMission rDailyMission = GameManager.gameManager.PlayerDataPool.DailyMissionData.GetDailyMissionByKind(i);

            int nMissionID = rDailyMission.MissionID;
            //byte yQuality = rDailyMission.Quality;

            Tab_MissionBase MissionBase = TableManager.GetMissionBaseByID(nMissionID, 0);
            if (MissionBase == null)
            {
                continue;
            }

            bool isHaveMission = GameManager.gameManager.MissionManager.IsHaveMission(nMissionID);
            if (isHaveMission)
            {
                continue;
            }

            GameManager.gameManager.MissionManager.AcceptMission(nMissionID);
        }
    }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        instance = this;
        if (resetPlayerPrefs)
        {
            PlayerPrefs.DeleteAll();
        }
        if (PlayerPrefs.HasKey("moneyOnHand"))
        {
            moneyOnHand  = PlayerPrefs.GetInt("moneyOnHand");
            currentExp   = PlayerPrefs.GetInt("currentExp");
            currentLevel = PlayerPrefs.GetInt("currentLevel");
        }
        else
        {
            moneyOnHand = starting_moneyOnHand;
            PlayerPrefs.SetInt("moneyOnHand", moneyOnHand);
            currentLevel = ExpToLevel(starting_exp);
            if (currentLevel <= 1)
            {
                currentExp = starting_exp;
            }
            else
            {
                currentExp = starting_exp - expRequired[currentLevel - 2];
            }

            PlayerPrefs.SetInt("currentExp", currentExp);
            PlayerPrefs.SetInt("currentLevel", currentLevel);
        }
        dailyMission = gameObject.GetComponent <DailyMission>();
        UpdateMoneyText();
        UpdateExpText();
    }
    void YuanBaoTipBox()
    {
        int nTotalYuanBao = 0;

        for (int i = 0; i < DailyMissionData.MAX_DAILYMISSION_KINDS; i++)
        {
            DailyMission rMission = GameManager.gameManager.PlayerDataPool.DailyMissionData.GetDailyMissionByKind(i);
            if (rMission.MissionID < 0)
            {
                continue;
            }
            bool IsHaveMission = GameManager.gameManager.MissionManager.IsHaveMission(rMission.MissionID);
            if (IsHaveMission)
            {
                continue;
            }
            Tab_MissionBase MissionBase = TableManager.GetMissionBaseByID(rMission.MissionID, 0);
            if (MissionBase == null)
            {
                return;
            }
            Tab_DailyMission DailyMission = TableManager.GetDailyMissionByID(MissionBase.DalityMissionTabID, 0);
            if (DailyMission == null)
            {
                return;
            }
            nTotalYuanBao += DailyMission.ConsumeBangdedYuanBao;
        }
        string str = "";

        str = StrDictionary.GetClientDictionaryString("#{1538}", nTotalYuanBao);
        MessageBoxLogic.OpenOKCancelBox(str, null, OnMessageOK, OnCancelClick);
    }
	public void Build()
	{
		currentMission = missions[GetMissionID()];
		bool completed = GetMissionCompleted();

		transform.FindChild("Completed").gameObject.SetActive(completed);
		transform.FindChild("Normal").gameObject.SetActive(!completed);

		Debug.Log(currentMission.mission + " = " + GetParameter() + " / " + currentMission.value + " (" + Mathf.Min(GetParameter() / (float)currentMission.value, 1) + ")");

		transform.FindChild("Normal").FindChild("Description").GetComponent<UILabel>().text = currentMission.Description;
		transform.FindChild("Normal").FindChild("reward").GetComponent<UILabel>().text = "+" + currentMission.reward.ToString();
		transform.FindChild("Normal").FindChild("bg-green").GetComponent<UISprite>().fillAmount = Mathf.Min(GetParameter() / (float)currentMission.value, 1);
	}
Exemple #5
0
        public static DailyMissionModel convertEntityToModel(DailyMission mission)
        {
            DailyMissionModel model = new DailyMissionModel();

            model.dailyId     = mission.dailyId;
            model.detailDesc  = mission.detailDesc;
            model.finished    = mission.finished;
            model.missionDate = mission.missionDate;
            model.missionDesc = mission.missionDesc;
            model.missionId   = mission.missionId;
            model.openId      = mission.openId;
            model.score       = mission.score;
            model.times       = mission.times;
            return(model);
        }
    void OnLoadItemList(GameObject DailyMissionItem)
    {
        if (null == DailyMissionItem)
        {
            return;
        }

        if (m_ItemGrid == null || m_ItemGrid.gameObject == null)
        {
            return;
        }
        m_ItemGrid.GetComponent <UITopGrid>().recenterTopNow = true;
        int nMaxKinds = DailyMissionData.MAX_DAILYMISSION_KINDS;

        for (int i = 0; i < nMaxKinds; i++)
        {
            DailyMission rDailyMission = GameManager.gameManager.PlayerDataPool.DailyMissionData.GetDailyMissionByKind(i);

            int  nMissionID = rDailyMission.MissionID;
            byte yQuality   = rDailyMission.Quality;

            Tab_MissionBase MissionBase = TableManager.GetMissionBaseByID(nMissionID, 0);
            if (MissionBase == null)
            {
                continue;
            }

            // 创建Item
            GameObject curItem = Utils.BindObjToParent(DailyMissionItem, m_ItemGrid.gameObject);
            if (curItem == null)
            {
                LogModule.DebugLog("AwardActivityItem create error");
                continue;
            }

            curItem.name = i.ToString();
            DailyMissionItemLogic AwardItem = curItem.GetComponent <DailyMissionItemLogic>();
            if (AwardItem != null)
            {
                AwardItem.Init(i, nMissionID, yQuality);
            }

            UpdateMissionState(nMissionID);
        }

        m_ItemGrid.repositionNow = true;
        m_ItemGrid.sorted        = true;
    }
	public void Sort()
	{
		int id = (int)UnityEngine.Random.Range(0, missions.Count);
		currentMission = missions[id];
		
		if(MissionNumber == 1)
		{
			Global.Mission1ID = id;
			Global.Mission1Completed = false;
		}
		else if(MissionNumber == 2)
		{
			Global.Mission2ID = id;
			Global.Mission2Completed = false;
		}
		else if(MissionNumber == 3)
		{
			Global.Mission3ID = id;
			Global.Mission3Completed = false;
		}
	}
 public void UpdateMissionItemByKind(int nKind)
 {
     DailyMissionItemLogic[] Item = m_ItemGrid.GetComponentsInChildren <DailyMissionItemLogic>();
     for (int i = 0; i < Item.Length; ++i)
     {
         if (Item[i].Kind == nKind)
         {
             DailyMission missionItem = GameManager.gameManager.PlayerDataPool.DailyMissionData.GetDailyMissionByKind(nKind);
             if (missionItem.MissionID <= Games.GlobeDefine.GlobeVar.INVALID_ID)
             {
                 Item[i].gameObject.SetActive(false);
                 break;
             }
             Item[i].Init(nKind, missionItem.MissionID, missionItem.Quality);
             return;
         }
         if (m_ItemGrid)
         {
             m_ItemGrid.repositionNow = true;
         }
     }
 }
 public Task UpdateDailyMission(DailyMission mission) => Task.Run(async() =>
 {
     var version = await _localDatabase.GetDailyMissionVersion(mission.DayNumber);
     await _localDatabase.UpdateDailyMission(mission, version);
 });
        public IHttpActionResult GenerateDailyMissions()
        {
            Character character = db.Characters.Where(y => y.ApplicationUserID == User.Identity.Name).FirstOrDefault();

            List <CharacterMission>     characterMissions     = db.CharacterMissions.Where(x => x.CharacterID == character.CharacterID).ToList();
            List <CharacterMissionTask> characterMissionTasks = db.CharacterMissionTasks.Where(x => x.CharacterID == character.CharacterID).ToList();

            foreach (var mission in db.DailyMissions)
            {
                foreach (var cm in characterMissions)
                {
                    if (mission.MissionID == cm.MissionID)
                    {
                        foreach (var cmt in characterMissionTasks.Where(x => x.CharacterMissionTaskID == cm.CharacterMissionID).ToList())
                        {
                            db.CharacterMissionTasks.Remove(cmt);
                        }
                    }
                }
            }

            db.SaveChanges();


            foreach (var mission in db.DailyMissions)
            {
                foreach (var cm in characterMissions)
                {
                    if (mission.MissionID == cm.MissionID)
                    {
                        if (cm.CharacterMissionTasks.Count == 0)
                        {
                            db.CharacterMissions.Remove(cm);
                        }
                    }
                }
            }


            db.SaveChanges();

            Random rand = new Random();
            List <DailyMission>       dailyCollectMissions     = new List <DailyMission>();
            List <CollectMissionTask> dailyCollectMissionTasks = db.CollectMissionTasks.ToList();

            foreach (var mission in db.DailyMissions)
            {
                foreach (var taskk in dailyCollectMissionTasks)
                {
                    if (taskk.MissionID == mission.MissionID)
                    {
                        dailyCollectMissions.Add(mission);
                    }
                }
            }

            int          missionIndex    = rand.Next(0, dailyCollectMissions.Count());
            DailyMission selectedMission = dailyCollectMissions.ElementAt <DailyMission>(missionIndex);

            selectedMission.MissionTasks = db.MissionTasks.Where(x => x.MissionID == selectedMission.MissionID).ToList();


            CharacterMission charMiss = new CharacterMission {
                CharacterID = character.CharacterID, MissionID = selectedMission.MissionID, IsCompleted = false
            };

            db.CharacterMissions.Add(charMiss);
            db.SaveChanges();

            foreach (var m in selectedMission.MissionTasks)
            {
                CharacterMissionTask characterMissionTask = new CharacterMissionTask {
                    CharacterID = character.CharacterID, MissionTaskID = m.MissionTaskID, CharacterMissionID = charMiss.CharacterMissionID, IsCompleted = false
                };
                db.CharacterMissionTasks.Add(characterMissionTask);
                db.SaveChanges();
            }


            selectedMission = db.DailyMissions.Find(27);
            selectedMission.MissionTasks = db.MissionTasks.Where(x => x.MissionID == selectedMission.MissionID).ToList();
            charMiss = new CharacterMission {
                CharacterID = character.CharacterID, MissionID = selectedMission.MissionID, IsCompleted = false
            };

            db.CharacterMissions.Add(charMiss);
            db.SaveChanges();

            foreach (var m in selectedMission.MissionTasks)
            {
                CharacterMissionTask characterMissionTask = new CharacterMissionTask {
                    CharacterID = character.CharacterID, MissionTaskID = m.MissionTaskID, CharacterMissionID = charMiss.CharacterMissionID, IsCompleted = false
                };
                db.CharacterMissionTasks.Add(characterMissionTask);
                db.SaveChanges();
            }

            selectedMission = db.DailyMissions.Find(28);
            selectedMission.MissionTasks = db.MissionTasks.Where(x => x.MissionID == selectedMission.MissionID).ToList();
            charMiss = new CharacterMission {
                CharacterID = character.CharacterID, MissionID = selectedMission.MissionID, IsCompleted = false
            };

            db.CharacterMissions.Add(charMiss);
            db.SaveChanges();

            foreach (var m in selectedMission.MissionTasks)
            {
                CharacterMissionTask characterMissionTask = new CharacterMissionTask {
                    CharacterID = character.CharacterID, MissionTaskID = m.MissionTaskID, CharacterMissionID = charMiss.CharacterMissionID, IsCompleted = false
                };
                db.CharacterMissionTasks.Add(characterMissionTask);
                db.SaveChanges();
            }

            selectedMission = db.DailyMissions.Find(29);
            selectedMission.MissionTasks = db.MissionTasks.Where(x => x.MissionID == selectedMission.MissionID).ToList();
            charMiss = new CharacterMission {
                CharacterID = character.CharacterID, MissionID = selectedMission.MissionID, IsCompleted = false
            };

            db.CharacterMissions.Add(charMiss);
            db.SaveChanges();

            foreach (var m in selectedMission.MissionTasks)
            {
                CharacterMissionTask characterMissionTask = new CharacterMissionTask {
                    CharacterID = character.CharacterID, MissionTaskID = m.MissionTaskID, CharacterMissionID = charMiss.CharacterMissionID, IsCompleted = false
                };
                db.CharacterMissionTasks.Add(characterMissionTask);
                db.SaveChanges();
            }

            character.DailyMissionDate = DateTime.Now;

            db.SaveChanges();

            return(Ok());
        }