public AISharedContext() { AIMapHelper = new AIMapHelper(); AIMovement = new AIMovement(); AIWeapon = new AIWeapon(); AIItemDetection = new AIItemDetection(); AIInformation = new AIInformation(); }
public void SpawnNewPlanets(GameObject originPlanet) { // put the possible spawn positions into an array Vector3[] possibleSpawnPositions = new Vector3[48]; for (int i = 0; i < originPlanet.transform.childCount - 1; i++) { // need to make sure this one child doesnt get added to the array if (originPlanet.transform.GetChild(i).name != "ConqueredLostSpriteHolder") { possibleSpawnPositions[i] = originPlanet.transform.GetChild(i).position; } } // get a random amount of spawn positions int minPlanets = 2; int maxPlanets = 6; int randomTotal = Random.Range(minPlanets, maxPlanets); // find a random open position and spawn there the randomTotal amount of times for (int i = 0; i < randomTotal; i++) { Vector3 mySpawnPosition = new Vector3(1, 1, 1); Vector3 defaultPosition = new Vector3(1, 1, 1); // while GetRandomPosition is failing keep trying until you get an open position while (mySpawnPosition == defaultPosition) { mySpawnPosition = GetRandomPosition(possibleSpawnPositions); } // we found an open position now spawn a random planet //mySpawnPosition = defaultPosition; GameObject newPlanet = Instantiate(planet, mySpawnPosition, Quaternion.identity); newPlanet.transform.SetParent(GameObject.Find("SpaceSceneSaver").transform); spawnedPlanets.Add(newPlanet); PlanetInformation planetInfo = newPlanet.GetComponent <PlanetInformation>(); planetInfo.planetName = planetBuilder.GetRandomPlanetName(); planetInfo.type = planetBuilder.GetPlanetType(); planetInfo.planetAI = Instantiate(planetBuilder.GetPlanetAI()); planetInfo.planetAI.transform.SetParent(planetInfo.transform); planetInfo.planetAI.SetActive(false); AIInformation aiInfo = planetInfo.planetAI.GetComponent <AIInformation>(); planetInfo.planetPowerLevel = aiInfo.aiPowerLevel; planetInfo.difficulty = planetInfo.planetPowerLevel.ToString(); planetInfo.negativeEffect = planetBuilder.GetPlanetNegativeEffect(planetInfo.type); planetInfo.planetSprite = planetBuilder.GetPlanetSprite(planetInfo.type); // manditory gold resource planetInfo.resources.Add("Gold"); for (int r = 0; r < 3; r++) { planetInfo.resources.Add(planetBuilder.GetPlanetResources(planetInfo.planetPowerLevel)); } newPlanet.GetComponent <SpriteRenderer>().sprite = planetInfo.unknownPlanetSprite; } }
private void Awake() { aiInfo = GetComponent <AIInformation>(); BuildAIInfo(); Scene currentScene = SceneManager.GetActiveScene(); if (currentScene.name != "02a_Space") { enemyBattleManager = GameObject.Find("EnemyBattleManager"); enemyBattleManagerScript = enemyBattleManager.GetComponent <EnemyBattleManager>(); } aiUnits = new List <string>(); SavedPlanetForBattleStatic.startingMiners = 1; }
private float BuildAIDifficultyScore(AIInformation aiInfo) { float score = (aiInfo.aiMaxMinerCount + aiInfo.aiMaxUnitCount + aiInfo.aiPossibleUnitsCount) * aiInfo.aiStrongUnitsCount; return(score); }