//Miscellaneous Update Code private void StandardUpdate() { if (CrossPlatformInputManager.GetButtonDown("Vomit")) { if (!m_Animator.GetCurrentAnimatorStateInfo(1).IsName("Vomit") && !m_Animator.GetNextAnimatorStateInfo(1).IsName("Vomit")) { m_Animator.SetTrigger("vomit"); } } //If we are looking at an ally RaycastHit hit; Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward * 10f, out hit); if (hit.collider != null && hit.collider.gameObject.GetComponent <AIAllyCharacterControl>()) { //This is an Ally, display the "Follow me" or "Stay here" text AIAllyCharacterControl follower = hit.collider.gameObject.GetComponent <AIAllyCharacterControl>(); if (follower.isFollowing) { GameController.instance.interactText.text = ""; } else { GameController.instance.interactText.text = "(E) Command: Follow me"; //Press E to toggle follow/stay if (Input.GetKeyDown(KeyCode.E)) { follower.isFollowing = !follower.isFollowing; if (follower.isFollowing) { GameController.instance.squadMgr.AddAlly(follower.gameObject); } } } } else if (GameController.instance.interactText.text == "(E) Command: Stay here" || GameController.instance.interactText.text == "(E) Command: Follow me") { GameController.instance.interactText.text = ""; } }
public void AddAlly(GameObject ally) { AIAllyCharacterControl AI = ally.GetComponent <AIAllyCharacterControl>(); //Don't add the ally if we already recruited them if (!Allies.Contains(AI)) { //Create a UI row for the allies GameObject UIPortrait = Instantiate(UIPortraitPfb, UIPortraitsPanel.transform); Allies.Add(AI); Portrait portrait = UIPortrait.GetComponent <Portrait>(); Portraits.Add(portrait); SelectAlly(Allies.IndexOf(AI)); Health health = ally.GetComponent <Health>(); health.healthSlider = portrait.sldHealth; portrait.txtName.text = AI.attributes.fullname; portrait.imgPortrait.sprite = AI.attributes.portrait; } }