Exemple #1
0
    private void patrol()
    {
        Vector3 distanceToPlayer = (player.transform.position - this.transform.position);
        float   dir = Vector3.Dot(this.transform.forward, distanceToPlayer);

        if (distanceToPlayer.magnitude < 3)
        {
            print("Calling endgame");
            endGame();
            return;
        }
        if (!nav_mesh.pathPending && nav_mesh.remainingDistance < 0.5f)
        {
            SetNextWaypoint();
        }
        if (distanceToPlayer.magnitude < chaseDistance - 10 && dir > 0)
        {
            setState(AIStates.Chase);
        }
        else if (hasKey && distanceToPlayer.magnitude < stealDistance && dir < 0)
        {
            NotificationScreen.getInstance().displayNotification("Press F to pay respects", Time.time, 2);

            if (Input.GetKeyDown(KeyCode.F))
            {
                stealKey();
            }
        }
        anim.Play("Walk");
    }
 void OnTriggerEnter(Collider other)
 {
     if (active & other.tag == "Player")
     {
         GrabKey gc = other.gameObject.GetComponent <GrabKey>();
         NotificationScreen.getInstance().displayNotification("Obtained key to cage!", Time.time, 3);
         AudioManager.getInstance().playObtained();
         ScoreSystem.getInstance().addToScore(50, ScoreSystem.scType.NONE);
         gc.giveKey();
         active = false;
     }
 }
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     Instance = this;
     Components.Notifiers.OnAdd    += OnAddNotifier;
     Components.Notifiers.OnRemove += OnRemoveNotifier;
     foreach (Notifier item in Components.Notifiers.Items)
     {
         OnAddNotifier(item);
     }
     MessagesPrefab.gameObject.SetActive(false);
     LabelPrefab.gameObject.SetActive(false);
     InitNotificationSounds();
 }
    void OnTriggerEnter(Collider other)
    {
        print("Collided with " + other);
        if (active && other.gameObject.tag == "Guard")
        {
            Rigidbody rb = other.gameObject.GetComponent <Rigidbody>();
            print("Obtained the rigidbody of cop");
            other.gameObject.GetComponent <AICop>().setState(AICop.AIStates.Eating);
            //rb.AddTorque(totalForce, ForceMode.Impulse);
            active = false;

            NotificationScreen.getInstance().displayNotification("NEWSFLASH : Diabetes on the rise in Zoo Guards!", Time.time + 1, 3);
            ScoreSystem.getInstance().addToScore(10, ScoreSystem.scType.DONUT);
        }
    }
 void OnTriggerEnter(Collider collider)
 {
     if (collider.gameObject.tag == "Player" && doorController.IsDoorClosed)         // this string is your newly created tag
     {
         GrabKey gc = collider.gameObject.GetComponent <GrabKey>();
         if (gc.nKeys > 0)
         {
             print("Opening the door");
             doorController.OpenDoor();
             gc.nKeys--;
         }
         else
         {
             NotificationScreen.getInstance().displayNotification("You must find the key to the cage!", Time.time, 3);
             print("Can't open the door");
         }
     }
 }
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player" & !rescued)
        {
            rescueTime = Time.time;
            rescued    = true;
            ScoreSystem.getInstance().addToScore(100, ScoreSystem.scType.NONE);

            switch (animal)
            {
            case Prefs.Animals.Hippo:
                print("Rescued Hippo");
                anim.Play("Success Hippo");
                NotificationScreen.getInstance().displayNotification("Thanks for rescuing me! Here is something to help you. I was working on this in my time in the cage.", Time.time, 5);
                break;

            case Prefs.Animals.Croc:
                print("Rescued Croc");
                anim.Play("Success Crocodile");
                NotificationScreen.getInstance().displayNotification("Thanks for rescuing me! Here is something to help you. I stole this from one of the guards.", Time.time, 5);
                break;

            case Prefs.Animals.Giraffe:
                print("Rescued Hippo");
                anim.Play("Success Giraffe");
                NotificationScreen.getInstance().displayNotification("Thanks for rescuing me! I have nothing to give you.", Time.time, 5);
                break;

            case Prefs.Animals.Lion:
                print("Rescued Lion");
                anim.Play("Success Lion");
                NotificationScreen.getInstance().displayNotification("ROAR! Thanks for rescuing me! Here is something to help you. It dropped out of the sky.", Time.time, 5);
                break;

            case Prefs.Animals.Elephant:
                print("Rescued Elephant");
                anim.Play("Success Elephant");
                NotificationScreen.getInstance().displayNotification("Thanks for rescuing me! I have nothing to give you.", Time.time, 5);
                break;
            }

            facesUI.RescuedAnimal(animal);
        }
    }
Exemple #7
0
 void OnTriggerEnter(Collider other)
 {
     if (active && other.gameObject.tag == "Guard")
     {
         Rigidbody rb = other.gameObject.GetComponent <Rigidbody>();
         print("Obtained the rigidbody of cop");
         other.gameObject.GetComponent <AICop>().setState(AICop.AIStates.Flying);
         Vector3 totalForce = new Vector3(0, 500, 0);
         print("Total force added " + totalForce);
         rb.AddForce(totalForce, ForceMode.Impulse);
         //rb.AddTorque(totalForce, ForceMode.Impulse);
         this.GetComponent <Rigidbody>().AddForce(totalForce, ForceMode.Impulse);
         this.GetComponent <AudioSource>().Play();
         other.gameObject.GetComponent <AudioSource>().Play();
         active   = false;
         isFlying = true;
         flyTime  = 0;
         NotificationScreen.getInstance().displayNotification("Zoo Guard found on " + Planets[chooseRandomPlanet()] + ". Alien abduction suspected.", Time.time + 1, 3);
         ScoreSystem.getInstance().addToScore(10, ScoreSystem.scType.ROCKET);
     }
 }
 public static void DestroyInstance()
 {
     Instance = null;
 }
Exemple #9
0
 private void Awake()
 {
     Instance          = this;
     canvasGroup       = GetComponent <CanvasGroup>();
     canvasGroup.alpha = 0f;
 }
Exemple #10
0
 void Awake()
 {
     instance = this;
 }