Example #1
0
 public static long GetAsLong(this NumericComponent self, int numericType)
 {
     if (self.IsFloat(numericType))
     {
         return(self.GetByKey(numericType) / 10000);
     }
     else
     {
         return(self.GetByKey(numericType));
     }
 }
Example #2
0
 public static int GetAsInt(this NumericComponent self, int numericType)
 {
     if (self.IsFloat(numericType))
     {
         return((int)self.GetByKey(numericType) / 10000);
     }
     else
     {
         return((int)self.GetByKey(numericType));
     }
 }
Example #3
0
        public static void Update(this NumericComponent self, int numericType, bool isPublicEvent)
        {
            int final    = (int)numericType / 10;
            int bas      = final * 10 + 1;
            int add      = final * 10 + 2;
            int pct      = final * 10 + 3;
            int finalAdd = final * 10 + 4;
            int finalPct = final * 10 + 5;

            // 一个数值可能会多种情况影响,比如速度,加个buff可能增加速度绝对值100,也有些buff增加10%速度,所以一个值可以由5个值进行控制其最终结果
            // final = (((base + add) * (100 + pct) / 100) + finalAdd) * (100 + finalPct) / 100;
            long result = (long)(((self.GetByKey(bas) + self.GetByKey(add)) * (100 + self.GetAsFloat(pct)) / 100f + self.GetByKey(finalAdd)) * (100 + self.GetAsFloat(finalPct)) / 100f);

            self.Insert(final, result, isPublicEvent);
        }
Example #4
0
        public static void Insert(this NumericComponent self, int numericType, long value, bool isPublicEvent = true)
        {
            long oldValue = self.GetByKey(numericType);

            if (oldValue == value)
            {
                return;
            }

            self.NumericDic[numericType] = value;

            if (numericType >= NumericType.Max)
            {
                self.Update(numericType, isPublicEvent);
                return;
            }

            if (isPublicEvent)
            {
                Game.EventSystem.Publish(self.DomainScene(),
                                         new EventType.NumbericChange()
                {
                    Unit = self.GetParent <Unit>(), New = value, Old = oldValue, NumericType = numericType
                });
            }
        }
Example #5
0
        public static void Insert(this NumericComponent self, int numericType, long value, bool isPublicEvent = true)
        {
            long oldValue = self.GetByKey(numericType);

            if (oldValue == value)
            {
                return;
            }

            self.NumericDic[numericType] = value;

            if (numericType >= NumericType.Max)
            {
                self.Update(numericType, isPublicEvent);
                return;
            }

            if (isPublicEvent)
            {
                EventType.NumbericChange args = EventType.NumbericChange.Instance;
                args.Parent      = self.Parent;
                args.NumericType = numericType;
                args.Old         = oldValue;
                args.New         = value;
                Game.EventSystem.PublishClass(args);
            }
        }
Example #6
0
 public static float GetAsFloat(this NumericComponent self, int numericType)
 {
     return((float)self.GetByKey(numericType) / 10000);
 }
Example #7
0
 public static long GetAsLong(this NumericComponent self, int numericType)
 {
     return(self.GetByKey(numericType));
 }
Example #8
0
 public static int GetAsInt(this NumericComponent self, int numericType)
 {
     return((int)self.GetByKey(numericType));
 }