public AIController() { _db = new MusicPortalDbContext(); _helper = new HttpResponseHelper<HeartedSongVM>(this); _mngr = new AIManager(_db); _songMngr = new SongManager(_db); }
// Use this for initialization void Start () { foreach(GameObject go in EnemyPre) { Logger.Write("Enemy " + go.name + " loaded"); EnemyPrefabs.Add(go.name, go); } Instance = this; }
protected override void Start() { base.Start(); health = gm.health.enemyMax; core = lm.enemyCore.GetComponent<Core>(); AI = GameObject.FindWithTag("AIManager").GetComponent<AIManager>(); AI.aiEnemies.Add(this); path = null; nextNode = null; ultimateGoal = -Vector2.one; }
public override void OnInspectorGUI() { AIM=(AIManager)target; //DrawDefaultInspector(); EditorGUILayout.Space(); int aIStance=(int)AIM.aIStance; cont=new GUIContent("AI Stance:", "The behaviour of AI"); contL=new GUIContent[AIStanceLabel.Length]; for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(AIStanceLabel[i], AIStanceTooltip[i]); aIStance = EditorGUILayout.IntPopup(cont, aIStance, contL, intVal); AIM.aIStance=(_AIStance)aIStance; if(GUI.changed){ EditorUtility.SetDirty(AIM); } }
public void DoSpawn(Google2u.SampleCharactersRow in_aiRow, Google2u.SampleDialogMapRow in_dialogMapRow, Google2u.SampleWeaponsRow in_weaponsRow, AIManager in_aiManager) { if (MyAIObject == null) { MyAIManager = in_aiManager; GameObject aiGameObject; if (in_aiRow._Prefab.Equals("mine_bot", StringComparison.InvariantCultureIgnoreCase)) aiGameObject = (GameObject)Instantiate(in_aiManager.pMineBot); else if (in_aiRow._Prefab.Equals("buzzer_bot", StringComparison.InvariantCultureIgnoreCase)) aiGameObject = (GameObject)Instantiate(in_aiManager.pBuzzBot); else return; var aiGameObjectScript = aiGameObject.GetComponent<BaseAIScript>(); if (aiGameObjectScript == null) return; var pos = transform.position + in_aiRow._Offset; aiGameObject.transform.position = pos; aiGameObject.transform.localScale = new Vector3(in_aiRow._Scale, in_aiRow._Scale, in_aiRow._Scale); aiGameObjectScript.BotLevel = in_aiRow._Level; aiGameObjectScript.BotName = in_aiRow._Name; aiGameObjectScript.CanFly = in_aiRow._CanFly; aiGameObjectScript.Health = in_aiRow._Health; aiGameObjectScript.Speed = in_aiRow._Speed; aiGameObjectScript.MySpawnPoint = this; aiGameObjectScript.WeaponID = in_weaponsRow._Name; aiGameObjectScript.OnDamaged = in_dialogMapRow._OnDamaged.ToArray(); aiGameObjectScript.OnDeath = in_dialogMapRow._OnDestroyed.ToArray(); aiGameObjectScript.EnableAiScript(in_aiRow._Rotation); MyAIObject = aiGameObject; } }
// Start is called before the first frame update void Start() { aiManager = FindObjectOfType <AIManager>(); if (aiManager == null) { Debug.LogError("No AIManager found in scene"); } // Add this gameobject to ai list aiManager.AddAI(gameObject); player = GameObject.FindGameObjectWithTag("Player"); if (Random.Range(0.0f, 1.0f) > 0.5f) { fleeDir = -1.0f; } float sqrtSpeed = Mathf.Sqrt(speed); currentSpeed = new Vector2(Random.Range(-sqrtSpeed, sqrtSpeed), Random.Range(-sqrtSpeed, sqrtSpeed)); animator = gameObject.GetComponent <Animator>(); }
private void Awake() { /////Singleton Initialization///// if (instance == null) { instance = this; } else if (instance != null) { Destroy(gameObject); } /////Singleton Initialization///// aiManager = GetComponent <AIManager>(); agentParent = GameObject.Find("PooledAgents"); if (agentParent.transform.position != Vector3.zero) //Resets agentParent to Vector3.zero if it has been moved { agentParent.transform.position = Vector3.zero; } WaveNumber = 0; }
void Awake() { aiManager = GameObject.Find("Managers").GetComponent<AIManager>(); uiManager = Camera.main.GetComponent<UIManager>(); playerSettings = Camera.main.GetComponent<PlayerSettings>(); cameraManager = Camera.main.GetComponent<CameraManager>(); board = GameObject.Find("Board").GetComponent<Board>(); black = (GameObject)Resources.Load("Black"); white = (GameObject)Resources.Load("White"); turn = GameTurn.Player; Count = 0; WhiteCount = 0; BlackCount = 0; WhiteCantMove = false; BlackCantMove = false; playerMove = null; }
// Use this for initialization void Start() { me = this; AIs = new List <AIControls>(); if (GameManager.playWithAIs) { if (GameObject.Find("AI 1").GetComponent <AIControls>() != null) { AIs.Add(GameObject.Find("AI 1").GetComponent <AIControls>()); } if (GameObject.Find("AI 2").GetComponent <AIControls>() != null) { AIs.Add(GameObject.Find("AI 2").GetComponent <AIControls>()); } if (!GameManager.twoPlayersGame) { if (GameObject.Find("AI 3").GetComponent <AIControls>() != null) { AIs.Add(GameObject.Find("AI 3").GetComponent <AIControls>()); } } } }
IEnumerator Start() { Time.timeScale = 1; blueMask = LayerMask.NameToLayer("Blue"); redMask = LayerMask.NameToLayer("Red"); player = FindObjectOfType <PlayerBehavior>(); capturePoint = FindObjectOfType <CapturePointManager>(); ai = FindObjectOfType <AIManager>(); ui = FindObjectOfType <UIManager>(); // Wait for player to select team while (!chosenTeam) { yield return(null); } player.SetValues(playerTeam, playerSpawn, enemy, team); player.Respawn(); ai.CreateAIs(playerTeam); }
public World(GraphicsDevice g) { RandomGen = new Random(); PhysicsManager = new PhysicsManager(g, this); Enemies = new List <Character>(); Player = PhysicsManager.Player; Target = PhysicsManager.Target; AIManager = new AIManager(this); MaximumEnemies = 5; Score = 0; PortalHealth = 100; GameOver = false; AllowAIBehaviour = true; ProjectileCharacterCollision = true; SpawnPoints = new List <SpawnPoint>(); ActiveSpawnPoints = new List <SpawnPoint>(); CreateSpawnPoints(); }
public int RunMonteCarloWithHuntGame() { var gameBoard = CreateGameBoard(); var maxScore = 100; var AIManager = new AIManager(); foreach (var move in Enumerable.Range(0, maxScore)) { var(column, row) = AIManager.PredictCoordinate(AILevel.MonteCarloAndHunt, gameBoard.ForOpponent().Matrix); var key = CoordinateKey.Build(column, row); var(shipFound, shipDestroyed) = gameBoard.MarkCoordinate(key); maxScore--; if (gameBoard.IsAllDestroyed()) { return(maxScore); } } return(maxScore); }
public void Update() { //inputs if ((Input.GetKeyDown(powerP1) || Input.GetAxis("Dashp1") == 1) && Time.time > nextPower["p1"] && !paused) { nextPower["p1"] = Time.time + cooldownTime; audio.clip = powerClip; audio.Play(); } else if (!ai && (Input.GetKeyDown(powerP2) || Input.GetAxis("Dashp2") == 1) && Time.time > nextPower["p2"] && !paused) { nextPower["p2"] = Time.time + cooldownTime; audio.clip = powerClip; audio.Play(); } else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetAxis("Quitp1") == 1) { SceneManager.LoadScene("menuScene"); } else if (Input.GetKeyDown(KeyCode.P) || Input.GetButtonDown("Pausep1")) { pauseUnpauseGame(); } //update time timeText.text = System.Math.Floor(Time.time - beginTime).ToString(); currentTime = (float)System.Math.Floor(Time.time - beginTime); //ai if (ai) { AIManager.processAI(); } //check if game is over checkGameOver(); }
public static Vector3Int GetClosestPositionWithinY(this Vector3Int goalPosition, Vector3Int currentPosition, int minMaxY) { var pos = AIManager.ClosestPosition(goalPosition, currentPosition); if (pos == Vector3Int.invalidPos) { var y = -1; var negY = minMaxY * -1; while (pos == Vector3Int.invalidPos) { pos = AIManager.ClosestPosition(goalPosition.Add(0, y, 0), currentPosition); if (y > 0) { y++; if (y > minMaxY) { break; } } else { y--; if (y < negY) { y = 1; } } } } return(pos); }
/// <summary> /// This gives all the people waiting their spawn points /// </summary> private static void SpawnRequestQueue() //Run by Host Only { Debug.Log($"Giving {spawnRequestQueue.Count} people their spawns"); Transform lastSpawn; while (spawnRequestQueue.Count > 0) { Message_RequestSpawn lastMessage = spawnRequestQueue.Dequeue(); lastSpawn = FindFreeSpawn(lastMessage.teaml); Debug.Log("The players spawn will be " + lastSpawn); if (Networker.isHost) { Debug.Log("Telling connected client about AI units"); AIManager.TellClientAboutAI(new CSteamID(lastMessage.senderSteamID)); } GameObject localVehicle = VTOLAPI.GetPlayersVehicleGameObject(); NetworkSenderThread.Instance.SendPacketToSpecificPlayer( new CSteamID(lastMessage.senderSteamID), new Message_RequestSpawn_Result(new Vector3D(localVehicle.transform.position), localVehicle.transform.rotation, Networker.GenerateNetworkUID(), players.Count), EP2PSend.k_EP2PSendReliable); } }
// Use this for initialization void Start() { localTag = AITag.Attacking; AIManager.SubscribeBehaviour(this); weaponStats = AIManager.GetStats.GetPrimaryWStats; aiStats = AIManager.GetStats.GetAIStats; bulletSpawnPos = AIManager.GetStats.GetWeaponObj.transform; aimPos = AIManager.GetStats.GetAimObj.transform; GameObject newLaser = Instantiate <GameObject> (linePrefab); laserLine = newLaser.GetComponent <LineRenderer> (); laserLine.startWidth = 0.005f; laserLine.endWidth = 0.005f; laserLine.positionCount = 2; laserLine.SetPosition(0, bulletSpawnPos.position); laserLine.SetPosition(1, bulletSpawnPos.position); laserLine.startColor = new Color(0, 0, 0, 0); laserLine.endColor = new Color(0, 0, 0, 0); }
/* 0 No AI * 1-4 Input routine + initialize HUD * >4 Initialize AI module */ void AssignPlayer(int player) { playerNumber = player; if(arms.Empty()){ arms.EquipAbility(Item.GetItem("Abilities/Unarmed")); } StartCoroutine(RegenRoutine()); if(player <5 && player > 0){ SetMenuOpen(false); if(menu){ menu.Change("HUD"); menu.actor = this; } if(Session.session != null && cam != null){ Session.session.RegisterPlayer(this, player, cam); } else{ print("Session or cam is null"); } if(player == 1){ input = new ActorInputHandler(this, "KEYBOARD AND MOUSE"); } else{ input = new ActorInputHandler(this, "XBOX 360 CONTROLLER"); } StartCoroutine(InputRoutine()); } else if(player == 5){ if(defaultAI == ""){ ai = new AIManager(this, "PASSIVE"); } else{ ai = new AIManager(this, defaultAI); } if(speechTreeFile != ""){ speechTree = new SpeechTree(speechTreeFile); } } }
protected override void OnEnable() { base.OnEnable(); if (this.m_Player.GetComponent <PlayerConditionModule>().IsOxygenCriticalLevel()) { this.m_Animator.SetBool(this.m_IsDeadUnderwaterHash, true); } else { this.m_Animator.SetBool(this.m_IsDeadHash, true); } DialogsManager.Get().StopDialog(); CutscenesManager.Get().StopCutscene(); AIManager.Get().OnPlayerDie(); if (this.m_Player.ShouldSwim() && this.m_Player.GetComponent <SwimController>().m_State == SwimState.Dive) { PlayerAudioModule.Get().PlayUnderwaterDeathSound(); } else { PlayerAudioModule.Get().PlayDeathSound(); } this.SetState(DeathController.DeathState.Dying); }
void Start() { instance = this; if (!terrain) { terrain = GameObject.Find("Terrain").GetComponent <Terrain>(); } if (!player) { player = GameObject.Find("Player").GetComponent <Player>(); } if (flockingAIPrefab.Count == 0)// || normalAIPrefab.Count == 0) { Debug.LogError("No AI prefab(s) configured. (Please configure them both)"); Destroy(this); } GetStats(); GenerateSpawnPoints(); SpawnFlockingAIGroups(); Invoke("SetAIAliveTextForTheFirstTime", 0.1f); }
void DetermineNewTarget() { Collider2D[] interactableObjects = Physics2D.OverlapCircleAll(transform.position, 10); //TODO: make sure this doesnt overlap with other maps Transform elevator = null; Mine m = GameData.Instance.playerMineLocations[playerID]; if ((m == Mine.IronMine && GameData.Instance.playerFloors[playerID][Mine.IronMine] == 0) || (m == Mine.JellyMine && GameData.Instance.playerFloors[playerID][Mine.JellyMine] == 0) || (m == Mine.IronMine && GameData.Instance.playerFloors[playerID][Mine.CoalMine] == 0)) { List <Collider2D> elevators = new List <Collider2D>(); for (int i = 0; i < interactableObjects.Length; i++) { if (interactableObjects[i].tag == "Elevator") { elevators.Add(interactableObjects[i]); } } elevator = AIManager.ChooseElevator(playerID, elevators); } if (elevator != null) { target = elevator; } else { TileType toSeek = AIManager.GetTileTypeToSeek(playerID, _isStuck); target = AIManager.GetTargetedTileTransformFromMap(interactableObjects, toSeek, playerID, transform); } if (target != null) { seeker.StartPath(rb.position, target.position, OnPathComplete); currentObj = target.gameObject; } }
protected virtual void Attack() { AIManager.Get().OnPlayerStartAttack(); }
public virtual void Init(AIManager aIManager) { this.aIManager = aIManager; }
public void Start() { this.timePauseCounter = 1f; if (this.redTeamUnits != null) { int childs = this.redTeamUnits.transform.childCount; for (int i = childs; i > 0; i--) { MonoBehaviour.Destroy(this.redTeamUnits.transform.GetChild(i - 1).gameObject); } } if (this.blueTeamUnits != null) { int childs = this.blueTeamUnits.transform.childCount; for (int i = childs; i > 0; i--) { MonoBehaviour.Destroy(this.blueTeamUnits.transform.GetChild(i - 1).gameObject); } } if (this.redTeam != null) { //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.redTeamUnits.transform); obj.transform.position = this.redTeamStartPosiiton.position; AIUnit unit = obj.GetComponent <AIUnit>(); //AI manager spawning. AIManager AImanager = this.redTeam.GetComponentInChildren <AIManager>(); if (AImanager != null) { this.redTeamAI = AImanager; unit.unitManager = AImanager; unit.teamFaction = AImanager.teamFaction; unit.SetTeamColor(0); AImanager.Activate(); } } if (this.blueTeam != null) { //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.blueTeamUnits.transform); obj.transform.position = this.blueTeamUnits.position; AIUnit unit = obj.GetComponent <AIUnit>(); unit.SetTeamColor(1); //AI manager spawning. AIManager AImanager = this.blueTeam.GetComponentInChildren <AIManager>(); if (AImanager != null) { this.blueTeamAI = AImanager; unit.unitManager = AImanager; unit.teamFaction = AImanager.teamFaction; unit.SetTeamColor(1); AImanager.Activate(); } } this.gameMatchStart = true; }
void Awake() { // set screen resolution Screen.SetResolution(900, 600, false); // reference to board board = GameObject.Find ("Board").GetComponent<Board> (); // set board enabled board.enabled = true; // rferenceto game manager aiManager = GameObject.Find("GameManager").GetComponent<AIManager>(); }
// Use this for initialization void Start() { me = this; AIs = new List<AIControls>(); if (GameManager.playWithAIs) { if (GameObject.Find("AI 1").GetComponent<AIControls>() != null) AIs.Add(GameObject.Find("AI 1").GetComponent<AIControls>()); if (GameObject.Find("AI 2").GetComponent<AIControls>() != null) AIs.Add(GameObject.Find("AI 2").GetComponent<AIControls>()); if (!GameManager.twoPlayersGame) if (GameObject.Find("AI 3").GetComponent<AIControls>() != null) AIs.Add(GameObject.Find("AI 3").GetComponent<AIControls>()); } }
void Start() { aiManager = GameObject.FindWithTag("AIManager").GetComponent<AIManager>(); aiManager.AddCharacter(this); }
//------------------------------------------------------------------------ void Awake() { instance = this; }
// Use this for initialization void Start() { aiManager = AIManager.GetInstance(); TimerDeath = 10f; // duration of animation + extra time bDying = false; speed = walkSpeed; angle = 0;//Random.Range(0.0f,Mathf.PI*2); currWanderAngle = Random.Range(0.0f, 8000.0f); speedCoefficient = Random.Range (0.9f,1.1f); float minJitter = 0.5f; float maxJitter = 3.75f; WanderRadius *= Random.Range(minJitter, maxJitter); WanderDistance *= Random.Range(minJitter, maxJitter); MaxWanderJitter *= Random.Range(minJitter, maxJitter); HardTurnThreshold *= Random.Range(minJitter, maxJitter); HardTurnAngle *= Random.Range(minJitter, maxJitter); }
public float hostileSpawnChance = 25; //% void Awake() { instance = this; // There is only one instance PreSpawnAI(); // Prespawn AI to prevent lag issues SpawnAI(GameObject.FindGameObjectWithTag("Player").transform.position); }
private async void initializeScene(string sceneName) //test stuff inside! will need to be rewritten for actual game { running = true; saveDataThread = new Thread(saveData); saveDataThread.Start(); if (currentSettings == "") { currentSettings = SettingsManager.DEFAULT_SETTINGS; } SettingPairs settingPairs = settingsManager.getSettingPairs(currentSettings); settingList = settingsManager.getSettingList(currentSettings); fieldSize = Field.getFieldSize(settingPairs.field_size); foreach (PartData partData in partsData) { Part part = partManager.partDataToPart(partData); if (part.GAME_OBJECT != null) { part.toggleGameObject(false); } parts.Add(part); } if (currentTest == TESTS.BUILD_HUB) { IconGenerator iconGenerator = new IconGenerator(); Camera camera = null; foreach (Camera currCam in Camera.allCameras) { if (currCam.name == "IconCamera") { camera = currCam; camera.forceIntoRenderTexture = true; break; } } iconGenerator.camera = camera; Camera.main.targetDisplay = 1; foreach (Part part in parts) { if (part.GAME_OBJECT == null) { continue; } part.toggleGameObject(true); part.GAME_OBJECT.transform.Rotate(new Vector3(9, 120, -15)); iconGenerator.gameObjectOfIcon = part.GAME_OBJECT; while (part.getIcon() == null) { if (part.GAME_OBJECT.GetComponent <Renderer>().isVisible) { iconGenerator.initialize(); if (iconGenerator.getIcon() != null) { part.setIcon(iconGenerator.getIcon()); } } if (part.getIcon() == null) { await Task.Delay(25); } } part.toggleGameObject(false); part.destroyGameObject(); } Camera.main.targetDisplay = 0; } else { foreach (Part part in parts) { if (part.GAME_OBJECT != null) { part.destroyGameObject(); } } } experience = playerData.experience; credits = playerData.credits; previousRoundDamageDifference = playerData.previousRoundDamageDifference; previousRoundMaxDamageDifference = playerData.previousRoundMaxDamageDifference; previousRoundTimeElapsed = playerData.previousRoundTimeElapsed; ObstacleGenerator obstacleGenerator = new ObstacleGenerator(experience, settingPairs.max_obstacles, fieldSize); humanRobotParts = new List <Part>(); obstaclesData = new List <ObstacleData>(); List <int> badIndices = new List <int>(); PerformanceMetricCalculator performanceMetricCalculator = new PerformanceMetricCalculator(); Head cheapestHead = null; Body cheapestBody = null; Mobility cheapestMobility = null; Blaster cheapestBlaster = null; foreach (Part part in parts) { if (part is Head && (cheapestHead == null || performanceMetricCalculator.calculateCost(part) < performanceMetricCalculator.calculateCost(cheapestHead))) { cheapestHead = (Head)part; } else if (part is Body && (cheapestBody == null || performanceMetricCalculator.calculateCost(part) < performanceMetricCalculator.calculateCost(cheapestBody))) { cheapestBody = (Body)part; } else if (part is Mobility && (cheapestMobility == null || performanceMetricCalculator.calculateCost(part) < performanceMetricCalculator.calculateCost(cheapestMobility))) { cheapestMobility = (Mobility)part; } else if (part is Blaster && (cheapestBlaster == null || performanceMetricCalculator.calculateCost(part) < performanceMetricCalculator.calculateCost(cheapestBlaster))) { cheapestBlaster = (Blaster)part; } } if (playerData.humanRobotParts != default) { for (int partIndex = 0; partIndex < playerData.humanRobotParts.Length; ++partIndex) { PlayerPartData playerPartData = playerData.humanRobotParts[partIndex]; if (parts.Exists(p => p.getID() == playerPartData.id)) { Part part = parts.Find(p => p.getID() == playerPartData.id); part.damage(part.getDurability() - playerPartData.remainingDurability); if (part is Head) { humanRobotParts.Add((Head)part.clone(true)); } else if (part is Body) { humanRobotParts.Add((Body)part.clone(true)); } else if (part is Mobility) { humanRobotParts.Add((Mobility)part.clone(true)); } else if (part is Attachment) { humanRobotParts.Add((Attachment)part.clone(true)); } } else { humanRobotParts.Add(null); badIndices.Add(partIndex); } } } else { humanRobotParts.AddRange(new Part[] { cheapestHead, cheapestBody, cheapestMobility, cheapestBlaster }); } myRobots = new List <Robot>(); if (playerData.myRobots != default) { foreach (RobotData robotData in playerData.myRobots) { List <Part> robotPartList = new List <Part>(); foreach (int partIndex in robotData.partIndices) { if (!badIndices.Contains(partIndex)) { robotPartList.Add(humanRobotParts[partIndex]); } } try { Robot robot = new Robot(robotData.name, true, robotData.human, robotPartList.ToArray()); myRobots.Add(robot); } catch {} } } foreach (int index in badIndices) { humanRobotParts.RemoveAt(index); } if (!humanRobotParts.Exists(part => part is Head)) { humanRobotParts.Add(cheapestHead); } if (!humanRobotParts.Exists(part => part is Body)) { humanRobotParts.Add(cheapestBody); } if (!humanRobotParts.Exists(part => part is Mobility)) { humanRobotParts.Add(cheapestMobility); } if (!humanRobotParts.Exists(part => part is Attachment && ((Attachment)part).isWeapon())) { humanRobotParts.Add(cheapestBlaster); } if (humanRobotParts.Contains(null)) { throw new Exception("There are missing part files. There neeeds to be at least one part file each of types Head, Body, Mobility, and a weapon Attachment."); } if (playerData.obstacles != default) { obstaclesData.AddRange(playerData.obstacles); } else { obstaclesData.AddRange(obstacleGenerator.getObstaclesData()); } if (currentSettingValueList.Count == 0) { foreach (Setting setting in settingList) { currentSettingValueList.Add(setting.currentValue); } } Head head1 = null; Head head2 = null; Body body1 = null; Body body2 = null; Mobility mobility = null; Attachment attachment1 = null; Attachment attachment2 = null; Attachment attachment3 = null; foreach (Part part in parts) { if (part is Head) { if (head1 == null) { head1 = (Head)part.clone(true); head1.damage(2); } else if (head2 == null) { head2 = (Head)part.clone(true); head2.damage(3); } } else if (part is Body) { if (body1 == null) { body1 = (Body)part.clone(true); body1.damage(3); } else if (body2 == null) { body2 = (Body)part.clone(true); body2.damage(4); } } else if (part is Mobility) { if (mobility == null) { mobility = (Mobility)part.clone(true); mobility.damage(1); } } else if (part is Attachment) { if (attachment1 == null) { attachment1 = (Attachment)part.clone(true); attachment1.damage(1); } else if (attachment2 == null) { attachment2 = (Attachment)part.clone(true); attachment2.damage(1); } else if (attachment3 == null) { attachment3 = (Attachment)part.clone(true); attachment3.damage(3); } } } List <Robot> robots = new List <Robot>(); int numberOfNonHumanRobots = 0; int numberOfHumanRobots = 0; Obstacle[] obstacles = null; List <BuildHubState> buildHubStates = default; if (buildHubStatesData != default && buildHubStatesData.Count > 0) { buildHubStates = new List <BuildHubState>(); foreach (BuildHubStateData buildHubStateData in buildHubStatesData) { buildHubStates.Add(buildHubStateDataManager.stateDataToState(buildHubStateData)); } } List <FieldState> fieldStates = default; if (fieldStatesData != default && fieldStatesData.Count > 0) { fieldStates = new List <FieldState>(); foreach (FieldStateData fieldStateData in fieldStatesData) { fieldStates.Add(fieldStateDataManager.stateDataToState(fieldStateData, parts)); } } BuildHub.MODES mode; switch (currentTest) { case TESTS.FIELD: case TESTS.HUMAN_V_VOID_ROBOT: List <Part> humanParts = new List <Part>(); foreach (Part part in humanRobot.getParts()) { Part clonePart = part.clone(false); if (clonePart is Head) { clonePart = (Head)clonePart; } else if (clonePart is Body) { clonePart = (Body)clonePart; } else if (clonePart is Mobility) { clonePart = (Mobility)clonePart; } else if (clonePart is Attachment) { clonePart = (Attachment)clonePart; } humanParts.Add(clonePart); } humanRobot = new Robot(humanRobot.getName(), humanRobot.isHuman(), humanParts.ToArray()); currentHumanRobotHealth = humanRobot.getRemainingDurability(); Attachment[] nonHumanAttachments = { (Attachment)attachment1.clone(true) }; numberOfNonHumanRobots = RANDOM.Next(1, settingPairs.max_ai_robots + 1); numberOfHumanRobots = 1; obstacles = obstacleGenerator.obstaclesDataToObstacles(obstaclesData.ToArray()); aiManager = new AIManager(numberOfNonHumanRobots, numberOfNonHumanRobots - 1 + numberOfHumanRobots, new Robot[] { humanRobot }, parts.ToArray(), new Part[] { cheapestHead, cheapestBody, cheapestMobility, cheapestBlaster }, obstacles, fieldSize, buildHubStates, fieldStates, experience); robots.Add(humanRobot); robots.AddRange(aiManager.getAgentRobots()); setScreen(new Field(settingList, robots.ToArray(), obstacles, previousRoundDamageDifference, previousRoundMaxDamageDifference, previousRoundTimeElapsed)); break; case TESTS.AI_AGENT_TRAINING: numberOfNonHumanRobots = NUMBER_OF_AGENTS; numberOfHumanRobots = 0; obstacles = obstacleGenerator.obstaclesDataToObstacles(obstaclesData.ToArray()); aiManager = new AIManager(numberOfNonHumanRobots, numberOfNonHumanRobots - 1 + numberOfHumanRobots, null, parts.ToArray(), new Part[] { cheapestHead, cheapestBody, cheapestMobility, cheapestBlaster }, obstacles, fieldSize, buildHubStates, fieldStates, experience); Robot[] agentRobots = aiManager.getAgentRobots(); for (int agentIndex = 0; agentIndex < NUMBER_OF_AGENTS; ++agentIndex) { FIELD_AGENT_ROBOTS[agentIndex] = agentRobots[agentIndex]; } robots.AddRange(FIELD_AGENT_ROBOTS); setScreen(new Field(settingList, robots.ToArray(), obstacles, previousRoundDamageDifference, previousRoundMaxDamageDifference, previousRoundTimeElapsed)); break; case TESTS.BUILD_HUB: mode = BuildHub.MODES.MY_ROBOTS; setScreen(new BuildHub(settingList, obstaclesData, myRobots, humanRobotParts, parts.ToArray(), credits, mode)); break; } }
private void Awake() { _boardManager = GameObject.FindGameObjectWithTag("BoardManager").GetComponent <BoardManager>(); _aiManager = GameObject.FindGameObjectWithTag("AIManager").GetComponent <AIManager>(); _createNode = new CreateNode(); }
public BaseAIState(AIManager ai) { _ai = ai; }
void Awake() { board = GameObject.Find("Board").GetComponent<Board>(); gameManager = GameObject.Find("Managers").GetComponent<GameManager>(); aiManager = GameObject.Find("Managers").GetComponent<AIManager>(); }
// Use this for initialization void Start() { GameSystem.GamePaused = false; //setup the camera //if we haven't been passed a rigidbody, lookup one in our children movedCurr = false; movedPrev = false; shivCurr = false; shivPrev = false; handsUpCurr = false; handsUpPrev = false; rotatedCurr = false; rotatedPrev = false; jumpCurr = false; jumpPrev = false; if (ActorCamera != null) { audioDev = ActorCamera.GetComponentInChildren<AudioListener>(); } //get info from the network if available. if (ActorCtrl.IsNetworked) { if (ActorCtrl.IsClientControlled) { networkID = Matchmaker.GetPlayerNum(); } } ReloadActor(); //add ourselves to the AI system aiManager = AIManager.GetInstance(); aiManager.AddMaster(this); //we don't want the friggin' mouse moving around! Screen.lockCursor = true; }
void Awake() { AIM=(AIManager)target; InitLabel(); }
private void OnDrawGizmos() { if (m_aiManager == null) { m_aiManager = GetComponentInParent <AIManager>(); return; } if (!m_aiManager.DebugRayOfEyeRange) { return; } Gizmos.DrawWireSphere(transform.position, m_aiManager.m_AIField.ThresoldViewRange); Vector3 cros = Vector3.Cross(transform.forward, Vector3.up); cros.Normalize(); float dist = m_aiManager.m_AIField.ViewRange * Mathf.Cos(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle); Vector3 center = transform.position + transform.forward * dist; Vector3 right = Vector3.zero; Vector3 left = Vector3.zero; Vector3 up = Vector3.zero; Vector3 down = Vector3.zero; if (m_aiManager.m_AIField.ViewAngle <= 90f) { right = Vector3.Normalize(transform.forward - cros * Mathf.Tan(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle)) * m_aiManager.m_AIField.ViewRange; left = Vector3.Normalize(transform.forward + cros * Mathf.Tan(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle)) * m_aiManager.m_AIField.ViewRange; up = Vector3.Normalize(transform.forward + transform.up * Mathf.Tan(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle)) * m_aiManager.m_AIField.ViewRange; down = Vector3.Normalize(transform.forward - transform.up * Mathf.Tan(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle)) * m_aiManager.m_AIField.ViewRange; } else { right = Vector3.Normalize(-transform.forward - cros * Mathf.Tan(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle)) * m_aiManager.m_AIField.ViewRange; left = Vector3.Normalize(-transform.forward + cros * Mathf.Tan(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle)) * m_aiManager.m_AIField.ViewRange; up = Vector3.Normalize(-transform.forward + transform.up * Mathf.Tan(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle)) * m_aiManager.m_AIField.ViewRange; down = Vector3.Normalize(-transform.forward - transform.up * Mathf.Tan(Mathf.Deg2Rad * m_aiManager.m_AIField.ViewAngle)) * m_aiManager.m_AIField.ViewRange; } float radius = Vector3.Distance(center, transform.position + up); Vector3 firstPos = transform.position + up; float angle = 0; int perAngle = 10; Gizmos.color = Color.yellow; for (int i = 0; i <= 36; i++) { angle = i * perAngle; float base_dist = Mathf.Cos(angle * Mathf.Deg2Rad) * radius; float perp_dist = Mathf.Sin(angle * Mathf.Deg2Rad) * radius; Vector3 lastPos = center + transform.up * base_dist + transform.right * perp_dist; if (i != 0) { Gizmos.DrawLine(firstPos, lastPos); } firstPos = lastPos; } Gizmos.color = Color.red; Gizmos.DrawRay(transform.position, right); Gizmos.DrawRay(transform.position, left); Gizmos.DrawRay(transform.position, up); Gizmos.DrawRay(transform.position, down); Gizmos.color = Color.yellow; perAngle = 10; angle = 90 - m_aiManager.m_AIField.ViewAngle; for (int i = 0; i <= 100; i++) { float base_dist = Mathf.Cos(angle * Mathf.Deg2Rad) * m_aiManager.m_AIField.ViewRange; float perp_dist = Mathf.Sin(angle * Mathf.Deg2Rad) * m_aiManager.m_AIField.ViewRange; Vector3 lastPos = transform.position + transform.right * base_dist + transform.forward * perp_dist; if (i != 0) { Gizmos.DrawLine(firstPos, lastPos); } firstPos = lastPos; if (angle >= 90 + m_aiManager.m_AIField.ViewAngle) { break; } angle = angle + perAngle; if (angle > 90 + m_aiManager.m_AIField.ViewAngle) { angle = 90 + m_aiManager.m_AIField.ViewAngle; } } angle = 90 - m_aiManager.m_AIField.ViewAngle; for (int i = 0; i <= 100; i++) { float base_dist = Mathf.Cos(angle * Mathf.Deg2Rad) * m_aiManager.m_AIField.ViewRange; float perp_dist = Mathf.Sin(angle * Mathf.Deg2Rad) * m_aiManager.m_AIField.ViewRange; Vector3 lastPos = transform.position + transform.up * base_dist + transform.forward * perp_dist; if (i != 0) { Gizmos.DrawLine(firstPos, lastPos); } firstPos = lastPos; if (angle >= 90 + m_aiManager.m_AIField.ViewAngle) { break; } angle = angle + perAngle; if (angle > 90 + m_aiManager.m_AIField.ViewAngle) { angle = 90 + m_aiManager.m_AIField.ViewAngle; } } }
void Awake() { mInstance = this; states.Load(); }
// Use this for initialization void Start() { Score = 0; levelManagerRef = GameObject.Find("LevelManager").GetComponent <LevelManager>(); aiManagerRef = GameObject.Find("AIManager").GetComponent <AIManager>(); }
public SeekPlayer(AIManager inAI) { ai = inAI; }
//----------------------------------------------------------------------------------------------- public void OnEnable() { m_selectedManager = this.target as AIManager; }
public virtual void onDialog(L2Player player, int ask, int reply) { player.FolkNpc = this; AIProcessor.TalkedReply(player, ask, reply); return; if (ask > 0 && ask < 1000) { QuestManager.getInstance().onQuestTalk(player, this, ask, reply); return; } AITemplate t = AIManager.getInstance().checkDialogResult(Template.NpcId); if (t != null) { t.onDialog(player, ask, reply, this); return; } switch (ask) { case -1: switch (reply) { case 8: player.sendPacket(new ExBuySellList_Buy(player.getAdena())); player.sendPacket(new ExBuySellList_Sell(player)); break; default: NpcData.getInstance().buylist(player, this, (short)reply); break; } break; case -3: grandmaster_total.onReply(player, reply, this); break; case -19: //нобл запрос switch (reply) { case 0: case 1: player.ShowHtm(player.Noblesse == 1 ? "fornobless.htm" : "fornonobless.htm", this); break; } break; case -20: //нобл запрос switch (reply) { case 2: NpcData.getInstance().RequestTeleportList(this, player, 2); break; } break; case -21: //нобл запрос switch (reply) { case 2: NpcData.getInstance().RequestTeleportList(this, player, 3); break; } break; case -22: //нобл запрос switch (reply) { case 2: NpcData.getInstance().RequestTeleportList(this, player, 1); break; } break; case -303: MultiSell.getInstance().showList(player, this, reply); break; case -305: switch (reply) { case 1: // NpcData.getInstance().multisell(player, this, reply); //TEST break; } break; case -1000: { switch (reply) { case 1: //See the lord and get the tax rate information break; } } break; } }
public RoamingAI(Actor actor, AIManager manager) : base(actor, manager) { }
void Start () { manager = GameObject.FindGameObjectWithTag (Tags.aiManager).GetComponent<AIManager>(); totalWaves = waves.Length; }
// Use this for initialization void Start() { rand = new Random (); currentGameState = GameState.PLAYING; if (!aiMovesFirst) currentPlayer = Player.PLAYER1; else currentPlayer = Player.PLAYER2; gridManager = FindObjectOfType<Grid> (); aiManager = FindObjectOfType<AIManager> (); gameOverScreen = FindObjectOfType<Canvas> (); gameOverScreen.enabled = false; winnerText = GameObject.Find ("WinnerDeclaration").GetComponent<Text>(); }
void Awake() { Application.targetFrameRate = 30; staticManager = this; GameObject[] totemGameObjects = GameObject.FindGameObjectsWithTag(Names.TOTEM); foreach (GameObject t in totemGameObjects) { totems.Add(t.GetComponent<Totem>()); } GameObject[] campGameObjects = GameObject.FindGameObjectsWithTag(Names.CAMP); foreach (GameObject c in campGameObjects) { camps.Add(c.GetComponent<Camp>()); } fruitScript = GameObject.Find("Fruit").GetComponent<Fruit>(); fruitMesh = GameObject.Find(Names.FRUIT); orangeObjective = GameObject.Find(Names.ORANGE_OBJECTIVE); purpleObjective = GameObject.Find(Names.PURPLE_OBJECTIVE); orangeDoor = GameObject.Find(Names.PLAYER_DOOR).GetComponent<Door>(); purpleDoor = GameObject.Find(Names.ENEMY_DOOR).GetComponent<Door>(); }
public void GameStart() { gaming = true; int mapSize; if (PlayerManager.Instance().playerNumber == 1) { mapSize = 1; } else { mapSize = (int)Mathf.Sqrt(PlayerManager.Instance().playerNumber) + 1; } NodeManager.Instance().nodeCountX = mapSize * playerArea.x; NodeManager.Instance().nodeCountY = mapSize * playerArea.y; NodeManager.Instance().GenerateNodes(); MapManager.Instance().GenerateMap(); //设置出生点,在所有可能点中取玩家数个 List <int> startingPointList = new List <int>(); for (int i = 0; i < mapSize * mapSize; i++) { startingPointList.Add(i); } for (int i = 0; i < PlayerManager.Instance().playerNumber; i++) { //随机取一个出生点 int a = startingPointList[Random.Range(0, startingPointList.Count - 1)]; startingPointList.Remove(a); int y = a / mapSize; int x = a % mapSize; PlayerManager.Instance().players[i].startingPoint = new Vector2Int(playerArea.y * y, playerArea.x * x); } //建造初始炮塔 for (int i = 0; i < PlayerManager.Instance().playerNumber; i++) { Vector2Int pos = PlayerManager.Instance().players[i].startingPoint; BuildManager.Instance().BuildInstantly(MapManager.Instance().GetNodeItem(pos), i); BuildManager.Instance().BuildOccupiableBuilding("Farm", MapManager.Instance().GetNodeItem(pos + new Vector2Int(8, 0))); BuildManager.Instance().BuildOccupiableBuilding("WatchTower", MapManager.Instance().GetNodeItem(pos + new Vector2Int(0, 4))); } //移动镜头到出生点 Vector2Int startingPoint = PlayerManager.Instance().players[0].startingPoint; CameraMoveToPoint(startingPoint); //开启AI for (int i = 0; i < PlayerManager.Instance().playerNumber; i++) { if (PlayerManager.Instance().players[i].isAI) { AIManager.Instance().AIStart(PlayerManager.Instance().players[i].id); } } }
public void Start() { this.timePauseCounter = 1f; if (this.redTeamUnits != null) { int childs = this.redTeamUnits.transform.childCount; for (int i = childs; i > 0; i--) { MonoBehaviour.Destroy(this.redTeamUnits.transform.GetChild(i-1).gameObject); } } if (this.blueTeamUnits != null) { int childs = this.blueTeamUnits.transform.childCount; for (int i = childs; i > 0; i--) { MonoBehaviour.Destroy(this.blueTeamUnits.transform.GetChild(i-1).gameObject); } } if (this.redTeam != null) { //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.redTeamUnits.transform); obj.transform.position = this.redTeamStartPosiiton.position; AIUnit unit = obj.GetComponent<AIUnit>(); //AI manager spawning. AIManager AImanager = this.redTeam.GetComponentInChildren<AIManager>(); if (AImanager != null) { this.redTeamAI = AImanager; unit.unitManager = AImanager; unit.teamFaction = AImanager.teamFaction; unit.SetTeamColor(0); AImanager.Activate(); } } if (this.blueTeam != null) { //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.blueTeamUnits.transform); obj.transform.position = this.blueTeamUnits.position; AIUnit unit = obj.GetComponent<AIUnit>(); unit.SetTeamColor(1); //AI manager spawning. AIManager AImanager = this.blueTeam.GetComponentInChildren<AIManager>(); if (AImanager != null) { this.blueTeamAI = AImanager; unit.unitManager = AImanager; unit.teamFaction = AImanager.teamFaction; unit.SetTeamColor(1); AImanager.Activate(); } } this.gameMatchStart = true; }
void OnDestroy() { mInstance = null; }
// Use this for initialization void Start() { aiManager = AIManager.GetInstance(); //TODO: Freak out if aiManager is null }
public void SingleStartHost() { DropdownFix[] fixes = GameObject.FindObjectsOfType <DropdownFix>(); int values = 0; for (int i = 0; i < fixes.Length; i++) { values += fixes[i].value; } if (values <= 0) { //Start Game button is now interactable only when player hasn't chosen a preset. return; } //Note(Thompson): Player is always index 1. //Note(Thompson): Obtain the A.I. level difficulty. GameMetricLogger.instance.levelDifficulty = fixes[0].value; //Note(Thompson): Check if the Player dropdown value is 5. If not, and is above 0, return difficulty equation used. Else, return a full range of custom equations used. GameMetricLogger.SetDifficultyEquation(ConvertCustomToEquations(fixes[1].value, fixes[1].options[fixes[1].value].text)); GameMetricLogger.SetPlayerName("Player"); if (this.attributePanelGroup != null) { this.attributePanelGroup.alpha = 0f; this.attributePanelGroup.blocksRaycasts = false; this.attributePanelGroup.interactable = false; } GameObject minimapCameraObject = GameObject.FindGameObjectWithTag("Minimap"); Camera minimapCamera = minimapCameraObject.GetComponent <Camera>(); if (minimapCamera != null && !minimapCamera.enabled) { minimapCamera.enabled = true; } if (this.playerObject != null) { this.playerObject.SetActive(true); } if (this.AIPlayer != null) { //AI attribute manager. AIAttributeManager attributeManager = this.AIPlayer.GetComponentInChildren <AIAttributeManager>(); if (attributeManager != null) { Debug.Log("It works!"); } //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.AIUnits.transform); obj.transform.position = this.GetStartPosition().position; AIUnit unit = obj.GetComponent <AIUnit>(); //AI manager spawning. AIManager AImanager = this.AIPlayer.GetComponentInChildren <AIManager>(); if (AImanager != null) { unit.unitManager = AImanager; if (attributeManager != null && attributeManager.attributePanelUI != null) { DifficultyGroup group = attributeManager.attributePanelUI.aiCalibrationDifficulty; AImanager.UpdateDifficulty(group.GetDifficulty()); } unit.SetTeam(AImanager.teamFaction); AImanager.Activate(); } } this.playerUmbrellaObject = GameObject.FindGameObjectWithTag("Player"); if (this.playerUmbrellaObject != null) { this.HumanPlayer = this.playerUmbrellaObject; Transform unitUmbrellaTransform = this.playerUmbrellaObject.transform.GetChild(0); this.HumanUnits = unitUmbrellaTransform.gameObject; } SetupPlayerUnits(); if (!this.isNetworkActive) { this.StartHost(); } this.enablePauseGameMenu = true; this.notReady = false; if (Taskbar.Instance != null) { Taskbar.Instance.ShowTaskbar(true); } GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics); GameMetricLogger.SetGameLogger(GameLoggerOptions.GameIsPlaying); GameMetricLogger.EnableLoggerHotkey(); }
public SongManager(Data.MusicPortalDbContext db) { this._db = db; _mngr = new AIManager(_db); }
// Use this for initialization void Start() { aiManager = GetComponent <AIManager>(); }
// Use this for initialization void Start () { GameObject aiManager = GameObject.FindWithTag("AIManager"); aiManagerScript = aiManager.GetComponent(typeof(AIManager)) as AIManager; }