- added zombie material (temporary)

- Updated class unit (added a destroyUnit method)
- Updated ZombeUnit and VampireUnit, now the class detect that there are
	ennemies and will attack each other when intering in collision.
This commit is contained in:
Samuel 2015-08-11 14:39:32 -04:00
parent 1571326998
commit 4690abe842
6 changed files with 536 additions and 127 deletions

View File

@ -0,0 +1,138 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: zombie_color
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _OcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _SrcBlend
second: 1
data:
first:
name: _DstBlend
second: 0
data:
first:
name: _Cutoff
second: .5
data:
first:
name: _Parallax
second: .0199999996
data:
first:
name: _ZWrite
second: 1
data:
first:
name: _Glossiness
second: .5
data:
first:
name: _BumpScale
second: 1
data:
first:
name: _OcclusionStrength
second: 1
data:
first:
name: _DetailNormalMapScale
second: 1
data:
first:
name: _UVSec
second: 0
data:
first:
name: _Mode
second: 0
data:
first:
name: _Metallic
second: 0
m_Colors:
data:
first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
data:
first:
name: _Color
second: {r: 0, g: .477941155, b: .22084181, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 200604d182d5e4949a10b24fc68a7d94
timeCreated: 1439316618
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -174,6 +174,93 @@ MeshFilter:
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 90076749} m_GameObject: {fileID: 90076749}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &110104606
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 110104611}
- 33: {fileID: 110104610}
- 135: {fileID: 110104609}
- 23: {fileID: 110104608}
- 114: {fileID: 110104607}
m_Layer: 0
m_Name: ZombieCollisionField
m_TagString: ZombiePlayer
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &110104607
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 110104606}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9346fd84c59bd7d42a27381aeed17dbf, type: 3}
m_Name:
m_EditorClassIdentifier:
defaultHp: 250
defaultAttack: 100
--- !u!23 &110104608
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 110104606}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 1
m_ReflectionProbeUsage: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_ImportantGI: 0
m_AutoUVMaxDistance: .5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!135 &110104609
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 110104606}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 3
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &110104610
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 110104606}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &110104611
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 110104606}
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_Children: []
m_Father: {fileID: 1589771518}
m_RootOrder: 0
--- !u!1 &209133695 --- !u!1 &209133695
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -249,7 +336,7 @@ Transform:
m_Children: m_Children:
- {fileID: 90076750} - {fileID: 90076750}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 1
--- !u!143 &209133700 --- !u!143 &209133700
CharacterController: CharacterController:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -280,7 +367,7 @@ Rigidbody:
m_UseGravity: 1 m_UseGravity: 1
m_IsKinematic: 0 m_IsKinematic: 0
m_Interpolate: 0 m_Interpolate: 0
m_Constraints: 0 m_Constraints: 112
m_CollisionDetection: 0 m_CollisionDetection: 0
--- !u!1 &215281597 --- !u!1 &215281597
GameObject: GameObject:
@ -341,7 +428,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 &370620261 --- !u!1 &370620261
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -426,7 +513,115 @@ 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!1 &1589771517
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1589771518}
- 33: {fileID: 1589771523}
- 65: {fileID: 1589771522}
- 23: {fileID: 1589771521}
- 143: {fileID: 1589771520}
- 54: {fileID: 1589771519}
m_Layer: 0
m_Name: Zombie
m_TagString: ZombiePlayer
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1589771518
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1589771517}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 5, z: 15}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 110104611}
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!54 &1589771519
Rigidbody:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1589771517}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: .0500000007
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!143 &1589771520
CharacterController:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1589771517}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Height: 1
m_Radius: .5
m_SlopeLimit: 45
m_StepOffset: .300000012
m_SkinWidth: .0799999982
m_MinMoveDistance: .00100000005
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1589771521
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1589771517}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_Materials:
- {fileID: 2100000, guid: 200604d182d5e4949a10b24fc68a7d94, type: 2}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 1
m_ReflectionProbeUsage: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_ImportantGI: 0
m_AutoUVMaxDistance: .5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!65 &1589771522
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1589771517}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &1589771523
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1589771517}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1674696785 --- !u!1 &1674696785
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -458,7 +653,7 @@ Transform:
m_Children: m_Children:
- {fileID: 2081975386} - {fileID: 2081975386}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 4
--- !u!23 &1674696787 --- !u!23 &1674696787
MeshRenderer: MeshRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -586,7 +781,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: 4 m_RootOrder: 5
--- !u!1 &2081975382 --- !u!1 &2081975382
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -6,51 +6,59 @@ 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 defaultHp = 250;
public int defaultAttack = 100; public int defaultAttack = 100;
// Use this for initialization // Use this for initialization
void Start () void Start ()
{ {
// initialize default hp // initialize default hp
//Hp = defaultHp; //Hp = defaultHp;
// initialize default attack // initialize default attack
Attack = defaultAttack; Attack = defaultAttack;
// initialize default team // initialize default team
// initialize default specie // initialize default specie
isDead = false; isDead = false;
} }
/// <summary> /// <summary>
/// Add a command at the end of the list /// Add a command at the end of the list
/// </summary> /// </summary>
/// <param name="c">The command to add</param> /// <param name="c">The command to add</param>
public void addCommand(Command c) protected void addCommand(Command c)
{ {
this.commandList.AddLast(c); this.commandList.AddLast(c);
} }
public void executeCommand() protected void executeCommand()
{ {
} }
#region Unit properties /// <summary>
/// Destroy the current unit
/// </summary>
protected void DestroyUnit()
{
Destroy(this.transform.parent.gameObject);
}
#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; }
public bool isDead { get; set; } public bool isDead { get; set; }
public String Tag public String Tag
{ {
get { return this.gameObject.tag; } get { return this.gameObject.tag; }
set { gameObject.tag = value; } set { gameObject.tag = value; }
} }
#endregion #endregion
} }

View File

@ -6,91 +6,92 @@ using System.Collections;
/// </summary> /// </summary>
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 // initialize default hp
//Hp = defaultHp; //Hp = defaultHp;
// initialize default attack // initialize default attack
Attack = defaultAttack; Attack = defaultAttack;
// initialize default team // initialize default team
// initialize default specie // initialize default specie
isDead = false; isDead = false;
} }
// Update is called once per frame // Update is called once per frame
void Update () void Update ()
{ {
if (isDead) if (isDead)
{ {
// TODO play dead animation before destroying unit // TODO play dead animation before destroying unit
DestroyUnit(); 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)
{ {
Debug.LogError( "Please set a vampire Tag, check the Tag & layers in the inspector!\n" + ex ); Debug.LogError( "Please set a vampire Tag, check the Tag & layers in the inspector!\n" + ex );
} }
// set the tag of the gameObject to vampire // set the tag of the gameObject to vampire
if (this.gameObject.tag != Tag) if (this.gameObject.tag != Tag)
{ {
this.gameObject.tag = Tag; this.gameObject.tag = Tag;
} }
} }
void CaptureHuman(Unit unit) void CaptureHuman(Unit unit)
{ {
// TODO either add the human as a squad member or change it's tag to vampireHuman // 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; // when the player is transformed we just make VampireUnit vampireUnit2 = (VampireUnit) unit;
Debug.Log("Entered in collision with: " + unit.Tag ); Debug.Log("Entered in collision with: " + unit.Tag );
} }
void AttackEnemy(Unit unit) void AttackEnemy(Unit unit)
{ {
// compute the amount of hp reduced to this unit //TODO improve this method to compute the reduce of hp, etc...
unit.Hp -= Attack; // we remove some hp of the unit that was if (unit.Hp <= 0)
Debug.Log("Attacked the ennemy : " + unit.Tag); {
} unit.isDead = true;
}
else
{
// compute the amount of hp reduced to this unit
unit.Hp -= Attack; // we remove some hp of the unit that was
/// <summary> Debug.Log("Attacked the ennemy : " + unit.Tag);
/// Destroy the current unit }
/// </summary> }
void DestroyUnit()
{
Destroy(this.gameObject);
}
void OnTriggerEnter(Collider collider) void OnTriggerEnter(Collider collider)
{ {
//var objectTag = collider.gameObject; //var objectTag = collider.gameObject;
// check if the game object have an attached Unit class // check if the game object have an attached Unit class
//switch(objectTag.GetType()) //switch(objectTag.GetType())
var unitComponent = collider.GetComponent<Unit>(); var unitComponent = collider.GetComponent<Unit>();
if (unitComponent != null) if (unitComponent != null)
{ {
// check if the unit is not a friendly one // check if the unit is not a friendly one
if (this.Tag != unitComponent.Tag) if (this.Tag != unitComponent.Tag)
{ {
if (unitComponent.Tag.Equals(TagManager.Human)) if (unitComponent.Tag.Equals(TagManager.Human))
{ {
CaptureHuman(unitComponent); CaptureHuman(unitComponent);
} }
else // we know that it's an ennemy else // we know that it's an ennemy
{ {
AttackEnemy(unitComponent); AttackEnemy(unitComponent);
} }
} }
} }
} }
} }

View File

@ -1,36 +1,95 @@
using System; using System;
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
/// <summary>
public class ZombieUnit : Unit /// This class contains the information of the Vampire Units.
/// </summary>
public class ZombieUnit : 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.ZombiePlayer; // set the tag to Zombie this.Tag = TagManager.ZombiePlayer; // set the tag to player 1
} }
catch (IndexOutOfRangeException ex) catch (IndexOutOfRangeException ex)
{ {
Debug.LogError("Please set a zombie Tag, check the Tag & layers in the inspector!\n" + ex); Debug.LogError("Please set a vampire Tag, check the Tag & layers in the inspector!\n" + ex);
} }
// set the tag of the gameObject to zombie // set the tag of the gameObject to vampire
if (this.gameObject.tag != Tag) if (this.gameObject.tag != Tag)
{ {
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)
{
if (unit.Hp <= 0)
{
unit.isDead = true;
}
else
{
// 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)
{
// 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);
}
}
}
}
} }