Example #1
0
        public override List <CombatantIndex> GetInvolved()
        {
            if (cachedInvolved != null)
            {
                return(cachedInvolved);
            }

            List <CombatantIndex> list = new List <CombatantIndex>();

            int len = m_children.Count;

            for (int i = 0; i < len; i++)
            {
                CombatEffectEvent effect = m_children[i] as CombatEffectEvent;
                list.AddRange(effect.GetInvolved());
            }

            list.Sort();
            for (int i = list.Count - 1; i > 0; --i)
            {
                if (list[i].Equals(list[i - 1]))
                {
                    list.RemoveAt(i);
                }
            }

            cachedInvolved = list;
            return(list);
        }
Example #2
0
        protected void UpdateCollide()
        {
            List <CombatEventTree> collide_queue = CalculateCollideList();

            if (collide_queue == null)
            {
                return;
            }

            Vector3 move_direction = CollidePoint - BackPoint;

            int len = collide_queue.Count;

            for (int i = 0; i < len; i++)
            {
                CombatEventTree node = collide_queue[i];
                if (node.NodeState != CombatEventTreeState.INITED)
                {
                    continue;
                }

                if (node.Event.Type != eCombatEventType.EFFECT)
                {
                    continue;
                }

                CombatEffectEvent effect           = node.Event as CombatEffectEvent;
                Combatant         target           = Hotfix_LT.UI.LTCombatEventReceiver.Instance.GetCombatant(effect.Target);
                Vector3           direction_vector = target.transform.position - Combatant.transform.position;
                if (Vector3.Dot(direction_vector, move_direction) < 0.0f)
                {
                    //CombatEventReceiver.Instance.DoEventNode(node);
                }
            }
        }
Example #3
0
        public override bool Parse(Hashtable info)
        {
            eCombatEventType type = ParseType(info);

            if (type != eCombatEventType.SYNC)
            {
                EB.Debug.LogWarning("CombatSyncEvent.Parse: invalid type = {0}", type);
                return(false);
            }

            List <CombatEvent> children = CombatUtil.ParseEffects(info);

            if (children != null)
            {
                m_children = children;
            }

            int len = m_children.Count;

            for (int i = 0; i < len; i++)
            {
                CombatEffectEvent effect = m_children[i] as CombatEffectEvent;
                if (effect.Timing == eCombatEventTiming.AUTO)
                {
                    effect.Timing = eCombatEventTiming.ON_START;
                }

                if (effect.Sender == null)
                {
                    effect.Sender = new CombatantIndex(effect.Target.TeamIndex, effect.Target.IndexOnTeam);
                }
            }

            return(true);
        }
Example #4
0
        public static CombatEffectEvent ParseEffect(Hashtable info)
        {
            string type_info = EB.Dot.String("type", info, null);

            if (string.IsNullOrEmpty(type_info))
            {
                EB.Debug.LogError("ParseEffect: type is empty, {0}", EB.JSON.Stringify(info));
                return(null);
            }
            eCombatEffectType effect_type = GetEffectType(type_info);

            if (effect_type == eCombatEffectType.INVALID)
            {
                EB.Debug.LogError("ParseEffect: invalid type, {0}", effect_type);
                return(null);
            }

            CombatEffectEvent effect = CreateEffectInstance((int)effect_type);

            if (effect == null)
            {
                EB.Debug.LogError("ParseEffect: create instance failed, {0}", effect_type);
                return(null);
            }

            if (!effect.Parse(info))
            {
                EB.Debug.LogError("ParseEffect: parse failed, {0}", EB.JSON.Stringify(info));
                return(null);
            }

            return(effect);
        }
Example #5
0
        public static CombatEventTree Parse(CombatEvent evt)
        {
            CombatEventTree root = new CombatEventTree();

            root.Event     = evt;
            root.NodeState = CombatEventTreeState.INITED;
            root.TreeState = CombatEventTreeState.INITED;

            if (evt.Children == null)
            {
                return(root);
            }

            // children are CombatEffectEvent
            for (int i = 0, cnt = evt.Children.Count; i < cnt; ++i)
            {
                CombatEffectEvent effect   = evt.Children[i] as CombatEffectEvent;
                CombatEventTree   sub_tree = Parse(effect);

                if (effect.Parent < 0)
                {
                    root.AddChild(sub_tree);
                }
                else
                {
                    CombatEvent     parent_effect = evt.Children[effect.Parent];
                    CombatEventTree parent        = root.FindInChildren(parent_effect);
                    parent.AddChild(sub_tree);
                }
            }

            return(root);
        }
Example #6
0
        public static List <CombatEvent> ParseEffects(Hashtable info)
        {
            ArrayList effects_info = EB.Dot.Array("effects", info, null);

            if (effects_info == null)
            {
                EB.Debug.LogWarning("Parse effect failed, effects key not found");
                return(new List <CombatEvent>());
            }

            List <CombatEvent> effects = new List <CombatEvent>();

            var enumerator = effects_info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Hashtable         effect_info = enumerator.Current as Hashtable;
                CombatEffectEvent effect      = ParseEffect(effect_info);
                if (effect == null)
                {
                    EB.Debug.LogError("Parse effect failed, {0}", EB.JSON.Stringify(effect_info));
                    return(null);
                }

                effects.Add(effect);
            }

            return(effects);
        }
Example #7
0
        public static CombatEffectEvent CreateEffectInstance(int effect_type)
        {
            Dictionary <int, System.Type> class_type_dic = sEffectClassDic;

            if (!class_type_dic.ContainsKey(effect_type))
            {
                return(null);
            }

            System.Type       class_type = class_type_dic[effect_type];
            CombatEffectEvent effect     = System.Activator.CreateInstance(class_type) as CombatEffectEvent;

            return(effect);
        }
Example #8
0
        public int GetHitTargetCount()
        {
            int cnt = 0;
            int len = m_children.Count;

            for (int i = 0; i < len; i++)
            {
                CombatEffectEvent effect = m_children[i] as CombatEffectEvent;
                if (effect.EffectType != eCombatEffectType.REACTION)
                {
                    continue;
                }

                ReactionEffectEvent reaction = effect as ReactionEffectEvent;
                cnt += reaction.IsMiss ? 0 : 1;
            }
            return(cnt);
        }
Example #9
0
        public void SetHitTimes(int times)
        {
            m_totalHitTimes = times;
            m_hitTimes      = times;

            int len = m_children.Count;

            for (int i = 0; i < len; i++)
            {
                CombatEffectEvent effect = m_children[i] as CombatEffectEvent;
                if (effect.EffectType != eCombatEffectType.REACTION)
                {
                    continue;
                }

                ReactionEffectEvent reaction = effect as ReactionEffectEvent;
                reaction.TotalTimes = m_hitTimes;
                reaction.Times      = 0;
            }
        }
Example #10
0
        public override bool Parse(Hashtable info)
        {
            m_owner = CombatantIndex.Parse(info["sender"] as Hashtable);
            if (m_owner == null)
            {
                EB.Debug.LogWarning("CombatImpactEvent.Parse: owner is empty {0}", EB.JSON.Stringify(info));
                return(false);
            }

            ImpactData = CombatUtil.ParseImpactData(info["impact_data"] as Hashtable, null);

            List <CombatEvent> children = CombatUtil.ParseEffects(info);

            if (children != null)
            {
                m_children = children;
            }

            int len = m_children.Count;

            for (int i = 0; i < len; i++)
            {
                CombatEffectEvent effect = m_children[i] as CombatEffectEvent;
                if (effect.Timing == eCombatEventTiming.AUTO)
                {
                    effect.Timing = eCombatEventTiming.ON_START;
                }

                if (effect.Sender == null)
                {
                    effect.Sender = new CombatantIndex(m_owner.TeamIndex, m_owner.IndexOnTeam);
                }
            }

            return(true);
        }
Example #11
0
        public ReactionEffectEvent FindComboTriggerReaction(CombatSkillEvent combo_skill)
        {
            bool res = (bool)GlobalUtils.CallStaticHotfixEx("Hotfix_LT.Data.SkillTemplateManager", "Instance", "IsComBo", combo_skill.SkillId);

            if (!res)
            {
                return(null);
            }

            CombatantIndex trigger = combo_skill.Trigger;

            if (trigger == null)
            {
                return(null);
            }

            int len = m_children.Count;

            for (int i = 0; i < len; i++)
            {
                CombatEffectEvent effect = m_children[i] as CombatEffectEvent;
                if (effect.EffectType != eCombatEffectType.REACTION)
                {
                    continue;
                }

                if (!effect.Target.Equals(trigger))
                {
                    continue;
                }

                return(effect as ReactionEffectEvent);
            }

            return(null);
        }
Example #12
0
        public override bool Parse(Hashtable info)
        {
            if (!base.Parse(info))
            {
                return(false);
            }

            IsCombo    = m_timing != eCombatEventTiming.AUTO;
            ComboDelay = EB.Dot.Single("delay", info, 0.0f);

            // skip flag
            m_skip = EB.Dot.Bool("skip", info, false);

            m_sender = ParseSender(info);
            if (m_sender == null)
            {
                EB.Debug.LogWarning("CombatSkillEvent.Parse: sender is empty {0}", EB.JSON.Stringify(info));
                return(false);
            }

            // may be empty
            m_trigger = ParseTrigger(info);
            m_target  = ParseTarget(info);

            m_skillId = ParseSkillId(info);
            if (m_skillId < 0)
            {
                EB.Debug.LogWarning("CombatSkillEvent.Parse: skill is empty {0}", EB.JSON.Stringify(info));
                return(false);
            }

            m_targets = ParseTargets(info);
            if (m_targets == null)
            {
                if (m_skip && m_target == null)
                {
                    m_targets = new HashSet <CombatantIndex>();
                }
                else
                {
                    EB.Debug.LogWarning("CombatSkillEvent.Parse: targets is empty {0}", EB.JSON.Stringify(info));
                    return(false);
                }
            }

            m_comboIndex = EB.Dot.Integer("combo_index", info, m_comboIndex);

            m_children = CombatUtil.ParseEffects(info);
            if (m_children == null)
            {
                if (m_skip && m_target == null)
                {
                    m_children = new List <CombatEvent>();
                }
                else
                {
                    EB.Debug.LogWarning("CombatSkillEvent.Parse: effects is empty {0}", EB.JSON.Stringify(info));
                    return(false);
                }
            }

            int len = m_children.Count;

            for (int i = 0; i < len; i++)
            {
                CombatEffectEvent effect = m_children[i] as CombatEffectEvent;
                if (effect.Timing == eCombatEventTiming.AUTO)
                {
                    effect.Timing = eCombatEventTiming.RUNTIME;
                }

                if (effect.Sender == null)
                {
                    effect.Sender = new CombatantIndex(m_sender.TeamIndex, m_sender.IndexOnTeam);
                }
            }

            return(true);
        }