public override void UpdateAbility(OtherNPCState npcState, Animator animator, AnimatorStateInfo stateInfo) { NPCControl c = npcState.GetNPCControl(animator); if (c.Move) { animator.SetBool(NPCControl.TransitionParameter.Move.ToString(), true); } if (c.Wonder) { animator.SetBool(NPCControl.TransitionParameter.Wonder.ToString(), true); } if (c.Float) { animator.SetBool(NPCControl.TransitionParameter.Float.ToString(), true); } if (c.CheckForDraggable()) { c.Wonder = true;; animator.SetBool(NPCControl.TransitionParameter.Wonder.ToString(), true); } }
public NPCControl GetNPCControl(Animator animator) { if (npcControl == null) { npcControl = animator.GetComponentInParent <NPCControl>(); } return(npcControl); }
public void EnemyDestroyed(NPCControl enemy) { enemies.Remove(enemy); if (enemies.Count == 0) { nextLevel(); } }
public void CloseDialogue() { UIHelper.CloseAllCanvasGroups(dialogueBox, buttonOptions, dialogueProgress); linesIndex = 0; scrollbar.value = 1; ClearButtons(); npc = null; }
public ChaseState(Transform player, Transform npc) { this.player = player; this.npc = npc; npcControl = npc.gameObject.GetComponent <NPCControl>(); npcRdb = npc.gameObject.GetComponent <Rigidbody>(); stateID = StateID.ChasingID; }
public void Initialize(NPCControl npc) { this.npc = npc; npcName.text = npc.GetComponent <Character>().CharacterName; mainText.text = npc.NpcDialogue.NPCIntroduction; UIHelper.ToggleCanvasGroup(buttonOptions); GenerateOptionButtons(); }
public override void UpdateAbility(OtherNPCState npcState, Animator animator, AnimatorStateInfo stateInfo) { NPCControl c = npcState.GetNPCControl(animator); if (!c.Float) { animator.SetBool(NPCControl.TransitionParameter.Float.ToString(), false); } }
public PatrolState(Transform player, Transform npc, Transform[] path) { this.player = player; this.npc = npc; npcRgb = npc.gameObject.GetComponent <Rigidbody>(); npcControl = npc.gameObject.GetComponent <NPCControl>(); currentWayPoint = 0; waypoints = path; stateID = StateID.PatrolID; }
void Awake() { if (instance != null) { Destroy(this.gameObject); return; } else { instance = this; GameObject.DontDestroyOnLoad(this.gameObject); } }
public override void OnEnter(OtherNPCState npcState, Animator animator, AnimatorStateInfo stateInfo) { NPCControl c = npcState.GetNPCControl(animator); Instantiate(QuestionMark, new Vector3(c.gameObject.transform.position.x, c.gameObject.transform.position.y + 3f, c.gameObject.transform.position.z), QuestionMark.rotation); GameObject closestDrone = c.FindClosestDrone(); if (closestDrone != null) { closestDrone.GetComponent <DroneNavAgent>().tracking = true; closestDrone.GetComponent <DroneNavAgent>().playerTarget++; } c.LED.material.color = Color.yellow; c.LED.material.SetColor("_EmissionColor", Color.yellow); AlertTimer = 5.0f; }
void OpenDialogueProcessCanvas(NPCControl npc, Button button) { ToggleCanvases(); int buttonIndex = optionsButtons.FindIndex(x => x == button); mainText.text = npc.NpcDialogue.DialogueLines[buttonIndex, linesIndex]; scrollbar.gameObject.SetActive(false); UpdateContinueButton(buttonIndex, linesIndex + 1); continueButton.onClick.AddListener(() => NextDialogueLine(buttonIndex)); returnButton.onClick.AddListener(() => OpenDialogueOptionsCanvas()); if (npc.NpcDialogue.DialogueButtons.buttonOptions[buttonIndex].dialogueEvent) { npc.NpcDialogue.DialogueButtons.buttonOptions[buttonIndex].dialogueEvent.PerformEventAction(npc); } }
void SpawnEnemy() { if (Timer <= 0 && NotInIce == true) { CurrentPosition = transform.position; GameObject EnemyClone = Instantiate(Enemy, CurrentPosition, Quaternion.identity); Destroy(this.gameObject); NPCControl enemyController = EnemyClone.GetComponent <NPCControl>(); theManager.EnemySpawn(enemyController); theManager.EggDestroyed(this); } if (IceDestroyed == true && NotInIce == true) { CurrentPosition = transform.position; Instantiate(Enemy, CurrentPosition, Quaternion.identity); Destroy(this.gameObject); } //Raycast to player }
public override void Act(GameObject player, GameObject npc) { Debug.Log("FollowPath: ACT"); Debug.Log("FollowPath: player - " + player.ToString() + ". npc - " + npc.ToString()); // Follow the path of waypoints // Find the direction of the current way point //Vector3 vel = npc.rigidbody.velocity; Vector3 vel = npc.GetComponent <Rigidbody>().velocity; Vector3 moveDir = waypoints[currentWayPoint].position - npc.transform.position; if (moveDir.magnitude < 1) { currentWayPoint++; Debug.Log("FollowPath: Incrementa WayPoint"); if (currentWayPoint >= waypoints.Length) { currentWayPoint = 0; } } else { Debug.Log("FollowPath: SEGUINDO WayPoints"); vel = moveDir.normalized * NPCControl.GetVelocityFactor(); Debug.DrawRay(npc.transform.position, moveDir); // Rotate towards the waypoint npc.transform.rotation = Quaternion.Slerp(npc.transform.rotation, Quaternion.LookRotation(moveDir), 2 * Time.deltaTime); //npc.transform.rotation.ToAngleAxis(180f,Vector3.up); //npc.transform.RotateAround(npc.transform.position,Vector3.up, 180.0f); //npc.transform.rotation = Quaternion.LookRotation(moveDir); npc.transform.eulerAngles = new Vector3(0, npc.transform.eulerAngles.y, 0); } // Apply the Velocity //npc.rigidbody.velocity = vel; npc.GetComponent <Rigidbody> ().velocity = vel; }
void OnTriggerExit2D(Collider2D act) { if (act.tag == "NPC") { Debug.Log("Bye, then."); NPCControl npc = act.gameObject.GetComponent <NPCControl>(); //bicara pada NPC talkNpc.gameObject.SetActive(false); } if (act.tag == "sPortal") { Debug.Log("Too bad..."); SpecialWarpControl sWarp = act.gameObject.GetComponent <SpecialWarpControl>(); actButton.gameObject.SetActive(false); } if (act.tag == "DemitArea") { inDemitArea = false; } }
public override void UpdateAbility(OtherNPCState npcState, Animator animator, AnimatorStateInfo stateInfo) { NPCControl c = npcState.GetNPCControl(animator); if (c.Wonder) { AlertTimer -= Time.deltaTime; if (AlertTimer <= 0) { c.LED.material.color = Color.green; c.LED.material.SetColor("_EmissionColor", Color.green); GameObject closestDrone = c.FindClosestDrone(); if (closestDrone != null) { closestDrone.GetComponent <DroneNavAgent>().playerTarget--; } animator.SetBool(NPCControl.TransitionParameter.Wonder.ToString(), false); c.Wonder = false; } } }
public override void Act(GameObject player, GameObject npc) { Debug.Log("ChasePlayer: PERSEGUINDO O JOGADOR"); // Follow the path of waypoints // Find the direction of the player //Vector3 vel = npc.rigidbody.velocity; Vector3 vel = npc.GetComponent <Rigidbody>().velocity; Vector3 moveDir = player.transform.position - npc.transform.position; Debug.DrawRay(npc.transform.position, moveDir); // Rotate towards the waypoint npc.transform.rotation = Quaternion.Slerp(npc.transform.rotation, Quaternion.LookRotation(moveDir), 5 * Time.deltaTime); npc.transform.eulerAngles = new Vector3(0, npc.transform.eulerAngles.y, 0); vel = moveDir.normalized * (NPCControl.GetVelocityFactor() * 1.8f); //Aumenta 1.8x a velocidade do Dinossauro para correr atras do player // Apply the new Velocity //npc.rigidbody.velocity = vel; npc.GetComponent <Rigidbody>().velocity = vel; //npc.GetComponent<NavMeshAgent>().destination = vel; }
public override void UpdateAbility(OtherNPCState npcState, Animator animator, AnimatorStateInfo stateInfo) { NPCControl c = npcState.GetNPCControl(animator); if (c.Move) { if (Vector3.Distance(c.Waypoint.position, c.transform.position) < DestroyRadius) { GameObject closestDrone = c.FindClosestDrone(); if (closestDrone != null) { closestDrone.GetComponent <DroneNavAgent>().npcTargets.Remove("npc" + c.ID); } animator.SetBool(NPCControl.TransitionParameter.Move.ToString(), false); c.Move = false; Destroy(c.gameObject); } else { Vector3 newDirection = Vector3.RotateTowards(c.transform.position, new Vector3(c.Waypoint.position.x, c.transform.position.y, c.Waypoint.position.z), 1f, 0.0f); c.transform.LookAt(new Vector3(c.Waypoint.position.x, c.transform.position.y, c.Waypoint.position.z)); c.transform.position = Vector3.MoveTowards(c.transform.position, c.Waypoint.transform.position, Time.deltaTime * Speed); } } else { animator.SetBool(NPCControl.TransitionParameter.Move.ToString(), false); } if (c.CheckForDraggable()) { c.Wonder = true;; animator.SetBool(NPCControl.TransitionParameter.Wonder.ToString(), true); } }
public void OpenDialogue(NPCControl npc) { UIHelper.ToggleCanvasGroup(dialogueBox); Initialize(npc); }
public void SetNPCref(NPCControl reference) { npcRef = reference; }
public void EnemySpawn(NPCControl enemy) { enemies.Add(enemy); }