Beispiel #1
0
	void Scan()
	{
		float minDist = detectRange;

		Vector3 ownPos = transform.position;

		bool found = false;

		foreach(GameObject t in GameObject.FindGameObjectsWithTag("Enemy"))
		{
			float dist = Vector3.Distance(t.transform.position, ownPos);
			if(dist < minDist)
			{
				found = true;
				currentTarget = t;
				minDist = dist;
			}
		}

		if (found) {
			state = turretStates.ATTACK;
		} else {
			state = turretStates.IDLE;
		}
	}
Beispiel #2
0
	void Idle()
	{
		scanTimer += Time.deltaTime;
		if (scanTimer > scanFrequency) 
		{
			scanTimer = 0;
			state = turretStates.SCAN;
		}
	}
Beispiel #3
0
	void Attack()
	{
		float dist = Vector3.Distance (currentTarget.transform.position, transform.position);

		if (dist > detectRange) {
			state = turretStates.IDLE;
		}

		if (dist > firingRange) {
			state = turretStates.CHASE;
		} else {
			// Actual attack
			// To Do: Animation, projectiles

			// Animation timer 

			// If animation timer finish
			for(int i = 0; i < i; ++i) // x being number of bullets fired during the animation
			{
				int accuracy = Random.Range(0, 101);
				if(accuracy < firingAccuracy)
				{
					// Minus health
					//currentTarget.GetComponent<MobStat>().health 

					// If mob dies
					// state = turrentStates.IDLE;
				}
			}
		}
	}
Beispiel #4
0
	// Use this for initialization
	void Start () {
		state = turretStates.IDLE;
	}