示例#1
0
    // Update is called once per frame
    void Update()
    {
        var  playerRoom = CalcRoom(player.transform.position);
        bool alert      = false;
        var  attachTo   = player.GetComponent <PlayerController>().attatchTo;

        foreach (var servant in servants)
        {
            if (servant == null || servant == attachTo)
            {
                continue;
            }
            if (CalcRoom(servant.transform.position) != null && CalcRoom(servant.transform.position) == playerRoom)
            {
                alert = true;
                musicController.alert();
                break;
            }
        }
        foreach (var fighter in fighters)
        {
            if (fighter == null || fighter == attachTo)
            {
                continue;
            }
            if (CalcRoom(fighter.transform.position) != null && CalcRoom(fighter.transform.position) == playerRoom)
            {
                Lose();
            }
        }
        if (boss == null && playerRoom == winRoom)
        {
            Win();
        }
        if (alertSecond > 0)
        {
            alertSecond -= Time.deltaTime;
            if (alertSecond < 0)
            {
                unAlert();
            }
        }
        if (alert == true)
        {
            alertFighter(playerRoom);
        }
    }