示例#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);
        }
示例#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());
        }
示例#3
0
 public override void OnGameLogicTurn()
 {
     base.OnGameLogicTurn();
     Rand();
     clearEventss.Clear();
     foreach (var item in EventCD)
     {
         item.Value.Update();
         if (item.Value.IsOver())
         {
             clearEventss.Add(item.Key);
         }
     }
     foreach (var item in clearEventss)
     {
         EventCD.Remove(item);
     }
 }