Merge remote-tracking branch 'origin/main' into feature/animationRecolte

This commit is contained in:
Ader Alisma 01 2023-06-25 13:56:24 -04:00
commit f333c21e06
24 changed files with 4919 additions and 873 deletions

View File

@ -1,18 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1101 &-6019688218706219262
--- !u!1101 &-6631594651663551408
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Attack
m_EventTreshold: 0
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -1287810223429890817}
m_DstState: {fileID: 4151081420978197387}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
@ -20,64 +17,11 @@ AnimatorStateTransition:
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &-1287810223429890817
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: baseStick_attack
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 6419842955330930747}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: ff0a07b8a8691ba4390094d6fb771bef, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &-351144688566974252
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: baseStick_idle
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 346b13552d55b9f4a989013f6aa4d869, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
@ -92,7 +36,7 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@ -116,41 +60,71 @@ AnimatorStateMachine:
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -351144688566974252}
m_Position: {x: 260, y: 110, z: 0}
m_State: {fileID: 4151081420978197387}
m_Position: {x: 360, y: 80, z: 0}
- serializedVersion: 1
m_State: {fileID: -1287810223429890817}
m_Position: {x: 260, y: 50, z: 0}
m_State: {fileID: 6697012865370906260}
m_Position: {x: 380, y: -50, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: -6019688218706219262}
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_AnyStatePosition: {x: 30, y: 0, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -351144688566974252}
--- !u!1101 &6419842955330930747
AnimatorStateTransition:
m_DefaultState: {fileID: 4151081420978197387}
--- !u!1102 &4151081420978197387
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -351144688566974252}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.6808511
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
m_Name: idle
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -6631594651663551408}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 346b13552d55b9f4a989013f6aa4d869, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &6697012865370906260
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: attack
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: ff0a07b8a8691ba4390094d6fb771bef, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:

View File

@ -2,7 +2,7 @@ fileFormatVersion: 2
guid: 3cb91de3f312e514a92c799adf35e898
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -522,7 +522,7 @@ AnimationClip:
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0

View File

@ -323,7 +323,7 @@ AnimationClip:
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0

View File

@ -11,7 +11,6 @@ GameObject:
- component: {fileID: 3028288566889208751}
- component: {fileID: 3028288566889208750}
- component: {fileID: 3028288566889208749}
- component: {fileID: 6046873345209315807}
- component: {fileID: -245230096461627285}
m_Layer: 0
m_Name: LevelManager
@ -80,18 +79,6 @@ MonoBehaviour:
- {fileID: 11400000, guid: e715669e1ed4b294c82d07ac011e89bb, type: 2}
- {fileID: 11400000, guid: a387250a316b97e43be83b85980101e1, type: 2}
- {fileID: 11400000, guid: ef5a154519b23a34aaded32e86bf7f2f, type: 2}
--- !u!114 &6046873345209315807
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3028288566889208744}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45e6e814b8c91334ca1d6d0e7f530fef, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &-245230096461627285
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 4052934185698417096}
- component: {fileID: 4052934185698417099}
- component: {fileID: 4052934185698417098}
- component: {fileID: 2108251457}
m_Layer: 5
m_Name: img_card
m_TagString: Untagged
@ -31,8 +32,8 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4052934186652138536}
m_RootOrder: 2
m_Father: {fileID: 4052934185976516874}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@ -121,6 +122,18 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!225 &2108251457
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4052934185698417100}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 0
m_BlocksRaycasts: 0
m_IgnoreParentGroups: 0
--- !u!1 &4052934185976516877
GameObject:
m_ObjectHideFlags: 0
@ -151,7 +164,10 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Children:
- {fileID: 4052934186809116250}
- {fileID: 4052934185698417101}
- {fileID: 4052934186824254731}
m_Father: {fileID: 4052934186652138536}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -251,6 +267,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 4052934186652138536}
- component: {fileID: 8584020651799379602}
m_Layer: 5
m_Name: BuyableUnitItem
m_TagString: Untagged
@ -271,17 +288,28 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4052934185976516874}
- {fileID: 4052934186809116250}
- {fileID: 4052934185698417101}
- {fileID: 4052934186824254731}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8584020651799379602
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4052934186652138539}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 1
m_VerticalFit: 1
--- !u!1 &4052934186809116253
GameObject:
m_ObjectHideFlags: 0
@ -293,7 +321,7 @@ GameObject:
- component: {fileID: 4052934186809116250}
- component: {fileID: 4052934186809116249}
- component: {fileID: 4052934186809116248}
- component: {fileID: 4052934186809116251}
- component: {fileID: 2108251458}
m_Layer: 5
m_Name: img_cardBack
m_TagString: Untagged
@ -313,8 +341,8 @@ RectTransform:
m_LocalScale: {x: 1.0796, y: 1.0796, z: 1.0796}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4052934186652138536}
m_RootOrder: 1
m_Father: {fileID: 4052934185976516874}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@ -359,50 +387,18 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &4052934186809116251
MonoBehaviour:
--- !u!225 &2108251458
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4052934186809116253}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.5242524, g: 0.9339623, b: 0.81106573, a: 1}
m_PressedColor: {r: 0.41930506, g: 0.8018868, b: 0.2988163, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 4052934186809116248}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Alpha: 1
m_Interactable: 0
m_BlocksRaycasts: 0
m_IgnoreParentGroups: 0
--- !u!1 &4052934186824254730
GameObject:
m_ObjectHideFlags: 0
@ -414,6 +410,7 @@ GameObject:
- component: {fileID: 4052934186824254731}
- component: {fileID: 4052934186824254729}
- component: {fileID: 4052934186824254728}
- component: {fileID: 2108251456}
m_Layer: 5
m_Name: txt_cost
m_TagString: Untagged
@ -428,13 +425,13 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4052934186824254730}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
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: 4052934186652138536}
m_RootOrder: 3
m_Father: {fileID: 4052934185976516874}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@ -538,3 +535,15 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!225 &2108251456
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4052934186824254730}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 0
m_BlocksRaycasts: 0
m_IgnoreParentGroups: 0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e20680474d73eee49836ff9cbc6d0b28
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: afc444040d3adcf45a882e4882521f5e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,60 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UIButtonOutline
m_Shader: {fileID: -6465566751694194690, guid: 5aed7d9426a25544b928536f1bd9edc0, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AlphaTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _EnableExternalAlpha: 0
- _OutlineThickness: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 0}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c14409fbe59d3a947a21aab7ffa6f6d0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ public class Archer : Ally
void Start() {
_rigidbodyAlly = GetComponent<Rigidbody2D>();
Animation = gameObject.AddComponent<AnimationEntity>();
}
void Update() {
@ -25,9 +26,12 @@ public class Archer : Ally
}
void AttackEnemy() {
//Attack Cooldown
if(AttackSpeed < AttackSpeedWait) {
Animation.Attack();
GameObject _newArrow = Instantiate(_arrow, _rigidbodyAlly.position, Quaternion.identity);
//Warning : the Speed of the arrow is equal to the speed of this unit, if this unit need to move, use an other variable !

View File

@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationEntity : MonoBehaviour
{
private Animator _animator_entity;
private bool _doSomething = false;
void Start() {
_animator_entity = GetComponentInChildren<Animator>();
}
void Update() {
if (_doSomething && _animator_entity.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1f)
{
Idle();
_doSomething = false;
}
}
public void Idle() {
_animator_entity.Play("idle", 0, 0f);
}
public void Attack() {
_animator_entity.Play("attack", 0, 0f);
_doSomething = true;
}
}

View File

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

View File

@ -1,9 +1,14 @@
using Codice.CM.Client.Differences;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class DraggablePlaceholder : MonoBehaviour
{
public int Food { get; set; }
public int Rock { get; set; }
public int Wood { get; set; }
protected const string OutlineColor = "_OutlineColor";
[SerializeField]
@ -13,7 +18,7 @@ public abstract class DraggablePlaceholder : MonoBehaviour
protected Camera _mainCamCache;
protected Rect _lvlBoundsCache;
protected bool _isOnValidPosition;
protected bool _canBePlacedHere;
private List<SpriteRenderer> _outlineRenderers = new List<SpriteRenderer>();
public List<SpriteRenderer> OutlineRenderers
@ -41,8 +46,9 @@ public abstract class DraggablePlaceholder : MonoBehaviour
{
if (!Input.GetMouseButton(0))
{
if (_isOnValidPosition)
if (_canBePlacedHere)
{
ResourceManager.Instance.Remove(Rock, Wood, Food);
Place();
}
Destroy(gameObject);
@ -50,7 +56,7 @@ public abstract class DraggablePlaceholder : MonoBehaviour
UpdatePosition();
_isOnValidPosition = CanBePlacedHere();
_canBePlacedHere = CanBePlacedHere();
ShowValidity();
}
@ -74,7 +80,8 @@ public abstract class DraggablePlaceholder : MonoBehaviour
/// </summary>
public virtual bool CanBePlacedHere()
{
return !LevelManager.Instance.Has<ILevelObject>(obj => obj.Position.IsContainedIn(transform.position));
return !LevelManager.Instance.Has<ILevelObject>(obj => obj.Position.IsContainedIn(transform.position))
&& ResourceManager.Instance.EnoughFor(Rock, Wood, Food);
}
/// <summary>
@ -85,7 +92,7 @@ public abstract class DraggablePlaceholder : MonoBehaviour
/// <returns></returns>
public virtual void ShowValidity()
{
Color getColor() => _isOnValidPosition ? _validColor : _invalidColor;
Color getColor() => _canBePlacedHere ? _validColor : _invalidColor;
foreach (var child in _outlineRenderers)
{

View File

@ -5,7 +5,7 @@ public class GameObjectPlacementButton : UnitPlacementButton
{
[SerializeField]
private GameObject _prefab;
protected override void Place()
protected override DraggablePlaceholder Place()
{
var instance = Instantiate(_prefab);
@ -20,6 +20,7 @@ public class GameObjectPlacementButton : UnitPlacementButton
foreach (var script in instance.transform.GetAllComponents<MonoBehaviour>()) Destroy(script);
var placeholder = instance.AddComponent<ObjectPlaceholder>();
placeholder.Prefab = _prefab;
//assign outline material to all renderers of the placeholder
@ -34,9 +35,9 @@ public class GameObjectPlacementButton : UnitPlacementButton
placeholder.OutlineRenderers.Add(rend);
}
CreateRange(placeholder, detectionRect);
return placeholder;
}
void CreateRange(DraggablePlaceholder placeholder, Rect detectionRect)

View File

@ -5,7 +5,7 @@ using UnityEngine;
public class TilePlacementButton : UnitPlacementButton
{
public LevelTile tile;
protected override void Place()
protected override DraggablePlaceholder Place()
{
var instance = new GameObject(tile.name);
var placeholder = instance.AddComponent<TilePlaceholder>();
@ -15,5 +15,6 @@ public class TilePlacementButton : UnitPlacementButton
rend.sortingLayerName = "Character";
rend.material = _outlineMaterial;
rend.sortingOrder = 2;
return placeholder;
}
}

View File

@ -1,17 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[RequireComponent(typeof(Button))]
public abstract class UnitPlacementButton : MonoBehaviour, IPointerDownHandler
{
[SerializeField]
protected Material _outlineMaterial;
[SerializeField]
protected Sprite _detectionRangeSprite;
[SerializeField]
private int _wood;
[SerializeField]
private int _rock;
[SerializeField]
private int _food;
private Button _button;
[SerializeField]
private TMP_Text _foodLabel;
[SerializeField]
private TMP_Text _woodLabel;
[SerializeField]
private TMP_Text _rockLabel;
protected virtual void Start()
{
_button = GetComponent<Button>();
}
protected virtual void Update()
{
_button.interactable = ResourceManager.Instance.EnoughFor(_rock, _wood, _food);
SetTextFor(_foodLabel, _food);
SetTextFor(_rockLabel, _rock);
SetTextFor(_woodLabel, _wood);
}
void SetTextFor(TMP_Text label, int value)
{
label.transform.parent.gameObject.SetActive(value > 0);
label.text = "" + value;
}
public void OnPointerDown(PointerEventData eventData)
{
Place();
if (!_button.interactable) return;
var placeholder = Place();
placeholder.Rock = _rock;
placeholder.Wood = _wood;
placeholder.Food = _food;
}
protected abstract void Place();
protected abstract DraggablePlaceholder Place();
}

View File

@ -15,6 +15,7 @@ public class Entity : LevelObject
[SerializeField]
private float _attack_speed;
private float _attack_speed_wait = 0f;
private AnimationEntity _animation;
//Enemy Spotted
private bool _isEnemyDetected = false;
@ -64,6 +65,12 @@ public class Entity : LevelObject
set { _enemy = value; }
}
public AnimationEntity Animation
{
get { return _animation; }
set { _animation = value; }
}
#region [LevelManager code]
public override bool Equals(ILevelObject other)
{

View File

@ -3,7 +3,7 @@ using UnityEngine;
/// <summary>
/// Sert d'inventaire et gère l'accès aux ressources
/// </summary>
public class ResourceManager : MonoBehaviour
public class ResourceManager : Singleton<ResourceManager>
{
private static ResourceManager _instance = null;
private int _rockAmount = 20;
@ -13,27 +13,6 @@ public class ResourceManager : MonoBehaviour
private const int MAX = 100;
private const int MIN = 0;
public ResourceManager() { }
public static ResourceManager Instance
{
get
{
return _instance;
}
}
private void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(this);
}
else
{
_instance = this;
}
}
public int RockAmount
{
set

View File

@ -59,6 +59,9 @@
},
{
"m_Id": "7aa529fabe2b4b199495cc44e889cc4b"
},
{
"m_Id": "b11ac65f24a34a4b89384329efe707dc"
}
],
"m_GroupDatas": [],
@ -92,6 +95,20 @@
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "03db1e07f0ee40d5bbb14b9afba574cc"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "b11ac65f24a34a4b89384329efe707dc"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
@ -204,6 +221,20 @@
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "9a7d1b885a4e4686adebd71427853c28"
},
"m_SlotId": 2
},
"m_InputSlot": {
"m_Node": {
"m_Id": "b11ac65f24a34a4b89384329efe707dc"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
@ -487,6 +518,30 @@
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
"m_ObjectId": "1e5d0b6e4ea849c1af623505437e3d55",
"m_Id": 2,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot",
@ -887,10 +942,10 @@
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1697.5999755859375,
"y": -127.99999237060547,
"x": 1680.800048828125,
"y": -154.39999389648438,
"width": 208.0,
"height": 301.60003662109377
"height": 301.5999755859375
}
},
"m_Slots": [
@ -1017,6 +1072,30 @@
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
"m_ObjectId": "8992789161914a099c54c3eb46f3f39c",
"m_Id": 1,
"m_DisplayName": "B",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "B",
"m_StageCapability": 3,
"m_Value": {
"x": 1.0,
"y": 1.0,
"z": 1.0,
"w": 1.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Texture2DPropertiesNode",
@ -1156,6 +1235,49 @@
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.SubtractNode",
"m_ObjectId": "b11ac65f24a34a4b89384329efe707dc",
"m_Group": {
"m_Id": ""
},
"m_Name": "Subtract",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1680.800048828125,
"y": -477.6000061035156,
"width": 208.0,
"height": 301.5999755859375
}
},
"m_Slots": [
{
"m_Id": "c61e864a2bb9473399f2da113e515de3"
},
{
"m_Id": "8992789161914a099c54c3eb46f3f39c"
},
{
"m_Id": "1e5d0b6e4ea849c1af623505437e3d55"
}
],
"synonyms": [
"subtraction",
"remove",
"minus",
"take away"
],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
@ -1255,6 +1377,30 @@
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
"m_ObjectId": "c61e864a2bb9473399f2da113e515de3",
"m_Id": 0,
"m_DisplayName": "A",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "A",
"m_StageCapability": 3,
"m_Value": {
"x": 1.0,
"y": 1.0,
"z": 1.0,
"w": 1.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",

View File

@ -14,6 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
_sprite: {fileID: 21300000, guid: ccca3e050cb082b45af0a099790463f6, type: 3}
_isCollidable: 0
_yieldPrefab: {fileID: 0}
_yieldSpeed: 0
_randomPositionConfig: 0.5
_yieldPrefab: {fileID: 6962989255644195630, guid: a2dc5d9672c10074fa9c35c12f6339c1, type: 3}
_yieldSpeed: 0.1
_randomPositionConfig: 0.25