예제 #1
0
 void Start()
 {
     if (SceneManager.GetActiveScene().name == "LoadScreen") return;
     GameObject monster = GameObject.Find("MonsterStandin");
     if ( monster != null )monsterAudio = GameObject.Find("MonsterStandin").GetComponent<spt_monsterAudio>();
     loss = false;
     lossMenu = false;
     player = this.transform.root.gameObject;
 }
    // Attack function for the monster.
    private void attack()
    {
        if (!isServer) return;
        // Monster can decide to attack or not
        int attackOrNot = UnityEngine.Random.Range(0, 3);

        // the monster will attack if the random number allows it, or if its anger has exceeded the top bound of its threshold.
        if (attackOrNot == 0 || (angerLevel >= upperThreshold)){

            // If the monster has not already warned the players of its anger, it does.
            if (hasGivenWarning == false){
                // Play warning noise.
                hasGivenWarning = true;
                angerAtWarning = angerLevel;
                timeOfWarning = time;
                audioScript = GetComponent<spt_monsterAudio>();
                audioScript.prepWarningNoise();
            }

            // If the players have already been warned, and there was a 8 second interval between the initial warning and an attack
            else if ((hasGivenWarning==true) && (timeOfWarning!= -1) && (time-timeOfWarning>8) && (angerLevel > lowerThreshold)){
                //populate network fields
                //whichPlayer = Random.Range(0, spawns.Length);

                if (hostThreat > clientThreat)
                    whichPlayer = 0;
                else
                    whichPlayer = 1;

                isAttacking = true;
                //animationScript.attackPlayer(spawns[whichPlayer].transform, whichPlayer);
            }
        }
    }