public void ActivateFromAnimation() { Debug.Log("Pulling"); Scr_CharacterController _Character = GetComponent <Scr_CharacterController>(); //Create a forward ray from the center of the objects collider Ray PullRay = new Ray(transform.position + new Vector3(0, -0.7f, 0), _Character.transform.forward); RaycastHit PullHit = new RaycastHit(); //Cast the ray if (Physics.Raycast(PullRay, out PullHit, PullRange)) { //Debug.Log("Shot ray"); //Debug.Log(PullHit.transform.gameObject.name); //If the object was at least 2 units away float Distance = (PullHit.transform.position - _Character.transform.position).magnitude; //Debug.Log("Distance from block: " + Distance); if (Distance > 2) { //If it hits something Check that it is an entity if (PullHit.transform.gameObject.GetComponent <Scr_Entity>() != null) { //Debug.Log("Hit Entity"); //If its an entity, run the entities "Hit by push" function PullHit.transform.gameObject.GetComponent <Scr_Entity>().Skill_Pull(_Character, PullHit.point); } } } }
public void ActivateFromAnimation() { //Reset the active state of the ability so it can eb used again //Active = false; Scr_CharacterController _Character = GetComponent <Scr_CharacterController>(); //Create a forward ray from the center of the objects collider Ray PushRay = new Ray(transform.position + new Vector3(0, -0.7f, 0), _Character.transform.forward); RaycastHit PushHit = new RaycastHit(); //Cast the ray if (Physics.Raycast(PushRay, out PushHit, 2)) { //Debug.Log("Shot ray"); Debug.Log(PushHit.transform.gameObject.name); //If it hits something Check that it is an entity if (PushHit.transform.gameObject.GetComponent <Scr_Entity>() != null) { //Debug.Log("Hit Entity"); //If its an entity, run the entities "Hit by push" function PushHit.transform.gameObject.GetComponent <Scr_Entity>().Skill_Push(_Character, PushHit.point); } } }
public override void Activate(Scr_CharacterController _Character) { //Runs the parent scripts Activate function base.Activate(_Character); if (!_Character.CharacterAnimator.GetCurrentAnimatorStateInfo(0).IsName("Push")) { //Debug.Log("Push Pull Activate"); _Character.CharacterAnimator.SetTrigger("Skill_Push"); } #region Effect ////Create a forward ray from the center of the objects collider //Ray PushRay = new Ray(transform.position + new Vector3(0, -0.7f, 0), _Character.transform.forward); //RaycastHit PushHit = new RaycastHit(); ////Cast the ray //if (Physics.Raycast(PushRay, out PushHit, 2)) //{ // Debug.Log("Shot ray"); // Debug.Log(PushHit.transform.gameObject.name); // //If it hits something Check that it is an entity // if (PushHit.transform.gameObject.GetComponent<Scr_Entity>() != null) // { // Debug.Log("Hit Entity"); // //If its an entity, run the entities "Hit by push" function // PushHit.transform.gameObject.GetComponent<Scr_Entity>().Skill_Push(_Character, PushHit.point); // } //} //else //{ // //Create a forward ray from the center of the objects collider // Ray PullRay = new Ray(transform.position + new Vector3(0, -0.7f, 0), _Character.transform.forward); // RaycastHit PullHit = new RaycastHit(); // //Cast the ray // if (Physics.Raycast(PullRay, out PullHit, PullRange)) // { // Debug.Log("Shot ray"); // Debug.Log(PullHit.transform.gameObject.name); // //If the object was at least 2 units away // float Distance = (PullHit.transform.position - _Character.transform.position).magnitude; // Debug.Log("Distance from block: " + Distance); // if(Distance > 2) // { // //If it hits something Check that it is an entity // if (PullHit.transform.gameObject.GetComponent<Scr_Entity>() != null) // { // Debug.Log("Hit Entity"); // //If its an entity, run the entities "Hit by push" function // PullHit.transform.gameObject.GetComponent<Scr_Entity>().Skill_Pull(_Character, PullHit.point); // } // } // } //} #endregion }
public int GetPartyIndex(Scr_CharacterController _character) { for (int i = 0; i < Characters.Count; i++) { if (_character == Characters[i]) { return(i); } } return(0); }
public override void Activate(Scr_CharacterController _Character) { //Runs the parent scripts Activate function base.Activate(_Character); if (!_Character.CharacterAnimator.GetCurrentAnimatorStateInfo(0).IsName("PortalTwo")) { //Debug.Log("Push Pull Activate"); _Character.CharacterAnimator.SetTrigger("Skill_PortalTwo"); //_Character.Channeling = true; } }
public override void Activate(Scr_CharacterController _Character) { //Runs the parent scripts Activate function base.Activate(_Character); //Scr_CharacterController _Character = GetComponent<Scr_CharacterController>(); if (!_Character.CharacterAnimator.GetCurrentAnimatorStateInfo(0).IsName("Pull")) { Debug.Log("Setting to pull"); //Debug.Log("Push Pull Activate"); _Character.CharacterAnimator.SetTrigger("Skill_Pull"); } }
public virtual void Skill_Pull(Scr_CharacterController _Character, Vector3 _HitPoint) { if (!Busy) { Debug.Log("Breakable block Got Pulled"); Vector3 Direction = _HitPoint - _Character.transform.position; Direction.y = 0; Direction.Normalize(); Debug.Log(Direction); if (HasObjectNextTo(EntityCollider.bounds.center, -Direction, UnitScale) == false) { StartCoroutine(ShiftPosition(transform.position - SnapVectorToGrid(Direction) * 2)); } } }
public void ActivateFromAnimation() { Scr_CharacterController _Character = GetComponent <Scr_CharacterController>(); //_Character.Channeling = false; //If they are not standing on a portal if (_Character.FloorObject.GetComponent <Scr_Portal_Entity>() == null) { //If the character is on flat ground if (_Character.FloorObject.layer == 8) { List <Vector3> PossiblePositions = DeterminePosition(SnapToGrid(_Character.transform.position + new Vector3(0, -0.9f, 0))); List <Vector3> GroundedPositions = new List <Vector3>(); //Check through all possible positions to see what is grounded for (int i = 0; i < PossiblePositions.Count; i++) { if (CheckPortalOverLand(PossiblePositions[i])) { Debug.Log("Postal Grounded: " + PossiblePositions[i]); GroundedPositions.Add(PossiblePositions[i]); } } //Figure out the closest position from the remaining grounded positions Vector3 ClosestPosition = CheckClosestPosition(GroundedPositions, _Character.transform.position + new Vector3(0, -0.9f, 0)); //Destroy the old portal if it exists if (CurrentPortalOne != null) { List <Transform> PortalChildren = new List <Transform>(); //Create a seperate list so yo udont take items out of a list youre working with for (int i = 0; i < CurrentPortalOne.transform.childCount; i++) { PortalChildren.Add(CurrentPortalOne.transform.GetChild(i)); } //Hands the objects parented over to their parent so they dont take their children with them for (int i = 0; i < PortalChildren.Count; i++) { //Set the floor objects to the things on top of the portal if (PortalChildren[i].gameObject.GetComponent <Scr_CharacterController>() != null) { Debug.Log("Unparenting Character Object"); PortalChildren[i].gameObject.GetComponent <Scr_CharacterController>().FloorObject = transform.parent.gameObject; PortalChildren[i].gameObject.GetComponent <Scr_CharacterController>().PreviousFloorObject = transform.parent.gameObject; PortalChildren[i].parent = transform.parent; } if (PortalChildren[i].gameObject.GetComponent <Scr_Block_Movable>() != null) { Debug.Log("Unparenting Entity Object"); PortalChildren[i].gameObject.GetComponent <Scr_Entity>().FloorObject = transform.parent.gameObject; PortalChildren[i].gameObject.GetComponent <Scr_Entity>().PreviousFloorObject = transform.parent.gameObject; PortalChildren[i].parent = transform.parent; } //Debug.Log("Moving Object: " + transform.GetChild(i) + " From parent: " + transform.GetChild(i).parent + " To Parent: " + transform.parent); } //The collider needs to be disabled in order to stop reparenting in the next frame before destroying CurrentPortalOne.GetComponent <Scr_Entity>().EntityCollider.enabled = false; Destroy(CurrentPortalOne); } //Create portal GameObject NewPortal = GameObject.Instantiate(PortalPrefab); //Set the new portal CurrentPortalOne = NewPortal; //Set the new portals partent to the characters parent NewPortal.transform.parent = _Character.transform.parent; //NewPortal.GetComponent<Scr_Portal_Entity>().FloorObject = _Character.transform.parent; //Set position Lowering it to be in line with the floor NewPortal.transform.position = ClosestPosition + new Vector3(0, -0.1f + 0.005f, 0); //Sets this portal to both current and previous floor objects to avoid instant porting _Character.FloorObject = NewPortal; _Character.PreviousFloorObject = NewPortal; //Also make the portal creator independant Scr_PlayerController.inst.SeperateCharacter(Scr_PlayerController.inst.GetPartyIndex(_Character)); //Adds the new portal to the from of the list Portals.Insert(0, NewPortal); ////If the portal list is now greater than 2, remove the oldest one //if (Portals.Count > 2) //{ // GameObject PortalToDelete = Portals[Portals.Count - 1]; // Portals.RemoveAt(Portals.Count - 1); // //Pass over parenting // if (PortalToDelete.transform.childCount > 0) // { // for (int i = 0; i < PortalToDelete.transform.childCount; i++) // { // PortalToDelete.transform.GetChild(i).parent = PortalToDelete.transform.parent; // } // } // Destroy(PortalToDelete); //} } } }
public override void Skill_Pull(Scr_CharacterController _Character, Vector3 _HitPoint) { //base.Skill_Push(); Debug.Log("Breakable block Got Pulled"); //Destroy(this.gameObject); }
private void Awake() { inst = this; playerCamera = GetComponent <Camera>(); }
public Scr_PositionTimeStamp GetPositionTimeStampFromCharacter(Scr_CharacterController _Leader) { //Grab the leaders timestamp return(_Leader.PositionTimeStamps[_Leader.PositionTimeStamps.Count - 1]); }
public virtual void Activate(Scr_CharacterController _Character) { Debug.Log("Base Skill Activate"); }
public override void Activate(Scr_CharacterController _Character) { //Runs the parent scripts Activate function base.Activate(_Character); if (PhasedEntity == null) { //Create a forward ray from the center of the objects collider Ray GrabRay = new Ray(transform.position + new Vector3(0, -0.7f, 0), _Character.transform.forward); RaycastHit GrabHit = new RaycastHit(); //Cast the ray if (Physics.Raycast(GrabRay, out GrabHit, 2)) { Debug.Log("Shot ray"); Debug.Log(GrabHit.transform.gameObject.name); //If it hits something Check that it is an entity if (GrabHit.transform.gameObject.GetComponent <Scr_Entity>() != null) { Debug.Log("Hit Entity"); //If its an entity, run the entities "Hit by push" function PhasedEntity = GrabHit.transform.gameObject.GetComponent <Scr_Entity>(); Debug.Log("Phasing Object"); //Check is the phased entity has a player as a child, if so do not phase bool PlayerInChildren = false; for (int i = 0; i < PhasedEntity.transform.childCount; i++) { if (PhasedEntity.transform.GetChild(i).GetComponent <Scr_CharacterController>() != null) { PlayerInChildren = true; } } //If there isnt a player in the heirachy then phase objects if (PlayerInChildren == false) { //Enable phase animation _Character.CharacterAnimator.SetBool("Skill_Phase", true); PhasedEntity.Skill_Phase(); //Loop through all the children and phase them too for (int i = 0; i < PhasedEntity.transform.childCount; i++) { if (PhasedEntity.transform.GetChild(i).GetComponent <Scr_Entity>() != null) { PhasedEntity.transform.GetChild(i).GetComponent <Scr_Entity>().Skill_Phase(); } } //Toggle on channeling _Character.Channeling = true; //Also make the portal creator independant Scr_PlayerController.inst.SeperateCharacter(Scr_PlayerController.inst.GetPartyIndex(_Character)); } //If there is a character on the object, set the phased object to null and stop the funciton else { PhasedEntity = null; } } } } else { //Check if there is anything in the collider Collider EntityCollider = PhasedEntity.EntityCollider; if (Physics.BoxCast(EntityCollider.bounds.center, EntityCollider.bounds.extents, new Vector3(0, 0, 0))) { Debug.Log("Something blocking the phase"); } else { //Turn off channeling //Turn off the skill phase animation _Character.CharacterAnimator.SetBool("Skill_Phase", false); _Character.Channeling = false; Debug.Log("Unphasing Object"); PhasedEntity.Skill_Phase(); //Unphase Children for (int i = 0; i < PhasedEntity.transform.childCount; i++) { if (PhasedEntity.transform.GetChild(i).GetComponent <Scr_Entity>() != null) { PhasedEntity.transform.GetChild(i).GetComponent <Scr_Entity>().Skill_Phase(); } } PhasedEntity = null; } } }