示例#1
0
        /// <summary>
        /// A factory to create achievement from specified data
        /// </summary>
        /// <param name="data">Not null please</param>
        /// <param name="manager">NOT NULL also</param>
        /// <returns></returns>
        public static Achievement CreateAchievement(AchievementModel data, AchievementManager manager)
        {
            if (data == null)
            {
                Debug.LogWarning("Trying to create achievement with null data, skipping...");
                return(null);
            }

            if (manager == null)
            {
                Debug.LogWarning("Trying to create achievement without manager, skipping...");
                return(null);
            }

            Achievement ach = new Achievement(data);

            ach.m_Manager = manager;

            if (!data.isUnlocked)
            {
                ach.Initialize();
                //ach.allOperators = new Dictionary<OperatorModel, Operator>(5);
                //ach.m_OperatorCompleted = 0;
                //ach.m_TotalOperator = data.listConditions.Count;

                ////Debug.Log("Creating achievement: " + data.ID + ", num condition: " + data.listConditions.Count);
                //for (int i = 0; i < listOperators.Count; i++){
                //    Operator op = manager.AddOperator(listOperators[i]);
                //    if (op != null) {
                //        op.SetOperatorCompleteCallBack(ach.OnOperatorCompleted);
                //        op.SetOperatorUndoneCallback(ach.OnOperatorUndone);
                //        ach.allOperators.Add(listOperators[i], op);
                //    }
                //    else {
                //        Debug.Log("Can NOT find suitable operator, creating Achievement failed for " + data.ID);
                //        return null;
                //    }
                //}
            }

            return(ach);
        }
示例#2
0
 public void Awake()
 {
     S = this;
 }