void Collide(Collider other)
    {
        if (other.name == leader.name && timer >= 2)
        {
            Component    playerHealthScript = leader.gameObject.GetComponent("Player");
            Player       pc = (Player)playerHealthScript;
            Component    playerHidingScript = leader.gameObject.GetComponent("HidingPlayer");
            HidingPlayer phs = (HidingPlayer)playerHidingScript;

            if (!phs.hidden && pc.hasKey1)
            {
                pc.Health -= 4;
                timer      = 0;
            }
        }
        else if (other.name == "HidingPlace")
        {
            transform.Rotate(0.0f, 0.0f, Random.Range(90, 270), Space.World);
        }
        else if (other.name == "Gate")
        {
        }
        else if (other.name == "LevelKey")
        {
        }
        else if (other.tag == "Trigger")
        {
        }
        else
        {
            colliding = true;
        }
        timer++;
    }
Ejemplo n.º 2
0
    void OnTriggerExit(Collider other)
    {
        var player = GameObject.FindWithTag("Player");

        Debug.Log("Patch End Collision");
        if (other.collider == player.collider)
        {
            HidingPlayer playerHidingScript = (HidingPlayer)player.gameObject.GetComponent("HidingPlayer");
            playerHidingScript.hidden = false;
        }
    }
Ejemplo n.º 3
0
    void OnTriggerEnter(Collider other)
    {
        var player = GameObject.FindWithTag("Player");

        Debug.Log("Patch Collision Start");
        if (other.collider == player.collider)
        {
            Debug.Log("Patch player detected");
            HidingPlayer playerHidingScript = (HidingPlayer)player.gameObject.GetComponent("HidingPlayer");
            playerHidingScript.hidden = true;
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        float        distance           = Vector3.Distance(leader.position, transform.position);
        Component    playerHidingScript = leader.gameObject.GetComponent("HidingPlayer");
        HidingPlayer phs    = (HidingPlayer)playerHidingScript;
        bool         hidden = phs.hidden;

        //bool hidden = false;

        if (distance < chase_radius)          //chasing!
        {
            transform.LookAt(leader);
            if (hidden == false)
            {
                speed = chase_speed;
            }
            else
            {
                if (Random.Range(0, 100) <= 1)
                {
                    transform.Rotate(0.0f, 0.0f, Random.Range(30, 360), Space.World);
                }
                transform.forward = Vector3.zero - transform.forward;
                speed             = 3;
                timer++;
            }
            Color mycolor = transform.renderer.material.color;
            mycolor.a = 100;
            transform.renderer.material.color = mycolor;
        }
        else           //not chasing
        {
            transform.renderer.material.color = Color.grey;
            Color mycolor = transform.renderer.material.color;
            mycolor.a = 0;
            transform.renderer.material.color = mycolor;
            if (Random.Range(0, 100) <= 1)
            {
                transform.Rotate(0.0f, 0.0f, Random.Range(30, 360), Space.World);
            }
            speed = 3;
        }

        if (colliding)
        {
            transform.Rotate(0.0f, 0.0f, Random.Range(30, 360), Space.World);
        }
        rigidbody.MovePosition(transform.position + transform.forward * speed * Time.deltaTime);
        timer++;
    }
Ejemplo n.º 5
0
 void OnTriggerStay(Collider other)
 {
     if (other.name == leader.name && timer2 <= 0)
     {
         Component    playerHealthScript = leader.gameObject.GetComponent("Player");
         Player       pc = (Player)playerHealthScript;
         Component    playerHidingScript = leader.gameObject.GetComponent("HidingPlayer");
         HidingPlayer hp = (HidingPlayer)playerHidingScript;
         if (!hp.hidden)
         {
             pc.Health -= 40;
             audio.PlayOneShot(damage);
             timer2 = 0.7f;
         }
     }
     timer2 -= Time.deltaTime;
 }