Пример #1
0
    void Start()
    {
        _nav = GetComponent <NavMeshAgent>();

        _guest = GameObject.Find("Player").transform;

        _wolf_manager = transform.parent.gameObject.GetComponent <WolfManager>();

        _main_controller = GameObject.Find("Root").GetComponent <MainController>();

        _original_position = transform.position;

        _holwed = false;

        _is_approaching = false;
        _is_retrieving  = false;
        _is_stopped     = false;

        SetApproaching();

        _audio          = GetComponent <AudioSource>();
        _audio.loop     = false;
        _audio.priority = 255;

        _wolfSounds    = new AudioClip[3];
        _wolfSounds[0] = Resources.Load("Sounds/Wolf Growl 1") as AudioClip;
        _wolfSounds[1] = Resources.Load("Sounds/Wolf Growl 2") as AudioClip;
        _wolfSounds[2] = Resources.Load("Sounds/Wolf Growl 3") as AudioClip;

        _reminder_played = false;
        _success_played  = false;
    }
Пример #2
0
    // handle Eat / Mating game oject collisions (eat rabbits, have baby wolves)
    void OnTriggerEnter(Collider collision)
    {
        wolfManagerInst    = GetComponentInParent <WolfManager>();  // get instance of WolfManager so that this script can access it variables
        wolfMoveScriptInst = GetComponentInParent <WolfMoveScript>();

        if ((collision.gameObject.tag == "Rabbit") || (collision.gameObject.tag == "BabyRabbit") || (collision.gameObject.tag == "Moose") || (collision.gameObject.tag == "BabyMoose") || (collision.gameObject.tag == "Beaver") || (collision.gameObject.tag == "BabyBeaver"))
        {
            // rabbit detected by eat collider, eat the rabbit
            wolfMoveScriptInst.WolfHunger  = 0.0f;
            wolfManagerInst.wolfHungry     = 0;
            wolfManagerInst.RabbitDetected = 0;
            wolfManagerInst.RabbitPosition = new Vector3(0f, 0f, 0f);
            if (debugLevel >= 1)
            {
                print("EatDetect: Just Ate: Hunger 0 " + wolfMoveScriptInst.WolfHunger + wolfManagerInst.RabbitDetected);
            }
            Instantiate(Gore, new Vector3(collision.transform.position.x, 0, collision.transform.position.z), collision.transform.rotation);
            if ((collision.gameObject.tag == "Rabbit") || (collision.gameObject.tag == "Moose") || (collision.gameObject.tag == "Beaver"))
            {
                Destroy(collision.gameObject.transform.parent.gameObject);
            }
            else
            {
                Destroy(collision.gameObject);
            }
        }
        else if (collision.gameObject.tag == "Wolf")
        {
            // wolf detected by mating collider, create baby wolf if it has been long enough since last mating
            if (wolfManagerInst.wolfMateTimer >= wolfManagerInst.wolfMateTimeCal)
            {
                if (debugLevel >= 1)
                {
                    print("WolfAI: wolf just mated");
                }
                Instantiate(BabyWolf, new Vector3(transform.position.x, transform.position.y, transform.position.z), transform.rotation);
                wolfManagerInst.wolfMateTimer = 0;
            }
        }
    }
Пример #3
0
 protected override void Collect()
 {
     WolfManager.AddLifetime(m_timeToAdd);
 }
Пример #4
0
 void Start()
 {
     navComponent = GetComponent <NavMeshAgent>();
     wolfManager  = GameObject.FindGameObjectWithTag("WolfManager").GetComponent <WolfManager>();
     MoveToRandom(areaRange, assignmentArea.position);
 }