public override ShootSolution GetShootSolution(UBasket basket, Area area, Player shooter, IM.PrecNumber rate, ShootSolution.Type type) { ShootSolution solution = practise_behaviour.GetShootSolution(basket, area, shooter, rate); if (solution == null) { solution = base.GetShootSolution(basket, area, shooter, rate, type); } Debug.Log("Practise shoot solution: " + solution.m_id); return(solution); }
public ShootSolution GetShootSolution(IM.Vector3 shootTarget, IM.Vector3 pos, bool bSuccess, ShootSolution.Type type = ShootSolution.Type.Shoot, bool bCleanShot = false) { int iSector = CalcSectorIdx(shootTarget, pos); if (m_ShootSolutionSectors[iSector].success.Count == 0 && m_ShootSolutionSectors[iSector].fail.Count == 0) { Debug.LogError("no solution found."); return(null); } List <ShootSolution> lockedSolutions = new List <ShootSolution>(); List <ShootSolution> validSolutions = new List <ShootSolution>(); List <ShootSolution> solutionsByType = new List <ShootSolution>(); List <ShootSolution> allSolutions = null; if (bSuccess) { allSolutions = m_ShootSolutionSectors[iSector].success; } else { allSolutions = m_ShootSolutionSectors[iSector].fail; } foreach (ShootSolution solution in allSolutions) { if (solution.m_type == type) { solutionsByType.Add(solution); } } if (solutionsByType.Count == 0) { Debug.Log("No corresponding solution of type: " + type + " sector:" + iSector); solutionsByType = allSolutions; } if (bSuccess && (type == ShootSolution.Type.Shoot || type == ShootSolution.Type.Layup)) { foreach (ShootSolution solution in solutionsByType) { if (solution.m_bCleanShot == bCleanShot) { validSolutions.Add(solution); } if (solution.m_isLock == true) { lockedSolutions.Add(solution); } } if (validSolutions.Count == 0) { Debug.Log("No clean shot solution, sector: " + iSector); } if (lockedSolutions.Count == 0) { Debug.Log("there is no locked solution!!"); } } if (validSolutions.Count == 0) { validSolutions = solutionsByType; } if (bSuccess) { if (!isLock) { return(validSolutions[IM.Random.Range(0, validSolutions.Count)]); } else { return(lockedSolutions[IM.Random.Range(0, lockedSolutions.Count)]); } } else { CurveRateConfig.HeightRate heightRange = GameSystem.Instance.CurveRateConfig.GetHeightRange(iSector, IM.Random.value); List <ShootSolution> heightValidSolutions = new List <ShootSolution>(); if (heightRange != null) { //Debug.Log("Solution height rang: " + heightRange.minHeight + ", " + heightRange.maxHeight); foreach (ShootSolution solution in validSolutions) { if (heightRange.minHeight <= solution.m_fMaxHeight && solution.m_fMaxHeight < heightRange.maxHeight) { heightValidSolutions.Add(solution); } if (solution.m_isLock == true) { lockedSolutions.Add(solution); } } if (heightValidSolutions.Count == 0) { Debug.Log("No solution of height range: " + heightRange.minHeight + " to " + heightRange.maxHeight + ", Sector: " + iSector); } if (lockedSolutions.Count == 0) { Debug.Log("there is no locked solution!!"); } } if (heightValidSolutions.Count == 0) { heightValidSolutions = validSolutions; } ShootSolution selectedSolution; if (!isLock) { selectedSolution = heightValidSolutions[IM.Random.Range(0, heightValidSolutions.Count)]; } else { selectedSolution = lockedSolutions[IM.Random.Range(0, lockedSolutions.Count)]; } Debugger.Instance.m_steamer.message += " \nSector:" + iSector + ", Solution height: " + selectedSolution.m_fMaxHeight; return(selectedSolution); Debug.Log("shootsolution sector:" + iSector); //return m_ShootSolutionSectors[25].success[2]; } }