public void StartState() { barion.StopMovement(); //Stop //Get throw direction Vector3 direction = new Vector3(); Ray ray_mouse = Camera.main.ScreenPointToRay(Input.mousePosition); //Ray to mouse position to set direction of the sphere RaycastHit hit_mouse; if (Physics.Raycast(ray_mouse, out hit_mouse, 100, barion.floor_layer)) { direction = hit_mouse.point; direction.y = barion.transform.position.y; //Same height direction = direction - barion.transform.position; direction.Normalize(); } else { Debug.Log("ERROR: Barion can't use INVISIBLE SPHERE because the mouse didn't find a floor collison to set the direction"); } Vector3 delay_pos = direction * delay_position_sphere; //Create invisible sphere GameObject sphere = GameObject.Instantiate(barion.invisible_sphere_prefab, barion.transform.position + delay_pos, new Quaternion()) as GameObject; sphere.GetComponent <InvisibleSphere>().direction = direction; barion.cooldown_inst.StartCooldown(1); //Start cooldown of ability1 }
public void UpdateState() { //TODO: cancel actions in progress //The box is far, Barion is approaching if (moving_to_box == true) { if (Vector3.Distance(barion.transform.position, box.transform.position) <= barion.agent.stoppingDistance) { barion.StopMovement(); PickUpBox(); } else { barion.agent.SetDestination(box.transform.position); //Constantly follow the box } } //Is carrying the box, now move with it. if (carrying_box == true) { //Get new destination if (barion.is_selected) { if (barion.GetMovement(ref destination)) { barion.agent.SetDestination(destination); } } //Update box position Vector3 pos = barion.transform.position; box.transform.position = new Vector3(pos.x, box_height, pos.z); if (drop_box == true) { DropBox(); } } }
public void UpdateState() { //TODO: cancel actions in progress //The corpse is far, Barion is approaching if (moving_to_corpse == true) { if (Vector3.Distance(barion.transform.position, corpse.transform.position) <= barion.agent.stoppingDistance) { barion.StopMovement(); PickUpCorpse(); } else { barion.agent.SetDestination(corpse.transform.position); //Constantly follow the corpse //TODO: Double check why I do this. The box isn't going anywhere, why set the destination every update? } } //Is carrying the corpse, now move with it. if (carrying_corpse == true) { //Get new destination if (barion.is_selected) { if (barion.GetMovement(ref destination)) { barion.agent.SetDestination(destination); } } //Update corpse position Vector3 pos = barion.transform.position; corpse.transform.position = new Vector3(pos.x, corpse_height, pos.z); if (drop_corpse == true) { DropCorpse(); } } }
void Hide() { hiding = true; barion.StopMovement(); barion.transform.position = new Vector3(box.transform.position.x, barion.transform.position.y, box.transform.position.z); //Set same pos as box. barion.is_hide = true; barion.selection_system.DeselectPlayer(barion.gameObject); //Deselect the player barion.GetComponent <SpriteRenderer>().enabled = false; //Hide sprite barion.GetComponent <NavMeshAgent>().enabled = false; //Disable the nav mesh to disable collisions box.GetComponent <BoxController>().HideCharacter(HideTags.barion); //Display UI of hide character }
public void ToInvisibleSphereState() { barion.StopMovement(); barion.ChangeStateTo(barion.invisible_sphere_state); }