diff --git a/Guardian of Silverkeep/Assets/Scene_Tianzhu/LVL1.unity b/Guardian of Silverkeep/Assets/Scene_Tianzhu/LVL1.unity index cc6c6cf..48a37f7 100644 --- a/Guardian of Silverkeep/Assets/Scene_Tianzhu/LVL1.unity +++ b/Guardian of Silverkeep/Assets/Scene_Tianzhu/LVL1.unity @@ -910,7 +910,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2d94b001577fb4600bea455d6b7e5d34, type: 3} m_Name: m_EditorClassIdentifier: - m_Camera: {fileID: 2000000, guid: 62a6e0865cec44656be439b399ff7f72, type: 2} --- !u!143 &375718592 CharacterController: m_ObjectHideFlags: 0 @@ -1457,7 +1456,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2d94b001577fb4600bea455d6b7e5d34, type: 3} m_Name: m_EditorClassIdentifier: - m_Camera: {fileID: 0} --- !u!1 &703977986 GameObject: m_ObjectHideFlags: 0 @@ -1575,7 +1573,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2d94b001577fb4600bea455d6b7e5d34, type: 3} m_Name: m_EditorClassIdentifier: - m_Camera: {fileID: 1139808591} --- !u!1 &759815423 GameObject: m_ObjectHideFlags: 0 @@ -1952,7 +1949,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2d94b001577fb4600bea455d6b7e5d34, type: 3} m_Name: m_EditorClassIdentifier: - m_Camera: {fileID: 1139808591} --- !u!1 &1053758543 GameObject: m_ObjectHideFlags: 0 @@ -2678,81 +2674,6 @@ MeshFilter: m_PrefabInternal: {fileID: 56728018} m_GameObject: {fileID: 1342842427} m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} ---- !u!1 &1365455812 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 100002, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - m_PrefabInternal: {fileID: 1686912363} - serializedVersion: 4 - m_Component: - - 4: {fileID: 1365455813} - - 33: {fileID: 1365455816} - - 23: {fileID: 1365455815} - - 111: {fileID: 1365455814} - m_Layer: 0 - m_Name: polar bear arm - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1365455813 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 400002, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1365455812} - m_LocalRotation: {x: .707106829, y: 0, z: 0, w: .707106709} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: .127640486, y: .127640486, z: .127640486} - m_Children: [] - m_Father: {fileID: 1833956521} ---- !u!111 &1365455814 -Animation: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11100000, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1365455812} - m_Enabled: 1 - serializedVersion: 3 - m_Animation: {fileID: 7400000, guid: e22c45ff57f43544889bc99cd4aba735, type: 2} - m_Animations: - - {fileID: 7400000, guid: e22c45ff57f43544889bc99cd4aba735, type: 2} - m_WrapMode: 0 - m_PlayAutomatically: 0 - m_AnimatePhysics: 0 - m_CullingType: 0 - m_UserAABB: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 0, y: 0, z: 0} ---- !u!23 &1365455815 -Renderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 2300002, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1365455812} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_LightmapIndex: 255 - m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0} - m_Materials: - - {fileID: 2100000, guid: 75c8987774589e94d84679f60ead9a5c, type: 2} - m_SubsetIndices: - m_StaticBatchRoot: {fileID: 0} - m_UseLightProbes: 0 - m_LightProbeAnchor: {fileID: 0} - m_ScaleInLightmap: 1 ---- !u!33 &1365455816 -MeshFilter: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 3300002, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1365455812} - m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1366416162 GameObject: m_ObjectHideFlags: 0 @@ -3069,46 +2990,6 @@ MeshFilter: m_PrefabInternal: {fileID: 1433495752} m_GameObject: {fileID: 1621733595} m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} ---- !u!1001 &1686912363 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 400000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - m_RootGameObject: {fileID: 1833956515} - m_IsPrefabParent: 0 - m_IsExploded: 1 --- !u!1 &1721511309 GameObject: m_ObjectHideFlags: 0 @@ -3266,7 +3147,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2d94b001577fb4600bea455d6b7e5d34, type: 3} m_Name: m_EditorClassIdentifier: - m_Camera: {fileID: 0} --- !u!1 &1737373806 GameObject: m_ObjectHideFlags: 0 @@ -3481,120 +3361,6 @@ MeshFilter: m_PrefabInternal: {fileID: 56728018} m_GameObject: {fileID: 1784722914} m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} ---- !u!1 &1833956515 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 100000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - m_PrefabInternal: {fileID: 1686912363} - serializedVersion: 4 - m_Component: - - 4: {fileID: 1833956521} - - 33: {fileID: 1833956520} - - 65: {fileID: 1833956519} - - 23: {fileID: 1833956518} - - 54: {fileID: 1833956517} - - 114: {fileID: 1833956516} - - 114: {fileID: 1833956522} - m_Layer: 0 - m_Name: Hero_Attack_01 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1833956516 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11400000, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1833956515} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c02910df57bb64e4a9db1fcc20be8ba3, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!54 &1833956517 -Rigidbody: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 5400000, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1833956515} - serializedVersion: 2 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: .0500000007 - m_UseGravity: 0 - m_IsKinematic: 1 - m_Interpolate: 0 - m_Constraints: 0 - m_CollisionDetection: 0 ---- !u!23 &1833956518 -Renderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 2300000, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1833956515} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_LightmapIndex: 255 - m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0} - m_Materials: - - {fileID: 2100000, guid: 54e650530d8a34a798a6d21077526610, type: 2} - m_SubsetIndices: - m_StaticBatchRoot: {fileID: 0} - m_UseLightProbes: 0 - m_LightProbeAnchor: {fileID: 0} - m_ScaleInLightmap: 1 ---- !u!65 &1833956519 -BoxCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 6500000, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1833956515} - m_Material: {fileID: 0} - m_IsTrigger: 1 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!33 &1833956520 -MeshFilter: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 3300000, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1833956515} - m_Mesh: {fileID: 0} ---- !u!4 &1833956521 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 400000, guid: 548fd220e2a904886aaeae294eed71a8, type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1833956515} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 2, y: 2, z: 2} - m_Children: - - {fileID: 1365455813} - m_Father: {fileID: 0} ---- !u!114 &1833956522 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11400002, guid: 548fd220e2a904886aaeae294eed71a8, - type: 2} - m_PrefabInternal: {fileID: 1686912363} - m_GameObject: {fileID: 1833956515} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 2d94b001577fb4600bea455d6b7e5d34, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Camera: {fileID: 0} --- !u!1 &1849082775 GameObject: m_ObjectHideFlags: 0 diff --git a/Guardian of Silverkeep/Assets/Scripts/CameraTest.cs b/Guardian of Silverkeep/Assets/Scripts/CameraTest.cs index eccd1a3..e97b522 100644 --- a/Guardian of Silverkeep/Assets/Scripts/CameraTest.cs +++ b/Guardian of Silverkeep/Assets/Scripts/CameraTest.cs @@ -3,8 +3,11 @@ using System.Collections; public class CameraTest : MonoBehaviour { - public Camera m_Camera; - + //public Camera m_Camera; + void Start () { + GameObject cam_H = GameObject.Find("Main Camera"); + + } void Update() { GameObject cam_H = GameObject.Find("Main Camera"); diff --git a/Guardian of Silverkeep/Assets/Scripts/Enemy_StandardWeak.cs b/Guardian of Silverkeep/Assets/Scripts/Enemy_StandardWeak.cs index d74e17e..e8deccf 100644 --- a/Guardian of Silverkeep/Assets/Scripts/Enemy_StandardWeak.cs +++ b/Guardian of Silverkeep/Assets/Scripts/Enemy_StandardWeak.cs @@ -7,12 +7,15 @@ public class Enemy_StandardWeak : MonoBehaviour public float enemyMoveSpeed; public int enemyHealth; public int enemyDamage; + + private GameObject hero; // keep track of hero position to alter animations private Vector3 selfPosition; + private Vector3 heroPos; + private Vector3 heroDir; public GameObject JoyStone; - private Vector3 moveDirection = Vector3.zero; - private CharacterController controller; - //this is a test for child toggle - //public GameObject testChild001; + private Vector3 moveDirection = Vector3.zero; + private CharacterController controller; + public string childFront; public string childBack; public string childLeft; @@ -22,12 +25,7 @@ public class Enemy_StandardWeak : MonoBehaviour private Transform left; private Transform right; - -// public GameObject water_baddie_front; -// public GameObject water_baddie_back; -// public GameObject water_baddie_left; -// public GameObject water_baddie_right; - + enum EnemyMentalState @@ -66,6 +64,7 @@ public class Enemy_StandardWeak : MonoBehaviour back.gameObject.SetActive(false); front.gameObject.SetActive(true); right.gameObject.SetActive(false); + hero = GameObject.FindWithTag("Player"); } // Update is called once per frame @@ -76,8 +75,11 @@ public class Enemy_StandardWeak : MonoBehaviour if(transform.position.y != 0) transform.Translate(0, -transform.position.y, 0); - //updating selfPosition + //updating selfPosition and hero position selfPosition = new Vector3(transform.position.x, 0, transform.position.z); + heroPos = new Vector3 (hero.transform.position.x, 0, hero.transform.position.z); + heroDir = heroPos - selfPosition; + //initiallize and updates self direction Vector3 CurrentDirection = Vector3.right; #region CurrentDirection choose(need improvement) @@ -85,34 +87,22 @@ public class Enemy_StandardWeak : MonoBehaviour if(direction == EnemyDirection.up) { CurrentDirection = Vector3.forward; - left.gameObject.SetActive(false); - back.gameObject.SetActive(false); - front.gameObject.SetActive(true); - right.gameObject.SetActive(false); + } else if(direction == EnemyDirection.down) { CurrentDirection = Vector3.back; - left.gameObject.SetActive(false); - back.gameObject.SetActive(true); - front.gameObject.SetActive(false); - right.gameObject.SetActive(false); + } else if(direction == EnemyDirection.right) { CurrentDirection = Vector3.right; - left.gameObject.SetActive(false); - back.gameObject.SetActive(false); - front.gameObject.SetActive(false); - right.gameObject.SetActive(true); + } else if(direction == EnemyDirection.left) { CurrentDirection = Vector3.left; - left.gameObject.SetActive(true); - back.gameObject.SetActive(false); - front.gameObject.SetActive(false); - right.gameObject.SetActive(false); + } moveDirection = CurrentDirection * enemyMoveSpeed; #endregion @@ -130,9 +120,10 @@ public class Enemy_StandardWeak : MonoBehaviour //float amtToMove = enemyMoveSpeed * Time.deltaTime; //transform.Translate (CurrentDirection * amtToMove); - controller.Move (moveDirection * Time.deltaTime); + controller.Move (moveDirection * Time.deltaTime); - + // *****************THIS IS WHERE YOU CALL THE FACING CHANGE FUNC************************** + FacingDirection(CurrentDirection, heroDir); } //boundary check @@ -182,4 +173,44 @@ public class Enemy_StandardWeak : MonoBehaviour otherObject.gameObject.SendMessage("heroGotHit",enemyDamage); } } + void FacingDirection(Vector3 currentDir, Vector3 heroDir) + { + Vector3 currentLeft = new Vector3(currentDir.x-1, 0, currentDir.z-1); + float faceFrontOrBack = Vector3.Angle(currentDir, heroDir); + float faceLeftOrRight = Vector3.Angle(currentLeft, heroDir); + if(faceFrontOrBack <45) + { + //***front facing hero + left.gameObject.SetActive(false); + back.gameObject.SetActive(false); + front.gameObject.SetActive(true); + right.gameObject.SetActive(false); + } + else if(faceFrontOrBack >135) + { + //***back facing hero + left.gameObject.SetActive(false); + back.gameObject.SetActive(true); + front.gameObject.SetActive(false); + right.gameObject.SetActive(false); + } + else if(faceLeftOrRight < 90) + { + //***going left + left.gameObject.SetActive(true); + back.gameObject.SetActive(false); + front.gameObject.SetActive(false); + right.gameObject.SetActive(false); + + } + else + { + left.gameObject.SetActive(false); + back.gameObject.SetActive(false); + front.gameObject.SetActive(false); + right.gameObject.SetActive(true); + } + + } +// }