コード例 #1
0
        public void SetNodeBool(bool kg)
        {
            PropsCacheItem parent = this.ParentPropsCacheItem;

            lock (this)
            {
                if (this.nowkg != kg)
                {
                    if (this.nowkg)
                    {
                        for (int i = 0; i < 177; i++)
                        {
                            if (this.ExtProps[i] != 0.0)
                            {
                                parent.SetExtProp(i, parent.ExtProps[i] - this.ExtProps[i]);
                            }
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            if (this.BaseProps[i] != 0.0)
                            {
                                parent.SetBaseProp(i, parent.BaseProps[i] - this.BaseProps[i]);
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < 177; i++)
                        {
                            if (this.ExtProps[i] != 0.0)
                            {
                                parent.SetExtProp(i, parent.ExtProps[i] + this.ExtProps[i]);
                            }
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            if (this.BaseProps[i] != 0.0)
                            {
                                parent.SetBaseProp(i, parent.BaseProps[i] + this.BaseProps[i]);
                            }
                        }
                    }
                }
                this.nowkg = kg;
            }
        }
コード例 #2
0
ファイル: PropsCacheManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 设置基础属性的值(数组)
        /// </summary>
        /// <param name="args"></param>
        public void SetBaseProps(params object[] args)
        {
            PropsCacheItem parent = PropsCacheRoot;
            PropsCacheItem child  = null;

            double[] props       = null;
            object   propsObject = null;

            if (args.Length > 1)
            {
                propsObject = args[args.Length - 1];
                EquipPropItem equipPropItem = args[args.Length - 1] as EquipPropItem;
                if (null != equipPropItem)
                {
                    props = equipPropItem.BaseProps;
                }
                else
                {
                    props = args[args.Length - 1] as double[];
                }
            }

            if (null == props)
            {
                return;
            }

            lock (PropsCacheRoot)
            {
                foreach (var obj in args)
                {
                    if (obj == propsObject)
                    {
                        if (child != null)
                        {
                            Contract.Assert(child.SubPropsItemDict.Count == 0, "only leaf node can set props!");
                            for (int i = 0; i < (int)UnitPropIndexes.Max && i < props.Length; i++)
                            {
                                child.SetBaseProp(i, props[i]);
                            }
                        }
                        break;
                    }
                    else
                    {
                        if (!parent.SubPropsItemDict.TryGetValue((int)obj, out child))
                        {
                            child = new PropsCacheItem(parent, Convert.ToInt32(obj));
                            parent.SubPropsItemDict.Add((int)obj, child);
                        }

                        parent = child;
                    }
                }
            }
        }