private void OnSceneGUI() { MySpawner = (AISpawner)target; HandleTransform = MySpawner.transform; HandleRotation = (Tools.pivotRotation == PivotRotation.Local) ? HandleTransform.rotation : Quaternion.identity; for (int i = 0; i < MySpawner.SpawnPoints.Count; i++) { Vector2 point = MySpawner.SpawnPoints[i]; //If handle is pressed if (Handles.Button(MySpawner.SpawnPoints[i], Quaternion.identity, 0.5f, 0.5f, Handles.SphereHandleCap)) { Repaint(); selected = i; } if (selected == i) { EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, HandleRotation); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(MySpawner); Undo.RecordObject(MySpawner, "Moved point"); MySpawner.SpawnPoints[i] = point; } } } }
public void AddSpawner(AISpawner spawner) { if (!_spawners.Contains(spawner)) { _spawners.Add(spawner); } }
public override void OnInspectorGUI() { MySpawner = (AISpawner)target; EditorGUILayout.LabelField("SpawnPoints"); for (int i = 0; i < MySpawner.SpawnPoints.Count; i++) { EditorGUI.BeginChangeCheck(); Vector2 Point = EditorGUILayout.Vector2Field("SpawnPoint " + i, MySpawner.SpawnPoints[i]); if (EditorGUI.EndChangeCheck()) { MySpawner.SpawnPoints[i] = Point; Undo.RecordObject(MySpawner, "Value Changed"); EditorUtility.SetDirty(MySpawner); } } if (GUILayout.Button("Add SpawnPoint")) { MySpawner.SpawnPoints.Add(new Vector2()); } if (GUILayout.Button("Remove SpawnPoint")) { if (MySpawner.SpawnPoints.Count > 0) { MySpawner.SpawnPoints.RemoveAt(MySpawner.SpawnPoints.Count - 1); } } base.OnInspectorGUI(); }
public void RemoveSpawner(AISpawner spawner) { if (_spawners.Contains(spawner)) { _spawners.Remove(spawner); } }
void Start() { nav = GetComponent <NavMeshAgent>(); counter = Random.Range(2, 5); nav.destination = patrolPoints[Random.Range(0, patrolPoints.Length)].transform.position; spawner = FindObjectOfType <AISpawner>(); }
public AISpawner() { if (aiSpawnerRef == null) { aiSpawnerRef = this; } }
// Use this for initialization void Start() { AIManager = transform.parent.GetComponentInParent <AISpawner>(); animator = GetComponentInChildren <Animator>(); SetUp(); }
private void Start() { ai = GetComponent <AIMove>(); m_AIManager = GetComponent <AISpawner>(); // Initiates new fish in with SwimState active SetState(new SwimState(this)); }
// Start is called before the first frame update void Start() { m_AIManager = transform.parent.GetComponentInParent <AISpawner>(); m_animator = GetComponent <Animator>(); SetUpNPC(); }
private void Awake() { ammo = 0; capsule = GetComponent <CapsuleCollider>(); capsule.isTrigger = true; Transform canvasT = transform.Find("Canvas"); ammoObjs = new List <GameObject>(); foreach (Transform t in canvasT) { ammoObjs.Add(t.gameObject); } updateAmmoUI(); towerPosition = transform.position; shock = transform.GetChild(1); shock.gameObject.SetActive(false); spawner = FindObjectOfType <AISpawner>(); if (spawner == null) { Debug.LogError("Couldn't find AISpawner!"); } anim = GetComponentInChildren <Animator>(); if (anim == null) { Debug.LogError("Couldn't find Animator in plant!"); } }
public override void OnExplode() { Debug.Log(DateTime.Now + " EXIT DESTROYED!!!"); AISpawner spawner = GameObject.Find(Constants.AI_SPAWNER_NAME).GetComponent <AISpawner>(); spawner.SpawnEnemiesAfterExitExploded(gameObject.transform.position); }
// Use this for initialization void Start() { rb2d = GetComponent <Rigidbody2D>(); aiAnim = GetComponent <Animator>(); audioData = GetComponent <AudioSource>(); aiSpawnerObj = GameObject.FindGameObjectWithTag("EnemySpawner"); aiSpawner = aiSpawnerObj.GetComponent <AISpawner>(); }
void Start() { spawnerScript = GameObject.Find("EnemySpawner").GetComponent <AISpawner> (); if (gameObject.GetComponent <ExportMap> ().enabled) { export = true; } }
void Start() { spawnerScript = GameObject.Find ("EnemySpawner").GetComponent<AISpawner> (); if (gameObject.GetComponent <ExportMap> ().enabled) { export = true; } }
// Start is called before the first frame update void Start() { //get the AISpawner from its paret m_AIManager = transform.parent.GetComponentInParent <AISpawner>(); m_animator = GetComponent <Animator>(); SetUpNPC(); }
// Use this for initialization void Start() { splashCanvas = GameObject.Find("SplashCanvas"); myMain = GameObject.Find("Main Camera"); myMain.SetActive(false); aiSpawner = GameObject.Find("AISpawner").GetComponent <AISpawner>(); getHeight = GetComponent <GetHeight>(); }
public void Catch() { if (this.m_AI) { return; } AI.AIID aiid = AI.AIID.None; if (!this.m_FishTrap) { List <AI.AIID> list = new List <AI.AIID>(); for (int i = 0; i < AIManager.Get().m_Spawners.Count; i++) { AISpawner aispawner = AIManager.Get().m_Spawners[i]; if (aispawner.enabled) { if (!aispawner.m_Bounds.Contains(base.transform.position)) { Vector3 to = aispawner.m_Bounds.ClosestPoint(base.transform.position); if (base.transform.position.Distance(to) > this.m_AdditionalDist) { goto IL_C5; } } if (this.m_AIIDs.Contains(aispawner.m_ID)) { list.Add(aispawner.m_ID); } } IL_C5 :; } if (list.Count > 0) { aiid = list[UnityEngine.Random.Range(0, list.Count)]; } else if (UnityEngine.Random.Range(0f, 1f) < this.m_ChanceToCatchOutsideSpawner) { aiid = this.m_AIIDs[UnityEngine.Random.Range(0, this.m_AIIDs.Count)]; } } else { aiid = this.m_AIIDs[UnityEngine.Random.Range(0, this.m_AIIDs.Count)]; } if (aiid != AI.AIID.None) { this.Catch(aiid); } else { if (this.m_Bait && this.m_Bait.m_Item) { this.m_Bait.DeleteItem(); } this.SetArmed(false); this.m_ChanceToCatchOutsideSpawner += this.m_ChanceToCatchOutsideSpawnerChange; } }
public void BotRequest(int connectionId) { MobileAgent _ma = agents.Find(x => ((x.user != null) ? x.user.connectionId : x.customId) == connectionId); if (_ma != null && agents[0] == _ma && !isStarted && canAddBots && agents.Count < MapLoader.maps[map].minPlayers && agents.FindAll(x => x.heroType == HeroType.Player).Count < MapLoader.maps[_ma.session.map].maxPlayers && !killed) { AISpawner.SpawnPlayerBot(ServerManager.playerHeroes [Random.Range(0, ServerManager.playerHeroes.Count)].clientPrefab, this); } }
// Use this for initialization void Start() { m_AIManager = transform.parent.GetComponentInParent <AISpawner>(); //m_animator = GetComponent<Animator>(); SetUpNPC(); fixedJoints = GetComponentsInChildren <FixedJoint>(); //creatureRigidbody = GetComponent<Rigidbody>(); IdentifyMovingParts(); }
// Use this for initialization void Start() { aiSpawner = GameObject.Find("AISpawner").GetComponent <AISpawner>(); geoForward = GameObject.Find("GeoForward").GetComponent <GeoForward>(); splashCanvas = GameObject.Find("SplashCanvas"); myMain = GameObject.Find("Main Camera"); myMain.SetActive(false); readLocationFile = GameObject.Find("ReadLocationFile").GetComponent <ReadLocationFile>(); GenerateLocationButtons(); }
// Start is called before the first frame update void Start() { if (player == null) { player = GameObject.FindGameObjectWithTag("Player"); } if (scoutLocationsParent == null) { scoutLocationsParent = GameObject.FindGameObjectWithTag("ScoutLocations").transform; } if (fleeLocationsParent == null) { fleeLocationsParent = GameObject.FindGameObjectWithTag("FleeLocations").transform; } if (collider == null) { collider = GameObject.FindGameObjectWithTag("MainCamera").transform; } if (anim == null) { anim = GetComponent <Animator>(); } if (spawner == null) { spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <AISpawner>(); } enemyResources = GetComponent <PlayerResources>(); enemyResources.SetHealth(100); enemyBehaviour = EnemyBehaviours.Scouting; // Get nav mesh agent from gameobject enemyNavMeshAgent = GetComponent <NavMeshAgent>(); // Add each scout point to scoutLocations list foreach (Transform child in scoutLocationsParent) { scoutLocations.Add(child); } // Add each flee point to fleeLocations list foreach (Transform child in fleeLocationsParent) { fleeLocations.Add(child); } // Assign first scout location int randomIndex = Random.Range(0, scoutLocations.Count); nextLocation = scoutLocations[randomIndex]; //anim = GetComponent<Animator>(); }
private void Awake() { ////Singleton initialization//// DontDestroyOnLoad(this.gameObject); if (instance == null) { instance = this; } else { Destroy(this.gameObject); } ///////////////////////////////// }
void Awake() { if (gameManagerRef == null) { gameManagerRef = this; } else { Destroy(this); } aiVisuals = new AIVisuals(); aiSpawnerRef = new AISpawner(); }
protected override void OnStateExited() { // cleanup battle here BattlePlayerTeams.ClearTeams(); BattleRecyclables.Clear(); PlayerSpawner.CleanupAllPlayers(); AISpawner.CleanupAllPlayers(); InGameConstants.AllowChargingLasers = true; InGameConstants.EnableQuacking = false; celebrateActionAccumulator_.EndAccumulating(); Hint.Hide(); }
// Start is called before the first frame update protected void Start() { agent = GetComponent <NavMeshAgent>(); agent.updateRotation = false; agent.updateUpAxis = false; animator = GetComponent <Animator>(); parentSpawner = GetComponentInParent <AISpawner>(); Walk(); SetRandomDestination(); maxStuckTime = 1.5f * info.maxIdleTime; SpawnPosition = this.transform.position; PerformStuckCheck(); }
void CreateSpawner(string json) { Transform spawner = (Transform)Instantiate(spawnerPrefab); spawner.name = "EnemySpawner"; JSON js = new JSON(); js.serialized = json; AssignTransform(spawner, js); AISpawner script = spawner.GetComponent <AISpawner> (); script.waves = js.ToInt("Waves"); script.perWave = js.ToInt("Per Wave"); script.interval = js.ToInt("Interval"); }
private void SpawnPlayer(float alterPlayerCount) { if (OfflineMode.modoDoOffline && !isTutorial) { aiSpawner = FindObjectOfType <AISpawner>(); aiSpawner.SpawnAI(); } if (alterPlayerCount > allPlayersInSession) //Contador pra sincronizar e adicionar quantos players entraram na cena { allPlayersInSession = alterPlayerCount; } allPlayersInSession++; if (PhotonNetwork.PlayerList.Length == allPlayersInSession || alterPlayerCount == 0) //Checando se todos entraram, se sim, todos são criados ao mesmo tempo(se falhar, outro player vai passar pelo mesmo) { StartCoroutine("UniteSynchronization", delayToCreate); //StartCoroutine("SpawnAI"); } }
// General functions public void Travel(AISpawner from, AISpawner to) { manager.AddAgent(this); _target = to; _spawner = from; UpdateDestination(); _moveMultiplier = 1.0f; _steerMultiplier = 1.0f; if (pedestrianRenderer) { pedestrianRenderer.material.SetFloat("_Offset", UnityEngine.Random.value); } if (umbrellaRenderer) { umbrellaRenderer.material.SetFloat("_Offset", UnityEngine.Random.value); } }
/// <summary> /// Initialize the AIDirector. Called on start when the AIDirector is instantiated. /// </summary> public void Init() { // Set the epoch settings to default. epochSettings = new EpochSettings(defaultEpochSettings); // Retrieve the 'AISpawner' instance used to spawn enemies on the battlefield. enemySpawner = GetComponent <AISpawner>(); // Set the enemy spawner to spawn enemies in the GameManager's current level enemySpawner.Level = GameManager.Instance.CurrentLevel; // Find the player gameObject to control his AI settings GameObject playerObject = GameObject.FindGameObjectWithTag("Player"); // Cache the player's Character component to modify his AI settings player = playerObject.GetComponent <Character>(); // Retrieve the EnemyMob component attached to this GameObject. This component controls the enemies' behavior enemyMob = GetComponent <EnemyMob>(); // Set the enemy mob's combat settings to default. enemyMob.Settings.Set(defaultEnemyAISettings); // Make the enemies attack the player. enemyMob.AttackTarget = player; // Initialize the enemy mob. enemyMob.Init(); // Update the settings for the player's AnxietyMonitor. These settings determine the rate at which player anxiety changes. playerAnxietyMonitor.Settings = playerAnxietyMonitorSettings; // Sets the AnxietyMonitor to monitor the player's anxiety. playerAnxietyMonitor.CharacterToMonitor = player; // Populate the current level with enemies PopulateLevel(GameManager.Instance.CurrentLevel); //paused = true; // Start updating the AI in a coroutine loop, where the AI is updated every 'aiTimeStep' seconds. StartCoroutine(UpdateAI()); // Update the game's intensity value every 'aiTimeStep' seconds. StartCoroutine(UpdateGameIntensity()); }
protected void SpawnFloaters(int amount) { AISpawner.SpawnFloaters(this, amount); }
// Use this for initialization void Start() { _instance = this; StartCoroutine(SpawnAIs()); }