Exemple #1
0
        bool IsInTarget(TDBaseEventData eventData)
        {
            if (eventData.Targets == null)
            {
                return(false);
            }
            if (EventCD.ContainsKey(eventData.TDID))
            {
                if (!EventCD[eventData.TDID].IsOver())
                {
                    return(false);
                }
            }

            if (eventData.Targets.Count > 0)
            {
                ACMgr.Reset(SelfBaseUnit);
                ACMgr.Add(eventData.Targets);
                if (!ACMgr.IsTrue())
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #2
0
        public TData Rand()
        {
            if (!RandUtil.Rand(GlobalProp))
            {
                return(null);
            }
            if (CurRandCount >= MaxRandCount)
            {
                CurRandCount = 0;
                return(null);
            }
            CurRandCount++;
            if (Options.IsNoEvent)
            {
                return(null);
            }
            if (!SelfBaseUnit.IsPlayerCtrl())
            {
                return(null);
            }
            if (TDLuaMgr.Keys.Count == 0)
            {
                return(null);
            }

            string key    = TDLuaMgr.Keys.Rand();
            TData  config = TDLuaMgr.Get <TData>(key);

            //判断事件的触发条件
            if (IsInTarget(config))
            {
                //判断事件的概率
                if (IsInProp(config))
                {
                    CurRandCount = 0;
                    if (config.CD > 0)
                    {
                        if (!EventCD.ContainsKey(key))
                        {
                            EventCD.Add(key, new CD());
                        }
                        EventCD[key] = new CD(config.CD);
                    }
                    return(Add(config.TDID));
                }
                else
                {
                    return(null);
                }
            }
            return(Rand());
        }