Пример #1
0
        private Resource GetByFixedValue(Resource res, int p)
        {
            bool   bv = false;
            int    iv = 0;
            string sv = null;

            if (p == 0)
            {
                GameManager.DebugLog("Eror - Invalid fixed value on Target resource");
            }

            if (p == 1)
            {
                bv = bool_mod;
                iv = number_mod;
                sv = text_mod;
            }

            if (p == 2)
            {
                bv = bool_mod2;
                iv = number_mod2;
                sv = text_mod2;
            }

            Resource return_resource = null;

            if (res is ResourceAction)
            {
                GameManager.DebugLog("Modifying a Resource Action is not currently supported");
                return(null);
            }
            else if (res is ResourceBool)
            {
                return_resource = new ResourceBool();
                (return_resource as ResourceBool).Value = bv;
            }
            else if (res is ResourceNumber)
            {
                return_resource = new ResourceNumber();
                (return_resource as ResourceNumber).Value = iv;
            }
            else if (res is ResourceText)
            {
                return_resource = new ResourceText();
                (return_resource as ResourceText).Value = sv;
            }

            return(return_resource);
        }
Пример #2
0
        private bool ModifyNumber(ResourceNumber target, ResourceNumber op1, ModifyOperation operation)
        {
            switch (operation)
            {
            case ModifyOperation.Divide:    target.Value /= op1.Value; return(true);

            case ModifyOperation.Multiply:  target.Value *= op1.Value; return(true);

            case ModifyOperation.Set:               target.Value = op1.Value; return(true);

            case ModifyOperation.Subtract:  target.Value -= op1.Value; return(true);

            case ModifyOperation.Sum:               target.Value += op1.Value; return(true);
            }

            return(false);
        }
        private bool CompareNumber(ResourceNumber target, ResourceNumber op1, CompareOperation operation)
        {
            //GameManager.DebugLog("Comparing: " + target.Value + " " + operation + " " + op1.Value);
            //GameManager.DebugLog((target.Value >= op1.Value).ToString());

            switch (operation)
            {
            case CompareOperation.Equals:                   return(target.Value == op1.Value);

            case CompareOperation.Larger:                   return(target.Value > op1.Value);

            case CompareOperation.LargerOrEqual:    return(target.Value >= op1.Value);

            case CompareOperation.Smaller:                  return(target.Value < op1.Value);

            case CompareOperation.SmallerOrEqual:   return(target.Value <= op1.Value);
            }

            return(false);
        }