mirror of
https://github.com/ConjureETS/VZ.git
synced 2026-03-24 02:11:15 +00:00
- Added CollisionEnter scripts
This commit is contained in:
parent
5837a7f2c9
commit
1571326998
@ -100,8 +100,8 @@ GameObject:
|
|||||||
- 23: {fileID: 90076752}
|
- 23: {fileID: 90076752}
|
||||||
- 114: {fileID: 90076751}
|
- 114: {fileID: 90076751}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: CollisionField
|
m_Name: VampireCollisionField
|
||||||
m_TagString: Untagged
|
m_TagString: VampirePlayer
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
@ -126,9 +126,11 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 90076749}
|
m_GameObject: {fileID: 90076749}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 8a1ccd1ad32d6bc4fb600c5b5720e01c, type: 3}
|
m_Script: {fileID: 11500000, guid: c1cd93867b8a1d7459a4fb92cac63854, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
defaultHp: 250
|
||||||
|
defaultAttack: 100
|
||||||
--- !u!23 &90076752
|
--- !u!23 &90076752
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -185,7 +187,6 @@ GameObject:
|
|||||||
- 23: {fileID: 209133696}
|
- 23: {fileID: 209133696}
|
||||||
- 143: {fileID: 209133700}
|
- 143: {fileID: 209133700}
|
||||||
- 54: {fileID: 209133701}
|
- 54: {fileID: 209133701}
|
||||||
- 114: {fileID: 209133702}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Vampire
|
m_Name: Vampire
|
||||||
m_TagString: VampirePlayer
|
m_TagString: VampirePlayer
|
||||||
@ -281,17 +282,6 @@ Rigidbody:
|
|||||||
m_Interpolate: 0
|
m_Interpolate: 0
|
||||||
m_Constraints: 0
|
m_Constraints: 0
|
||||||
m_CollisionDetection: 0
|
m_CollisionDetection: 0
|
||||||
--- !u!114 &209133702
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 209133695}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: c1cd93867b8a1d7459a4fb92cac63854, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
--- !u!1 &215281597
|
--- !u!1 &215281597
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -448,7 +438,7 @@ GameObject:
|
|||||||
- 33: {fileID: 1674696789}
|
- 33: {fileID: 1674696789}
|
||||||
- 65: {fileID: 1674696788}
|
- 65: {fileID: 1674696788}
|
||||||
- 23: {fileID: 1674696787}
|
- 23: {fileID: 1674696787}
|
||||||
- 114: {fileID: 1674696790}
|
- 54: {fileID: 1674696791}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Human
|
m_Name: Human
|
||||||
m_TagString: Human
|
m_TagString: Human
|
||||||
@ -463,7 +453,7 @@ Transform:
|
|||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1674696785}
|
m_GameObject: {fileID: 1674696785}
|
||||||
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: 25}
|
m_LocalPosition: {x: 0, y: 15, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 2081975386}
|
- {fileID: 2081975386}
|
||||||
@ -512,17 +502,21 @@ MeshFilter:
|
|||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1674696785}
|
m_GameObject: {fileID: 1674696785}
|
||||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
--- !u!114 &1674696790
|
--- !u!54 &1674696791
|
||||||
MonoBehaviour:
|
Rigidbody:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1674696785}
|
m_GameObject: {fileID: 1674696785}
|
||||||
m_Enabled: 1
|
serializedVersion: 2
|
||||||
m_EditorHideFlags: 0
|
m_Mass: 1
|
||||||
m_Script: {fileID: 11500000, guid: 8a1ccd1ad32d6bc4fb600c5b5720e01c, type: 3}
|
m_Drag: 0
|
||||||
m_Name:
|
m_AngularDrag: .0500000007
|
||||||
m_EditorClassIdentifier:
|
m_UseGravity: 1
|
||||||
|
m_IsKinematic: 0
|
||||||
|
m_Interpolate: 0
|
||||||
|
m_Constraints: 0
|
||||||
|
m_CollisionDetection: 0
|
||||||
--- !u!1 &1780458434
|
--- !u!1 &1780458434
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -606,8 +600,8 @@ GameObject:
|
|||||||
- 23: {fileID: 2081975383}
|
- 23: {fileID: 2081975383}
|
||||||
- 114: {fileID: 2081975387}
|
- 114: {fileID: 2081975387}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: CollisionField
|
m_Name: HumanCollisionField
|
||||||
m_TagString: Untagged
|
m_TagString: Human
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
@ -678,3 +672,5 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 8a1ccd1ad32d6bc4fb600c5b5720e01c, type: 3}
|
m_Script: {fileID: 11500000, guid: 8a1ccd1ad32d6bc4fb600c5b5720e01c, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
defaultHp: 250
|
||||||
|
defaultAttack: 100
|
||||||
|
|||||||
@ -7,19 +7,19 @@ using JetBrains.Annotations;
|
|||||||
public class Unit : MonoBehaviour
|
public class Unit : MonoBehaviour
|
||||||
{
|
{
|
||||||
private LinkedList<Command> commandList;
|
private LinkedList<Command> commandList;
|
||||||
|
public int defaultHp = 250;
|
||||||
|
public int defaultAttack = 100;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start ()
|
void Start ()
|
||||||
{
|
{
|
||||||
// initialize default hp
|
// initialize default hp
|
||||||
|
//Hp = defaultHp;
|
||||||
// initialize default attack
|
// initialize default attack
|
||||||
|
Attack = defaultAttack;
|
||||||
// initialize default team
|
// initialize default team
|
||||||
// initialize default specie
|
// initialize default specie
|
||||||
}
|
isDead = false;
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update ()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -38,7 +38,8 @@ public class Unit : MonoBehaviour
|
|||||||
|
|
||||||
#region Unit properties
|
#region Unit properties
|
||||||
|
|
||||||
public int HP { get; set; }
|
public int Hp { get; set; }
|
||||||
|
|
||||||
public int Attack { get; set; }
|
public int Attack { get; set; }
|
||||||
//public bool isAlly { get; set; }
|
//public bool isAlly { get; set; }
|
||||||
//public bool isHuman { get; set; }
|
//public bool isHuman { get; set; }
|
||||||
|
|||||||
@ -7,22 +7,34 @@ using System.Collections;
|
|||||||
public class VampireUnit : Unit
|
public class VampireUnit : Unit
|
||||||
{
|
{
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
|
|
||||||
void Start ()
|
void Start ()
|
||||||
{
|
{
|
||||||
InitializeDefaultTag();
|
InitializeDefaultTag();
|
||||||
|
// initialize default hp
|
||||||
|
//Hp = defaultHp;
|
||||||
|
// initialize default attack
|
||||||
|
Attack = defaultAttack;
|
||||||
|
// initialize default team
|
||||||
|
// initialize default specie
|
||||||
|
isDead = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update ()
|
void Update ()
|
||||||
{
|
{
|
||||||
|
if (isDead)
|
||||||
|
{
|
||||||
|
// TODO play dead animation before destroying unit
|
||||||
|
DestroyUnit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeDefaultTag()
|
private void InitializeDefaultTag()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.Tag = TagManager.VampirePlayer; // set the tag to player 1
|
this.Tag = TagManager.VampirePlayer; // set the tag to player 1
|
||||||
}
|
}
|
||||||
catch (IndexOutOfRangeException ex)
|
catch (IndexOutOfRangeException ex)
|
||||||
{
|
{
|
||||||
@ -35,4 +47,50 @@ public class VampireUnit : Unit
|
|||||||
this.gameObject.tag = Tag;
|
this.gameObject.tag = Tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 VampireUnit vampireUnit2 = (VampireUnit) unit;
|
||||||
|
Debug.Log("Entered in collision with: " + unit.Tag );
|
||||||
|
}
|
||||||
|
|
||||||
|
void AttackEnemy(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destroy the current unit
|
||||||
|
/// </summary>
|
||||||
|
void DestroyUnit()
|
||||||
|
{
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// check if the unit is not a friendly one
|
||||||
|
if (this.Tag != unitComponent.Tag)
|
||||||
|
{
|
||||||
|
if (unitComponent.Tag.Equals(TagManager.Human))
|
||||||
|
{
|
||||||
|
CaptureHuman(unitComponent);
|
||||||
|
}
|
||||||
|
else // we know that it's an ennemy
|
||||||
|
{
|
||||||
|
AttackEnemy(unitComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user