Exemple #1
0
 public override void OnBeAdded(IMono mono)
 {
     base.OnBeAdded(mono);
     AssianModel();
     if (Model == null)
     {
         CLog.Error("Unit 没有model");
         return;
     }
     ModelRenders = Model.GetComponentsInChildren <Renderer>();
     {
     }
     SkinnedMeshRenderers = Model.GetComponentsInChildren <SkinnedMeshRenderer>();
     {
         float lastSize = 0.0f;
         float curSize  = 0.0f;
         foreach (var item in SkinnedMeshRenderers)
         {
             Vector3 extents = item.bounds.extents;
             curSize = extents.x + extents.y + extents.z;
             if (curSize > lastSize)
             {
                 lastSize        = curSize;
                 MainSkinnedMesh = item;
             }
         }
     }
     IsEnableRenders = true;
     if (IsUseSurfaceMaterial)
     {
         Surface_Source.Init(this);
     }
     if (IsNeedHighlighter)
     {
         highlighter = Mono.EnsureComponet <Highlighter>();
     }
 }
Exemple #2
0
        // 初始化所有属性
        public void Load(Dictionary <T, float> attrs)
        {
            if (attrs == null)
            {
                return;
            }

            Enum <T> .For((x) =>
            {
                int index = Enum <T> .Int(x);
                if (attrDataList.Count <= index)
                {
                    CLog.Error("没有这个属性:{0}", x);
                    return;
                }
                var tempAttrData = attrDataList[index];
                float obj        = tempAttrData.Default;
                if (attrs.ContainsKey(x))
                {
                    obj = attrs[x];
                }
                SetVal(x, obj);
            });
        }
Exemple #3
0
        public override void OnLuaParseEnd()
        {
            base.OnLuaParseEnd();

            //添加到全局属性表
            Type type = typeof(T);
            List <TDAttrData> data = new List <TDAttrData>();
            Dictionary <string, TDAttrData> dataDic = new Dictionary <string, TDAttrData>();

            string[] names = Enum.GetNames(type);
            foreach (var item in names)
            {
                var val = Find(item);
                if (val == null || val.TDID.IsInvStr())
                {
                    CLog.Error("没有这个属性:{0}", item);
                    continue;
                }
                data.Add(val);
                dataDic.Add(item, val);
            }
            AttrDataList.Add(type, data);
            AttrDataDic.Add(type, dataDic);
        }
Exemple #4
0
        /// <summary>
        /// 手动改变属性值
        /// </summary>
        /// <param name="type">属性类型</param>
        /// <param name="val">改变的值</param>
        /// <param name="minVal">最小值</param>
        /// <param name="maxVal">最大值</param>
        /// <param name="onlyDynamicVal">只能改变Dynamic属性,如果改变了Fixed属性则会提示错误</param>
        public virtual void ChangeVal(T type, float val, float?minVal = null, float?maxVal = null, bool onlyDynamicVal = true)
        {
            if (val == 0)
            {
                return;
            }
            int index = Enum <T> .Int(type);

            TDBaseAttrData tempAttrData = GetAttrData(index);

            if (tempAttrData == null)
            {
                return;
            }
            else if (onlyDynamicVal)
            {
                if (tempAttrData.Type == AttrType.Fixed)
                {
                    CLog.Error("错误!! {0}是Fixed类型,无法使用ChangeVal", typeof(T).Name);
                    return;
                }
            }
            SetVal(type, _getBaseAttrVal(index) + val, minVal, maxVal);
        }
Exemple #5
0
        public virtual T AddComponent <T>() where T : BaseMgr, new()
        {
            var component = BaseMgr.Create <T>();

            if (!Util.IsFit(this, component))
            {
                CLog.Error("AddComponent=>{0},{1}:{2}", GOName, component.ToString(), "组件类型不一致");
            }
            componets.Add(component);
            if (component is IOnAnimTrigger)
            {
                triggersComponets.Add(component as IOnAnimTrigger);
            }
            if (component.NeedUpdate)
            {
                updateComponets.Add(component);
            }
            if (component.NeedLateUpdate)
            {
                lateUpdateComponets.Add(component);
            }
            if (component.NeedFixedUpdate)
            {
                fixedUpdateComponets.Add(component);
            }
            if (component.NeedGUI)
            {
                guiComponets.Add(component);
            }
            if (component.NeedGameLogicTurn)
            {
                needGameLogicTurnComponets.Add(component);
            }
            component.OnBeAdded(this);
            return(component);
        }
Exemple #6
0
        /// <summary>
        /// 初始化所有属性
        /// </summary>
        /// <param name="attrs"></param>
        public void InitAllAttr(Dictionary <T, float> attrs)
        {
            if (attrs == null)
            {
                return;
            }

            BaseUtils.ForeachEnum <T>((x) =>
            {
                int index = (int)(object)x;
                if (attrDataList.Count < index)
                {
                    CLog.Error("没有这个属性:{0}", x);
                    return;
                }
                var tempAttrData = attrDataList[index];
                float obj        = tempAttrData.Default;
                if (attrs.ContainsKey(x))
                {
                    obj = attrs[x];
                }
                InitAttr(x, obj);
            });
        }
        public override void OnBeAdded(IMono mono)
        {
            base.OnBeAdded(mono);
            uint appId = GetAppId();

            // 使用try防止崩溃
            try
            {
                SteamClient.Init(appId);
            }
            catch (Exception e)
            {
                CLog.Info("Error starting steam client: {0}", e);
                SteamClient.Shutdown();
            }
            if (SteamClient.IsValid)
            {
                IsSDKInited = true;
            }
            else
            {
                SteamClient.Shutdown();
            }
        }
Exemple #8
0
 /// <summary>
 /// 开始一段旁白
 /// isPause=暂停
 /// isUnPauseOnEndTalk=对话结束后取消暂停
 /// </summary>
 /// <param name="id"></param>
 public virtual NarrationFragment Start(string id)
 {
     CurData = Table.Find(id);
     if (CurData == null)
     {
         CLog.Error($"没有找到这个Plot:{id}");
         return(null);
     }
     CurNarrationIndex = 0;
     if (IsHave())
     {
         var ret = CurData.Fragments[CurNarrationIndex];
         Callback_OnStartNarration?.Invoke(CurData, ret);
         IsStartNarration = true;
         if (!PauseFlag)
         {
             SelfBaseGlobal.BattleMgr.LockGameStartFlow(true);
             SelfBaseGlobal.PlotMgr.EnablePlotMode(true);
         }
         PauseFlag = true;
         return(ret);
     }
     return(null);
 }
Exemple #9
0
        public override void OnEnable()
        {
            base.OnEnable();
            try
            {
                if (LocalArchiveMgr != null)
                {
                    LocalArchiveMgr.Init(GetLocalArchivePath());
                }

                if (RemoteArchiveMgr != null)
                {
                    RemoteArchiveMgr.Init(GetCloudArchivePath());
                }
            }
            catch (Exception e)
            {
                if (e != null)
                {
                    CLog.Error(e.ToString());
                }
            }
            UseRemoteArchives(!Prefers.GetLastAchiveLocal());
        }
Exemple #10
0
        private TData Add(string tdid, BaseUnit cast = null, Callback <TData> action = null, bool isAutoTrigger = false)
        {
            if (!TDLuaMgr.Contains(tdid))
            {
                if (CommonAlert == tdid)
                {
                    CLog.Error("没有:{0},请手动添加CommonAlert", tdid);
                }
                else
                {
                    CLog.Error("没有:{0},请手动添加Alert", tdid);
                }
                return(null);
            }

            TData sourceAlert = TDLuaMgr.Get <TData>(tdid);

            sourceAlert.Cast     = cast ? cast : LocalPlayer;
            sourceAlert.AlertMgr = this;

            //判断通知是否可以被合并
            var finalAlert = CanMerge(sourceAlert);

            if (finalAlert != null)
            {
                finalAlert.OnMerge();
                Callback_OnMerge?.Invoke(finalAlert);
            }
            else
            {
                finalAlert    = sourceAlert.Copy <TData>();
                finalAlert.ID = IDUtil.Gen();
                finalAlert.OnBeAdded(SelfBaseUnit);
                Data.Add(finalAlert);
                if (finalAlert.Type == AlertType.Interaction)
                {
                    //推送最近一次的谈判信息
                    if (ArticleMgr.IsStarNegotiation)
                    {
                        ArticleMgr.PushNagotiationToAlert(finalAlert);
                    }
                    InteractionData.Add(finalAlert);
                    Callback_OnInteractionChange?.Invoke(finalAlert);
                }
                else if (finalAlert.Type == AlertType.Disposable)
                {
                    DisposableData.Add(finalAlert);
                    Callback_DisposableChange?.Invoke(finalAlert);
                }
                else if (finalAlert.Type == AlertType.Continue)
                {
                    ContinueData.Add(finalAlert);
                    Callback_ContinueChange?.Invoke(finalAlert);
                }
                action?.Invoke(finalAlert);
                if (BaseGlobal.IsUnReadData)
                {
                    Callback_OnAdded?.Invoke(finalAlert);
                }
            }
            if (finalAlert.IsAutoTrigger || isAutoTrigger)
            {
                finalAlert.DoLeftClickTrigger();
            }
            return(finalAlert);
        }
Exemple #11
0
        // 载入存档
        public void Load(string path, string name, int curVersion, bool isReadContent, DateTime fileTime)
        {
            ArchiveFile <T> archive = this;

            archive.Name       = name;
            archive.curVersion = curVersion;
            archive.FileTime   = fileTime;
            using (Stream stream = File.OpenRead(path))
            {
                try
                {
                    BinaryReader reader    = new BinaryReader(stream);
                    string       headerStr = null;
                    //使用try防止无效的存档
                    headerStr = reader.ReadString();
                    if (string.IsNullOrEmpty(headerStr))
                    {
                        archive.IsBroken = true;
                    }
                    else
                    {
                        archive.Header = JsonUtility.FromJson <ArchiveHeader>(headerStr);
                        int contentSize = archive.Header.ContentLength;
                        if (contentSize <= 0)
                        {
                            archive.IsBroken = true;
                        }
                        else
                        {
                            archive.Content = reader.ReadBytes(contentSize);
                            if (!string.IsNullOrEmpty(archive.Header.ContentHash))
                            {
                                // 内容损坏
                                if (archive.Header.ContentHash != FileUtil.Hash(archive.Content))
                                {
                                    archive.IsBroken = true;
                                    return;
                                }
                            }
                            if (isReadContent && archive.IsCompatible && contentSize > 0)
                            {
                                byte[] toBeDeserialized = null;
                                if (archive.Header.IsCompressed)
                                {
                                    toBeDeserialized = FileUtil.GZDecompressToBytes(archive.Content);
                                }
                                else
                                {
                                    toBeDeserialized = archive.Content;
                                }
                                archive.GameDatas = SerializationUtility.DeserializeValue <T>(toBeDeserialized, DataFormat.Binary);
                            }
                        }
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    archive.IsBroken = true;
                    CLog.Error("读取存档{0}时出现异常:{1}, 因此认为是损坏的存档。", archive.Name, e.Message);
                }
            }
            return;
        }
Exemple #12
0
 public void AddInfo(string str)
 {
     CLog.Info(str);
     InfoStr += str + "\n";
 }
Exemple #13
0
        void Present_Main()
        {
            EditorGUILayout.BeginVertical(VerticalStyle);
            if (BuildLocalConfig.Ins.Fold_Present_Main = EditorGUILayout.Foldout(BuildLocalConfig.Ins.Fold_Present_Main, "构建", true))
            {
                BuildConfig.Platform     = (Platform)EditorGUILayout.Popup("目标", (int)BuildConfig.Platform, Enum.GetNames(typeof(Platform)));
                BuildConfig.Distribution = (Distribution)EditorGUILayout.EnumPopup("发布平台", BuildConfig.Distribution);
                EditorGUILayout.LabelField(string.Format("版本号预览:{0}", BuildConfig));
                EditorGUILayout.LabelField(string.Format("完整版本号预览:{0}", BuildConfig.FullVersionName));
                BuildConfig.Name     = EditorGUILayout.TextField("名称", BuildConfig.Name);
                BuildConfig.SubTitle = EditorGUILayout.TextField("副标题", BuildConfig.SubTitle);
                BuildConfig.Major    = EditorGUILayout.IntField("主版本", BuildConfig.Major);
                BuildConfig.Minor    = EditorGUILayout.IntField("副版本", BuildConfig.Minor);
                BuildConfig.Data     = EditorGUILayout.IntField("数据库版本", BuildConfig.Data);
                BuildConfig.Prefs    = EditorGUILayout.IntField("Prefs", BuildConfig.Prefs);

                EditorGUILayout.BeginHorizontal();
                BuildConfig.Tag    = (VersionTag)EditorGUILayout.EnumPopup("后缀", BuildConfig.Tag);
                BuildConfig.Suffix = EditorGUILayout.IntField(BuildConfig.Suffix);
                EditorGUILayout.EndHorizontal();

                BuildConfig.BuildType = (BuildType)EditorGUILayout.EnumPopup("打包版本", BuildConfig.BuildType);

                BuildConfig.IgnoreChecker = EditorGUILayout.Toggle("忽略检查", BuildConfig.IgnoreChecker);
                bool preDevelopmentBuild = BuildConfig.IsUnityDevelopmentBuild;
                BuildConfig.IsUnityDevelopmentBuild = EditorGUILayout.Toggle("UnityDevBuild", BuildConfig.IsUnityDevelopmentBuild);
                if (preDevelopmentBuild != BuildConfig.IsUnityDevelopmentBuild)
                {
                    EditorUserBuildSettings.development = BuildConfig.IsUnityDevelopmentBuild;
                }

                if (PlayerSettings.bundleVersion != BuildConfig.ToString())
                {
                    PlayerSettings.bundleVersion = BuildConfig.ToString();
                }


                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("构建Manifest"))
                {
                    Builder.BuildManifest(Native);
                }
                if (GUILayout.Button("构建AB"))
                {
                    Builder.BuildBundle(Native);
                }
                if (GUILayout.Button("构建EXE"))
                {
                    if (CheckEorr())
                    {
                        return;
                    }
                    if (!CheckDevBuildWarring())
                    {
                        return;
                    }
                    if (!CheckAuthority())
                    {
                        return;
                    }
                    Builder.BuildEXE();
                }
                if (GUILayout.Button("构建AB&EXE"))
                {
                    if (CheckEorr())
                    {
                        return;
                    }
                    if (!CheckDevBuildWarring())
                    {
                        return;
                    }
                    if (!CheckAuthority())
                    {
                        return;
                    }
                    Builder.BuildBundleAndEXE(Native);
                }
                EditorGUILayout.EndHorizontal();


                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("运行游戏"))
                {
                    BaseFileUtils.OpenFile(BuildConfig.ExePath);
                    CLog.Info("Run:{0}", BuildConfig.ExePath);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
Exemple #14
0
 protected virtual void OnDrawPresentExplorer()
 {
     DrawButton("LogTag", () => SafeOpenJsonFile(BaseConstMgr.Path_LoggerTag, CLog.CreateDefaultData()));
     DrawButton("Language", () => BaseFileUtils.OpenExplorer(BaseConstMgr.Path_NativeDLCLLanguage, true));
     DrawButton("Lua", () => BaseFileUtils.OpenExplorer(BaseConstMgr.Path_NativeDLCLuaScript, true));
 }
Exemple #15
0
 protected static bool CheckAuthority()
 {
     CLog.Info("打包:" + SystemInfo.deviceName);
     return(true);
 }
Exemple #16
0
        void Present_Build()
        {
            EditorGUILayout.BeginVertical(VerticalStyle);
            if (LocalConfig.FoldDLC = EditorGUILayout.Foldout(LocalConfig.FoldDLC, "构建", true))
            {
                EditorGUILayout.BeginVertical();

                foreach (var item in DLCConfig.EditorAll)
                {
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.LabelField(item.Name, GUILayout.MaxWidth(100));

                    if (DLCConfig.IsSimulationEditor)
                    {
                        if (GUILayout.Button("Build Config"))
                        {
                            Builder.BuildDLCConfig(item);
                            AssetDatabase.Refresh();
                        }
                        if (GUILayout.Button("Build Bundle"))
                        {
                            Builder.BuildBundle(item);
                            EditorUtility.DisplayDialog("提示!", "恭喜! 已经打包完成!!", "确定");
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("请勾选编辑器模式");
                    }

                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical();
                if (GUILayout.Button("RrfreshDLC"))
                {
                    DLCConfig.RefreshDLC();
                }
                if (GUILayout.Button("RecreateDLC"))
                {
                    DLCConfig.RecreateDLC();
                    DLCConfig.RefreshDLC();
                }
                if (DLCConfig.IsSimulationEditor)
                {
                    if (GUILayout.Button("One click build"))
                    {
                        if (CheckEorr())
                        {
                            return;
                        }
                        if (!CheckDevBuildWarring())
                        {
                            return;
                        }
                        if (!CheckAuthority())
                        {
                            return;
                        }
                        RefreshData();
                        foreach (var item in DLCConfig.EditorAll)
                        {
                            Builder.BuildBundle(item);
                        }
                        Builder.BuildEXE();
                        EditorUtility.DisplayDialog("提示!", "恭喜! 已经打包完成!!", "确定");
                        EditorApplication.Beep();
                    }
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Build"))
                {
                    if (CheckEorr())
                    {
                        return;
                    }
                    if (!CheckDevBuildWarring())
                    {
                        return;
                    }
                    if (!CheckAuthority())
                    {
                        return;
                    }
                    RefreshData();
                    Builder.BuildEXE();
                    EditorUtility.DisplayDialog("提示!", "恭喜! 已经打包完成!!", "确定");
                }

                if (GUILayout.Button("Run game"))
                {
                    FileUtil.OpenFile(BuildConfig.ExePath);
                    CLog.Info("Run:{0}", BuildConfig.ExePath);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
Exemple #17
0
        // 加载战场
        // readData:是否读取数据
        IEnumerator <float> _loadBattle(bool readData = true)
        {
            BaseGlobal.ResumeGame();
            BaseInputMgr.ResetFullScreenState();
            Callback_OnBattleLoadStart?.Invoke();
            yield return(Timing.WaitForOneFrame);

            float startTime = Time.realtimeSinceStartup;

            IsLoadedScene        = false;
            IsLoadingBattle      = true;
            IsLoadBattleEnd      = false;
            IsGameStartOver      = false;
            IsGameStart          = false;
            IsInPauseLoadingView = false;
            //开始Tip
            BattleCoroutine.Run(_randTip());
            //开始加载
            Callback_OnBattleLoad?.Invoke();
            yield return(Timing.WaitForOneFrame);

            OnLoadSceneStart();
            Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("StartToLoad"), 0.0f);
            //演示几秒,给UI渐变的时间
            yield return(Timing.WaitForSeconds(DelayLoadSceneTime));

            //加载场景
            SceneName  = CurData.GetSceneName();
            SceneAsset = GRMgr.LoadScene(SceneName);
            while (!SceneAsset.IsDone)
            {
                yield return(Timing.WaitForOneFrame);

                Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("LoadingScene"), SceneAsset.Progress * 0.8f);
            }
            //延时一帧
            yield return(Timing.WaitForOneFrame);

            Scene = SceneManager.GetSceneByName(SceneName);
            SceneManager.SetActiveScene(Scene);
            IsLoadedScene = true;
            Callback_OnBattleLoadedScene?.Invoke();
            if (BaseSceneObject == null)
            {
                CLog.Error("错误,场景里没有SceneObject");
            }
            //这里必须延迟一帧,等待UI创建,注册事件
            yield return(Timing.WaitForOneFrame);

            //读取数据前,资源加载
            yield return(Timing.WaitUntilDone(BattleCoroutine.Run(BeforeReadData())));

            Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("BeforeReadData"), 0.9f);
            if (readData)
            {
                BaseGlobal.IsUnReadData = false;
                //读取战场数据
                BaseGlobal.DBMgr.ReadGameDBData();
                BaseGlobal.IsUnReadData = true;
            }
            yield return(Timing.WaitForOneFrame);

            Callback_OnBattleReadDataEnd?.Invoke();
            //增加加载战场次数
            LoadBattleCount++;
            //读取数据后资源加载
            yield return(Timing.WaitUntilDone(BattleCoroutine.Run(AffterReadData())));

            Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("AffterReadData"), 0.95f);
            while (IsInCustomLoading)
            {
                yield return(Timing.WaitForOneFrame);
            }
            GC.Collect();
            Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("GC"), 1.0f);
            IsLoadingBattle = false;
            //场景加载结束
            Callback_OnBattleLoaded?.Invoke();
            IsLoadBattleEnd = true;
            yield return(Timing.WaitForOneFrame);

            //游戏开始(预处理最后阶段)
            SelfBaseGlobal.OnGameStart1();
            SelfBaseGlobal.OnGameStart2();
            Callback_OnGameStart?.Invoke();
            yield return(Timing.WaitForOneFrame);

            SelfBaseGlobal.OnGameStarted1();
            SelfBaseGlobal.OnGameStarted2();
            Callback_OnGameStarted?.Invoke();
            IsGameStart = true;
            //暂停在加载界面
            Callback_OnInPauseLoadingView?.Invoke();
            IsInPauseLoadingView = NeedPauseLoading;
            while (IsInPauseLoadingView)
            {
                yield return(Timing.WaitForOneFrame);
            }
            SelfBaseGlobal.OnCloseLoadingView();
            Callback_OnCloseLoadingView?.Invoke();
            //锁定进入战场流程
            while (IsLockBattleStartFlow)
            {
                yield return(Timing.WaitForOneFrame);
            }
            yield return(Timing.WaitUntilDone(BattleCoroutine.Run(BattleStart())));

            //进入自定义流程的时候暂停
            Callback_OnStartCustomBattleCoroutine?.Invoke();
            if (PlotMgr != null)
            {
                PlotMgr?.SetPlotPause(true);
                yield return(Timing.WaitUntilDone(PlotMgr.CustomStartBattleCoroutine()));

                PlotMgr?.SetPlotPause(false);
            }
            Callback_OnEndCustomBattleCoroutine.Invoke();
            //结尾部分
            SelfBaseGlobal.OnGameStartOver();
            Callback_OnGameStartOver?.Invoke();
            IsGameStartOver = true;
        }
Exemple #18
0
 private void OnAddScoreFail(Result reason)
 {
     CLog.Error("AddScore Fail :" + reason.ToString());
 }
Exemple #19
0
 public void AddErrorLog(string str)
 {
     CLog.Error(str);
     ErrorStr += str + "\n";
 }
        // 根据所有的条件判断
        public bool IsTrue(bool isFast = true)
        {
            if (!IsReseted && !IsIgnoreReset)
            {
                CLog.Error("ACM 组件没有Reset,无法添加条件");
                return(false);
            }
            IsIgnoreReset = false;
            IsReseted     = false;
            if (IgnoreCondition)
            {
                return(true);
            }
            bool isEx        = true;
            bool isAnd       = true;
            bool isAndSimple = true;
            bool isOr        = false;
            bool isOrSimple  = false;

            //判断独占条件
            for (int i = 0; i < exConditions.Count; ++i)
            {
                if (exConditions[i].IsOnlyPlayer && !ParamSelfBaseUnit.IsPlayer())
                {
                    continue;
                }
                if (!exConditions[i].DoAction())
                {
                    isEx = false;
                    if (isFast)
                    {
                        return(false);
                    }
                }
            }

            //判断必须的条件
            for (int i = 0; i < andCacheConditions.Count; ++i)
            {
                BaseCondition con = andCacheConditions[i];
                if (con.IsOnlyPlayer && !ParamSelfBaseUnit.IsPlayer())
                {
                    continue;
                }
                bool ret = con.DoAction();
                if (!ret)
                {
                    isAnd = false;
                    if (isFast)
                    {
                        return(false);
                    }
                }
            }

            for (int i = 0; i < andSimpleConditions.Count; ++i)
            {
                if (andSimpleConditions[i].IsOnlyPlayer && !ParamSelfBaseUnit.IsPlayer())
                {
                    continue;
                }
                if (!andSimpleConditions[i].DoAction())
                {
                    isAndSimple = false;
                    if (isFast)
                    {
                        return(false);
                    }
                }
            }

            //判断多选一的条件
            for (int i = 0; i < orCacheConditions.Count; ++i)
            {
                BaseCondition con = orCacheConditions[i];
                if (con.IsOnlyPlayer && !ParamSelfBaseUnit.IsPlayer())
                {
                    continue;
                }
                bool r = con.DoAction();
                if (r)
                {
                    isOr = true;
                    if (isFast)
                    {
                        return(true);
                    }
                }
            }

            for (int i = 0; i < orSimpleConditions.Count; ++i)
            {
                if (orSimpleConditions[i].IsOnlyPlayer && !ParamSelfBaseUnit.IsPlayer())
                {
                    continue;
                }
                if (orSimpleConditions[i].DoAction())
                {
                    isOrSimple = true;
                    if (isFast)
                    {
                        return(true);
                    }
                }
            }

            if (!isEx)
            {
                return(false);
            }
            return(isAnd && isAndSimple && (orCacheConditions.Count == 0 || isOr) && (orSimpleConditions.Count == 0 || isOrSimple));
        }
Exemple #21
0
 void OnTest()
 {
     Delay.Run(1, () => CLog.Info("Delay 测试成功"));
     SuperInvoke.Run(() => CLog.Info("SuperInvoke 测试成功"), 2);
 }
Exemple #22
0
        void LoadLanguageData(string item)
        {
            HSSFWorkbook dataSet = BaseExcelMgr.ReadExcelNPOI(item);

            if (dataSet == null)
            {
                CLog.Error("无法读取下面文件{0}:", item);
                return;
            }
            //读取每一个Sheet
            for (int i = 0; i < dataSet.NumberOfSheets; ++i)
            {
                ISheet sheet   = dataSet.GetSheetAt(i);
                var    collect = sheet.GetRowEnumerator();
                //读取每一行
                while (collect.MoveNext())
                {
                    //读取语言类型:中文,英文,繁体等等
                    IRow row = (IRow)collect.Current;
                    if (row.RowNum == 0)
                    {
                        foreach (var cell in row.Cells)
                        {
                            if (cell.ColumnIndex == 0)
                            {
                                continue;
                            }
                            else
                            {
                                try
                                {
                                    LangTypes.Add((LanguageType)Enum.Parse(typeof(LanguageType), cell.ToString()));
                                }
                                catch (Exception e)
                                {
                                    CLog.Error("解析Excel表格错误:" + e.ToString());
                                }
                            }
                        }
                    }
                    //读取翻译
                    else
                    {
                        string key = "";
                        //读取每一列
                        foreach (var cell in row.Cells)
                        {
                            //读取每一行的key
                            if (cell.ColumnIndex == 0)
                            {
                                key = cell.ToString();
                                if (key.IsInvStr())
                                {
                                    continue;
                                }
                            }
                            //读取每一行的翻译
                            else
                            {
                                string val = cell.ToString();
                                if (val.IsInvStr())
                                {
                                    val = key;
                                }
                                Add(LangTypes[cell.ColumnIndex - 1], key, val);
                            }
                        }
                    }
                }
            }
        }
        void LoadLanguageData(byte[] buffer)
        {
            var workbook = BaseExcelMgr.ReadWorkbook(buffer);

            if (workbook == null)
            {
                CLog.Error("无法读取下面文件");
                return;
            }
            //读取每一个Sheet
            foreach (var sheet in workbook)
            {
                if (sheet.Count <= 0)
                {
                    continue;
                }
                if (sheet.Name.StartsWith(SysConst.Prefix_Lang_Notes))
                {
                    continue;
                }
                string lastedCategory = "";
                int    NumberOfRows   = sheet.Rows.Count;
                int    NumberOfCols   = sheet.Rows[0].Count;
                if (NumberOfRows <= 0 || NumberOfCols <= 0)
                {
                    continue;
                }
                //读取行
                for (int rowIndex = 0; rowIndex < NumberOfRows; ++rowIndex)
                {
                    #region key
                    //读取第一行
                    if (rowIndex == 0)
                    {
                        for (int colIndex = 0; colIndex < NumberOfCols; ++colIndex)
                        {
                            string tempStr = sheet.Rows[rowIndex][colIndex].ToString();
                            if (tempStr.IsInv())
                            {
                                continue;
                            }
                            if (!FirstRowStrs.ContainsKey(tempStr))
                            {
                                CLog.Error("语言包错误!无效的首行:" + tempStr + ",TableName:" + sheet.Name + ",ID:" + sheet.ID);
                                foreach (var item in FirstRowStrs)
                                {
                                    CLog.Error("首行:" + item.Key.ToString());
                                }
                                return;
                            }
                        }
                    }
                    #endregion
                    #region 读取翻译
                    //读取非首行
                    else
                    {
                        string key = "";
                        for (int colIndex = 0; colIndex < NumberOfCols; ++colIndex)
                        {
                            if (sheet.Rows[rowIndex].Count <= colIndex)
                            {
                                continue;
                            }
                            if (colIndex - 1 >= LangTypes.Count)
                            {
                                continue;
                            }
                            //读取key
                            if (colIndex == 0)
                            {
                                key = sheet.Rows[rowIndex][colIndex].ToString();
                                //跳过无效的字符
                                if (key.IsInv())
                                {
                                    continue;
                                }
                                //跳过注释
                                if (key.StartsWith(Const.Prefix_Lang_Notes))
                                {
                                    continue;
                                }
                                //跳过分类
                                if (key.StartsWith(Const.Prefix_Lang_Category))
                                {
                                    lastedCategory = key.Remove(0, 1);
                                    continue;
                                }
                            }
                            //读取desc
                            else
                            {
                                string firstRowKey = sheet.Rows[0][colIndex].ToString();
                                if (!FirstRowStrs.ContainsKey(firstRowKey))
                                {
                                    CLog.Error("语言包错误!无效的首行:" + firstRowKey);
                                }
                                string desc = sheet.Rows[rowIndex][colIndex].ToString();
                                if (desc.IsInv())
                                {
                                    continue;
                                }
                                Add(FirstRowStrs[firstRowKey], key, desc, "", lastedCategory);
                            }
                        }
                    }
                    #endregion
                }
            }
        }
Exemple #24
0
        public List <AttrAdditon <T> > Add(List <AttrAdditon <T> > array)
        {
            if (array == null)
            {
                return(null);
            }
            for (var i = 0; i < array.Count; ++i)
            {
                if (array[i] != null)
                {
                    var item  = array[i];
                    var index = Enum <T> .Int(item.Type);

                    var tempAttrData = attrDataList[index];

                    //检查数值合适性
                    if (tempAttrData.NumberType == NumberType.Percent)
                    {
                        if (item.Val < -1 || item.Val > 1)
                        {
                            CLog.Error("错误!AddAttrAdditon,Percent,范围越界,Type:{0},Val:{1}", item.Type, item.Val);
                        }
                        else if (item.AddType == AttrOpType.Percent ||
                                 item.AddType == AttrOpType.PercentAdd)
                        {
                            CLog.Error("错误!AddAttrAdditon,Percent,加成方式不对,Type:{0},Val:{1}", item.Type, item.Val);
                        }
                    }
                    else if (tempAttrData.NumberType == NumberType.Bool)
                    {
                        if (item.Val != 0 || item.Val != 1)
                        {
                            CLog.Error("错误!AddAttrAdditon,Bool,Type:{0},Val:{1}", item.Type, item.Val);
                        }
                        else if (item.AddType == AttrOpType.Percent ||
                                 item.AddType == AttrOpType.PercentAdd)
                        {
                            CLog.Error("错误!AddAttrAdditon,Bool,加成方式不对,Type:{0},Val:{1}", item.Type, item.Val);
                        }
                    }

                    //固定值,持续变化
                    if (tempAttrData.Type == AttrType.Fixed)
                    {
                        if (item.AddType == AttrOpType.Direct || item.AddType == AttrOpType.DirectAdd)
                        {
                            _data.Add(item);
                        }
                        else
                        {
                            _percentData.Add(item);
                        }
                    }
                    //动态值一次性变化
                    else if (tempAttrData.Type == AttrType.Dynamic)
                    {
                        if (item.AddType == AttrOpType.Direct)
                        {
                            SetVal(item.Type, item.RealVal);
                        }
                        else if (item.AddType == AttrOpType.DirectAdd)
                        {
                            ChangeVal(item.Type, item.RealVal);
                        }
                        else if (item.AddType == AttrOpType.Percent)
                        {
                            SetVal(item.Type, item.RealVal * _getCurAttrVal(index));
                        }
                        else if (item.AddType == AttrOpType.PercentAdd)
                        {
                            ChangeVal(item.Type, item.RealVal * _getCurAttrVal(index));
                        }
                    }
                }
            }
            SetDirty();
            return(array);
        }