Please enable Javascript to view the contents

耕作與作物MOD

 ·  ☕ 5 分钟  ·  👩🏿‍🚀 伊琉沙 AKA 哇咔咔

最後更新:2020/04/29

作物MOD資料庫

  • 作物資料檔:CropData.text
  • 作物資料類:CCropData
    • 作物資料結構:SCropData
      • 作物ID:mCropId
      • 名稱ID:mNameId
      • 收穫次數:mHarvestCount
      • 成長階數:mStep
      • 減少階數:mReduceStep
      • 收成天數:mHarvestDays
      • 生長季節:mSeason
        • 0為春季生長、1為夏季生長、2為秋季生長、3為冬季生長、-1為四季皆生長。
      • 是否收割:mCanReap
      • 圖集ID:mAtlasId
      • 圖片ID:mSpriteId
      • 物品ID:mItemId
      • 種子ID:mSeedItemId
  • 作物主模板類:CropMasterModel
    • 作物ID:CropMasterModel.CropId = CCropData.SCropData.mCropId
    • 收穫次數:CropMasterModel.HarvestCount = CCropData.SCropData.mHarvestCount
    • 成長階數:CropMasterModel.Step = CCropData.SCropData.mStep
    • 減少階數:CropMasterModel.ReduceStep = CCropData.SCropData.mReduceStep
    • 收成天數:CropMasterModel.HarvestDays = CCropData.SCropData.mHarvestDays
    • 生長季節:CropMasterModel.Season = CCropData.SCropData.mSeason
    • 是否收割:CropMasterModel.CanReap = CCropData.SCropData.mCanReap
  • 作物模板類CropModel,土裡作物的實例。
    • 成長方法:CropModel.Grow()
    • 減少成長方法:CropModel.GrowStep()
    • 成長值:CropModel.Growth
    • 品質分:CropModel.Quality
  • 作物定義類:Crop
    • 最低品質分:MIN_QUALITY,常數值:1

    • 最高品質分:Crop.MAX_QUALITY,常數值:500

    • 品質轉換率:Crop.QUALITY_CONVERSION_RATE,常數值:50

    • 播種方法:GroundModel.SowSeed(int crop_id, int item_quality)

    • 莊稼:GroundModel.mCrop

    • 作物模板類:CropModel

    • 作物品質分:CropModel.mQuality

    • 作物品質等級:CropModel.Quality

    • 作物最低品質分:Crop.MIN_QUALITY

    • 作物最高品質分:Crop.MAX_QUALITY

耕作界面

整地指令類

  • GroundFlattenCommand @020001D0

耕地指令類

  • GroundCultivateCommand @020001CE

播種指令類

GroundSowSeedCommand @020001DA

施肥指令類

GroundFertilizeCommand @020001CF

澆水指令類

  • GroundWetCommand @020001DC

成長指令類

GroundGrowCommand @020001D4

割草指令類

GroundMowCropCommand @020001D7

收割指令類

GroundReapCropCommand @020001D9

收成指令類

GroundHarvestCropCommand @020001D5

農地模板類

  • 農地模板類:GroundModel @02000567

澆水方法

1
2
3
4
5
6
7
8
9
public void Wet()
{
	if (this.IsWet || !this.HasCrop)
	{
		return;
	}
	this.mType = Ground.TypeEnum.Wet;
	this.Crop.Grow();
}

播種方法

1
2
3
4
5
6
7
8
9
public void SowSeed(int crop_id, int item_quality)
{
    if (this.HasCrop || this.Type != Ground.TypeEnum.Cultivated)
    {
        return;
    }
    int quality = (item_quality - 2) * Define.Crop.QUALITY_CONVERSION_RATE;
    this.mCrop = new CropModel(crop_id, quality);
}

施肥方法

1
2
3
4
5
6
7
8
9
public void Fertilize(int item_id)
{
	if (this.IsFertilized || !this.HasCrop)
	{
		return;
	}
	this.mFertilizerId = item_id;
	this.Crop.Upgrade(item_id);
}

收成方法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public void HarvestCrop()
{
    if (this.HasCrop && this.Crop.CanRepeat)
    {
        this.Crop.ReduceGrowth();
    }
    else
    {
        this.mCrop = null;
    }
    this.mType = Ground.TypeEnum.Cultivated;
    this.mFertilizerId = -1;
}

收割方法

1
2
3
4
5
6
7
8
9
public void MowCrop()
{
    if (this.HasCrop)
    {
        this.mCrop = null;
    }
    this.mType = Ground.TypeEnum.Cultivated;
    this.mFertilizerId = -1;
}

作物主模板類

  • 作物主模板類:CropMasterModel @02000583
    • 收成天數:CropMasterModel.HarvestDays : int @17000909
    • 成長階數:CropMasterModel.Step : int @17000907
    • 減少階數:CropMasterModel.ReduceStep : int @17000908

作物模板類

作物模板

1
2
3
4
5
public CropModel(int id, int quality)
{
    this.mId = id;
    this.mQuality = Mathf.Clamp(quality, Crop.MIN_QUALITY, Crop.MAX_QUALITY);
}

成長值

1
2
3
4
5
6
7
8
private int mGrowth;
public int Growth
{
    get
    {
        return this.mGrowth;
    }
}

品質等級

1
2
3
4
5
6
7
public int Quality
{
    get
    {
        return (this.mQuality != Crop.MAX_QUALITY) ? (this.mQuality / Crop.QUALITY_CONVERSION_RATE + 1) : Item.MAX_QUALITY;
    }
}

能否收成判斷方法

1
2
3
4
5
6
7
public bool CanHarvest
{
	get
	{
		return !this.IsWithered && this.mGrowth == this.Master.HarvestDays;
	}
}

成長方法

1
2
3
4
5
6
7
public void Grow()
{
	if (!this.CanHarvest && !this.IsWithered)
	{
		this.mGrowth++;
	}
}

成長減少方法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
public void ReduceGrowth()
{
    if (!this.CanRepeat && !this.IsWithered)
    {
        return;
    }
    int num2;
    int num = Math.DivRem(this.Master.HarvestDays, this.Master.Step - 1, out num2);
    num2 = ((num2 <= this.Master.ReduceStep) ? num2 : this.Master.ReduceStep);
    int num3 = num * this.Master.ReduceStep + num2;
    this.mGrowth -= num3;
    this.mQuality -= Mathf.CeilToInt(Crop.GetUpgradeValue(Item.ID_HIGH_QUALITY_FERTILIZER) / (float)this.Master.HarvestDays) * num3;
    if (this.mQuality < Crop.MIN_QUALITY)
    {
        this.mQuality = Crop.MIN_QUALITY;
    }
    this.mRepeatCount++;
}

成長進階方法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
public void GrowStep()
{
	if (this.CanHarvest || this.IsWithered)
	{
		return;
	}
	int num2;
	int num = Math.DivRem(this.Master.HarvestDays, this.Master.Step - 1, out num2);
	int num3 = (this.Master.Step - 1 - num2) * num;
	if (this.mGrowth < num3)
	{
		this.mGrowth += num;
	}
	else
	{
		this.mGrowth += num + 1;
	}
	if (this.mGrowth > this.Master.HarvestDays)
	{
		this.mGrowth = this.Master.HarvestDays;
	}
}

品質提升方法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
public void Upgrade(int item_id)
{
    if (this.CanHarvest || this.IsWithered)
    {
        return;
    }
    this.mQuality += Mathf.CeilToInt(Crop.GetUpgradeValue(item_id) / (float)this.Master.HarvestDays);
    if (this.mQuality > Crop.MAX_QUALITY)
    {
        this.mQuality = Crop.MAX_QUALITY;
    }
}

品質分

1
private int mQuality;

定義

作物類

最小品質分

1
public static readonly int MIN_QUALITY = 1;

最大品質分

1
public static readonly int MAX_QUALITY = 500;

品質轉換率

1
public static readonly int QUALITY_CONVERSION_RATE = Crop.MAX_QUALITY / Item.MAX_QUALITY;

施肥品質提升表

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
private static readonly Dictionary<int, float> UpgradeValueTable = new Dictionary<int, float>
{
    {
        Item.ID_FERTILIZER,
        100f
    },
    {
        Item.ID_HIGH_QUALITY_FERTILIZER,
        200f
    }
};
分享

伊琉沙 AKA 哇咔咔
作者
伊琉沙 AKA 哇咔咔
遊戲開發者 / 密室機關師