Exemple #1
0
    void fillAchieveInfo(int achieveId)
    {
        AchievementConfig config = AchievementConfig.instance();

        AchievementConfig.AchieveItem achieveItem = config.getAchieveConfigItem(achieveId);
        if (achieveItem == null)
        {
            return;
        }

        _achieveNameText.text = achieveItem.name.ToUpper();
        _achieveInfoText.gameObject.SetActive(!achieveItem.initFinished);
        if (achieveItem.initFinished)
        {
            _achieveFinishTimeText.text = "\nOh my sweetheart\nThe future's not ours to see";
        }
        else
        {
            string detail          = "";
            long   finishTimeStamp = System.Convert.ToInt64(PlayerPrefs.GetString("achieve_finish_time" + achieveId, "0"));

            System.DateTime finishDate = new System.DateTime(finishTimeStamp);
            _achieveFinishTimeText.text = finishDate.ToString("yyyy.MM.dd\nH:mm");

            int firstPawnType  = PlayerPrefs.GetInt("achieve_progress" + achieveId + "_pawn_type0");
            int secondPawnType = PlayerPrefs.GetInt("achieve_progress" + achieveId + "_pawn_type1");

            int neighborMark = achieveItem.parameters[0];
            _achieveDetailFirstPawn.pawnType = (PawnType)firstPawnType;
            _achieveDetailFirstPawn.setNeighborCountMark(neighborMark, true);
            _achieveDetailSecondPawn.pawnType = (PawnType)secondPawnType;
            _achieveDetailSecondPawn.setNeighborCountMark(neighborMark, true);
        }
    }
Exemple #2
0
    public void SetActive(AchievementData achievementData)
    {
        // get achievement config
        Debug.Log("Get config for " + achievementData.achievement + " achievement");
        AchievementConfig achievementConfig = Array.Find(AchievementsManager.Instance.AchievementConfigs, element => element.achievement == achievementData.achievement);

        // set name
        achievementNameText.text = achievementConfig.displayName;
        // convert time to timespan
        DateTime dateTime = new DateTime(achievementData.timeTicksWhenAchieved);

        // set date
        achievementDateText.text = dateTime.ToShortDateString();
        // verify if achivement additional info is not empty
        if ((achievementData.additionalDetails != null) && (achievementData.additionalDetails != ""))
        {
            // set description from data
            achievementDescriptionText.text = achievementData.additionalDetails;
        }
        else
        {
            // set description from config
            achievementDescriptionText.text = achievementConfig.description;
        }
        // activate it
        gameObject.SetActive(true);
    }
Exemple #3
0
    /// <summary>
    /// 领取成就奖励
    /// </summary>
    public void getReward(int id)
    {
        AchievementCompleteData cData = _d.completeDatas.get(id);

        if (cData == null)
        {
            me.warnLog("领取成就奖励时,找不到完成成就", id);
            return;
        }

        if (cData.hasGotReward)
        {
            me.warnLog("领取成就奖励时,已经领过", id);
            return;
        }

        AchievementConfig config = AchievementConfig.get(id);

        if (config.rewardID > 0)
        {
            if (!me.bag.hasRewardPlace(config.rewardID))
            {
                me.warnLog("领取成就奖励时,背包空间不足", id);
                return;
            }
        }

        me.send(GetAchievementRewardRequest.create(id));
    }
Exemple #4
0
    public static AchievementConfig instance()
    {
        if (_instance == null)
        {
            _instance = new AchievementConfig();
        }

        return(_instance);
    }
Exemple #5
0
    /// <summary>
    /// 检查并添加成就
    /// </summary>
    protected void checkAndAccept(int id)
    {
        AchievementConfig config;

        if (checkCanAcceptAchievement(config = AchievementConfig.get(id)))
        {
            addRunningAchievement(config);
        }
    }
Exemple #6
0
	private void checkAchieve(int eliminateNeighborCount, PawnType pawnType) {
		int[] parameters = new int[]{ eliminateNeighborCount, (int)pawnType };
		List<int> newlyFinishedAchieves = AchievementConfig.instance().checkAchieve(
			AchievementConfig.Condition.CLEAR_BY_TYPE, parameters, GameApp.instance().finishedAchieves);

		if (newlyFinishedAchieves.Count > 0) {
			_newlyFinishedAchieves.AddRange(newlyFinishedAchieves);
			GameApp.instance().saveAchieveChange();
		}
	}
Exemple #7
0
    /// <summary>
    /// 添加运行中成就
    /// </summary>
    protected void addRunningAchievement(AchievementConfig config)
    {
        AchievementData data = createAchievementData();

        data.id   = config.id;
        data.task = me.quest.createTaskByID(config.taskID, FunctionType.Achievement, config.id, 0);

        _d.runningDatas.put(data.id, data);

        me.quest.addRunningTask(data.task);
    }
Exemple #8
0
    public void refresh()
    {
        AchievementConfig config = AchievementConfig.instance();
        int achieveCount         = config.getAchieveItemCount();

        for (int i = 0; i < achieveCount; ++i)
        {
            AchievementConfig.AchieveItem item = config.getAchieveItemByIndex(i);
            AchieveUIItem uiItem   = _achieveUIItems[i];
            bool          finished = PlayerPrefs.GetInt("finished_achieve_" + item.id, 0) > 0;
            uiItem.setAchieve(item, finished);
        }
    }
Exemple #9
0
        public static AchievementConfigs deserialize(byte[] buffer, ref uint offset)
        {
            int _AchievementConfig_length = intBuffer.deserialize(buffer, ref offset);

            AchievementConfig[] _AchievementConfig = new AchievementConfig[_AchievementConfig_length];
            for (int i = 0; i < _AchievementConfig_length; i++)
            {
                _AchievementConfig[i] = AchievementConfigBuffer.deserialize(buffer, ref offset);
            }

            AchievementConfigs _AchievementConfigs = new AchievementConfigs();

            _AchievementConfigs._configList = _AchievementConfig;
            return(_AchievementConfigs);
        }
Exemple #10
0
    public void refresh()
    {
        AchievementConfig config = AchievementConfig.instance();
        int achieveCount         = config.getAchieveItemCount();

        for (int i = 0; i < achieveCount; ++i)
        {
            AchievementConfig.AchieveItem item = config.getAchieveItemByIndex(i);
            bool finished = PlayerPrefs.GetInt("finished_achieve_" + item.id, 0) > 0;
            if (i < _achieveIcons.Count)
            {
                Image icon = _achieveIcons[i];
                icon.enabled = finished;
            }
        }
    }
Exemple #11
0
    private void showNext()
    {
        if (_displayIndex < _finishedAchieves.Count)
        {
            int achieveId = _finishedAchieves[_displayIndex];
            AchievementConfig.AchieveItem achieveItem = AchievementConfig.instance().getAchieveConfigItem(achieveId);
            _title.text = achieveItem.name.ToUpper();

            Texture2D achieveIconTex = Resources.Load <Texture2D>("texture/achievement0" + (achieveId - 1));
            _achieveIcon.sprite = Sprite.Create(achieveIconTex,
                                                new Rect(0, 0, achieveIconTex.width, achieveIconTex.height),
                                                new Vector2(0.5f, 0.5f));

            ++_displayIndex;
        }
    }
Exemple #12
0
    void initPlayerDefaults()
    {
        if (Application.isEditor)
        {
            PlayerPrefs.DeleteAll();

            /*long now = System.DateTime.Now.Ticks;
             * PlayerPrefs.SetString("achieve_finish_time1", now.ToString());
             * PlayerPrefs.SetString("achieve_finish_time2", now.ToString());
             * PlayerPrefs.SetInt("achieve_progress" + 1 + "_pawn_type0", 0);
             * PlayerPrefs.SetInt("achieve_progress" + 1 + "_pawn_type1", 1);
             * PlayerPrefs.SetInt("achieve_progress" + 2 + "_pawn_type0", 1);
             * PlayerPrefs.SetInt("achieve_progress" + 2 + "_pawn_type1", 0);
             * PlayerPrefs.SetInt("achieve_progress" + 1, 3);
             * PlayerPrefs.SetInt("achieve_progress" + 2, 3);
             *
             * PlayerPrefs.SetInt("achieve_progress" + 3, 1);
             * PlayerPrefs.SetInt("achieve_progress" + 3 + "_pawn_type0", 0);
             *
             * PlayerPrefs.SetInt("finished_achieve_" + 1, 1);
             * PlayerPrefs.SetInt("finished_achieve_" + 2, 1);*/

            PlayerPrefs.Save();
        }

        if (0 == PlayerPrefs.GetInt("first_create", 0))
        {
            PlayerPrefs.SetInt("first_create", 1);
            PlayerPrefs.SetInt("finished_achieve_" + 7, 1);
            PlayerPrefs.SetInt("finished_achieve_" + 8, 1);
            PlayerPrefs.Save();
        }

        AchievementConfig config = AchievementConfig.instance();
        int achieveCount         = config.getAchieveItemCount();

        for (int i = 0; i < achieveCount; ++i)
        {
            AchievementConfig.AchieveItem item = config.getAchieveItemByIndex(i);
            bool finished = PlayerPrefs.GetInt("finished_achieve_" + item.id, 0) > 0;
            if (finished)
            {
                _finishedAchieves.Add(item.id);
            }
        }
    }
Exemple #13
0
    /// <summary>
    /// 完成成就,g层可复写
    /// </summary>
    protected virtual void onAchievementComplete(int id)
    {
        if (CommonSetting.isClientDriveLogic)
        {
            AchievementConfig config = AchievementConfig.get(id);

            IntList list;
            if (!(list = config.afters).isEmpty())
            {
                int[] values = list.getValues();

                for (int i = 0, len = list.size(); i < len; ++i)
                {
                    checkAndAccept(values[i]);
                }
            }
        }
    }
Exemple #14
0
    /// <summary>
    /// 检查是否可接成就
    /// </summary>
    protected bool checkCanAcceptAchievement(AchievementConfig config)
    {
        //已接
        if (_d.runningDatas.contains(config.id))
        {
            return(false);
        }

        foreach (int v in config.pres)
        {
            if (!isAchievementComplete(v))
            {
                return(false);
            }
        }

        return(true);
    }
Exemple #15
0
    private void initAchieveUI()
    {
        _achieveInfoLayer             = gameObject.transform.Find("AchieveInfoLayer").gameObject.GetComponent <Image>();
        _achieveInfoLayerCanvas       = _achieveInfoLayer.gameObject.GetComponent <CanvasGroup>();
        _achieveInfoLayerCanvas.alpha = 0;

        _achieveNameText         = _achieveInfoLayer.transform.Find("AchieveName").gameObject.GetComponent <Text>();
        _achieveFinishTimeText   = _achieveInfoLayer.transform.Find("AchieveFinishTime").gameObject.GetComponent <Text>();
        _achieveInfoText         = _achieveInfoLayer.transform.Find("AchieveInfo").gameObject.GetComponent <Text>();
        _achieveDetailFirstPawn  = _achieveInfoLayer.transform.Find("AchieveInfo/Pawn1").gameObject.GetComponent <PawnDisplayer>();
        _achieveDetailSecondPawn = _achieveInfoLayer.transform.Find("AchieveInfo/Pawn2").gameObject.GetComponent <PawnDisplayer>();
        _achieveDetailFirstPawn.disableSendMessage  = true;
        _achieveDetailSecondPawn.disableSendMessage = true;

        _achieveInfoLayer.gameObject.SetActive(false);

        AchievementConfig config   = AchievementConfig.instance();
        int       achieveCount     = config.getAchieveItemCount();
        Transform achieveIconLayer = gameObject.transform.Find("AchieveIconLayer");

        _achieveIconGlow = achieveIconLayer.Find("IconGlow").GetComponent <Image>();
        _achieveIconGlow.gameObject.SetActive(false);

        for (int i = 0; i < achieveCount; ++i)
        {
            AchievementConfig.AchieveItem item = config.getAchieveItemByIndex(i);
            bool finished = PlayerPrefs.GetInt("finished_achieve_" + item.id, 0) > 0;

            Transform achieveIcon = achieveIconLayer.Find("Achieve" + i);
            if (achieveIcon)
            {
                Image icon = achieveIcon.gameObject.GetComponent <Image>();
                _achieveIcons.Add(icon);
            }
        }

        refresh();
    }
Exemple #16
0
    private void initAchieveUI()
    {
        Debug.Log("AchieveDetailUI initAchieveUI");

        AchievementConfig config   = AchievementConfig.instance();
        int       achieveCount     = config.getAchieveItemCount();
        Transform achieveItemLayer = gameObject.transform.Find("Panel/AchieveItemLayer");

        for (int i = 0; i < achieveCount; ++i)
        {
            AchievementConfig.AchieveItem item = config.getAchieveItemByIndex(i);
            bool finished = PlayerPrefs.GetInt("finished_achieve_" + item.id, 0) > 0;

            GameObject achieveUIItem = (GameObject)Instantiate(achieveItemPrefab);
            achieveUIItem.transform.SetParent(achieveItemLayer);
            achieveUIItem.transform.localScale = Vector3.one;
            achieveUIItem.name = "AchieveUIItem" + i;

            AchieveUIItem uiItem = achieveUIItem.GetComponent <AchieveUIItem>();
            _achieveUIItems.Add(uiItem);
        }

        refresh();
    }
Exemple #17
0
        public static AchievementConfig deserialize(byte[] buffer, ref uint offset)
        {
            // null
            bool _null = boolBuffer.deserialize(buffer, ref offset);

            if (_null)
            {
                return(null);
            }

            // Id

            int _Id = intBuffer.deserialize(buffer, ref offset);



            // Name

            int _Name = intBuffer.deserialize(buffer, ref offset);



            // Desc

            int _Desc = intBuffer.deserialize(buffer, ref offset);



            // Icon

            int _Icon = intBuffer.deserialize(buffer, ref offset);



            // Difficulty

            int _Difficulty = intBuffer.deserialize(buffer, ref offset);



            // Condition

            AchievementCondition _Condition = AchievementConditionBuffer.deserialize(buffer, ref offset);



            // RewardItem


            int _RewardItem_length = intBuffer.deserialize(buffer, ref offset);

            RewardItem[] _RewardItem = new RewardItem[_RewardItem_length];
            for (int i = 0; i < _RewardItem_length; i++)
            {
                _RewardItem[i] = RewardItemBuffer.deserialize(buffer, ref offset);
            }


            // Buff

            IdPair _Buff = IdPairBuffer.deserialize(buffer, ref offset);



            // NeedAchievement

            int _NeedAchievement = intBuffer.deserialize(buffer, ref offset);



            // TargetSystem

            TargetSystem _TargetSystem = TargetSystemBuffer.deserialize(buffer, ref offset);



            // Group

            int _Group = intBuffer.deserialize(buffer, ref offset);

            AchievementConfig _AchievementConfig = new AchievementConfig();

            _AchievementConfig.Id = _Id;

            _AchievementConfig.Name = _Name;

            _AchievementConfig.Desc = _Desc;

            _AchievementConfig.Icon = _Icon;

            _AchievementConfig.Difficulty = _Difficulty;

            _AchievementConfig.Condition = _Condition;

            _AchievementConfig.RewardItem = _RewardItem;

            _AchievementConfig.Buff = _Buff;

            _AchievementConfig.NeedAchievement = _NeedAchievement;

            _AchievementConfig.TargetSystem = _TargetSystem;

            _AchievementConfig.Group = _Group;
            return(_AchievementConfig);
        }
Exemple #18
0
        public static void serialize(AchievementConfig value, XSteam steam)
        {
            // null
            boolBuffer.serialize(value == null, steam);
            if (value == null)
            {
                return;
            }

            // Id

            intBuffer.serialize(value.Id, steam);



            // Name

            intBuffer.serialize(value.Name, steam);



            // Desc

            intBuffer.serialize(value.Desc, steam);



            // Icon

            intBuffer.serialize(value.Icon, steam);



            // Difficulty

            intBuffer.serialize(value.Difficulty, steam);



            // Condition

            AchievementConditionBuffer.serialize(value.Condition, steam);



            // RewardItem


            intBuffer.serialize(value.RewardItem.Length, steam);
            for (int i = 0; i < value.RewardItem.Length; i++)
            {
                RewardItemBuffer.serialize(value.RewardItem[i], steam);
            }


            // Buff

            IdPairBuffer.serialize(value.Buff, steam);



            // NeedAchievement

            intBuffer.serialize(value.NeedAchievement, steam);



            // TargetSystem

            TargetSystemBuffer.serialize(value.TargetSystem, steam);



            // Group

            intBuffer.serialize(value.Group, steam);
        }