Esempio n. 1
0
    // 冷却时间(s)
    public static int GetCDTime(eFoodType eType)
    {
        int cd = 30;

        switch (eType)
        {
        case eFoodType.banana:
            cd = 30;
            break;

        case eFoodType.bone:
            cd = 30;
            break;

        case eFoodType.fish:
            cd = 30;
            break;

        case eFoodType.meat:
            cd = 30;
            break;

        case eFoodType.radish:
            cd = 30;
            break;

        case eFoodType.vegetable:
            cd = 30;
            break;

        default:
            break;
        }
        return(cd);
    }
Esempio n. 2
0
    public void SetItemData(eFoodType type, int num)
    {
        if (_item != null)
        {
            _item.CountChangeEvent -= OnCountChangeEvent;
            _item = null;
        }

        _item = new FoodItem(type, num);
        string path = FoodItem.GetSpritePath(_item.Type);
        Sprite s    = Resources.Load <Sprite>(path);

        if (s != null)
        {
            _image.sprite = s;
        }
        else
        {
            Debug.LogError(string.Format("Sprite \"{0}\" is NOT exist !!!", FoodItem.GetSpritePath(_item.Type)));
        }
        _text.text              = _item.Count.ToString();
        _item.CountChangeEvent += OnCountChangeEvent;

        _maskImg.fillAmount = 0f;
    }
Esempio n. 3
0
    // 难度系数
    public static int GetDifficulty(eFoodType eType)
    {
        int d = 3;

        switch (eType)
        {
        case eFoodType.banana:
            d = 3;
            break;

        case eFoodType.bone:
            d = 1;
            break;

        case eFoodType.fish:
            d = 2;
            break;

        case eFoodType.meat:
            d = 5;
            break;

        case eFoodType.radish:
            d = 2;
            break;

        case eFoodType.vegetable:
            d = 4;
            break;

        default:
            break;
        }
        return(d);
    }
Esempio n. 4
0
    FoodItemView _GetFootBtn(eFoodType eType)
    {
        FoodItemView btn = null;

        if (_btnList == null || _btnList.Count <= 0)
        {
            return(btn);
        }

        for (int i = 0; i < _btnList.Count; ++i)
        {
            if (eType == _btnList[i].ItemData.Type)
            {
                btn = _btnList[i];
                break;
            }
        }
        return(btn);
    }
    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());
        }
    }
Esempio n. 6
0
 public bool IsFoodSuitable(eFoodType eFood)
 {
     return(_foodsList.Contains(eFood));
 }
Esempio n. 7
0
 public void ChangeFoodAmountOnTile(eFoodType foodType, float delta)
 {
     _foodTable[foodType] += delta;
 }
Esempio n. 8
0
 public void SetFoodAmountOnTile(eFoodType foodType, float newValue)
 {
     _foodTable[foodType] = newValue;
 }
Esempio n. 9
0
 public float GetFoodAmountOnTile(eFoodType foodType)
 {
     return(_foodTable[foodType]);
 }
Esempio n. 10
0
 /// <summary>
 /// 计算得分。目前先将食物和动物的难度系数相加。
 /// </summary>
 /// <param name="food"></param>
 /// <param name="power"></param>
 /// <returns></returns>
 int _CalculateScore(eFoodType food, float power)
 {
     return(FoodItem.GetDifficulty(food) + _animal.difficulty);
 }
Esempio n. 11
0
 public static string GetPrefabPath(eFoodType eType)
 {
     //TODO:
     //return "Prefabs/" + eType.ToString() + "Prefab";
     return("Prefabs/FoodsModel/ball");
 }
Esempio n. 12
0
 public static string GetSpritePath(eFoodType eType)
 {
     return("Texture/Foods/" + eType.ToString());
 }
Esempio n. 13
0
 public FoodItem(eFoodType eType, int num)
 {
     _type  = eType;
     _count = num;
 }
Esempio n. 14
0
 public EventArgs_ThrowFinish(eFoodType t, float f)
 {
     eventType = Events.GameEvent.ThrowFoodFinish;
     eType     = t;
     fPower    = f;
 }
Esempio n. 15
0
 public EventArgs_FoodType(string type, eFoodType eType) : base(type)
 {
     eFoodType = eType;
 }