Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     if (!isServer)
     {
         return;
     }
     timer += Time.deltaTime;
     if (state == GaurdianState.Idle)
     {
         if (timer > timeInIdle)
         {
             timer = 0f;
             state = (GaurdianState)rand.Next(1, 4);
             if (state == GaurdianState.Left)
             {
                 leftSpawn.active = true;
                 leftBarrier.CmdDisable();
                 anim.SetBool("raisingLeft", true);
             }
             else if (state == GaurdianState.Right)
             {
                 rightSpawn.active = true;
                 rightBarrier.CmdDisable();
                 anim.SetBool("raisingRight", true);
             }
             else
             {
                 leftSpawn.active = true;
                 leftBarrier.CmdDisable();
                 rightSpawn.active = true;
                 rightBarrier.CmdDisable();
                 anim.SetBool("raisingBoth", true);
             }
         }
     }
     else
     {
         if (timer > timeInState)
         {
             timer            = 0f;
             state            = GaurdianState.Idle;
             leftSpawn.active = false;
             leftBarrier.CmdEnable();
             rightSpawn.active = false;
             rightBarrier.CmdEnable();
             anim.SetBool("raisingLeft", false);
             anim.SetBool("raisingRight", false);
             anim.SetBool("raisingBoth", false);
         }
     }
 }
Esempio n. 2
0
	// Update is called once per frame
	void Update () {
		if (!isServer)
			return;
		timer += Time.deltaTime;
		if (state == GaurdianState.Idle) {
			if (timer > timeInIdle) {
				timer = 0f;
				state = (GaurdianState)rand.Next (1, 4);
				if (state == GaurdianState.Left) {
					leftSpawn.active = true;
					leftBarrier.CmdDisable ();
					anim.SetBool ("raisingLeft", true);
				} else if (state == GaurdianState.Right) {
					rightSpawn.active = true;
					rightBarrier.CmdDisable ();
					anim.SetBool ("raisingRight", true);
				} else {
					leftSpawn.active = true;
					leftBarrier.CmdDisable ();
					rightSpawn.active = true;
					rightBarrier.CmdDisable ();
					anim.SetBool ("raisingBoth", true);
				}
			}
		} else {
			if (timer > timeInState) {
				timer = 0f;
				state = GaurdianState.Idle;
				leftSpawn.active = false;
				leftBarrier.CmdEnable ();
				rightSpawn.active = false;
				rightBarrier.CmdEnable ();
				anim.SetBool ("raisingLeft", false);
				anim.SetBool ("raisingRight", false);
				anim.SetBool ("raisingBoth", false);
			}
		}
	}