private AITurn ComputeTurn() { float[,] influenceMap = InfluenceMap.GetInfluenceMap(MapInfos, Team.Player); InfluenceMapDrawer drawer = GameObject.Find("InfluenceMapDrawer").GetComponent <InfluenceMapDrawer>(); drawer.influenceMap = influenceMap; AITurn turn = new AITurn(); turn.Actions = new List <AIAction>(); AIActionMovement movement = new AIActionMovement(); movement.GetHighestScore(influenceMap, CurrentCell.X, CurrentCell.Z, (int)MapInfos.Size.x, (int)MapInfos.Size.y, AttributesSheet.GetAttribute(AttributeType.MovementPoint)); turn.Actions.Add(movement); /* while (enough AP to use a skill || enough MP to move) { * * // if (enough AP to use a skill) { * * - Get Available Skills * * if (health == low && has a healing skill) * Use healing skill * else { * - Get potential targets in Range * - Get skill cellTarget * - Add potential kills to turn * - Add potential damage to turn * } * * } else (Move) { * GetInfluenceMap(Team.Player); * AIActionMovement movement = new AIActionMovement(); * if (CurrentHealth > 50%) { * GetHighestScore(); * } else * GetLowestScore(); * turns.Action.Add(movement); * } */ return(turn); }
Vector3 GetTargetPosition() { float[,] map = m_influenceMap.GetInfluenceMap(); float minPosValue = 100.0f; float currentPosValue = 0.0f; List <Vector3> positions = new List <Vector3>(); Vector3 currentPos = transform.position; // Kernel of 3x3 square if (m_kernelSize == 3) { // Loop through all to find the position with the smallest value for (int y = 1; y < m_mapSize - 1; y = y + m_kernelSize) { for (int x = 1; x < m_mapSize - 1; x = x + m_kernelSize) { currentPosValue = map[x - 1, y + 1] + map[x, y + 1] + map[x + 1, y + 1] + map[x - 1, y] + map[x, y] + map[x + 1, y] + map[x - 1, y - 1] + map[x, y - 1] + map[x + 1, y - 1]; // Check if current value is the smallest one and replace list with the new value if (currentPosValue < minPosValue) { minPosValue = currentPosValue; positions.Clear(); positions.Add(m_influenceMap.Indices2World(x, y)); } // Check if position is close enough and add to list else if (Mathf.Abs(Mathf.Min(currentPosValue, minPosValue)) < 0.5f) { positions.Add(m_influenceMap.Indices2World(x, y)); } // Do nothing if the position is not of interest } } } // Randomise between the values in the list of positions currentPos = positions[Mathf.RoundToInt((Random.Range(0, positions.Count)))]; return(currentPos); }