diff --git a/Assets/Materials/zombie_color.mat b/Assets/Materials/zombie_color.mat new file mode 100644 index 0000000..267a2d9 --- /dev/null +++ b/Assets/Materials/zombie_color.mat @@ -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} diff --git a/Assets/Materials/zombie_color.mat.meta b/Assets/Materials/zombie_color.mat.meta new file mode 100644 index 0000000..48f51e0 --- /dev/null +++ b/Assets/Materials/zombie_color.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 200604d182d5e4949a10b24fc68a7d94 +timeCreated: 1439316618 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Sam_UnitScene.unity b/Assets/Scenes/Sam_UnitScene.unity index 7296f44..7455d33 100644 --- a/Assets/Scenes/Sam_UnitScene.unity +++ b/Assets/Scenes/Sam_UnitScene.unity @@ -174,6 +174,93 @@ MeshFilter: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 90076749} 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 GameObject: m_ObjectHideFlags: 0 @@ -249,7 +336,7 @@ Transform: m_Children: - {fileID: 90076750} m_Father: {fileID: 0} - m_RootOrder: 0 + m_RootOrder: 1 --- !u!143 &209133700 CharacterController: m_ObjectHideFlags: 0 @@ -280,7 +367,7 @@ Rigidbody: m_UseGravity: 1 m_IsKinematic: 0 m_Interpolate: 0 - m_Constraints: 0 + m_Constraints: 112 m_CollisionDetection: 0 --- !u!1 &215281597 GameObject: @@ -341,7 +428,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 3 --- !u!1 &370620261 GameObject: m_ObjectHideFlags: 0 @@ -426,7 +513,115 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] 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 GameObject: m_ObjectHideFlags: 0 @@ -458,7 +653,7 @@ Transform: m_Children: - {fileID: 2081975386} m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 4 --- !u!23 &1674696787 MeshRenderer: m_ObjectHideFlags: 0 @@ -586,7 +781,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 5 --- !u!1 &2081975382 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Unit.cs b/Assets/Scripts/Unit.cs index b57c2ed..1b708ab 100644 --- a/Assets/Scripts/Unit.cs +++ b/Assets/Scripts/Unit.cs @@ -6,51 +6,59 @@ using JetBrains.Annotations; public class Unit : MonoBehaviour { - private LinkedList commandList; + private LinkedList commandList; public int defaultHp = 250; public int defaultAttack = 100; - // Use this for initialization - void Start () - { - // initialize default hp - //Hp = defaultHp; - // initialize default attack - Attack = defaultAttack; - // initialize default team - // initialize default specie - isDead = false; - } + // Use this for initialization + void Start () + { + // initialize default hp + //Hp = defaultHp; + // initialize default attack + Attack = defaultAttack; + // initialize default team + // initialize default specie + isDead = false; + } - /// - /// Add a command at the end of the list - /// - /// The command to add - public void addCommand(Command c) - { - this.commandList.AddLast(c); - } + /// + /// Add a command at the end of the list + /// + /// The command to add + protected void addCommand(Command c) + { + this.commandList.AddLast(c); + } - public void executeCommand() - { - - } + protected void executeCommand() + { + + } - #region Unit properties + /// + /// Destroy the current unit + /// + protected void DestroyUnit() + { + Destroy(this.transform.parent.gameObject); + } + + #region Unit properties public int Hp { get; set; } - public int Attack { get; set; } - //public bool isAlly { get; set; } - //public bool isHuman { get; set; } - public bool isDead { get; set; } + public int Attack { get; set; } + //public bool isAlly { get; set; } + //public bool isHuman { get; set; } + public bool isDead { get; set; } - public String Tag - { - get { return this.gameObject.tag; } - set { gameObject.tag = value; } - } + public String Tag + { + get { return this.gameObject.tag; } + set { gameObject.tag = value; } + } - #endregion + #endregion } diff --git a/Assets/Scripts/VampireUnit.cs b/Assets/Scripts/VampireUnit.cs index eb25b55..8de8360 100644 --- a/Assets/Scripts/VampireUnit.cs +++ b/Assets/Scripts/VampireUnit.cs @@ -6,91 +6,92 @@ using System.Collections; /// public class VampireUnit : Unit { - // Use this for initialization + // Use this for initialization - void Start () - { - 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 - void Update () - { - if (isDead) - { - // TODO play dead animation before destroying unit - DestroyUnit(); - } - } + void Start () + { + 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 + void Update () + { + if (isDead) + { + // TODO play dead animation before destroying unit + DestroyUnit(); + } + } - private void InitializeDefaultTag() - { - try - { - this.Tag = TagManager.VampirePlayer; // set the tag to player 1 - } - catch (IndexOutOfRangeException 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 - if (this.gameObject.tag != Tag) - { - this.gameObject.tag = Tag; - } - } + private void InitializeDefaultTag() + { + try + { + this.Tag = TagManager.VampirePlayer; // set the tag to player 1 + } + catch (IndexOutOfRangeException 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 + if (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 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); - } + void AttackEnemy(Unit unit) + { + //TODO improve this method to compute the reduce of hp, etc... + 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 - /// - /// Destroy the current unit - /// - void DestroyUnit() - { - Destroy(this.gameObject); - } + 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(); + 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(); - 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); - } - } - } - } + 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); + } + } + } + } } diff --git a/Assets/Scripts/ZombieUnit.cs b/Assets/Scripts/ZombieUnit.cs index ecfa975..bacbdcd 100644 --- a/Assets/Scripts/ZombieUnit.cs +++ b/Assets/Scripts/ZombieUnit.cs @@ -1,36 +1,95 @@ using System; using UnityEngine; using System.Collections; - -public class ZombieUnit : Unit +/// +/// This class contains the information of the Vampire Units. +/// +public class ZombieUnit : Unit { // Use this for initialization + void Start() { 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 void Update() { - + if (isDead) + { + // TODO play dead animation before destroying unit + DestroyUnit(); + } } private void InitializeDefaultTag() { try { - this.Tag = TagManager.ZombiePlayer; // set the tag to Zombie + this.Tag = TagManager.ZombiePlayer; // set the tag to player 1 } 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) { 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(); + + 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); + } + } + } + } }