- Updated prefabs

- VampireSquad
	- ZombieSquad
- Removed class
	ZombieSquad
	VampireSquad
- Refactoring
	- Updated Squad.cs
	- Updated Unit.cs
- New functions
	- Now the class unit have new class members
	- The the Squad class have new class members and functions
This commit is contained in:
samJa 2015-08-20 14:01:28 -04:00
parent 8b94ce59c2
commit 3a5294091b
14 changed files with 8635 additions and 2796 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: eaa81b40663d4ca4e982795d1d9488e2 guid: 399d6675ad4fa384096256e051a3e131
timeCreated: 1439652863 timeCreated: 1440093571
licenseType: Free licenseType: Free
NativeFormatImporter: NativeFormatImporter:
userData: userData:

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 67442489137253e408a13ecfab4b5e3b guid: 7f5390bf3f9aa514eac25888e0bd7723
timeCreated: 1439652861 timeCreated: 1440093567
licenseType: Free licenseType: Free
NativeFormatImporter: NativeFormatImporter:
userData: userData:

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ public class CharacterBehavior : MonoBehaviour
private CapsuleCollider _col; private CapsuleCollider _col;
private Rigidbody _rb; private Rigidbody _rb;
// LerpSpeed vector // CapturedLerpSpeed vector
private Vector3 _velocity; private Vector3 _velocity;
// origin collider height // origin collider height
// //

View File

@ -7,68 +7,196 @@ using System.Linq;
public class Squad : Unit public class Squad : Unit
{ {
#region class members #region class members
public float TimeBetweenAttacks = 0.5f;
public string TeamTag;
/// <summary> /// <summary>
/// List of non attackable units. /// List of non attackable units.
/// </summary> /// </summary>
private List<Unit> _humans; public List<Unit> Humans;
/// <summary> /// <summary>
/// List of attackable units. /// List of attackable units.
/// </summary> /// </summary>
private List<Squad> _soldiers; public List<Squad> Soldiers;
/// <summary> private bool _playerInRange;
/// List of abandonned units. (this list is accessible for both teams) private Squad _enemySquad;
/// </summary> private float _timer;
private List<Unit> _abandonnedUnits;
/// <summary>
/// Index of the first soldier in the list.
/// </summary>
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;
private int _numberOfAliveSoldiers;
#endregion #endregion
#region Unity functions
// Use this for initialization // Use this for initialization
void Awake () void Start ()
{ {
_humans = new List<Unit>(); Humans = new List<Unit>();
_soldiers = new List<Squad>(); Soldiers = new List<Squad>();
_abandonnedUnits = new List<Unit>();
InitializeSquad();
InitializeDefaultTagAndLayer();
CurrentHP = ComputeTotalHp();
// Debug.Log("Current Zomb HP " + CurrentHP);
Attack = ComputeAttackDamage();
_numberOfAliveSoldiers = ComputeNumberOfAliveSoldiers();
_enemySquad = null;
_timer = 0f;
} }
//void Awake()
//{
/* InitializeSquad();
InitializeDefaultTagAndLayer();
CurrentHP = 255;
Debug.Log("Current HP" + CurrentHP) ;
Attack = ComputeAttackDamage();
_enemySquad = null;
_timer = 0f;*/
//}
// Update is called once per frame // Update is called once per frame
void Update () void Update ()
{ {
CurrentHP = ComputeTotalHp();
_numberOfAliveSoldiers = ComputeNumberOfAliveSoldiers();
_timer += Time.deltaTime;
if (_timer >= TimeBetweenAttacks && _playerInRange && !IsDead)
{
AttackEnemySquad(_enemySquad);
}
// 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)
{ if (_numberOfAliveSoldiers > 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();
IsDead = true; IsDead = true;
} }
void OnTriggerEnter(Collider collider)
{
if (IsDead) return;
//var objectTag = collider.gameObject;
// check if the game object have an attached Unit class
//switch(objectTag.GetType())
var unitComponent = collider.GetComponent<Unit>();
if (unitComponent == null)
return;
// check if the unit is not a friendly one
if (this.Tag == unitComponent.Tag)
return;
if (unitComponent.Tag.Equals(TagLayerManager.Human))
{
if (unitComponent.IsCaptured)
{
return;
}
else
{
CaptureHuman(unitComponent);
}
}
else // we know that it's an enemy
{
if (unitComponent.IsDead)
return;
_playerInRange = true;
_enemySquad = collider.GetComponent<Squad>();
/* try
{
AttackEnemySquad(unitComponent as Squad);
}
catch (InvalidCastException exception)
{
Debug.LogError(exception.ToString());
//throw;
}*/
}
} }
void OnTriggerExit(Collider collider)
{
if (collider.gameObject.tag != Tag && collider.gameObject.tag != TagLayerManager.Human)
{
_playerInRange = false;
this.gameObject.GetComponent<CharacterBehavior>().PlayAttackAnimation(false);
_enemySquad = null;
// collider.GetComponent<CharacterBehavior>().PlayAttackAnimation(false);
}
}
#endregion
#region squad related functions #region squad related functions
public int ComputeNumberOfAliveSoldiers()
{
// LINQ + Resharper FTW!!!!!
return Soldiers.Count(soldier => !soldier.IsDead);
}
/// <summary> /// <summary>
/// Assign the corresponding squad tag to each soldiers. /// Assign the corresponding squad tag to each soldiers.
/// </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>());
}
}
private void InitializeDefaultTagAndLayer()
{
try
{
if (this.TeamTag.Length == 0)
{
this.Tag = TagLayerManager.VampirePlayer;
this.Layer = TagLayerManager.VampireLayerIndex;
}
else
{
if (Tag.Equals(TagLayerManager.VampirePlayer))
{
this.Tag = TagLayerManager.VampirePlayer; // set the tag to player 1
this.Layer = TagLayerManager.VampireLayerIndex;
}
else
{
this.Tag = TagLayerManager.ZombiePlayer; // set the tag to player 2
this.Layer = TagLayerManager.ZombieLayerIndex;
}
}
}
catch (IndexOutOfRangeException ex)
{
Debug.LogError("Please set a vampire Tag, check the Tag & layers in the inspector!\n" + ex);
}
// set the tag and the layer of the gameObject to vampire
if (this.gameObject.tag != Tag)
{
this.gameObject.tag = Tag;
}
if (this.gameObject.layer != Layer)
{
this.gameObject.layer = Layer;
} }
} }
@ -78,36 +206,17 @@ 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>
/// Add the human unit in the abandonned unit list. /// Add the human unit in the abandoned unit list.
/// </summary> /// </summary>
/// <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)
{ {
soldierUnit.IsCaptured = false; soldierUnit.IsCaptured = false;
_soldiers.Add(soldierUnit); Soldiers.Add(soldierUnit);
}
/// <summary>
/// Add the human unit in the abandonned unit list.
/// </summary>
/// <param name="humanUnit">the human to add in the abandonned unit list</param>
void AddAbandonnedHuman(Unit humanUnit)
{
humanUnit.IsCaptured = false;
_abandonnedUnits.Add(humanUnit);
}
/// <summary>
/// Remove the human unit from the abandonned unit list.
/// </summary>
/// <param name="humanUnit">the human unit to remove</param>
void RemoveAbandonnedHuman(Unit humanUnit)
{
_abandonnedUnits.Remove(humanUnit);
} }
/// <summary> /// <summary>
@ -118,11 +227,11 @@ public class Squad : Unit
public void HealSquad(Unit humanUnit) public void HealSquad(Unit humanUnit)
{ {
var percentageOfHpToHeal = ( humanUnit.Hp / _soldiers.Count ); var percentageOfHpToHeal = ( humanUnit.CurrentHP / Soldiers.Count );
foreach (var soldier in _soldiers) foreach (var soldier in Soldiers)
{ {
soldier.Hp += soldier.Hp * ( 1 + percentageOfHpToHeal ); soldier.CurrentHP += soldier.CurrentHP * ( 1 + percentageOfHpToHeal );
} }
humanUnit.GetComponent<CharacterBehavior>().PlayFetchedAnimation(); humanUnit.GetComponent<CharacterBehavior>().PlayFetchedAnimation();
@ -136,26 +245,28 @@ 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 // retrieve the human at the specified index
var humanUnit = _humans.ElementAt(i); var humanUnit = Humans.ElementAt(i);
// reassign the human attributes // reassign the human attributes
humanUnit.Tag = TagLayerManager.Human; humanUnit.Tag = TagLayerManager.Human;
humanUnit.Layer = TagLayerManager.HumanLayerIndex; humanUnit.Layer = TagLayerManager.HumanLayerIndex;
humanUnit.gameObject.GetComponent<Rigidbody>().useGravity = true; humanUnit.gameObject.GetComponent<Rigidbody>().useGravity = true;
// add the human to the abandonned Unit list // add the human to the abandoned Unit list
AddAbandonnedHuman(humanUnit); humanUnit.IsCaptured = false;
// remove the human from the humandUnit that was added to the abandonned unit list Debug.Log(string.Format("{0} has abandoned the unit {1}", this.gameObject.name, humanUnit.gameObject.name));
// remove the human from the humandUnit that was added to the abandoned unit list
RemoveHuman(humanUnit); RemoveHuman(humanUnit);
} }
} }
else else
{ {
Debug.LogError("Exceded the maximum numbers of units in the humans list!"); Debug.LogError("Exceeded the maximum numbers of units in the humans list!");
} }
} }
@ -165,7 +276,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>
@ -174,7 +285,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>
@ -183,12 +294,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 // retrieve 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);
@ -196,8 +307,9 @@ public class Squad : Unit
// set the human tag to the same as the squad // set the human tag to the same as the squad
humanUnit.Tag = Tag; humanUnit.Tag = Tag;
AddSoldier(humanUnit as Squad);
// AddSoldier((VampireSquad) humanUnit) ) (VampireSquad or ZombieSquad) // AddSoldier((VampireSquad) humanUnit) ) (VampireSquad or ZombieSquad)
if (Tag.Equals(TagLayerManager.VampirePlayer)) /*if (Tag.Equals(TagLayerManager.VampirePlayer))
{ {
// add the vampire to the soldier list // add the vampire to the soldier list
AddSoldier((VampireSquad) humanUnit); AddSoldier((VampireSquad) humanUnit);
@ -206,12 +318,12 @@ public class Squad : Unit
{ {
// add the zombie to the soldier list // add the zombie to the soldier list
AddSoldier((ZombieSquad)humanUnit); AddSoldier((ZombieSquad)humanUnit);
} }*/
} }
} }
else else
{ {
Debug.LogError("Exceded the maximum nb of humans in the humans list!"); Debug.LogError("Exceeded the maximum number of humans in the humans list!");
} }
} }
@ -219,10 +331,12 @@ 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
foreach (var soldier in _soldiers) foreach (var soldier in Soldiers)
{ {
soldier.Hp -= amountOfDamage; //soldier.CurrentHP -= amountOfDamage;
soldier.TakeDamage(amountOfDamage);
Debug.Log(string.Format("{0} received {1} damage!", soldier.name, amountOfDamage)); Debug.Log(string.Format("{0} received {1} damage!", soldier.name, amountOfDamage));
Debug.Log(string.Format("{0} remaining hp : {1}", soldier.name, soldier.CurrentHP));
} }
} }
@ -241,39 +355,54 @@ public class Squad : Unit
protected void AttackEnemySquad(Squad targettedEnemySquad) protected void AttackEnemySquad(Squad targettedEnemySquad)
{ {
_timer = 0f;
if (targettedEnemySquad.CurrentHP > 0)
{
foreach (var soldier in Soldiers)
{
soldier.GetComponent<CharacterBehavior>().PlayAttackAnimation(true);
}
targettedEnemySquad.ReceiveDamage(ComputeAttackDamage());
Debug.Log(string.Format("{0} Attacked the enemy : {1} ", this.gameObject.name, targettedEnemySquad.gameObject.name));
}
else
{
foreach (var soldier in Soldiers)
{
soldier.GetComponent<CharacterBehavior>().PlayAttackAnimation(false);
}
}
//TODO improve this method add the total of squad damage or to compute the reduce of hp, etc... //TODO improve this method add the total of squad damage or to compute the reduce of hp, etc...
// compute the amount of hp reduced to this unit // compute the amount of hp reduced to this unit
//unit.Hp -= Attack; // we remove some hp of the unit that was //unit.Hp -= Attack; // we remove some hp of the unit that was
targettedEnemySquad.ReceiveDamage(ComputeAttackDamage()); // targettedEnemySquad.ReceiveDamage(ComputeAttackDamage());
Debug.Log("Attacked the enemy : " + targettedEnemySquad.Tag);
} }
/// <summary> /// <summary>
/// Compute to attack damage depending of the numbers of soldiers in the squad. /// Compute to attack damage depending of the numbers of soldiers in the squad.
/// </summary> /// </summary>
/// <returns>the damage to apply to each enemy soldiers units</returns> /// <returns>the damage to apply to each enemy soldiers units</returns>
int ComputeAttackDamage() protected int ComputeAttackDamage()
{ {
// LINQ + Resharper FTW!!!!! // LINQ + Resharper FTW!!!!!
var sumOfAttack = _soldiers.Sum(soldier => soldier.Attack); var sumOfAttack = Soldiers.Sum(soldier => soldier.Attack);
return ( 1 + (sumOfAttack / _soldiers.Count)); return ( 1 + (sumOfAttack / Soldiers.Count));
}
protected int ComputeTotalHp()
{
var sumOfHp = Soldiers.Sum(x => x.CurrentHP);
return sumOfHp;
} }
#endregion #endregion
#region squad accessors and mutators #region squad accessors and mutators
/// <summary>
/// Return the list of the abandonned units to the ennemy team
/// </summary>
/// <returns></returns>
public List<Unit> GetAbandonnedUnits()
{
return _abandonnedUnits;
}
#endregion #endregion
} }

View File

@ -3,25 +3,32 @@ using UnityEngine;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
using UnityEngine.UI;
public class Unit : MonoBehaviour public class Unit : MonoBehaviour
{ {
public int defaultHp = 250; public int StartingHealth = 250;
public int defaultAttack = 100; public int StartingAttack = 100;
public float LerpSpeed = 1; public Slider HealthSlider;
public int destinationGap = 5; public float CapturedLerpSpeed = 1;
public int DestinationGap = 5;
public float DyingTime = 1.0f; public float DyingTime = 1.0f;
public AudioClip DeathClip;
private LinkedList<Command> commandList; private LinkedList<Command> commandList;
private int _hp; // the unit hp private int _currentHp; // the unit hp
private CharacterBehavior _character; private CharacterBehavior _character;
private bool isDamaged;
// Use this for initialization // Use this for initialization
void Start () void Awake ()
{ {
IsCaptured = false; IsCaptured = false;
Hp = defaultHp; CurrentHP = StartingHealth;
Attack = defaultAttack; // Debug.Log("Current Human HP: " + CurrentHP);
Attack = StartingAttack;
// initialize default specie // initialize default specie
Tag = TagLayerManager.Human; Tag = TagLayerManager.Human;
Layer = TagLayerManager.HumanLayerIndex; Layer = TagLayerManager.HumanLayerIndex;
@ -31,15 +38,15 @@ public class Unit : MonoBehaviour
void Update() void Update()
{ {
if (IsDead) /* if (IsDead)
{ {
DestroyUnit(DyingTime); DestroyUnit(DyingTime);
} }*/
else if (IsCaptured) if (IsCaptured)
{ {
var gapVector = new Vector3(TargetDestination.position.x + destinationGap, TargetDestination.position.y,TargetDestination.position.z + destinationGap); var gapVector = new Vector3(TargetDestination.position.x + DestinationGap, TargetDestination.position.y,TargetDestination.position.z + DestinationGap);
// TODO improve the translation position so that every unit captured are around the squad leader and not at only one position. // TODO improve the translation position so that every unit captured are around the squad leader and not at only one position.
transform.position = Vector3.Lerp(transform.position, gapVector, LerpSpeed * 3.0f * Time.deltaTime); transform.position = Vector3.Lerp(transform.position, gapVector, CapturedLerpSpeed * 3.0f * Time.deltaTime);
//See more at: http://unitydojo.blogspot.ca/2014/03/how-to-use-lerp-in-unity-like-boss.html#sthash.ueWlstRk.dpuf*/ //See more at: http://unitydojo.blogspot.ca/2014/03/how-to-use-lerp-in-unity-like-boss.html#sthash.ueWlstRk.dpuf*/
_character.PlayCaptureAnimation(IsCaptured); _character.PlayCaptureAnimation(IsCaptured);
} }
@ -47,6 +54,34 @@ public class Unit : MonoBehaviour
{ {
_character.PlayCaptureAnimation(IsCaptured); _character.PlayCaptureAnimation(IsCaptured);
} }
isDamaged = false;
}
public void TakeDamage(int amountOfDamage)
{
isDamaged = true;
CurrentHP -= amountOfDamage;
// HealthSlider.value = CurrentHP;
// TODO play hurt animation
// TODO play hurt sound
if (CurrentHP <= 0 && !IsDead)
{
Death();
}
}
public void Death()
{
IsDead = true;
_character.PlayDeathAnimation();
// TODO play death sound
// TODO disable this gameobject movements.
Debug.Log("Entered death function!");
StartCoroutine(DestroyUnit(DyingTime));
} }
/// <summary> /// <summary>
@ -69,30 +104,32 @@ public class Unit : MonoBehaviour
protected IEnumerator DestroyUnit(float dyingTime) protected IEnumerator DestroyUnit(float dyingTime)
{ {
//TODO First play dead animation //TODO First play dead animation
// retreive the character behavior object, so that we can access it's animation properties... // retrieve the character behavior object, so that we can access it's animation properties...
var character = GetComponent<CharacterBehavior>(); //var character = GetComponent<CharacterBehavior>();
// play the death animation // play the death animation
character.PlayDeathAnimation(); //character.PlayDeathAnimation();
yield return new WaitForSeconds(character.CurrrentAnimationLength()); yield return new WaitForSeconds(_character.CurrrentAnimationLength());
// then destroy the game object only 3 seconds after the animation // then destroy the game object only 3 seconds after the animation
Destroy(this.transform.gameObject, dyingTime); //Destroy(this.transform.gameObject, dyingTime);
} }
#region Unit properties #region Unit properties
public bool IsCaptured { get; set; } public bool IsCaptured { get; set; }
public int Hp public int CurrentHP
{ {
get { return _hp; } get { return _currentHp; }
set set
{ {
_hp = value > defaultHp ? defaultHp : value; _currentHp = value > StartingHealth ? StartingHealth : value;
if (Hp <= 0) /* if (CurrentHP <= 0)
{ {
//IsDead = true; IsDead = true;
StartCoroutine(DestroyUnit(DyingTime)); StartCoroutine(DestroyUnit(DyingTime));
} }*/
} }
} }

View File

@ -1,111 +0,0 @@
using System;
using UnityEngine;
using System.Collections;
/// <summary>
/// This class contains the information of the Vampire Units.
/// </summary>
public class VampireSquad : Squad
{
// Use this for initialization
void Start ()
{
InitializeSquad();
InitializeDefaultTagAndLayer();
// initialize default hp
//Hp = defaultHp;
// initialize default attack
Attack = defaultAttack;
// initialize default team
// initialize default specie
IsDead = false;
}
// Update is called once per frame
void Update ()
{
if (IsDead)
{
// TODO play dead animation before destroying unit
DestroyUnit(DyingTime);
}
}
private void InitializeDefaultTagAndLayer()
{
try
{
this.Tag = TagLayerManager.VampirePlayer; // set the tag to player 1
this.Layer = TagLayerManager.VampireLayerIndex;
}
catch (IndexOutOfRangeException ex)
{
Debug.LogError( "Please set a vampire Tag, check the Tag & layers in the inspector!\n" + ex );
}
// set the tag and the layer of the gameObject to vampire
if (this.gameObject.tag != Tag)
{
this.gameObject.tag = Tag;
}
if (this.gameObject.layer != Layer)
{
this.gameObject.layer = Layer;
}
}
/*void CaptureHuman(Unit unit)
{
// TODO either add the human as a squad member or change it's tag to vampireHuman
// when the player is transformed we just make VampireSquad vampireUnit2 = (VampireSquad) unit;
Debug.Log("Entered in collision with: " + unit.Tag );
}*/
/* void AttackEnemySquad(Unit unit)
{
//TODO improve this method to compute the reduce of hp, etc...
// compute the amount of hp reduced to this unit
unit.Hp -= Attack; // we remove some hp of the unit that was
Debug.Log("Attacked the ennemy : " + unit.Tag);
}*/
void OnTriggerEnter(Collider collider)
{
//var objectTag = collider.gameObject;
// check if the game object have an attached Unit class
//switch(objectTag.GetType())
var unitComponent = collider.GetComponent<Unit>();
if (unitComponent == null)
return;
// check if the unit is not a friendly one
if (this.Tag == unitComponent.Tag)
return;
if (unitComponent.Tag.Equals(TagLayerManager.Human))
{
if (unitComponent.IsCaptured)
{
return;
}
else
{
CaptureHuman(unitComponent);
}
}
else // we know that it's an ennemy
{
try
{
AttackEnemySquad(unitComponent as Squad);
}
catch (InvalidCastException exception)
{
Debug.LogError(exception.ToString());
//throw;
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: c1cd93867b8a1d7459a4fb92cac63854
timeCreated: 1439305303
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,103 +0,0 @@
using System;
using UnityEngine;
using System.Collections;
/// <summary>
/// This class contains the information of the Vampire Units.
/// </summary>
public class ZombieSquad : Squad
{
// Use this for initialization
void Start()
{
InitializeSquad();
InitializeDefaultTagAndLayer();
// initialize default hp
//Hp = defaultHp;
// initialize default attack
Attack = defaultAttack;
// initialize default team
// initialize default specie
IsDead = false;
}
// Update is called once per frame
void Update()
{
if (IsDead)
{
// TODO play dead animation before destroying unit
DestroyUnit(DyingTime);
}
}
private void InitializeDefaultTagAndLayer()
{
try
{
this.Tag = TagLayerManager.ZombiePlayer; // set the tag to player 1
this.Layer = TagLayerManager.ZombieLayerIndex;
}
catch (IndexOutOfRangeException ex)
{
Debug.LogError("Please set a vampire Tag, check the Tag & layers in the inspector!\n" + ex);
}
// set the tag and the layer of the gameObject to vampire
if (this.gameObject.tag != Tag)
{
this.gameObject.tag = Tag;
}
if (this.gameObject.layer != Layer)
{
this.gameObject.layer = Layer;
}
}
/*void CaptureHuman(Unit unit)
{
// TODO either add the human as a squad member or change it's tag to vampireHuman
// when the player is transformed we just make VampireSquad vampireUnit2 = (VampireSquad) unit;
Debug.Log("Entered in collision with: " + unit.Tag);
}*/
/*void AttackEnemySquad(Unit unit)
{
// compute the amount of hp reduced to this unit
unit.Hp -= Attack; // we remove some hp of the unit that was
Debug.Log("Attacked the ennemy : " + unit.Tag);
}*/
void OnTriggerEnter(Collider collider)
{
//var objectTag = collider.gameObject;
// check if the game object have an attached Unit class
//switch(objectTag.GetType())
var unitComponent = collider.GetComponent<Unit>();
if (unitComponent == null)
return;
// check if the unit is not a friendly one
if (this.Tag == unitComponent.Tag)
return;
if (unitComponent.Tag.Equals(TagLayerManager.Human))
{
CaptureHuman(unitComponent);
}
else // we know that it's an ennemy
{
try
{
AttackEnemySquad(unitComponent as Squad);
}
catch (InvalidCastException exception)
{
Debug.LogError(exception.ToString());
//throw;
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 9346fd84c59bd7d42a27381aeed17dbf
timeCreated: 1439305314
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -77,6 +77,7 @@ PlayerSettings:
metroEnableIndependentInputSource: 0 metroEnableIndependentInputSource: 0
metroEnableLowLatencyPresentationAPI: 0 metroEnableLowLatencyPresentationAPI: 0
xboxOneDisableKinectGpuReservation: 0 xboxOneDisableKinectGpuReservation: 0
virtualRealitySupported: 0
productGUID: 54ead80470c104b4682c53a4f7f867b5 productGUID: 54ead80470c104b4682c53a4f7f867b5
AndroidBundleVersionCode: 1 AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 9 AndroidMinSdkVersion: 9
@ -254,7 +255,6 @@ PlayerSettings:
psp2InfoBarOnStartup: 0 psp2InfoBarOnStartup: 0
psp2InfoBarColor: 0 psp2InfoBarColor: 0
psmSplashimage: {fileID: 0} psmSplashimage: {fileID: 0}
virtualRealitySupported: 0
spritePackerPolicy: spritePackerPolicy:
scriptingDefineSymbols: {} scriptingDefineSymbols: {}
metroPackageName: VZ metroPackageName: VZ

View File

@ -1,2 +1,2 @@
m_EditorVersion: 5.1.0f3 m_EditorVersion: 5.1.2f1
m_StandardAssetsVersion: 0 m_StandardAssetsVersion: 0