Ejemplo n.º 1
0
    void _OnSelectedFoodChanged(EventArgs args)
    {
        EventArgs_FoodType selectedFoodArgs = args as EventArgs_FoodType;

        if (selectedFoodArgs != null)
        {
            _selFoodBtn = _GetFootBtn(selectedFoodArgs.eFoodType);
        }
        else
        {
            Debug.LogErrorFormat("Error: BagManager::OnSelectedFoodChanged args type is {0}", args.GetType().ToString());
        }
    }
Ejemplo n.º 2
0
    void _OnFoodItemCooldownComplete(EventArgs args)
    {
        EventArgs_FoodType foodTypeArgs = args as EventArgs_FoodType;

        if (foodTypeArgs != null)
        {
            FoodItemView btn = _GetFootBtn(foodTypeArgs.eFoodType);
            if (btn != null)
            {
                btn.ItemData.Count = _initDict[foodTypeArgs.eFoodType];
            }
        }
        else
        {
            Debug.LogErrorFormat("Error: _OnFoodItemCooldownComplete args type is {0}", args.GetType().ToString());
        }
    }
    void _OnSelectedFoodChanged(EventArgs args)
    {
        EventArgs_FoodType selectedFoodArgs = args as EventArgs_FoodType;

        if (selectedFoodArgs != null)
        {
            _eSelFoodType = selectedFoodArgs.eFoodType;
            string     path   = FoodItem.GetPrefabPath(_eSelFoodType);
            GameObject prefab = Resources.Load <GameObject>(path);
            if (prefab != null)
            {
                if (_foodModel != null)
                {
                    // 如果之前的食物还没扔出去,就删除掉,再重新创建一个
                    Projectile p = _foodModel.GetComponent <Projectile>();
                    if (!p.Move)
                    {
                        Destroy(_foodModel);
                        _foodModel = null;
                    }
                }
                _foodModel = Instantiate(prefab);
                Vector3 originPos = _foodModel.transform.localPosition;
                _foodModel.transform.parent        = transform;
                _foodModel.transform.localPosition = originPos;
                _projectile = _foodModel.GetComponent <Projectile>();
            }
            else
            {
                Debug.LogErrorFormat("Can NOT Load object in path: {0}", path);
            }
        }
        else
        {
            Debug.LogErrorFormat("Error: FoodModel::OnSelectedFoodChanged args type is {0}", args.GetType().ToString());
        }
    }