- Upgraded the AttackSquad functions

- Upgraded the default positions of the prefabs : Zombie and Vampire
This commit is contained in:
Samuel 2015-08-13 15:25:55 -04:00
parent 6152a68a3d
commit 93f8868ba1
4 changed files with 133 additions and 60 deletions

View File

@ -29,7 +29,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 159974} m_GameObject: {fileID: 159974}
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: 5, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
@ -140,7 +140,11 @@ Prefab:
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: [] m_Modifications:
- target: {fileID: 0}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 0} m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 159974} m_RootGameObject: {fileID: 159974}

View File

@ -29,7 +29,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 196328} m_GameObject: {fileID: 196328}
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: 5, z: 41.8800011} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
@ -140,7 +140,15 @@ Prefab:
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: [] m_Modifications:
- target: {fileID: 0}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 0} m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 196328} m_RootGameObject: {fileID: 196328}

View File

@ -87,6 +87,78 @@ NavMeshSettings:
cellSize: .166666672 cellSize: .166666672
manualCellSize: 0 manualCellSize: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1001 &151831733
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_LocalPosition.x
value: 15
objectReference: {fileID: 0}
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_LocalPosition.y
value: 5
objectReference: {fileID: 0}
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 159974, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_Name
value: Human
objectReference: {fileID: 0}
- target: {fileID: 159974, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_TagString
value: Human
objectReference: {fileID: 0}
- target: {fileID: 2386094, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_RemovedComponents:
- {fileID: 11449880, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
m_ParentPrefab: {fileID: 100100000, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
m_IsPrefabParent: 0
--- !u!1 &151831734 stripped
GameObject:
m_PrefabParentObject: {fileID: 159974, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
m_PrefabInternal: {fileID: 151831733}
--- !u!114 &151831735
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 151831734}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8a1ccd1ad32d6bc4fb600c5b5720e01c, type: 3}
m_Name:
m_EditorClassIdentifier:
defaultHp: 250
defaultAttack: 100
--- !u!1 &272569008 --- !u!1 &272569008
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -171,7 +243,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 1
--- !u!1 &550371263 --- !u!1 &550371263
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -231,7 +303,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 2
--- !u!1001 &1196959011 --- !u!1001 &1196959011
Prefab: Prefab:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -249,7 +321,7 @@ Prefab:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 417792, guid: 8d6d640df84c10549b99d9ccf6b349d9, type: 2} - target: {fileID: 417792, guid: 8d6d640df84c10549b99d9ccf6b349d9, type: 2}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 41.8800011 value: 40.7999992
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 417792, guid: 8d6d640df84c10549b99d9ccf6b349d9, type: 2} - target: {fileID: 417792, guid: 8d6d640df84c10549b99d9ccf6b349d9, type: 2}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
@ -269,7 +341,7 @@ Prefab:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 417792, guid: 8d6d640df84c10549b99d9ccf6b349d9, type: 2} - target: {fileID: 417792, guid: 8d6d640df84c10549b99d9ccf6b349d9, type: 2}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 4 value: 5
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 8d6d640df84c10549b99d9ccf6b349d9, type: 2} m_ParentPrefab: {fileID: 100100000, guid: 8d6d640df84c10549b99d9ccf6b349d9, type: 2}
@ -311,7 +383,11 @@ Prefab:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2} - target: {fileID: 421072, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 3 value: 4
objectReference: {fileID: 0}
- target: {fileID: 11449880, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
propertyPath: defaultHp
value: 10050
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2} m_ParentPrefab: {fileID: 100100000, guid: 55aad163f90cc4e40b686a69ba29569d, type: 2}
@ -385,7 +461,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 3
--- !u!1 &1740025638 --- !u!1 &1740025638
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -397,7 +473,6 @@ GameObject:
- 33: {fileID: 1740025642} - 33: {fileID: 1740025642}
- 65: {fileID: 1740025641} - 65: {fileID: 1740025641}
- 23: {fileID: 1740025640} - 23: {fileID: 1740025640}
- 114: {fileID: 1740025639}
m_Layer: 0 m_Layer: 0
m_Name: Cube m_Name: Cube
m_TagString: Untagged m_TagString: Untagged
@ -405,19 +480,6 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 0
--- !u!114 &1740025639
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1740025638}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 03db9d7aaef4ee545971f18bb90ceadb, type: 3}
m_Name:
m_EditorClassIdentifier:
defaultHp: 250
defaultAttack: 100
--- !u!23 &1740025640 --- !u!23 &1740025640
MeshRenderer: MeshRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -472,4 +534,4 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 5 m_RootOrder: 6

View File

@ -11,12 +11,12 @@ public class Squad : Unit
/// <summary> /// <summary>
/// List of non attackable units. /// List of non attackable units.
/// </summary> /// </summary>
private List<Unit> humans; private List<Unit> _humans;
/// <summary> /// <summary>
/// List of attackable units. /// List of attackable units.
/// </summary> /// </summary>
private List<Squad> soldiers; private List<Squad> _soldiers;
/// <summary> /// <summary>
/// List of abandonned units. (this list is accessible for both teams) /// List of abandonned units. (this list is accessible for both teams)
@ -26,20 +26,20 @@ public class Squad : Unit
/// <summary> /// <summary>
/// Index of the first soldier in the list. /// Index of the first soldier in the list.
/// </summary> /// </summary>
private int targetSoldierIndex; private int squadLeaderPosition;
/// <summary> /// <summary>
/// The tag to assign for each soldiers in the squad /// The tag to assign for each soldiers in the squad
/// </summary> /// </summary>
protected String squadTag; //protected String SquadTag;
#endregion #endregion
// Use this for initialization // Use this for initialization
void Awake () void Awake ()
{ {
humans = new List<Unit>(); _humans = new List<Unit>();
soldiers = new List<Squad>(); _soldiers = new List<Squad>();
} }
// Update is called once per frame // Update is called once per frame
@ -48,9 +48,9 @@ public class Squad : Unit
// TODO execute movement command // TODO execute movement command
// TODO Check if all the units are dead // TODO Check if all the units are dead
// if yes destroy // if yes destroy
if (soldiers.Count != 0) return; if (_soldiers.Count != 0) return;
// first release all humans ... // first release all humans ...
AbandonUnits(humans.Count); AbandonUnits(_humans.Count);
// then we destroy the squad // then we destroy the squad
DestroyUnit(); DestroyUnit();
} }
@ -61,9 +61,9 @@ public class Squad : Unit
/// </summary> /// </summary>
protected void InitializeSquad() protected void InitializeSquad()
{ {
if (soldiers.Count == 0) if (_soldiers.Count == 0)
{ {
this.soldiers.Add(this.gameObject.GetComponent<Squad>()); this._soldiers.Add(this.gameObject.GetComponent<Squad>());
} }
} }
@ -73,7 +73,7 @@ public class Squad : Unit
/// <param name="humanUnit">the human unit to add in the human unit list</param> /// <param name="humanUnit">the human unit to add in the human unit list</param>
void AddHuman(Unit humanUnit) void AddHuman(Unit humanUnit)
{ {
humans.Add(humanUnit); _humans.Add(humanUnit);
} }
/// <summary> /// <summary>
@ -82,7 +82,7 @@ public class Squad : Unit
/// <param name="soldierUnit">the soldier unit to add in the soldier unit list</param> /// <param name="soldierUnit">the soldier unit to add in the soldier unit list</param>
void AddSoldier(Squad soldierUnit) void AddSoldier(Squad soldierUnit)
{ {
soldiers.Add(soldierUnit); _soldiers.Add(soldierUnit);
} }
/// <summary> /// <summary>
@ -111,9 +111,9 @@ public class Squad : Unit
public void HealSquad(Unit humanUnit) public void HealSquad(Unit humanUnit)
{ {
var percentageOfHpToHeal = ( humanUnit.Hp / soldiers.Count ); var percentageOfHpToHeal = ( humanUnit.Hp / _soldiers.Count );
foreach (var soldier in soldiers) foreach (var soldier in _soldiers)
{ {
soldier.Hp += soldier.Hp * ( 1 + percentageOfHpToHeal ); soldier.Hp += soldier.Hp * ( 1 + percentageOfHpToHeal );
} }
@ -128,12 +128,12 @@ public class Squad : Unit
/// <param name="nbUnits">The number of units to abandon</param> /// <param name="nbUnits">The number of units to abandon</param>
public void AbandonUnits(int nbUnits) public void AbandonUnits(int nbUnits)
{ {
if (nbUnits <= humans.Count) if (nbUnits <= _humans.Count)
{ {
for (var i = 0; i < nbUnits; i++) for (var i = 0; i < nbUnits; i++)
{ {
// retreive the human at the specified index // retreive the human at the specified index
var humanUnit = humans.ElementAt(i); var humanUnit = _humans.ElementAt(i);
// add the human to the abandonned Unit list // add the human to the abandonned Unit list
AddAbandonnedHuman(humanUnit); AddAbandonnedHuman(humanUnit);
// remove the human from the humandUnit that was added to the abandonned unit list // remove the human from the humandUnit that was added to the abandonned unit list
@ -152,7 +152,7 @@ public class Squad : Unit
/// <param name="soldierUnit">the corresponding soldier that we want to remove</param> /// <param name="soldierUnit">the corresponding soldier that we want to remove</param>
void RemoveSoldier(Squad soldierUnit) void RemoveSoldier(Squad soldierUnit)
{ {
soldiers.Remove(soldierUnit); _soldiers.Remove(soldierUnit);
} }
/// <summary> /// <summary>
@ -161,7 +161,7 @@ public class Squad : Unit
/// <param name="humanUnit">the corresponding human that we want to remove</param> /// <param name="humanUnit">the corresponding human that we want to remove</param>
void RemoveHuman(Unit humanUnit) void RemoveHuman(Unit humanUnit)
{ {
humans.Remove(humanUnit); _humans.Remove(humanUnit);
} }
/// <summary> /// <summary>
@ -170,12 +170,12 @@ public class Squad : Unit
/// <param name="nbHumans">the number of humans to transform</param> /// <param name="nbHumans">the number of humans to transform</param>
public void TransformHuman(int nbHumans) public void TransformHuman(int nbHumans)
{ {
if (nbHumans <= humans.Count) if (nbHumans <= _humans.Count)
{ {
for (var i = 0; i < nbHumans; i++) for (var i = 0; i < nbHumans; i++)
{ {
// retreive the human at the specified index // retreive the human at the specified index
var humanUnit = humans.ElementAt(i); var humanUnit = _humans.ElementAt(i);
// remove the human from the human list // remove the human from the human list
RemoveHuman(humanUnit); RemoveHuman(humanUnit);
@ -184,7 +184,7 @@ public class Squad : Unit
humanUnit.Tag = Tag; humanUnit.Tag = Tag;
// AddSoldier((VampireSquad) humanUnit) ) (VampireSquad or ZombieSquad) // AddSoldier((VampireSquad) humanUnit) ) (VampireSquad or ZombieSquad)
if (squadTag.Equals(TagManager.VampirePlayer)) if (Tag.Equals(TagManager.VampirePlayer))
{ {
// add the vampire to the soldier list // add the vampire to the soldier list
AddSoldier((VampireSquad) humanUnit); AddSoldier((VampireSquad) humanUnit);
@ -206,14 +206,11 @@ public class Squad : Unit
public void ReceiveDamage(int amountOfDamage) public void ReceiveDamage(int amountOfDamage)
{ {
// apply the damage to the first soldier in the list // apply the damage to the first soldier in the list
// update the soldier hp foreach (var soldier in _soldiers)
// if the soldier hp reach zero {
// the soldier is destroyed soldier.Hp -= amountOfDamage;
// and then dead soldier is removed in the soldier list Debug.Log(string.Format("{0} received {1} damage!", soldier.name, amountOfDamage));
var topSoldier = soldiers.ElementAt(0); }
topSoldier.Hp -= amountOfDamage;
Debug.Log(string.Format("{0} received {1} damage!",topSoldier.name, amountOfDamage));
} }
void CaptureHuman(Unit unit) void CaptureHuman(Unit unit)
@ -233,10 +230,16 @@ public class Squad : Unit
Debug.Log("Attacked the ennemy : " + targettedEnemySquad.Tag); Debug.Log("Attacked the ennemy : " + targettedEnemySquad.Tag);
} }
/// <summary>
/// Compute to attack damage depending of the numbers of soldiers in the squad.
/// </summary>
/// <returns>the damage to apply to each enemy soldiers units</returns>
int ComputeAttackDamage() int ComputeAttackDamage()
{ {
// TODO improve the damage algorithm depending of the number of units in the soldiers list. // LINQ + Resharper FTW!!!!!
return Attack; var sumOfAttack = _soldiers.Sum(soldier => soldier.Attack);
return ( 1 + (sumOfAttack / _soldiers.Count));
} }
#endregion #endregion
@ -253,9 +256,5 @@ public class Squad : Unit
return abandonnedUnits; return abandonnedUnits;
} }
public int NumberOfSoldiers()
{
return soldiers.Count();
}
#endregion #endregion
} }