mirror of
https://github.com/ConjureETS/VZ.git
synced 2026-03-24 02:11:15 +00:00
- 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:
parent
8b94ce59c2
commit
3a5294091b
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaa81b40663d4ca4e982795d1d9488e2
|
||||
timeCreated: 1439652863
|
||||
guid: 399d6675ad4fa384096256e051a3e131
|
||||
timeCreated: 1440093571
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67442489137253e408a13ecfab4b5e3b
|
||||
timeCreated: 1439652861
|
||||
guid: 7f5390bf3f9aa514eac25888e0bd7723
|
||||
timeCreated: 1440093567
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,7 @@ public class CharacterBehavior : MonoBehaviour
|
||||
|
||||
private CapsuleCollider _col;
|
||||
private Rigidbody _rb;
|
||||
// LerpSpeed vector
|
||||
// CapturedLerpSpeed vector
|
||||
private Vector3 _velocity;
|
||||
// origin collider height
|
||||
//
|
||||
|
||||
@ -7,68 +7,196 @@ using System.Linq;
|
||||
public class Squad : Unit
|
||||
{
|
||||
#region class members
|
||||
|
||||
public float TimeBetweenAttacks = 0.5f;
|
||||
public string TeamTag;
|
||||
/// <summary>
|
||||
/// List of non attackable units.
|
||||
/// </summary>
|
||||
private List<Unit> _humans;
|
||||
public List<Unit> Humans;
|
||||
|
||||
/// <summary>
|
||||
/// List of attackable units.
|
||||
/// </summary>
|
||||
private List<Squad> _soldiers;
|
||||
public List<Squad> Soldiers;
|
||||
|
||||
/// <summary>
|
||||
/// List of abandonned units. (this list is accessible for both teams)
|
||||
/// </summary>
|
||||
private List<Unit> _abandonnedUnits;
|
||||
|
||||
/// <summary>
|
||||
/// Index of the first soldier in the list.
|
||||
/// </summary>
|
||||
private int squadLeaderPosition;
|
||||
private bool _playerInRange;
|
||||
private Squad _enemySquad;
|
||||
private float _timer;
|
||||
|
||||
/// <summary>
|
||||
/// The tag to assign for each soldiers in the squad
|
||||
/// </summary>
|
||||
//protected String SquadTag;
|
||||
private int _numberOfAliveSoldiers;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity functions
|
||||
// Use this for initialization
|
||||
void Awake ()
|
||||
void Start ()
|
||||
{
|
||||
_humans = new List<Unit>();
|
||||
_soldiers = new List<Squad>();
|
||||
_abandonnedUnits = new List<Unit>();
|
||||
Humans = new List<Unit>();
|
||||
Soldiers = new List<Squad>();
|
||||
|
||||
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
|
||||
void Update ()
|
||||
{
|
||||
CurrentHP = ComputeTotalHp();
|
||||
_numberOfAliveSoldiers = ComputeNumberOfAliveSoldiers();
|
||||
|
||||
_timer += Time.deltaTime;
|
||||
|
||||
if (_timer >= TimeBetweenAttacks && _playerInRange && !IsDead)
|
||||
{
|
||||
AttackEnemySquad(_enemySquad);
|
||||
}
|
||||
|
||||
// TODO execute movement command
|
||||
// TODO Check if all the units are dead
|
||||
// if yes destroy
|
||||
if (_soldiers.Count == 0)
|
||||
{
|
||||
|
||||
if (_numberOfAliveSoldiers > 0) return;
|
||||
// first release all humans ...
|
||||
AbandonUnits(_humans.Count);
|
||||
AbandonUnits(Humans.Count);
|
||||
// then we destroy the squad
|
||||
//DestroyUnit();
|
||||
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
|
||||
|
||||
public int ComputeNumberOfAliveSoldiers()
|
||||
{
|
||||
// LINQ + Resharper FTW!!!!!
|
||||
return Soldiers.Count(soldier => !soldier.IsDead);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assign the corresponding squad tag to each soldiers.
|
||||
/// </summary>
|
||||
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>
|
||||
void AddHuman(Unit humanUnit)
|
||||
{
|
||||
_humans.Add(humanUnit);
|
||||
Humans.Add(humanUnit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the human unit in the abandonned unit list.
|
||||
/// Add the human unit in the abandoned unit list.
|
||||
/// </summary>
|
||||
/// <param name="soldierUnit">the soldier unit to add in the soldier unit list</param>
|
||||
void AddSoldier(Squad soldierUnit)
|
||||
{
|
||||
soldierUnit.IsCaptured = false;
|
||||
_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);
|
||||
Soldiers.Add(soldierUnit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -118,11 +227,11 @@ public class Squad : Unit
|
||||
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();
|
||||
@ -136,26 +245,28 @@ public class Squad : Unit
|
||||
/// <param name="nbUnits">The number of units to abandon</param>
|
||||
public void AbandonUnits(int nbUnits)
|
||||
{
|
||||
if (nbUnits <= _humans.Count)
|
||||
if (nbUnits <= Humans.Count)
|
||||
{
|
||||
for (var i = 0; i < nbUnits; i++)
|
||||
{
|
||||
// retreive the human at the specified index
|
||||
var humanUnit = _humans.ElementAt(i);
|
||||
// retrieve the human at the specified index
|
||||
var humanUnit = Humans.ElementAt(i);
|
||||
// reassign the human attributes
|
||||
humanUnit.Tag = TagLayerManager.Human;
|
||||
humanUnit.Layer = TagLayerManager.HumanLayerIndex;
|
||||
humanUnit.gameObject.GetComponent<Rigidbody>().useGravity = true;
|
||||
|
||||
// add the human to the abandonned Unit list
|
||||
AddAbandonnedHuman(humanUnit);
|
||||
// remove the human from the humandUnit that was added to the abandonned unit list
|
||||
// add the human to the abandoned Unit list
|
||||
humanUnit.IsCaptured = false;
|
||||
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);
|
||||
}
|
||||
}
|
||||
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>
|
||||
void RemoveSoldier(Squad soldierUnit)
|
||||
{
|
||||
_soldiers.Remove(soldierUnit);
|
||||
Soldiers.Remove(soldierUnit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -174,7 +285,7 @@ public class Squad : Unit
|
||||
/// <param name="humanUnit">the corresponding human that we want to remove</param>
|
||||
void RemoveHuman(Unit humanUnit)
|
||||
{
|
||||
_humans.Remove(humanUnit);
|
||||
Humans.Remove(humanUnit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -183,12 +294,12 @@ public class Squad : Unit
|
||||
/// <param name="nbHumans">the number of humans to transform</param>
|
||||
public void TransformHuman(int nbHumans)
|
||||
{
|
||||
if (nbHumans <= _humans.Count)
|
||||
if (nbHumans <= Humans.Count)
|
||||
{
|
||||
for (var i = 0; i < nbHumans; i++)
|
||||
{
|
||||
// retreive the human at the specified index
|
||||
var humanUnit = _humans.ElementAt(i);
|
||||
// retrieve the human at the specified index
|
||||
var humanUnit = Humans.ElementAt(i);
|
||||
|
||||
// remove the human from the human list
|
||||
RemoveHuman(humanUnit);
|
||||
@ -196,8 +307,9 @@ public class Squad : Unit
|
||||
// set the human tag to the same as the squad
|
||||
humanUnit.Tag = Tag;
|
||||
|
||||
AddSoldier(humanUnit as Squad);
|
||||
// AddSoldier((VampireSquad) humanUnit) ) (VampireSquad or ZombieSquad)
|
||||
if (Tag.Equals(TagLayerManager.VampirePlayer))
|
||||
/*if (Tag.Equals(TagLayerManager.VampirePlayer))
|
||||
{
|
||||
// add the vampire to the soldier list
|
||||
AddSoldier((VampireSquad) humanUnit);
|
||||
@ -206,12 +318,12 @@ public class Squad : Unit
|
||||
{
|
||||
// add the zombie to the soldier list
|
||||
AddSoldier((ZombieSquad)humanUnit);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
// 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} remaining hp : {1}", soldier.name, soldier.CurrentHP));
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,39 +355,54 @@ public class Squad : Unit
|
||||
|
||||
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...
|
||||
// compute the amount of hp reduced to this unit
|
||||
//unit.Hp -= Attack; // we remove some hp of the unit that was
|
||||
targettedEnemySquad.ReceiveDamage(ComputeAttackDamage());
|
||||
|
||||
Debug.Log("Attacked the enemy : " + targettedEnemySquad.Tag);
|
||||
// targettedEnemySquad.ReceiveDamage(ComputeAttackDamage());
|
||||
}
|
||||
|
||||
/// <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()
|
||||
protected int ComputeAttackDamage()
|
||||
{
|
||||
// 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
|
||||
|
||||
|
||||
#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
|
||||
|
||||
}
|
||||
|
||||
@ -3,25 +3,32 @@ using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Unit : MonoBehaviour
|
||||
{
|
||||
|
||||
public int defaultHp = 250;
|
||||
public int defaultAttack = 100;
|
||||
public float LerpSpeed = 1;
|
||||
public int destinationGap = 5;
|
||||
public int StartingHealth = 250;
|
||||
public int StartingAttack = 100;
|
||||
public Slider HealthSlider;
|
||||
public float CapturedLerpSpeed = 1;
|
||||
public int DestinationGap = 5;
|
||||
public float DyingTime = 1.0f;
|
||||
public AudioClip DeathClip;
|
||||
|
||||
private LinkedList<Command> commandList;
|
||||
private int _hp; // the unit hp
|
||||
private int _currentHp; // the unit hp
|
||||
private CharacterBehavior _character;
|
||||
private bool isDamaged;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
void Awake ()
|
||||
{
|
||||
IsCaptured = false;
|
||||
Hp = defaultHp;
|
||||
Attack = defaultAttack;
|
||||
CurrentHP = StartingHealth;
|
||||
// Debug.Log("Current Human HP: " + CurrentHP);
|
||||
Attack = StartingAttack;
|
||||
// initialize default specie
|
||||
Tag = TagLayerManager.Human;
|
||||
Layer = TagLayerManager.HumanLayerIndex;
|
||||
@ -31,15 +38,15 @@ public class Unit : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (IsDead)
|
||||
/* if (IsDead)
|
||||
{
|
||||
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.
|
||||
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*/
|
||||
_character.PlayCaptureAnimation(IsCaptured);
|
||||
}
|
||||
@ -47,6 +54,34 @@ public class Unit : MonoBehaviour
|
||||
{
|
||||
_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>
|
||||
@ -69,30 +104,32 @@ public class Unit : MonoBehaviour
|
||||
protected IEnumerator DestroyUnit(float dyingTime)
|
||||
{
|
||||
//TODO First play dead animation
|
||||
// retreive the character behavior object, so that we can access it's animation properties...
|
||||
var character = GetComponent<CharacterBehavior>();
|
||||
// retrieve the character behavior object, so that we can access it's animation properties...
|
||||
//var character = GetComponent<CharacterBehavior>();
|
||||
// play the death animation
|
||||
character.PlayDeathAnimation();
|
||||
yield return new WaitForSeconds(character.CurrrentAnimationLength());
|
||||
//character.PlayDeathAnimation();
|
||||
yield return new WaitForSeconds(_character.CurrrentAnimationLength());
|
||||
|
||||
|
||||
// then destroy the game object only 3 seconds after the animation
|
||||
Destroy(this.transform.gameObject, dyingTime);
|
||||
//Destroy(this.transform.gameObject, dyingTime);
|
||||
}
|
||||
|
||||
#region Unit properties
|
||||
public bool IsCaptured { get; set; }
|
||||
public int Hp
|
||||
public int CurrentHP
|
||||
{
|
||||
get { return _hp; }
|
||||
get { return _currentHp; }
|
||||
|
||||
set
|
||||
{
|
||||
_hp = value > defaultHp ? defaultHp : value;
|
||||
_currentHp = value > StartingHealth ? StartingHealth : value;
|
||||
|
||||
if (Hp <= 0)
|
||||
/* if (CurrentHP <= 0)
|
||||
{
|
||||
//IsDead = true;
|
||||
IsDead = true;
|
||||
StartCoroutine(DestroyUnit(DyingTime));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1cd93867b8a1d7459a4fb92cac63854
|
||||
timeCreated: 1439305303
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9346fd84c59bd7d42a27381aeed17dbf
|
||||
timeCreated: 1439305314
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -77,6 +77,7 @@ PlayerSettings:
|
||||
metroEnableIndependentInputSource: 0
|
||||
metroEnableLowLatencyPresentationAPI: 0
|
||||
xboxOneDisableKinectGpuReservation: 0
|
||||
virtualRealitySupported: 0
|
||||
productGUID: 54ead80470c104b4682c53a4f7f867b5
|
||||
AndroidBundleVersionCode: 1
|
||||
AndroidMinSdkVersion: 9
|
||||
@ -254,7 +255,6 @@ PlayerSettings:
|
||||
psp2InfoBarOnStartup: 0
|
||||
psp2InfoBarColor: 0
|
||||
psmSplashimage: {fileID: 0}
|
||||
virtualRealitySupported: 0
|
||||
spritePackerPolicy:
|
||||
scriptingDefineSymbols: {}
|
||||
metroPackageName: VZ
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 5.1.0f3
|
||||
m_EditorVersion: 5.1.2f1
|
||||
m_StandardAssetsVersion: 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user