Beispiel #1
0
    // 执行收获逻辑
    private void DoHarvest(long buildingID, int value)
    {
        ProduceBuildingInfo info = GetBuilding(buildingID) as ProduceBuildingInfo;

        if (info == null)
        {
            return;
        }

        // 实际增加资产
        switch (info.BuildingType)
        {
        case CityBuildingType.HOUSE:
            UserManager.Instance.Money += value;
            UIUtil.AddFloatingMsg(Str.Get("UI_CITY_BUILDING_MONEY") + "+" + value.ToString());
            break;

        case CityBuildingType.WOOD:
            UserManager.Instance.Wood += value;
            UIUtil.AddFloatingMsg(Str.Get("UI_CITY_BUILDING_WOOD") + "+" + value.ToString());
            break;

        case CityBuildingType.STONE:
            UserManager.Instance.Stone += value;
            UIUtil.AddFloatingMsg(Str.Get("UI_CITY_BUILDING_STONE") + "+" + value.ToString());
            break;
        }

        // 收获完清理建筑的产值
        info.ClearProduceValue();
    }
Beispiel #2
0
 private void AddFloatingMsg(string text, float value, float delayTime)
 {
     if (value > 0)
     {
         UIUtil.AddFloatingMsg(text + " +" + value, Color.green, delayTime);
     }
     else
     {
         UIUtil.AddFloatingMsg(text + " -" + Mathf.Abs(value), Color.red, delayTime);
     }
 }