Пример #1
0
        /// <summary>
        /// Create orb instance
        /// </summary>
        /// <param name="p_SkillCaster"></param>
        /// <param name="p_OrbCaster"></param>
        /// <param name="p_OrbTarget"></param>
        /// <param name="p_OrbData"></param>
        /// <returns></returns>
        public static Orb Instantiate(ISkillCaster p_SkillCaster, IOrbCaster p_OrbCaster, IOrbTarget p_OrbTarget, OrbData p_OrbData)
        {
            Orb _orb = new Orb(p_OrbData);

            //Init some data
            _orb.SkillCaster = p_SkillCaster;
            _orb.OrbCaster   = p_OrbCaster;
            _orb.OrbTarget   = p_OrbTarget;

            #region Init action motion trigger
            if (p_OrbData.createActions != null)
            {
                for (int i = 0; i < p_OrbData.createActions.Length; i++)
                {
                    OrbAction ac = SkillFactory.CreateAction(p_OrbData.createActions[i]);
                    ac.Holder = _orb;
                    _orb.CreateActions.Add(ac);
                }
            }
            if (p_OrbData.triggerActions != null)
            {
                for (int i = 0; i < p_OrbData.triggerActions.Length; i++)
                {
                    OrbAction ac = SkillFactory.CreateAction(p_OrbData.triggerActions[i]);
                    ac.Holder = _orb;
                    _orb.TriggerActions.Add(ac);
                }
            }
            if (p_OrbData.destroyActions != null)
            {
                for (int i = 0; i < p_OrbData.destroyActions.Length; i++)
                {
                    OrbAction ac = SkillFactory.CreateAction(p_OrbData.destroyActions[i]);
                    ac.Holder = _orb;
                    _orb.DestroyActions.Add(ac);
                }
            }
            if (p_OrbData.motions != null)
            {
                for (int i = 0; i < p_OrbData.motions.Length; i++)
                {
                    OrbMotion mo = SkillFactory.CreateMotion(p_OrbData.motions[i]);
                    mo.Holder = _orb;
                    _orb.Motions.Add(mo);
                }
            }
            #endregion

            _orb.TriggerCreate();
            return(_orb);
        }