Monster Core #21

Open
Ader_Alisma wants to merge 7 commits from feature/monsterCore into main
17 changed files with 1087 additions and 128 deletions
Showing only changes of commit a2fc9c2980 - Show all commits

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

View File

@ -0,0 +1,123 @@
fileFormatVersion: 2
guid: 6ac775d3d669c124fbbb2032dde07b62
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
%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: f431d5fa196e5ea4da69343642d10d2f, type: 3}
m_Name: TestMonsterCore
m_EditorClassIdentifier:
_monsterCorePrefab: {fileID: 6962989255644195630, guid: 1130702cca945b542bec6c5cd7ff859b, type: 3}

View File

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

View File

@ -0,0 +1,221 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6962989255644195630
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6962989255644195631}
- component: {fileID: 6072713849781841816}
- component: {fileID: -1491803373025033585}
- component: {fileID: 2238237770060079311}
- component: {fileID: 3600016298306940116}
m_Layer: 0
m_Name: yieldMonsterCore
m_TagString: Resource
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6962989255644195631
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6962989255644195630}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -6.61, y: -0.638, z: 1.8112363}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6962989256011107500}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1839735485 &6072713849781841816
Tilemap:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6962989255644195630}
m_Enabled: 0
m_Tiles: {}
m_AnimatedTiles: {}
m_TileAssetArray: []
m_TileSpriteArray: []
m_TileMatrixArray: []
m_TileColorArray: []
m_TileObjectToInstantiateArray: []
m_AnimationFrameRate: 1
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Origin: {x: 0, y: 0, z: 0}
m_Size: {x: 0, y: 0, z: 1}
m_TileAnchor: {x: 0.5, y: 0.5, z: 0}
m_TileOrientation: 0
m_TileOrientationMatrix:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
--- !u!50 &-1491803373025033585
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6962989255644195630}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!61 &2238237770060079311
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6962989255644195630}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.05, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.29, y: 0.25}
m_EdgeRadius: 0
--- !u!114 &3600016298306940116
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6962989255644195630}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9dd6bad38b516d64e8e23a5822ca37bb, type: 3}
m_Name:
m_EditorClassIdentifier:
_resourceChoice: 3
_animate: 1
--- !u!1 &6962989256011107503
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6962989256011107500}
- component: {fileID: 6962989256011107501}
m_Layer: 0
m_Name: sprite
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6962989256011107500
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6962989256011107503}
m_LocalRotation: {x: 0, y: -0, z: 0, w: -1}
m_LocalPosition: {x: 0.0259, y: 0.01, z: 0}
m_LocalScale: {x: 0.5394133, y: 0.56488746, z: 0.9686}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6962989255644195631}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 360}
--- !u!212 &6962989256011107501
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6962989256011107503}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 4
m_Sprite: {fileID: 21300000, guid: 8354a544f4ca3514e87d40d2de9afaee, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1.06, y: 1.69}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,8 @@ public class Enum
{
Rock = 0,
Wood = 1,
Food = 2
Food = 2,
MonsterCore = 3
};
public enum ResourceNodeType
{

View File

@ -253,7 +253,6 @@ public class WaveObserver : Singleton<WaveObserver>
bool dropsCore = _monsterCoreGroups != null && _monsterCoreGroups.Count > _currentGroupIndex && _monsterCoreGroups[_currentGroupIndex];
int totalToSpawn = _copyGroupSpawn[_currentGroupIndex][groupIndex];
int monsterCoreTarget = -1;
// TODO : Afficher input box quand bool "DropsMonsterCore" est checked
// TODO : Si spécifié, nbr fixe de core à drop
if (dropsCore && totalToSpawn > 0)
{
@ -265,15 +264,12 @@ public class WaveObserver : Singleton<WaveObserver>
int currentRow = rand.Next(_subjects.Count);
if (!usedRows.Contains(currentRow)) //If picked row has laready been used
{
GameObject spawnedInstance = _subjects[currentRow].TriggerSpawn(currentGroup[groupIndex].GetEnemyObject());
Opponent spawnedInstance = _subjects[currentRow].TriggerSpawn(currentGroup[groupIndex].GetEnemyObject()).GetComponent<Opponent>();
// WHen Monster core time
// When Monster core time
if (monsterCoreTarget >= 0 && spawnCount == monsterCoreTarget)
{
if (spawnedInstance != null)
{
spawnedInstance.AddComponent<MonsterCoreDrop>();
}
spawnedInstance.ActivateMonsterCore();
}
_copyGroupSpawn[_currentGroupIndex][groupIndex]--;

View File

@ -23,12 +23,15 @@ namespace GatherAndDefend.LevelEditor
[SerializeField]
private int _startPopulation = 10;
[SerializeField]
private int _startMonsterCore = 0;
[SerializeField]
private int _startFood = 50;
[SerializeField]
private int _startWood = 0;
[SerializeField]
private int _startRock = 0;
public int StartPopulation => _startPopulation;
public int StartMonsterCore => _startMonsterCore;
public int StartFood => _startFood;
public int StartWood => _startWood;
public int StartRock => _startRock;

View File

@ -1,40 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MonsterCoreDrop : MonoBehaviour
[CreateAssetMenu(menuName = "Gather And Defend/" + nameof(MonsterCoreDrop))]
public class MonsterCoreDrop : ScriptableObject
{
[SerializeField]
private GameObject _monsterCorePrefab;
public void Start()
{
Debug.Log("MONSTER CORING SSO HARD");
// Si le prefab n'est pas fixé via l'inspector, tenter de le charger depuis Resources/"Food"
//if (_monsterCorePrefab == null)
//{
// _monsterCorePrefab = Resources.Load<GameObject>("yieldFood");
// if (_monsterCorePrefab == null)
// {
// Debug.LogWarning("MonsterCoreDrop: prefab 'yieldFood' introuvable dans le dossier Resources. Assignez-le dans l'inspector ou placez-le dans Resources/yieldFood.");
// }
//}
if (_monsterCorePrefab == null)
{
Debug.LogWarning("Prefab MonsterCore non defini");
}
}
public void Death()
public void Death(Vector3 position)
{
//if (_monsterCorePrefab != null)
//{
// Instantiate(_monsterCorePrefab, transform.position, Quaternion.identity);
//}
Debug.Log("MONSTER CORE DROPPEDD");
}
private void OnDestroy()
{
//if (_monsterCorePrefab != null)
//{
// Instantiate(_monsterCorePrefab, transform.position, Quaternion.identity);
//}
if (_monsterCorePrefab != null)
{
Instantiate(_monsterCorePrefab, position, Quaternion.identity);
}
Debug.Log("MONSTER CORE DROPPEDD");
}
}

View File

@ -15,6 +15,7 @@ public class Opponent : Entity
private WaveObserver _observer;
private int _observerIndex;
private float _toughness;
private bool _dropsMonsterCore = false;
public override void Start()
{
@ -59,8 +60,17 @@ public class Opponent : Entity
public override void Death()
{
if (_dropsMonsterCore)
{
// TODO: Fetch scriptable object from Dict
}
_observer.NotifyDies(_observerIndex, _toughness, gameObject);
base.Death();
}
public void ActivateMonsterCore()
{
_dropsMonsterCore = true;
}
}

View File

@ -40,6 +40,9 @@ public class ResourceMaker : MonoBehaviour
case Enum.ResourceChoice.Food:
_destination = GameObject.FindWithTag("Food");
break;
case Enum.ResourceChoice.MonsterCore:
_destination = GameObject.FindWithTag("MonsterCore");
break;
default:
_destination = GameObject.FindWithTag("Food");
break;
@ -100,6 +103,9 @@ public class ResourceMaker : MonoBehaviour
case Enum.ResourceChoice.Food:
_resourceManagerInstance.FoodAmount += amount;
break;
case Enum.ResourceChoice.MonsterCore:
_resourceManagerInstance.MonsterCoreAmount += amount;
break;
}
}

View File

@ -11,6 +11,7 @@ public class ResourceManager : Singleton<ResourceManager>
private int _rockAmount = 0;
private int _woodAmount = 0;
private int _foodAmount = 0;
private int _monsterCoreAmount = 0;
private float _currentPopulation;
private float _maximumPopulation;
@ -29,6 +30,7 @@ public class ResourceManager : Singleton<ResourceManager>
_rockAmount = 0;
_woodAmount = 0;
_foodAmount = 0;
_monsterCoreAmount = 0;
_currentPopulation = 0;
_maximumPopulation = 0;
}
@ -37,6 +39,7 @@ public class ResourceManager : Singleton<ResourceManager>
RockAmount = level.StartRock;
WoodAmount = level.StartWood;
FoodAmount = level.StartFood;
MonsterCoreAmount = level.StartMonsterCore;
CurrentPopulation = 0;
MaximumPopulation = level.StartPopulation;
}
@ -77,6 +80,18 @@ public class ResourceManager : Singleton<ResourceManager>
}
get { return _foodAmount; }
}
public int MonsterCoreAmount
{
set
{
if (value != _monsterCoreAmount)
{
_monsterCoreAmount = value;
EventAggregator.Instance.GetEvent<ResourcesChangedEvent>().Invoke();
}
}
get { return _monsterCoreAmount; }
}
public float CurrentPopulation
{
@ -112,24 +127,26 @@ public class ResourceManager : Singleton<ResourceManager>
}
}
public void Remove(int rock, int wood, int food)
public void Remove(int rock, int wood, int food, int monsterCore = 0)
{
int oldRock = _rockAmount, oldWood = _woodAmount, oldFood = _foodAmount;
int oldRock = _rockAmount, oldWood = _woodAmount, oldFood = _foodAmount, oldMonsterCore = _monsterCoreAmount;
_rockAmount = (_rockAmount - rock) < MIN ? MIN : _rockAmount - rock;
_woodAmount = (_woodAmount - wood) < MIN ? MIN : _woodAmount - wood;
_foodAmount = (_foodAmount - food) < MIN ? MIN : _foodAmount - food;
_monsterCoreAmount = (_monsterCoreAmount - monsterCore) < MIN ? MIN : _monsterCoreAmount - monsterCore;
if (oldRock != _rockAmount || oldFood != _foodAmount || oldWood != _woodAmount)
if (oldRock != _rockAmount || oldFood != _foodAmount || oldWood != _woodAmount || oldMonsterCore != _monsterCoreAmount)
{
EventAggregator.Instance.GetEvent<ResourcesChangedEvent>().Invoke();
}
}
public bool EnoughFor(int rock, int wood, int food = 0)
public bool EnoughFor(int rock, int wood, int food = 0, int monsterCore = 0)
{
return _rockAmount >= rock
&& _woodAmount >= wood
&& _foodAmount >= food;
&& _foodAmount >= food
&& _monsterCoreAmount >= monsterCore;
}
public bool EnoughPopulationFor(int population = 1)
{

View File

@ -20,6 +20,9 @@ public class ResourceRemover : MonoBehaviour
[SerializeField]
private int _food;
[SerializeField]
private int _monsterCore;
[SerializeField]
private TextMeshProUGUI _text;
@ -40,7 +43,7 @@ public class ResourceRemover : MonoBehaviour
private void ChangeAvailability()
{
//checks if player has enough resources then changes the state of button's availability
if (_resourceManager.EnoughFor(_rock, _wood, _food))
if (_resourceManager.EnoughFor(_rock, _wood, _food, _monsterCore))
{
if (_text.color != Color.green)
{
@ -60,7 +63,7 @@ public class ResourceRemover : MonoBehaviour
if (_text.color == Color.green)
{
Debug.Log("Removed items...");
_resourceManager.Remove(_rock, _wood, _food);
_resourceManager.Remove(_rock, _wood, _food, _monsterCore);
}
}

View File

@ -21,6 +21,8 @@ public class ResourceText : MonoBehaviour
[SerializeField]
private TextMeshProUGUI _foodText;
[SerializeField]
private TextMeshProUGUI _monsterCoreText;
[SerializeField]
private TextMeshProUGUI _populationText;
[SerializeField]
private Image _populationCriticalIndicator;
@ -43,6 +45,7 @@ public class ResourceText : MonoBehaviour
_rockText.text = _resourceManager.RockAmount.ToString();
_woodText.text = _resourceManager.WoodAmount.ToString();
_foodText.text = _resourceManager.FoodAmount.ToString();
_monsterCoreText.text = _resourceManager.MonsterCoreAmount.ToString();
}
void RefreshPopulation()
{

View File

@ -11,6 +11,7 @@ TagManager:
- Wood
- Rock
- Upgrade
- MonsterCore
layers:
- Default
- TransparentFX