mill implemented

This commit is contained in:
Adam Salah 2025-06-30 03:41:44 -04:00
parent 921449fc1d
commit a1d79f326c
10 changed files with 216 additions and 48 deletions

View File

@ -12,8 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a92d696df7037b44585aaac56ec9ed98, type: 3}
m_Name: Mill
m_EditorClassIdentifier:
_wood: 80
_wood: 10
_rock: 0
_food: 0
_cooldownInSeconds: 30
_cooldownInSeconds: 1
_tooltipString:

View File

@ -11,7 +11,7 @@ GameObject:
- component: {fileID: 7635908653065262707}
- component: {fileID: 4893380182456950857}
- component: {fileID: 5051996996752872273}
- component: {fileID: 1038659306882990067}
- component: {fileID: 6061630371781146510}
- component: {fileID: 1045236105932526234}
m_Layer: 0
m_Name: Mill
@ -84,7 +84,7 @@ Rigidbody2D:
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!114 &1038659306882990067
--- !u!114 &6061630371781146510
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -93,14 +93,17 @@ MonoBehaviour:
m_GameObject: {fileID: 1038659306882990064}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2c66f72e2c09df040a9196ed782233d6, type: 3}
m_Script: {fileID: 11500000, guid: 59a743c16ad953c4192f59706be0c243, type: 3}
m_Name:
m_EditorClassIdentifier:
_lifeBar: {fileID: 4795252161776368380}
_hp: 10
_hp: 0
_speed: 0
_attack_damage: 0
_attack_interval: 0
_enemy: {fileID: 0}
_range: 2
_multiplier: 1.15
--- !u!114 &1045236105932526234
MonoBehaviour:
m_ObjectHideFlags: 0
@ -229,6 +232,78 @@ Transform:
m_Father: {fileID: 5939671854127199056}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5799165302180276253
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6770826418803405524}
- component: {fileID: 4877144423808268021}
- component: {fileID: 2468754937282593442}
m_Layer: 6
m_Name: range_outline
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6770826418803405524
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5799165302180276253}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5939671854127199056}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &4877144423808268021
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5799165302180276253}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 3.26, y: 4.88}
newSize: {x: 3.26, y: 4.88}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 5, y: 5}
m_EdgeRadius: 0
--- !u!114 &2468754937282593442
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5799165302180276253}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 531d7966d86bd0c4d83baf58bcb56cd5, type: 3}
m_Name:
m_EditorClassIdentifier:
_entityLinked: {fileID: 6061630371781146510}
--- !u!1 &6453988705367329854
GameObject:
m_ObjectHideFlags: 0
@ -260,6 +335,7 @@ Transform:
m_Children:
- {fileID: 1371331379827620356}
- {fileID: 4768125905524963531}
- {fileID: 6770826418803405524}
m_Father: {fileID: 7635908653065262707}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -3179,11 +3179,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3191,7 +3191,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -5
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1144883118211503064, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
@ -3243,11 +3243,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1740692696410812620, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1740692696410812620, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1740692696410812620, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3255,7 +3255,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1740692696410812620, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -47.711605
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2335911515764278902, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
@ -3423,11 +3423,11 @@ PrefabInstance:
objectReference: {fileID: 11400000, guid: 0334115ab72f6d5449497db1bb50377e, type: 2}
- target: {fileID: 4453469705328566160, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453469705328566160, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453469705328566160, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3435,15 +3435,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4453469705328566160, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -6.0372024
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4457185042551965567, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4457185042551965567, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4457185042551965567, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3451,7 +3451,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4457185042551965567, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -26.874405
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4817988606444742093, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_Name
@ -3559,11 +3559,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5139721980499987197, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5139721980499987197, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5139721980499987197, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3571,15 +3571,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5139721980499987197, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -47.711605
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5316389173819650276, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5316389173819650276, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5316389173819650276, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3587,15 +3587,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5316389173819650276, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -26.874405
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5319145879937787915, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5319145879937787915, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5319145879937787915, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3603,7 +3603,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5319145879937787915, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -6.0372024
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5639720393060989426, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
@ -3639,11 +3639,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5639720394252960041, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5639720394252960041, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5639720394252960041, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3651,7 +3651,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5639720394252960041, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -103.3
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5639720394327989355, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5639720394327989356, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
@ -3669,13 +3673,17 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: -299.90002
objectReference: {fileID: 0}
- target: {fileID: 6044811384361869332, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
- target: {fileID: 6044811384361869331, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6044811384361869332, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6044811384361869332, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6044811384361869332, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3683,7 +3691,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 6044811384361869332, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -201.6
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6772290102801599907, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: _unitCardInformation
@ -3691,11 +3699,11 @@ PrefabInstance:
objectReference: {fileID: 11400000, guid: f4dcf11b827a5ca49a70b5db1e72e16e, type: 2}
- target: {fileID: 7106892479276285262, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7106892479276285262, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7106892479276285262, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3703,15 +3711,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7106892479276285262, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -26.874405
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7112938881271752097, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7112938881271752097, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7112938881271752097, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3719,15 +3727,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7112938881271752097, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -6.0372024
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7797049475554395991, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7797049475554395991, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7797049475554395991, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.x
@ -3735,7 +3743,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7797049475554395991, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -47.711605
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8434244524890535526, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
propertyPath: _unitCardInformation

View File

@ -1,6 +1,6 @@
public class House : Building
{
public float PopulationGiven => GlobalConfig.Instance.Current.populationGivenPerHouse;
public virtual float PopulationGiven => GlobalConfig.Instance.Current.populationGivenPerHouse;
public override void LevelStart()
{
ResourceManager.Instance.MaximumPopulation += PopulationGiven;

View File

@ -0,0 +1,6 @@
using UnityEngine;
public class Mill : ProductionBuilding
{
protected override Enum.ResourceNodeType RessourceNodeType { get { return Enum.ResourceNodeType.BerryBush; } }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 59a743c16ad953c4192f59706be0c243
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,45 @@
using UnityEngine;
public abstract class ProductionBuilding : House
{
[SerializeField]
private int _range;
[SerializeField]
private float _multiplier;
public override float PopulationGiven => GlobalConfig.Instance.Current.populationGivenPerHouseUpgrade;
protected abstract Enum.ResourceNodeType RessourceNodeType { get; }
private Vector3 _position;
public override void Start()
{
base.Start();
_position = Position;
ApplyMultiplier(_multiplier);
}
public override void LevelDestroy()
{
ApplyMultiplier(1 / _multiplier);
base.LevelDestroy();
}
private void ApplyMultiplier(float multiplier)
{
for (int i = -_range; i <= _range; i++)
{
for (int j = -_range; j <= _range; j++)
{
Vector3 checkPosition = new Vector3(_position.x + i, _position.y + j, _position.z);
var tile = LevelManager.Instance.Get<ResourceTile>(t => t.Position == checkPosition);
if (tile == default) continue;
var checkResourceType = tile.ResourceNodeType;
if (checkResourceType != RessourceNodeType) continue;
tile.YieldSpeedMultiplier *= multiplier;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a8e2553295ecbca42b071a2eea2ed22d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -29,6 +29,7 @@ public class GlobalConfigFile : ScriptableObject
[Header("Population")]
public int basePopulation = 5;
public int populationGivenPerHouse = 5;
public int populationGivenPerHouseUpgrade = 15;
public int populationCostPerUnit = 1;
public float populationWarningPercentage = 0.75f;

View File

@ -10,7 +10,7 @@ public class ResourceTile : LevelTile
private GameObject _yieldPrefab;
[SerializeField]
private Enum.ResourceNodeType _resourceNodeType;
public Enum.ResourceNodeType ResourceNodeType => _resourceNodeType;
public GameObject YieldPrefab => _yieldPrefab;
private string YieldPrefabName => _yieldPrefab.name;
@ -20,6 +20,8 @@ public class ResourceTile : LevelTile
private float _randomPositionConfig = 0.5f;
private float _yieldCounter = 0;
private float _yieldSpeedMultiplier = 1.0f;
public override void LevelStart()
{
base.LevelStart();
@ -48,7 +50,7 @@ public class ResourceTile : LevelTile
var yielded = Instantiate(_yieldPrefab, yieldPosition, Quaternion.identity);
yielded.transform.SetParent(LevelManager.Instance.LevelTransform);
}
private void ResetYieldDuration()
private void ResetYieldDuration()
{
_yieldCounter = 0;
var config = GlobalConfig.Instance.Current;
@ -58,11 +60,11 @@ public class ResourceTile : LevelTile
{
float min = config.randomHarvestDurationMinimum,
max = config.randomHarvestDurationMaximum;
_yieldCounter = Random.Range(min, max);
_yieldCounter = Random.Range(min, max) / _yieldSpeedMultiplier;
}
else
{
_yieldCounter = config.harvestDuration;
_yieldCounter = config.harvestDuration / _yieldSpeedMultiplier;
}
}
public override bool Equals(ILevelObject other)
@ -84,4 +86,12 @@ public class ResourceTile : LevelTile
var prefabName = dict[nameof(YieldPrefabName)].ToString();
_yieldPrefab = Database.Instance.Prefabs[prefabName];
}
// GETTERS AND SETTERS
public float YieldSpeedMultiplier
{
get { return _yieldSpeedMultiplier; }
set { _yieldSpeedMultiplier = value; }
}
}