コード例 #1
0
        public static T Clone <T>(ActItem src) where T : ActItem
        {
            T item = Activator.CreateInstance <T>();

            FieldInfo[] fields = item.GetType().GetFields();
            for (int i = 0; i < fields.Length; i++)
            {
                FieldInfo newField = fields[i];
                if (newField.IsDefined(typeof(SerializeField), true) &&
                    newField.IsDefined(typeof(ActFieldAttribute), true) == false)
                {
                    FieldInfo oldField = src.GetType().GetField(newField.Name);
                    if (oldField != null)
                    {
                        newField.SetValue(item, oldField.GetValue(src));
                    }
                }
            }
            for (int i = 0; i < src.Children.Count; i++)
            {
                ActItem child = Clone(src.Children[i]);
                item.AddChild(child);
            }
            return(item);
        }
コード例 #2
0
 protected void LoopChildren(List <ActItem> list)
 {
     if (mFinishList.Count >= list.Count)
     {
         Exit();
         return;
     }
     if (list.Count > 0)
     {
         for (int i = 0; i < list.Count; i++)
         {
             if (mFinishList.Contains(i))
             {
                 continue;
             }
             ActItem item = list[i];
             item.Loop();
             if (item.Status == EActStatus.SUCCESS)
             {
                 mFinishList.Add(i);
             }
         }
     }
     else
     {
         Exit();
     }
 }
コード例 #3
0
ファイル: ActSystem.cs プロジェクト: zyb2013/GameProject3
 public void Execute()
 {
     for (int i = 0; i < mRunItems.Count; i++)
     {
         ActItem item = mRunItems[i];
         item.Loop();
         if (item.Status == EActStatus.INITIAL || item.Status == EActStatus.SUCCESS)
         {
             mDelItems.Add(item);
         }
     }
     for (int i = 0; i < mDelItems.Count; i++)
     {
         ActItem item = mDelItems[i];
         mRunItems.Remove(item);
     }
     mDelItems.Clear();
     for (int i = 0; i < mMovers.Count; i++)
     {
         MoverBase mover = mMovers[i];
         if (mover.IsDead())
         {
             mDeleteMovers.Add(mover);
         }
         else
         {
             mover.Execute();
         }
     }
     for (int i = 0; i < mDeleteMovers.Count; i++)
     {
         mMovers.Remove(mDeleteMovers[i]);
     }
 }
コード例 #4
0
ファイル: ActSystem.cs プロジェクト: zyb2013/GameProject3
 public void Run(ActItem item)
 {
     lock (mRunItems)
     {
         mRunItems.Add(item);
     }
 }
コード例 #5
0
 public override void SaveDoc(XmlDocument doc, XmlElement element)
 {
     base.SaveDoc(doc, element);
     for (int i = 0; i < Children.Count; i++)
     {
         ActItem    act   = Children[i];
         XmlElement child = doc.CreateElement(act.GetType().Name);
         element.AppendChild(child);
         act.SaveDoc(doc, child);
     }
 }
コード例 #6
0
ファイル: ActSkill.cs プロジェクト: zyb2013/GameProject3
 public override void Begin()
 {
     this.Skill    = this;
     this.StatTime = Time.time;
     this.Status   = EActStatus.SELFEND;
     for (int i = 0; i < Children.Count; i++)
     {
         ActItem child = Children[i];
         child.ApplyCenter = Skill.Caster.CacheTransform;
     }
     this.FirstUse = false;
 }
コード例 #7
0
 protected override void ExecuteChildren()
 {
     if (Children.Count > 0)
     {
         ActItem item = Children[RandomIndex];
         item.Loop();
         if (item.Status == EActStatus.SUCCESS)
         {
             Exit();
         }
     }
     else
     {
         Exit();
     }
 }
コード例 #8
0
        public static void RunChildrenInNewTree(ActItem src, Callback <ActTree> initTreeCallback)
        {
            ActTree tree = new ActTree();

            for (int i = 0; i < src.Children.Count; i++)
            {
                ActItem child = ActItem.Clone(src.Children[i]);
                tree.AddChild(child);
            }
            tree.Skill = src.Skill;
            if (initTreeCallback != null)
            {
                initTreeCallback.Invoke(tree);
            }
            GTWorld.Instance.Act.Run(tree);
        }
コード例 #9
0
ファイル: ActScope.cs プロジェクト: zyb2013/GameProject3
        protected override bool Trigger()
        {
            base.Trigger();
            this.ClearAttackList();
            List <Character> listAffect = Skill.Caster.GetAffectCharacters(Affect, false);

            for (int i = 0; i < listAffect.Count; i++)
            {
                Character cc = listAffect[i];
                if (ApplyByCenter)
                {
                    if (IsTouch(cc, ApplyCenter))
                    {
                        this.AddInAttackList(cc);
                    }
                }
                else
                {
                    if (IsTouch(cc, ApplyHitPoint, ApplyHitDir))
                    {
                        this.AddInAttackList(cc);
                    }
                }
                if (mTargetList.Count >= MaxCount && MaxCount > 0)
                {
                    break;
                }
            }
            for (int i = 0; i < Children.Count; i++)
            {
                ActItem item = Children[i];
                item.ClearAttackList();
                item.AddRangeInAttackList(mTargetList);
                if (ApplyByCenter && ApplyCenter != null)
                {
                    item.ApplyHitPoint = ApplyCenter.position;
                    item.ApplyHitDir   = Vector3.zero;
                }
                else
                {
                    item.ApplyHitPoint = ApplyHitPoint;
                    item.ApplyHitDir   = Vector3.zero;
                }
            }
            HideWarning();
            return(mTargetList.Count > 0);
        }
コード例 #10
0
 protected override void ExecuteChildren()
 {
     if (Children.Count > 0)
     {
         if (ExecuteIndex >= Children.Count)
         {
             Exit();
         }
         else
         {
             ActItem item = Children[ExecuteIndex];
             if (item.Status == EActStatus.SUCCESS)
             {
                 ExecuteIndex++;
             }
         }
     }
     else
     {
         Exit();
     }
 }
コード例 #11
0
        public override void LoadDoc(XmlElement element)
        {
            base.LoadDoc(element);
            XmlElement child = element.FirstChild as XmlElement;

            while (child != null)
            {
                Type type = System.Type.GetType("ACT" + "." + child.Name);

                try
                {
                    ActItem act = (ActItem)System.Activator.CreateInstance(type);
                    act.LoadDoc(child);
                    AddChild(act);
                    child = child.NextSibling as XmlElement;
                }
                catch (Exception ex)
                {
                    Debug.LogError(child.Name);
                    child = child.NextSibling as XmlElement;
                }
            }
        }
コード例 #12
0
ファイル: ActSkill.cs プロジェクト: zyb2013/GameProject3
 public override void DelChild(ActItem act)
 {
     base.DelChild(act);
 }
コード例 #13
0
ファイル: ActSkill.cs プロジェクト: zyb2013/GameProject3
 public override void AddChild(ActItem act)
 {
     base.AddChild(act);
     act.Skill = this;
 }
コード例 #14
0
 public virtual void DelChild(ActItem item)
 {
     Children.Remove(item);
 }
コード例 #15
0
 public virtual void AddChild(ActItem item)
 {
     Children.Add(item);
     item.Parent = this;
 }