Beispiel #1
0
        public static double GetValueAsDouble(this MapField <string, Value> mapField, string key, double?defaultValue = null)
        {
            if (!mapField.ContainsKey(key))
            {
                return(defaultValue.HasValue ? defaultValue.Value : default(double));
            }

            return(mapField[key].NumberValue);
        }
Beispiel #2
0
        public static string GetValueAsString(this MapField <string, Value> mapField, string key, string defaultValue = null)
        {
            if (!mapField.ContainsKey(key))
            {
                return(defaultValue != null ? defaultValue : null);
            }

            return(mapField[key].StringValue);
        }
Beispiel #3
0
        public static bool GetValueAsBool(this MapField <string, Value> mapField, string key, bool?defaultValue = null)
        {
            if (!mapField.ContainsKey(key))
            {
                return(defaultValue.HasValue ? defaultValue.Value : default(bool));
            }

            return(mapField[key].BoolValue);
        }
 protected override void ApplyMeta(MapField <uint, SerializedMetadata.Types.MetadataEntry> meta)
 {
     if (meta.ContainsKey(0))
     {
         TextMesh txt = transform.gameObject.GetComponent <TextMesh>();
         if (txt == null)
         {
             txt = (TextMesh)transform.gameObject.AddComponent(typeof(TextMesh));
         }
         txt.text = "USERNAME=" + meta[0].StringValue;
     }
 }
Beispiel #5
0
 public void AddField(MapField <string, Value> fields, String fieldName, String fieldValue)
 {
     if (fields.ContainsKey(fieldName))
     {
         fields[fieldName].StringValue = fieldValue;
     }
     else
     {
         Value strValue = new Value();
         strValue.StringValue = fieldValue;
         fields.Add(fieldName, strValue);
     }
 }
Beispiel #6
0
 public void AddField(MapField <string, Value> fields, String fieldName, long fieldValue)
 {
     if (fields.ContainsKey(fieldName))
     {
         fields[fieldName].IntegerValue = fieldValue;
     }
     else
     {
         Value value = new Value();
         value.IntegerValue = fieldValue;
         fields.Add(fieldName, value);
     }
 }
Beispiel #7
0
        /// <summary>
        /// login callback implement
        /// </summary>
        /// <param name="cookieFile">cookie file</param>
        /// <param name="paramaters">paramaters</param>
        public void OnLogin(string cookieFile, MapField <string, ByteString> paramaters)
        {
            if (paramaters == null || string.IsNullOrEmpty(cookieFile))
            {
                return;
            }
            if (paramaters.ContainsKey("user"))
            {
                BotUID = paramaters["user"].ToString(Encoding.ASCII);
            }
            Dictionary <string, string> cookieDics = new Dictionary <string, string>();

            cookieDics["schema"] = "token";
            if (paramaters.ContainsKey("token"))
            {
                cookieDics["secret"]  = JsonConvert.DeserializeObject <string>(paramaters["token"].ToString(Encoding.UTF8));
                cookieDics["expires"] = JsonConvert.DeserializeObject <string>(paramaters["expires"].ToString(Encoding.UTF8));
            }
            else
            {
                cookieDics["schema"] = "basic";
                cookieDics["secret"] = JsonConvert.DeserializeObject <string>(paramaters["token"].ToString(Encoding.UTF8));
            }
            //save token for upload operation
            token = cookieDics["secret"];
            try
            {
                using (FileStream stream = new FileStream(cookieFile, FileMode.Create, FileAccess.Write))
                    using (StreamWriter w = new StreamWriter(stream))
                    {
                        w.Write(JsonConvert.SerializeObject(cookieDics));
                    }
            }
            catch (Exception e)
            {
                Log("On Login", $"Failed to save authentication cookie:{e}");
            }
        }
 protected override void ApplyMeta(MapField <uint, SerializedMetadata.Types.MetadataEntry> meta)
 {
     if (meta.ContainsKey(0xBA))
     {
         // Debug.Log("GOT ITEM META");
         SerializedMetadata.Types.MetadataEntry ent = null;
         meta.TryGetValue(0xBA, out ent);
         if (ent == null)
         {
             return;
         }
         Debug.Log("GOT ITEM META -- not null");
         MapField <uint, SerializedMetadata.Types.MetadataEntry> item = ent.MetaValue.Entries;
         int item_id   = item[0].Int32Value;
         int item_meta = item[1].Int32Value;
         // int item_count = item[2].Int32Value;
         MeshRenderer renderer = GetComponentInChildren <MeshRenderer>();
         Material     mat      = new Material(itemMaterial);
         mat.mainTexture   = Inventory.getItemTexture(item_id);
         renderer.material = mat;
     }
 }
Beispiel #9
0
    protected override void ApplyMeta(MapField <uint, SerializedMetadata.Types.MetadataEntry> meta)
    {
        if (meta.ContainsKey(0xBA))
        {
            // Debug.Log("GOT ITEM META");
            SerializedMetadata.Types.MetadataEntry ent = null;
            meta.TryGetValue(0xBA, out ent);
            if (ent == null)
            {
                return;
            }
            Debug.Log("GOT ITEM META -- not null");
            MapField <uint, SerializedMetadata.Types.MetadataEntry> item = ent.MetaValue.Entries;
            int item_id = item[0].Int32Value;
            // int item_count = item[1].Int32Value;

            Transform cube = transform.Find("Cube");
            if (item_id < Block.prototypes.Length && Block.prototypes[item_id] != null)
            {
                MeshRenderer renderer = cube.GetComponent <MeshRenderer>();
                Material     mat      = new Material(itemMaterial);
                mat.mainTexture   = Inventory.getItemTexture(item_id);
                renderer.material = mat;
                cube.gameObject.SetActive(true);
            }
            else
            {
                cube.gameObject.SetActive(false);
                Transform model = transform.Find("Model");
                if (model != null)
                {
                    DestroyImmediate(model.gameObject);
                    GameObject prefab = (GameObject)Resources.Load("Entities/Items/" + item_id);
                    GameObject.Instantiate(prefab, transform, false);
                }
            }
        }
    }
Beispiel #10
0
        /// <summary>
        /// 按照礼包ID去检查触发
        /// </summary>
        /// <param name="mallId">礼包ID</param>
        /// <returns></returns>
        public bool CheckTrigger(int mallId)
        {
            TriggerGiftRulePB rule = null;

            foreach (var rulePb in _triggerGiftsRule)
            {
                if (rulePb.MallId == mallId)
                {
                    rule = rulePb;
                    break;
                }
            }

            if (rule == null)
            {
                return(false);
            }

            if (_triggerMap != null && _triggerMap.ContainsKey(mallId))
            {
                if (_triggerMap[mallId] >= rule.TriggerLimit)
                {
                    return(false);
                }
            }

            if (mallId == 7007 || mallId == 7008 || mallId == 7009)
            {
                return(CheckTrigger7007_7009(mallId));
            }

            if (mallId >= 7010)
            {
                return(true);
            }


            List <bool> orList = new List <bool>();

            //rule.TriggerGoalLists 数组元素满足逻辑与
            foreach (var goal in rule.TriggerGoalLists)
            {
                List <bool> andList = new List <bool>();
                //goal.TriggerGoal 数组元素满足逻辑或
                foreach (var trigger in goal.TriggerGoal)
                {
                    bool isGreater = trigger.LssOrGtr == 0;
                    bool result2   = false;

                    switch (trigger.TriggerGoalType)
                    {
                    case TriggerGoalTypePB.DrawCredit:
                        break;

                    case TriggerGoalTypePB.ExpendPower:
                        result2 = CompareValue(isGreater, EnergyUsed, trigger.Finish);
                        break;

                    case TriggerGoalTypePB.CurrentOwer:
                        result2 = CompareValue(isGreater, GlobalData.PlayerModel.PlayerVo.Energy, trigger.Finish);
                        break;

                    case TriggerGoalTypePB.CardMemoriesNum:
                        result2 = CompareValue(isGreater, RecollectionTimes, trigger.Finish);
                        break;

                    case TriggerGoalTypePB.ResetCardMemoriesNum:
                        result2 = CompareValue(isGreater, RecollectionResetTimes, trigger.Finish);
                        break;

                    case TriggerGoalTypePB.StarCardDrawNum:
                        result2 = CompareValue(isGreater, GemDrawCardTimes, trigger.Finish);
                        break;

                    case TriggerGoalTypePB.GemCredit:
                        result2 = CompareValue(isGreater,
                                               GlobalData.PropModel.GetUserProp(PropConst.DrawCardByGem).Num, trigger.Finish);
                        break;

                    case TriggerGoalTypePB.GoldDrawNum:
                        result2 = CompareValue(isGreater, GoldDrawCardTimes, trigger.Finish);
                        break;

                    case TriggerGoalTypePB.GoldNum:
                        result2 = CompareValue(isGreater, (int)GlobalData.PlayerModel.PlayerVo.Gold,
                                               trigger.Finish);
                        break;

                    case TriggerGoalTypePB.DepartmentLevel:
                        result2 = CompareValue(isGreater, (int)GlobalData.PlayerModel.PlayerVo.Level,
                                               trigger.Finish);
                        break;
                    }

                    andList.Add(result2);
                }

                bool result1 = true;
                foreach (var andVal in andList)
                {
                    if (andVal == false)
                    {
                        result1 = false;
                        break;
                    }
                }

                orList.Add(result1);
            }

            bool result = false;

            foreach (var orVal in orList)
            {
                if (orVal)
                {
                    result = true;
                    break;
                }
            }

            return(result);
        }
 public bool ContainsKey(K key)
 {
     return(original.ContainsKey(key));
 }
 public bool ContainsKey(TKey key)
 {
     return(_internal.ContainsKey(key));
 }