Exemple #1
0
    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);
        }
    }
Exemple #2
0
 public NPCControl GetNPCControl(Animator animator)
 {
     if (npcControl == null)
     {
         npcControl = animator.GetComponentInParent <NPCControl>();
     }
     return(npcControl);
 }
Exemple #3
0
 public void EnemyDestroyed(NPCControl enemy)
 {
     enemies.Remove(enemy);
     if (enemies.Count == 0)
     {
         nextLevel();
     }
 }
Exemple #4
0
 public void CloseDialogue()
 {
     UIHelper.CloseAllCanvasGroups(dialogueBox, buttonOptions, dialogueProgress);
     linesIndex      = 0;
     scrollbar.value = 1;
     ClearButtons();
     npc = null;
 }
Exemple #5
0
 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;
 }
Exemple #6
0
        public void Initialize(NPCControl npc)
        {
            this.npc      = npc;
            npcName.text  = npc.GetComponent <Character>().CharacterName;
            mainText.text = npc.NpcDialogue.NPCIntroduction;
            UIHelper.ToggleCanvasGroup(buttonOptions);

            GenerateOptionButtons();
        }
Exemple #7
0
    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);
        }
    }
Exemple #8
0
 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;
 }
Exemple #9
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(this.gameObject);
     }
 }
Exemple #10
0
    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;
    }
Exemple #11
0
        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);
            }
        }
Exemple #12
0
    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
    }
Exemple #13
0
    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;
        }
    }
Exemple #15
0
    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;
            }
        }
    }
Exemple #16
0
    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;
    }
Exemple #17
0
    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);
        }
    }
Exemple #18
0
 public void OpenDialogue(NPCControl npc)
 {
     UIHelper.ToggleCanvasGroup(dialogueBox);
     Initialize(npc);
 }
 public void SetNPCref(NPCControl reference)
 {
     npcRef = reference;
 }
Exemple #20
0
 public void EnemySpawn(NPCControl enemy)
 {
     enemies.Add(enemy);
 }