Implemented the basis for the castle unit, including having it shoot, the shooting range, and the upgrading logic.

This commit is contained in:
MaximilienBlanchardBizien1 2025-01-05 10:49:19 -05:00
parent 116d9610c4
commit 503a8dedbc
4 changed files with 179 additions and 11 deletions

View File

@ -1,5 +1,36 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &677021742661546270
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7055490709728624221}
m_Layer: 0
m_Name: '@projectileSpawn'
m_TagString: Untagged
m_Icon: {fileID: 6519382022992737161, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7055490709728624221
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 677021742661546270}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -0.103, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8169559242600365314}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1436362432952518814
GameObject:
m_ObjectHideFlags: 0
@ -37,6 +68,7 @@ Transform:
- {fileID: 6894793432076062629}
- {fileID: 4738724134341998529}
- {fileID: 4727854499611739481}
- {fileID: 8169559242600365314}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -210,10 +242,11 @@ MonoBehaviour:
m_EditorClassIdentifier:
_lifeBar: {fileID: 981581452810264329}
_hp: 20
_speed: 0
_speed: 1
_attack_damage: 2
_attack_interval: 2
_enemy: {fileID: 0}
_root: {fileID: 3828680565076245792}
--- !u!114 &7118484083738872079
MonoBehaviour:
m_ObjectHideFlags: 0
@ -271,7 +304,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 531d7966d86bd0c4d83baf58bcb56cd5, type: 3}
m_Name:
m_EditorClassIdentifier:
_entityLinked: {fileID: 0}
_entityLinked: {fileID: 498655111277194201}
--- !u!61 &3389094527817988571
BoxCollider2D:
m_ObjectHideFlags: 0
@ -288,16 +321,65 @@ BoxCollider2D:
m_Offset: {x: 0, 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
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 11.65, y: 5.55}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 5, y: 3}
m_Size: {x: 10, y: 6}
m_EdgeRadius: 0
--- !u!1 &7593581371702012092
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8169559242600365314}
- component: {fileID: 3828680565076245792}
m_Layer: 0
m_Name: root
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8169559242600365314
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7593581371702012092}
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:
- {fileID: 7055490709728624221}
- {fileID: 7939484193916151742}
m_Father: {fileID: 8393796362083852573}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3828680565076245792
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7593581371702012092}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c0fbd934c179894458914437255781c4, type: 3}
m_Name:
m_EditorClassIdentifier:
_entity: {fileID: 498655111277194201}
_projectile: {fileID: 6962989255644195630, guid: 869a03bba705e8d4485aa73daad773dc, type: 3}
_projectileSpawn: {fileID: 7055490709728624221}
--- !u!1 &7803635882566565305
GameObject:
m_ObjectHideFlags: 0
@ -382,6 +464,78 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &8310043151180040893
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7939484193916151742}
- component: {fileID: 5488513296025383449}
- component: {fileID: 8186041413564706385}
m_Layer: 0
m_Name: detection
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7939484193916151742
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8310043151180040893}
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: 8169559242600365314}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &5488513296025383449
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8310043151180040893}
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, 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: 10, y: 6}
m_EdgeRadius: 0
--- !u!114 &8186041413564706385
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8310043151180040893}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 531d7966d86bd0c4d83baf58bcb56cd5, type: 3}
m_Name:
m_EditorClassIdentifier:
_entityLinked: {fileID: 498655111277194201}
--- !u!1001 &6268201541322694619
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -44,7 +44,7 @@ public class Ally : Entity
public override void LevelStart()
{
base.LevelStart();
if(this is not Building) ResourceManager.Instance.CurrentPopulation += PopulationCost;
if (this is not Building) ResourceManager.Instance.CurrentPopulation += PopulationCost;
}
public override void LevelDestroy()
{

View File

@ -6,6 +6,9 @@ public class Castle : Building
{
public float PopulationGiven => GlobalConfig.Instance.Current.populationGivenPerHouse;
[SerializeField]
private Root _root;
public override void Start()
{
base.Start();
@ -37,8 +40,14 @@ public class Castle : Building
//Attack Cooldown
if (AttackInterval < AttackSpeedWait)
{
Animation.PlayAttackAnim();
//TODO: Probleme avec l'envoie de projectile sur un angle.
//Sur la meme fonctionne, mais doit corriger le projectile
//pour qu'il puisse etre envoye dans les lignes du bas et haut.
for(int i = 0; i < 5 && IsEnemyDetected; i++)
{
Invoke("ShootInterval", 0.1f);
if(Enemy.Hp <= 0) IsEnemyDetected = false;
}
AttackSpeedWait = 0f;
@ -47,4 +56,9 @@ public class Castle : Building
AttackSpeedWait += Time.deltaTime;
}
void ShootInterval()
{
_root.ShotProjectile();
}
}

View File

@ -68,7 +68,7 @@ public class AnimationEntity : MonoBehaviour
public void PlayAttackAnim()
{
if(!_isDead) {
if(!_isDead && _animatorEntity != null) {
_animatorEntity.speed = AttackSpeedMultiplier;
_animatorEntity.Play("attack", 0, 0f);
entityState = EntityAnimationState.Attacking;