Exemplo n.º 1
0
    private void ThrowFood()
    {
        if (_vegetableCarried != null)
        {
            _vegetableCarried = null;

            _playerCanvas.DisableFeedback();
        }
    }
Exemplo n.º 2
0
    private void GiveFood()
    {
        if (_vegetableCarried != null)
        {
            if (_childInRange.GiveFood(_vegetableCarried) == true)
            {
                _vegetableCarried = null;

                _playerCanvas.DisableFeedback();
            }
        }
    }
Exemplo n.º 3
0
    private void TakeFood(FoodSlotController foodSlot)
    {
        if (_vegetableCarried == null)
        {
            VegetableConfig vegetableConfig = foodSlot.Take();

            if (vegetableConfig != null)
            {
                _vegetableCarried = vegetableConfig;

                _playerCanvas.EnableFeedback("Food/food_" + vegetableConfig.name.ToLower(), true);
            }
        }
    }
Exemplo n.º 4
0
        public static VegetableConfig ParseVegetable(JSON json)
        {
            VegetableConfig config = new VegetableConfig(
                json.ToUInt(VEGETABLE_ID_CRC),
                json.ToString(VEGETABLE_ID),
                json.ToString(NAME),
                json.ToString(DIFFICULTY),
                json.ToFloat(TIME_TO_INCIDENT),
                json.ToFloat(TIME_TO_EAT),
                json.ToInt(POINTS)
                );

            return(config);
        }
Exemplo n.º 5
0
        public static Dictionary <uint, VegetableConfig> ParseVegetables(JSON json)
        {
            Dictionary <uint, VegetableConfig> vegetables = new Dictionary <uint, VegetableConfig>();
            List <JSON> vegetableConfigJSONs = json.ToJSONList(ROOT);
            int         vegetableCount       = vegetableConfigJSONs.Count;

            for (int i = 0; i < vegetableCount; ++i)
            {
                VegetableConfig vegetableConfig = ParseVegetable(vegetableConfigJSONs[i]);
                vegetables.Add(vegetableConfig.id, vegetableConfig);
            }

            return(vegetables);
        }
Exemplo n.º 6
0
    private void EndMeal()
    {
        if (m_currentVegetable != null)
        {
            _playerManager.UpdateScore(m_currentVegetable.points, true);

            m_isEating         = false;
            m_currentVegetable = null;
            m_Slider.value     = 0;
            m_timer            = 0;
            m_waiting_timer    = 0;

            _childCanvas.DisableFeedback();
        }
    }
Exemplo n.º 7
0
    // Give vegetable to a kid
    // If he is currently in an incident, he doesn't start to eat
    public bool GiveFood(VegetableConfig vegetable)
    {
        Debug.Log("Give Food : " + vegetable.name);

        if (m_isOutOfTable == true)
        {
            return(false);
        }

        if (m_currentIncident == null)
        {
            m_isEating         = true;
            m_elapsedTime      = 0f;
            m_currentVegetable = vegetable;
            _childCanvas.EnableSlider(true);
            _childCanvas.EnableFeedback("Food/food_" + m_currentVegetable.name.ToLower(), true, true);
        }

        return(m_currentIncident == null);
    }
Exemplo n.º 8
0
        public VegetableConfig Refill()
        {
            int rand  = Random.Range(0, GameManager.instance.vegetableIdToConfig.Keys.Count);
            int count = 0;

            foreach (KeyValuePair <uint, VegetableConfig> pair in GameManager.instance.vegetableIdToConfig)
            {
                if (rand == count)
                {
                    _isAvailable     = true;
                    _vegetableConfig = pair.Value;

                    _foodImage.sprite  = Resources.Load <Sprite>("Images/Food/food_" + _vegetableConfig.name.Replace(" ", "").ToLower());
                    _foodImage.enabled = true;

                    break;
                }

                count++;
            }

            return(_vegetableConfig);
        }
Exemplo n.º 9
0
        //在联网前,读取Read本地缓存文件,如果没有文件,hashcode为"",第一行是hashcode
        //加载Load hashcode,数据,到内存
        //登录,比较新hashcode,相同则跳过;不同,则申请新的hashcode
        //申请的结果和运行时动态更新都是收到服务端的ResponseTextConfig,加载hashcode,数据,到内存,组装新文件替换缓存

        /// <summary>
        /// 从硬盘读取bytes加载到内存。每次刚运行时调用
        /// </summary>
        public static void ReadCacheAndLoadAllLargeConfigs()
        {
            for (int i = 0; i < Configs.Length; i++)
            {
                var configType = (ConfigType)i;

                var    path  = GetFilePath(configType);
                byte[] bytes = null;
                if (File.Exists(path))
                {
                    try
                    {
                        //bytes = File.ReadAllBytes(path);
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                }
                if (bytes != null)
                {
                    IReceiveable configCmd = null;
                    switch (configType)
                    {
                    case ConfigType.CoreConfig:
                        configCmd = new CoreConfig();
                        break;

                    case ConfigType.RechargeConfig:
                        configCmd = new RechargeConfig();
                        break;

                    case ConfigType.SkillConfig:
                        configCmd = new SkillConfig();
                        break;

                    case ConfigType.SkillParameterConfig:
                        configCmd = new SkillParameterConfig();
                        break;

                    case ConfigType.ExchangeConfig:
                        configCmd = new ExchangeConfig();
                        break;

                    case ConfigType.VegetableConfig:
                        configCmd = new VegetableConfig();
                        break;

                    case ConfigType.ChallengeLevelConfig:
                        configCmd = new ChallengeLevelConfig();
                        break;

                    case ConfigType.SkillIntroTextConfig:
                        configCmd = new SkillIntroTextConfig();
                        break;

                    case ConfigType.SkillLevelDetailTextConfig:
                        configCmd = new SkillLevelDetailTextConfig();
                        break;

                    case ConfigType.VegetableIntroTextConfig:
                        configCmd = new VegetableIntroTextConfig();
                        break;

                    case ConfigType.WaitHintTextConfig:
                        configCmd = new WaitHintTextConfig();
                        break;

                    case ConfigType.CharacterConfig:
                        configCmd = new CharacterConfig();
                        break;

                    case ConfigType.EquipConfig:
                        configCmd = new EquipConfig();
                        break;

                    case ConfigType.MajorLevelIntroTextConfig:
                        configCmd = new MajorLevelIntroTextConfig();
                        break;

                    case ConfigType.EquipIntroTextConfig:
                        configCmd = new EquipIntroTextConfig();
                        break;

                    case ConfigType.CharacterIntroTextConfig:
                        configCmd = new CharacterIntroTextConfig();
                        break;

                    case ConfigType.OAuthParamConfig:
                        configCmd = new OAuthParamConfig();
                        break;

                    default:
                        Debug.LogError("遇到新的ConfigType,需添加代码。type:" + configType);
                        break;
                    }
                    if (configCmd != null)
                    {
                        configCmd.ParseFrom(bytes);
                        SetConfig(configType, configCmd);
                    }
                }
            }
        }