예제 #1
0
    private void Start()
    {
        takeDamage = GetComponent <RatDefend>();
        dealDamage = GetComponent <RatAttack>();

        ChangeBehaviour(RatState.IDLE);

        StartCoroutine(StartStates());
    }
예제 #2
0
    // Use this for initialization
    void OnEnable()
    {
        timer          = wanderTimer;
        player         = GameObject.FindGameObjectWithTag("Player");
        anim           = GetComponent <Animator>();
        m_GroundNormal = new Vector3(0, 1, 0);

        agent.updateRotation = false;
        agent.updatePosition = true;

        if (chaseEvent == null)
        {
            chaseEvent = new UnityEvent();
        }

        attackScript = GetComponent <RatAttack>();

        chaseEvent.AddListener(attackScript.OnStartChase);
    }
예제 #3
0
 private void Start()
 {
     attack = FindObjectOfType <RatAttack>();
 }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        if (LevelEnd == null)
        {
            LevelEnd = new UnityEvent();
        }

        if (GameOver == null)
        {
            GameOver = new UnityEvent();
        }

        if (uiManager == null)
        {
            uiManager = GetComponent <UIManager>();
        }

        LevelEnd.AddListener(uiManager.OnLevelEnd);
        LevelEnd.AddListener(AddLevelCount);
        player   = GameObject.FindGameObjectWithTag("Player");
        endLight = GameObject.Find("End Light");
        GameObject[] monsterObjects = GameObject.FindGameObjectsWithTag("Monster");
        for (int i = 0; i < monsterObjects.Length; i++)
        {
            WanderingAI   aiScript     = monsterObjects[i].GetComponent <WanderingAI>();
            MonsterAttack attackScript = monsterObjects[i].GetComponent <MonsterAttack>();
            GameOver.AddListener(aiScript.PlayerIsDead);
            GameOver.AddListener(attackScript.PlayerIsDead);
            LevelEnd.AddListener(aiScript.PlayerIsDead);
            LevelEnd.AddListener(attackScript.PlayerIsDead);
        }
        GameObject[] skullObjects = GameObject.FindGameObjectsWithTag("Skull");
        for (int i = 0; i < skullObjects.Length; i++)
        {
            SkullMove   aiScript     = skullObjects[i].GetComponent <SkullMove>();
            SkullAttack attackScript = skullObjects[i].GetComponent <SkullAttack>();
            GameOver.AddListener(aiScript.PlayerIsDead);
            GameOver.AddListener(attackScript.PlayerIsDead);
            LevelEnd.AddListener(aiScript.PlayerIsDead);
            LevelEnd.AddListener(attackScript.PlayerIsDead);
        }
        GameObject[] ratObjects = GameObject.FindGameObjectsWithTag("Rat");
        for (int i = 0; i < ratObjects.Length; i++)
        {
            RatMove   aiScript     = ratObjects[i].GetComponent <RatMove>();
            RatAttack attackScript = ratObjects[i].GetComponent <RatAttack>();
            GameOver.AddListener(aiScript.PlayerIsDead);
            GameOver.AddListener(attackScript.PlayerIsDead);
            LevelEnd.AddListener(aiScript.PlayerIsDead);
            LevelEnd.AddListener(attackScript.PlayerIsDead);
        }

        GameOver.AddListener(uiManager.OnGameOver);
        GameOver.AddListener(GetComponent <ScreenFader>().OnGameOver);
    }