Pull request #25: Animation de la récolte au clic et au commencement. Aussi, ajout au HUD
Merge in CGD/gather-and-defend from feature/animationRecolte to main * commit '1dcca774d5e0922c483dc4957845a875e574c942': Correction des commentaires de merge pour ResourceMaker ResourceMaker démarre le yield en hauteur, puis il descend vers le sol Merge commit ResourceMaker déplace la ressource à ramasser vers un point fixe avant d'augmenter la quantité de ressources du joueur
This commit is contained in:
commit
93e3ab1929
@ -135,6 +135,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_resourceMakingAmount: 10
|
_resourceMakingAmount: 10
|
||||||
_resourceChoice: 2
|
_resourceChoice: 2
|
||||||
|
_endPosition: {x: -2, y: 5}
|
||||||
--- !u!1 &6962989256011107503
|
--- !u!1 &6962989256011107503
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -135,6 +135,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_resourceMakingAmount: 10
|
_resourceMakingAmount: 10
|
||||||
_resourceChoice: 0
|
_resourceChoice: 0
|
||||||
|
_endPosition: {x: -10, y: 5}
|
||||||
--- !u!1 &6962989256011107503
|
--- !u!1 &6962989256011107503
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -135,6 +135,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_resourceMakingAmount: 10
|
_resourceMakingAmount: 10
|
||||||
_resourceChoice: 1
|
_resourceChoice: 1
|
||||||
|
_endPosition: {x: -5, y: 0}
|
||||||
--- !u!1 &6962989256011107503
|
--- !u!1 &6962989256011107503
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -1723,6 +1723,8 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1364544234}
|
- component: {fileID: 1364544234}
|
||||||
- component: {fileID: 1364544236}
|
- component: {fileID: 1364544236}
|
||||||
|
- component: {fileID: 1364544238}
|
||||||
|
- component: {fileID: 1364544237}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Wood
|
m_Name: Wood
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -1770,7 +1772,7 @@ MonoBehaviour:
|
|||||||
m_Top: 0
|
m_Top: 0
|
||||||
m_Bottom: 0
|
m_Bottom: 0
|
||||||
m_ChildAlignment: 4
|
m_ChildAlignment: 4
|
||||||
m_Spacing: 0
|
m_Spacing: 5
|
||||||
m_ChildForceExpandWidth: 0
|
m_ChildForceExpandWidth: 0
|
||||||
m_ChildForceExpandHeight: 0
|
m_ChildForceExpandHeight: 0
|
||||||
m_ChildControlWidth: 0
|
m_ChildControlWidth: 0
|
||||||
@ -1778,6 +1780,44 @@ MonoBehaviour:
|
|||||||
m_ChildScaleWidth: 0
|
m_ChildScaleWidth: 0
|
||||||
m_ChildScaleHeight: 0
|
m_ChildScaleHeight: 0
|
||||||
m_ReverseArrangement: 0
|
m_ReverseArrangement: 0
|
||||||
|
--- !u!114 &1364544237
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1364544233}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 21300000, guid: a9a9dd4da2d899b4fbf1bdac279f205f, type: 3}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1364544238
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1364544233}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1461572642
|
--- !u!1 &1461572642
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1864,6 +1904,8 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1472986333}
|
- component: {fileID: 1472986333}
|
||||||
- component: {fileID: 1472986335}
|
- component: {fileID: 1472986335}
|
||||||
|
- component: {fileID: 1472986337}
|
||||||
|
- component: {fileID: 1472986336}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Food
|
m_Name: Food
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -1911,7 +1953,7 @@ MonoBehaviour:
|
|||||||
m_Top: 0
|
m_Top: 0
|
||||||
m_Bottom: 0
|
m_Bottom: 0
|
||||||
m_ChildAlignment: 4
|
m_ChildAlignment: 4
|
||||||
m_Spacing: 0
|
m_Spacing: 5
|
||||||
m_ChildForceExpandWidth: 0
|
m_ChildForceExpandWidth: 0
|
||||||
m_ChildForceExpandHeight: 0
|
m_ChildForceExpandHeight: 0
|
||||||
m_ChildControlWidth: 0
|
m_ChildControlWidth: 0
|
||||||
@ -1919,6 +1961,44 @@ MonoBehaviour:
|
|||||||
m_ChildScaleWidth: 0
|
m_ChildScaleWidth: 0
|
||||||
m_ChildScaleHeight: 0
|
m_ChildScaleHeight: 0
|
||||||
m_ReverseArrangement: 0
|
m_ReverseArrangement: 0
|
||||||
|
--- !u!114 &1472986336
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1472986332}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 0
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 0
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 21300000, guid: b4ecdeb6795f5c944befcf087eef850c, type: 3}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1472986337
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1472986332}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1577235757
|
--- !u!1 &1577235757
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -2009,6 +2089,8 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1843606528}
|
- component: {fileID: 1843606528}
|
||||||
- component: {fileID: 1843606529}
|
- component: {fileID: 1843606529}
|
||||||
|
- component: {fileID: 1843606531}
|
||||||
|
- component: {fileID: 1843606530}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Rock
|
m_Name: Rock
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -2056,7 +2138,7 @@ MonoBehaviour:
|
|||||||
m_Top: 0
|
m_Top: 0
|
||||||
m_Bottom: 0
|
m_Bottom: 0
|
||||||
m_ChildAlignment: 4
|
m_ChildAlignment: 4
|
||||||
m_Spacing: 0
|
m_Spacing: 5
|
||||||
m_ChildForceExpandWidth: 0
|
m_ChildForceExpandWidth: 0
|
||||||
m_ChildForceExpandHeight: 0
|
m_ChildForceExpandHeight: 0
|
||||||
m_ChildControlWidth: 0
|
m_ChildControlWidth: 0
|
||||||
@ -2064,6 +2146,44 @@ MonoBehaviour:
|
|||||||
m_ChildScaleWidth: 0
|
m_ChildScaleWidth: 0
|
||||||
m_ChildScaleHeight: 0
|
m_ChildScaleHeight: 0
|
||||||
m_ReverseArrangement: 0
|
m_ReverseArrangement: 0
|
||||||
|
--- !u!114 &1843606530
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1843606527}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 21300000, guid: c0fa0883074be5b4cb030fc39eb9d3c7, type: 3}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1843606531
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1843606527}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1932921574
|
--- !u!1 &1932921574
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -554,7 +554,6 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 588027704}
|
- component: {fileID: 588027704}
|
||||||
- component: {fileID: 588027705}
|
|
||||||
- component: {fileID: 588027706}
|
- component: {fileID: 588027706}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: GameManager
|
m_Name: GameManager
|
||||||
@ -583,18 +582,6 @@ RectTransform:
|
|||||||
m_AnchoredPosition: {x: 423, y: 178}
|
m_AnchoredPosition: {x: 423, y: 178}
|
||||||
m_SizeDelta: {x: 100, y: 100}
|
m_SizeDelta: {x: 100, y: 100}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &588027705
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 588027703}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 45e6e814b8c91334ca1d6d0e7f530fef, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
--- !u!114 &588027706
|
--- !u!114 &588027706
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -10,17 +10,44 @@ public class ResourceMaker : MonoBehaviour
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Enum.ResourceChoice _resourceChoice;
|
private Enum.ResourceChoice _resourceChoice;
|
||||||
private ResourceManager _resourceManagerInstance;
|
private ResourceManager _resourceManagerInstance;
|
||||||
|
[SerializeField]
|
||||||
|
private Vector2 _endPosition;
|
||||||
|
private Vector2 _startPosition;
|
||||||
|
private Rigidbody2D _rigidbody;
|
||||||
|
private float _desiredTime = 1.5f;
|
||||||
|
private float _timePassed = 0f;
|
||||||
|
private bool _isPlaying = false;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_resourceManagerInstance = ResourceManager.Instance;
|
_resourceManagerInstance = ResourceManager.Instance;
|
||||||
|
_startPosition = transform.position;
|
||||||
|
transform.position = new Vector2(transform.position.x, transform.position.y + 0.5f);
|
||||||
|
_rigidbody = GetComponent<Rigidbody2D>();
|
||||||
|
_rigidbody.AddForce(transform.up * 20.0f);
|
||||||
|
_rigidbody.gravityScale = 0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// D'après le choix de resource à générer, choisi le prefab à instancier
|
/// D'après le choix de resource à générer, choisi le prefab à instancier
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GenerateResource()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
if (Vector2.Distance(transform.position, _startPosition) < 0.01f)
|
||||||
|
{
|
||||||
|
_rigidbody.gravityScale = 0.0f;
|
||||||
|
_rigidbody.velocity = Vector2.zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_isPlaying)
|
||||||
|
{
|
||||||
|
_timePassed += Time.deltaTime;
|
||||||
|
float duration = _timePassed / _desiredTime;
|
||||||
|
duration = duration * duration * (3.0f - 2.0f * duration);
|
||||||
|
transform.position = Vector2.Lerp(transform.position, _endPosition, duration);
|
||||||
|
if(Vector2.Distance(transform.position,_endPosition) < 0.001f)
|
||||||
|
{
|
||||||
|
_isPlaying = false;
|
||||||
switch (_resourceChoice)
|
switch (_resourceChoice)
|
||||||
{
|
{
|
||||||
case Enum.ResourceChoice.Rock:
|
case Enum.ResourceChoice.Rock:
|
||||||
@ -36,3 +63,12 @@ public class ResourceMaker : MonoBehaviour
|
|||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GenerateResource()
|
||||||
|
{
|
||||||
|
_isPlaying = true;
|
||||||
|
_rigidbody.gravityScale = 0.0f;
|
||||||
|
_rigidbody.velocity = Vector2.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -23,13 +23,15 @@ public class ResourceTile : LevelTile
|
|||||||
{
|
{
|
||||||
_yieldCounter += Time.deltaTime * _yieldSpeed;
|
_yieldCounter += Time.deltaTime * _yieldSpeed;
|
||||||
if (_yieldCounter < 1) return;
|
if (_yieldCounter < 1) return;
|
||||||
|
if(_yieldPrefab != null)
|
||||||
|
{
|
||||||
_yieldCounter = 0;
|
_yieldCounter = 0;
|
||||||
float rangeConfig = 0.5f + _randomPositionConfig;
|
float rangeConfig = 0.5f + _randomPositionConfig;
|
||||||
Vector3 yieldPosition = new Vector3(Position.x + Random.Range(-rangeConfig, rangeConfig), Position.y, Position.z);
|
Vector3 yieldPosition = new Vector3(Position.x + Random.Range(-rangeConfig, rangeConfig), Position.y, Position.z);
|
||||||
var yielded = Instantiate(_yieldPrefab, yieldPosition, Quaternion.identity);
|
var yielded = Instantiate(_yieldPrefab, yieldPosition, Quaternion.identity);
|
||||||
yielded.transform.SetParent(LevelManager.Instance.LevelTransform);
|
yielded.transform.SetParent(LevelManager.Instance.LevelTransform);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public override bool Equals(ILevelObject other)
|
public override bool Equals(ILevelObject other)
|
||||||
{
|
{
|
||||||
return other is ResourceTile otherRes
|
return other is ResourceTile otherRes
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 84b05f2a26f63da46a1028488482d079, type: 3}
|
|
||||||
m_Name: Meat
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
_sprite: {fileID: 21300000, guid: b1e6b8ebeb2e25f4f8c5de93a31dd6a2, type: 3}
|
|
||||||
_isCollidable: 0
|
|
||||||
_yieldPrefab: {fileID: 6962989255644195630, guid: a2dc5d9672c10074fa9c35c12f6339c1, type: 3}
|
|
||||||
_yieldSpeed: 0.5
|
|
||||||
_randomPositionConfig: 0.5
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a19b3b6859986b449aac7484e064097a
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Loading…
x
Reference in New Issue
Block a user