void Start() { float distToEdge = ((DigSpotsSqrRoot - 1) * DigSpotSpacing) / 2; float maxPayoffDist = Mathf.Sqrt(distToEdge * distToEdge * 2); var(digPositions, cannonPositions) = DigPositions(DigSpotsSqrRoot, DigSpotSpacing); foreach (var pos in digPositions) { var diggable = Object.Instantiate(DigSpotPrefab, pos, Quaternion.identity).GetComponent <Diggable>(); diggable.ContentsPrefab = TreasurePrefab; diggable.Quantity = Random.Range(0, Mathf.Max((int)Mathf.Ceil(pos.magnitude * MaxPayoff / maxPayoffDist), 2)); diggable.Controller = this; } _cannonBallSpawns = cannonPositions; _cannons = new List <Cannon>(); foreach (var pos in _cannonBallSpawns) { var goal = CannonBallGoal(pos); float yAngle = Angle.Degrees(goal); _cannons.Add(Object.Instantiate(CannonPrefab, pos, Quaternion.Euler(0, 90.0f - yAngle, 0)).GetComponent <Cannon>()); } _nextSpawn = NextCannonBallSpawnTime(Time.time); Shark.GetComponent <NavMeshAgent>().Warp(SharkStartPosition(Shark)); ScoreText.text = "Score: 0"; }
void Start() { seeker.GetComponent <Seeker>(); rb.GetComponent <Rigidbody2D>(); InvokeRepeating("UpdatePath", 0f, .5f); }
public void BoostingLoop() { if (thingDoingTimer.TimeElapsedSecs() < boostDelay) { //emit boost particles Debug.Log("boosting things"); if (particleTimer.TimeElapsedSecs() > 0.3f) { if (targets.Count > 0) { particleTimer.Restart(); float randEnemyIdxF = Random.Range(0, targets.Count); int randEnemyIdx = (int)randEnemyIdxF; if (randEnemyIdx == targets.Count) { randEnemyIdx--; } //remove inclusive max //Debug.Log(randEnemyIdx); Enemy e = targets[randEnemyIdx]; GameObject particle = GameObject.Instantiate(Resources.Load("Prefabs/MainCanvas/BoostParticle")) as GameObject; //Debug.Log ("we spawned it"); particle.transform.SetParent(Dial.spawnLayer, false); Seeker s = particle.GetComponent <Seeker>(); s.target = e.GetComponent <RectTransform>(); s.GetComponent <RectTransform>().anchoredPosition = this.GetComponent <RectTransform>().anchoredPosition; } } } else { foreach (Enemy e in targets) { e.Unfreeze(); } PickTargetZone(); currentState = state.DECIDING; } }
public GameObject CheckForEnemyInSphere() { targetInSphere = null; int layerMask = 1 << 8; if (gameObject.tag == "EnemyWeapon") { Collider[] colliders = Physics.OverlapSphere(gameObject.transform.position, range, layerMask); for (int i = 0; i < colliders.Length; i++) { if ((colliders[i].GetComponent <FactionIndex>() != null && objectToStick != null && colliders[i].gameObject != null && colliders[i].GetComponent <FactionIndex>().factionId != objectToStick.GetComponent <FactionIndex>().factionId && currentSeeker.GetComponent <FactionIndex>().dead == false && colliders[i].GetComponent <FactionIndex>().isSimpleFollower == false && colliders[i].GetComponent <FactionIndex>().dead == false) ) { foundTargetToShoot = true; targetInSphere = colliders[i].gameObject; if (objectToStick.transform.GetComponent <Trooper>() != null) { objectToStick.transform.GetComponent <Trooper>().enemyToLook = targetInSphere.gameObject; } break; } } if (foundTargetToShoot == false) { if (objectToStick.transform.GetComponent <Trooper>() != null) { objectToStick.transform.GetComponent <Trooper>().enemyToLook = null; } } } return(targetInSphere); }