// Update is called once per frame void Update() { if (!hasgonethrough) { hasgonethrough = true; for (int k = 0; k < enemySpawns.Length; k++) { for (int i = 0; i < enemySpawns[k]; i++) { ArrayList spawnableTiles = AiManager.instance._aiSystem.GetTilesByTier(k + 1); int randomTile = Random.Range(0, spawnableTiles.Count); TileObject targetPosition = (TileObject)spawnableTiles[randomTile]; for (int j = 0; j < usedTiles.Count; j++) { if (targetPosition.GetPosition() == (Vector2)usedTiles[j]) { randomTile = Random.Range(0, spawnableTiles.Count); targetPosition = (TileObject)spawnableTiles[randomTile]; j = 0; } } GameObject newEntity = Instantiate(enemyTiers[k], targetPosition.GetPosition(), Quaternion.identity); AiManager.AddAiEntity(newEntity.GetComponent <AiEntity>()); AiEntity ae = newEntity.GetComponent <AiEntity>(); ae.SetCurrentTile(targetPosition); ae.SetPath(AiManager.instance._aiSystem.CalculateRandomPathByTier(targetPosition.GetPosition(), k + 1)); usedTiles.Add(targetPosition.GetPosition()); } } } }
/// <summary> /// Actions this commander performs on start of battle /// </summary> public override void OnBattleStart() { Debug.Log("VANQUISHER $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ " + this.playerId); //Register for turn started event BattleEventManager._instance.RegisterForEvent(BattleEventManager.EventType.StartTurn, this); aiManager = FindObjectOfType <AiManager>(); }
public void SacrificeForLordSavior(GameObject grabbedObject, AiManager aiManager) { _aiManager = aiManager; if (grabbedObject.GetComponent <Resource>() != null) { if (grabbedObject.GetComponent <Resource>().resourceType == ResourceType.whiteSoul) { resourceManager.amountOfEnergy += gameSettings.BrokenSoulValueInEnergy; } else if (grabbedObject.GetComponent <Resource>().resourceType == ResourceType.energy) { resourceManager.amountOfEnergy += gameSettings.EnergyGetOutOfSacrificingHouse; } } if (grabbedObject.GetComponent <AIDemons>() != null) { resourceManager.amountOfEnergy += gameSettings.EnergyOutOfDemonSacrifice; if (grabbedObject.GetComponent <AIDemons>().AssignedBuilding != null) { grabbedObject.GetComponent <AIDemons>().AssignedBuilding.GetComponent <Building>().amountOfActiveWorker -= 1; grabbedObject.GetComponent <AIDemons>().AssignedBuilding = null; } } CleanFromAiManagerAnyResidualInconveniences(grabbedObject); }
IEnumerator ProgressAndCompleteNextTurn() { while (true) { TurnManager.CycleToNextTurn(); // Set camera to next character ProgressQueueUnit now = TurnManager.ProgressQueue.Peek(); Character character = CharacterManager.ActiveCharacters[now.CharacterId]; CameraManager.FollowNewCharacter(now.CharacterId); Debug.Log(character.Name + "'s turn."); if (character.IsControllable) { uiManager.BeginPlayerTurn(); // Wait for player to finish turn yield return(new WaitUntil(() => UiManager.hasFinishedControlling)); } else { AiManager.CompleteTurn(now.CharacterId); } TurnManager.ResetCurrentCharacterProgress(); yield return(new WaitForSeconds(0.1f)); } }
private bool _FindCoverPointsInVolume( IHTNAgent npc, Vector3 position, List <CoverPoint> coverPoints, ref CoverPointVolume volume, ref float nextTime, float time, AiLocationManager location, float maxDistanceToCoverSqr) { if (Object.op_Equality((Object)SingletonComponent <AiManager> .Instance, (Object)null) || !((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() || !((AiManager)SingletonComponent <AiManager> .Instance).UseCover) { return(false); } if ((double)time > (double)nextTime) { nextTime = time + this.TickFrequency * AI.npc_cover_info_tick_rate_multiplier; if (Object.op_Equality((Object)volume, (Object)null) || !volume.Contains(position)) { if (Object.op_Inequality((Object)npc.Body, (Object)null) && Object.op_Inequality((Object)npc.Body.GetParentEntity(), (Object)null) && Object.op_Inequality((Object)location.DynamicCoverPointVolume, (Object)null)) { volume = location.DynamicCoverPointVolume; } else if (Object.op_Inequality((Object)SingletonComponent <AiManager> .Instance, (Object)null) && ((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() && ((AiManager)SingletonComponent <AiManager> .Instance).UseCover) { volume = ((AiManager)SingletonComponent <AiManager> .Instance).GetCoverVolumeContaining(position); if (Object.op_Equality((Object)volume, (Object)null)) { volume = AiManager.CreateNewCoverVolume(position, Object.op_Inequality((Object)location, (Object)null) ? location.CoverPointGroup : (Transform)null); } } } } if (!Object.op_Inequality((Object)volume, (Object)null)) { return(false); } if (coverPoints.Count > 0) { coverPoints.Clear(); } foreach (CoverPoint coverPoint in volume.CoverPoints) { if (!coverPoint.IsReserved && !coverPoint.IsCompromised) { Vector3 position1 = coverPoint.Position; Vector3 vector3 = Vector3.op_Subtraction(position, position1); if ((double)((Vector3) ref vector3).get_sqrMagnitude() <= (double)maxDistanceToCoverSqr) { coverPoints.Add(coverPoint); } } } if (coverPoints.Count > 1) { coverPoints.Sort((IComparer <CoverPoint>) this.coverPointComparer); } return(true); }
private bool _FindCoverPointsInVolume(IHTNAgent npc, Vector3 position, List <CoverPoint> coverPoints, ref CoverPointVolume volume, ref float nextTime, float time, AiLocationManager location, float maxDistanceToCoverSqr) { Transform coverPointGroup; if (SingletonComponent <AiManager> .Instance == null || !SingletonComponent <AiManager> .Instance.enabled || !SingletonComponent <AiManager> .Instance.UseCover) { return(false); } if (time > nextTime) { nextTime = time + this.TickFrequency * ConVar.AI.npc_cover_info_tick_rate_multiplier; if (volume == null || !volume.Contains(position)) { if (npc.Body != null && npc.Body.GetParentEntity() != null && location.DynamicCoverPointVolume != null) { volume = location.DynamicCoverPointVolume; } else if (SingletonComponent <AiManager> .Instance != null && SingletonComponent <AiManager> .Instance.enabled && SingletonComponent <AiManager> .Instance.UseCover) { volume = SingletonComponent <AiManager> .Instance.GetCoverVolumeContaining(position); if (volume == null) { Vector3 vector3 = position; if (location != null) { coverPointGroup = location.CoverPointGroup; } else { coverPointGroup = null; } volume = AiManager.CreateNewCoverVolume(vector3, coverPointGroup); } } } } if (volume == null) { return(false); } if (coverPoints.Count > 0) { coverPoints.Clear(); } foreach (CoverPoint coverPoint in volume.CoverPoints) { if (coverPoint.IsReserved || coverPoint.IsCompromised || (position - coverPoint.Position).sqrMagnitude > maxDistanceToCoverSqr) { continue; } coverPoints.Add(coverPoint); } if (coverPoints.Count > 1) { coverPoints.Sort(this.coverPointComparer); } return(true); }
public void Initialize() { BattleGuiManager.Instance.Initialize(); _aiManager = new AiManager(); BattlePresenter.GetInstance().Initialize(this); EndBattle = new AsyncSubject <List <LootItemStruct> >(); Invoke("TurnStart", 2f); }
public override void Init() { aiData = AiManager.Get(aiName); player = netData as PlayerData; vInput = new VirtulInput(); player.Input = vInput; teamManager = player.client.GetManager <TeamManager>(); }
public static void Init(BehaviorTree behaviourTree, AbstractActor unit, BehaviorTreeIDEnum behaviourTreeType) { AiManager aiManager = AiManager.Instance; if (!(unit is Turret)) { aiManager.LoadCustomBehaviourSequences(behaviourTree, behaviourTreeType, unit); } }
public static void Init() { InitDataManager(); InitGameSetting(DynamicDataManager.GetGameData <DynamicGameSetting>("GameSetting"), StaticDataManager.GetGameData <StaticGameSetting>("GameSetting")); MapContorl.Init(); TimeManager.SetDynGameSetting(Setting.Dynamic); AiManager = new AiManager(); // BattleContorl contorl = // new BattleContorl(Game.DynamicDataManager.GetGameData<King>("Player"), // Game.DynamicDataManager.GetGameData<King>("Enemy")); }
/// <summary> /// 连接服务器函数 /// </summary> /// <param name="serverIP">服务器IP地址</param> /// <param name="serverPort">服务器端口</param> /// <param name="maxUserCount">最大玩家数</param> public void Connect(string serverIP, int serverPort, int maxUserCount, params IGameManager[] managers) { _serverCon = new Connection(); ServerCon.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); ServerCon.socket.NoDelay = true; this.maxUserCount = maxUserCount; this.managers = managers; SkillManager.Init(); AiManager.Init(); WeaponManager.Init(); ServerCon.socket.BeginConnect(serverIP, serverPort, ConnectCallback, ServerCon); }
void Start() { aiManager = GameObject.Find("Main Camera").GetComponent <AiManager>(); _gameSettings = aiManager.GameSettings; if (!aiManager.Priest.Contains(this.gameObject)) { aiManager.Priest.Add(this.gameObject); } CheckClosestDemonToAttack(); }
public void AiAction(int uniqId) { ObservableUtils.Timer(1000).Subscribe(__ => { var battler = BattlerDictionary.GetBattlerByUniqId(uniqId); var ai = AiManager.Action(uniqId); BattleLogic.SkillByAi(ai, battler).Subscribe(___ => { TurnEnd(); }); }); }
private void Awake() { if (!instance) { instance = this; SpawnAI(); } else { Destroy(gameObject); } }
private void Start() { _path = new Queue <TileObject>(); AiManager.AddAiEntity(this); if (_entityInfo.IsDoctor) { StartCoroutine(doctorSearch()); } this.GetComponent <SpriteRenderer>().color = _entityInfo.color; }
public void spawnNewDoctor() { ArrayList spawnableTiles = AiManager.instance._aiSystem.GetTilesByTier(doctor.GetComponent <AiEntity>().getEntityInfo().Tier); int randomTile = Random.Range(0, spawnableTiles.Count); TileObject targetPosition = (TileObject)spawnableTiles[randomTile]; GameObject newEntity = Instantiate(doctor, targetPosition.GetPosition(), Quaternion.identity); AiManager.AddAiEntity(newEntity.GetComponent <AiEntity>()); AiEntity ae = newEntity.GetComponent <AiEntity>(); ae.SetCurrentTile(targetPosition); ae.SetPath(AiManager.instance._aiSystem.CalculateRandomPathByTier(targetPosition.GetPosition(), doctor.GetComponent <AiEntity>().getEntityInfo().Tier)); }
void Awake() { // create instance if (instance == null) { instance = this; } else { Destroy(this); return; } _aiSystem = this.GetComponent <AiSystem>(); instance._aiEntitys = new ArrayList(); }
void Start() { foreach (var resource in GameObject.FindGameObjectsWithTag("Resource")) { if (resource.GetComponent <CharacterTypeTagger>().characterType == CharacterType.demon) { Resource.Add(resource); } } if (_aiManager == null) { _aiManager = GameObject.Find("Main Camera").GetComponent <AiManager>(); } StartCoroutine(SlowUpdate()); }
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.buildIndex == GameConstants.SCENE_INDEX_GAME_COMMANDERS) { BuildDeck(); ShuffleDeck(player1Deck); if (!GlobalObject.storyEnabled) { ShuffleDeck(player2Deck); } globalObject = GameObject.FindObjectOfType <GlobalObject>(); playField = GameObject.FindObjectOfType <PlayField>(); aiManager = GameObject.FindObjectOfType <AiManager>(); if (GlobalObject.instance.useCommanders) { //TODO - may need to load specific assets here - DECK START BATTLE } } }
//-------------------------------------------------------------- // *** CONSTRUCTORS *** public void Awake() { // If the singleton has already been initialized yet if (_pInstance != null && _pInstance != this) { Destroy(this.gameObject); return; } // Set singleton _pInstance = this; // Create vector arrays _POOL_ALIVE_MINIONS = new List <GameObject>(); _POOL_DEAD_MINIONS = new List <GameObject>(); _POOL_MINOR_MINIONS = new List <GameObject>(); _POOL_MAJOR_MINIONS = new List <GameObject>(); _POOL_CURSED_MINIONS = new List <GameObject>(); }
/// <summary> /// Get references to all of this ship's components /// </summary> void Awake() { #region Get Component References this.cTransform = this.gameObject.GetComponent <Transform>(); this.cRigidbody = this.GetComponent <Rigidbody2D>(); this.cMovement = this.gameObject.GetComponent <Movement>(); this.cCollider = this.GetComponent <Collider2D>(); this.cRenderer = this.GetComponent <SpriteRenderer>(); this.cHealth = this.GetComponent <Health>(); this.shipAi = this.gameObject.GetComponent <AiManager>(); this.cShield = this.gameObject.GetComponentInChildren <Shield>(); if (this.cShield != null) { this.HasShield = true; } else { this.HasShield = false; } #endregion Get Component References }
void Start() { BoudingBoxTag.SetActive(false); detectPlacement.gameObject.SetActive(false); if (visualsOnTable != null) { visualsOnTable.SetActive(false); } if (_aiManager == null) { _aiManager = GameObject.Find("Main Camera").GetComponent <AiManager>(); } Health = _aiManager.GameSettings.processorBuilding.BuildingHealth; maxHealth = Health; this.gameObject.GetComponent <CharacterTypeTagger>().characterType = CharacterType.neutral; UiHealth.life = Health; UiHealth.maxLife = maxHealth; BoudingBoxTag.SetActive(false); for (int i = 0; i < StockPileVisuals.Count; i++) { StockPileVisuals[i].SetActive(false); } UpdateStockVisu(); ResetFlowVisu(); StartCoroutine(feedToNotLooseGame()); }
void Start() { switch (pathingBehavior) { case PathingBehavior.FixedPatrolPathing: fixedPathing = true; variablePathing = false; break; case PathingBehavior.RandomizedWanderPathing: fixedPathing = false; variablePathing = true; break; case PathingBehavior.Both: fixedPathing = true; variablePathing = true; break; case PathingBehavior.Neither: fixedPathing = false; variablePathing = false; break; default: break; } if (variablePathing == true) { entityStatus = EntityStatus.Wandering; } if ((target = GameObject.FindGameObjectWithTag("Player")) != null) { target = GameObject.FindGameObjectWithTag("Player"); } manager = GameObject.FindGameObjectWithTag(AiManager.TAG).GetComponentInChildren<AiManager>(); if (stoppingDistance <= 0) { stoppingDistance = 5; } if (wanderRadius < 1) { wanderRadius = 50f; } CanMove = true; navMeshAgent.updatePosition = true; navMeshAgent.updateRotation = true; lastRecordedPosition = Vector3.zero; dataValidation(); gun = null; if ((gun = gameObject.GetComponentInChildren<Gun>()) != null) // chekcs if null then assigns it inside conditional statement { } //manager.registerAI(gameObject); //gameObject.GetComponent<AI>().enabled = false; // AI manager will activate }
IEnumerator attack(Vector3 startPos, Enemy e, int dif) { if (stuckOn != null) { stuckOn.GetComponent <AiEntity>().enabled = true; AiManager.SetNewRandomPath(stuckOn.GetComponent <AiEntity>()); curRidgidBody.bodyType = RigidbodyType2D.Kinematic; curRidgidBody = null; stuckOn.gameObject.layer = LayerMask.NameToLayer("Default"); sprRenderer.enabled = true; transform.parent = null; } for (int i = 0; i < AiManager.instance._aiEntitys.Count; i++) { print(AiManager.instance._aiEntitys[i].GetType()); ((AiEntity)AiManager.instance._aiEntitys[i]).isWaiting = true; } attacking = true; float t = 0; while ((t += Time.deltaTime) < 0.8f) { transform.position = Vector3.Lerp(startPos, e.transform.position, t); Camera.main.orthographicSize = Mathf.Lerp(minZoom, maxZoom, (minZoom - maxZoom) * t); // Shake camera Camera.main.transform.position = new Vector3(Camera.main.transform.position.x + Random.value * Time.deltaTime * shakePower, Camera.main.transform.position.y + Random.value * Time.deltaTime * shakePower, Camera.main.transform.position.z); yield return(new WaitForEndOfFrame()); } transform.position = Vector3.Lerp(startPos, e.transform.position, 0.8f); for (int i = 0; i < dif; i++) { yield return(qte(dif)); transform.position = Vector3.Lerp(startPos, e.transform.position, 0.8f + (0.2f / dif) * i); // Shake camera Camera.main.transform.position = new Vector3(Camera.main.transform.position.x + Random.value * Time.deltaTime * shakePower, Camera.main.transform.position.y + Random.value * Time.deltaTime * shakePower, Camera.main.transform.position.z); if (qteFailed) { SceneManager.LoadScene(2); } } stuckOn = e; if (!stuckOn.visited) { stuckOn.visited = true; PlayerLevelManager.instance.addExp(25 * stuckOn.ai.getEntityInfo().Tier *stuckOn.ai.getEntityInfo().Tier); } foreach (TileObject tObj in AiManager.instance._aiSystem.GetTilesByTierHigher(e.ai.getEntityInfo().Tier)) { BoxCollider2D bc2D = tObj.GetComponent <BoxCollider2D>(); if (bc2D != null) { bc2D.enabled = true; } } foreach (TileObject tObj in AiManager.instance._aiSystem.GetTilesByTier(e.ai.getEntityInfo().Tier)) { BoxCollider2D bc2D = tObj.GetComponent <BoxCollider2D>(); if (bc2D != null) { bc2D.enabled = false; } } curRidgidBody = e.GetComponent <Rigidbody2D>(); curRidgidBody.bodyType = RigidbodyType2D.Dynamic; stuckOn.GetComponent <AiEntity>().enabled = false; transform.parent = stuckOn.transform; sprRenderer.enabled = false; transform.localPosition = Vector3.zero; stuckOn.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast"); attacking = false; Quicktime.DisableQuicktime(); foreach (AiEntity aiE in AiManager.instance._aiEntitys) { aiE.isWaiting = false; } }