public void InitForFightReg(FightRegion _fightReg, FightPoint _initialFightPoint) { fightReg = _fightReg; selectedFightPoint = _initialFightPoint; needsToGoToInitialPoint = true; initialPoint = _initialFightPoint; }
public FightPoint[] GetFightPointsOfLane(int _laneNum) { int lNum = _laneNum; List <FightPoint> fps = new List <FightPoint>(); foreach (FightPoint fp in fightPoints) { if (fp.lane == lNum) { fps.Add(fp); } } if (fps.Count == 0) { Debug.LogError("No fight point in needed lane found!"); return(fightPoints); } FightPoint[] result = new FightPoint[fps.Count]; for (int i = 0; i < fps.Count; i++) { result[i] = fps[i]; } return(result); }
public void SetPoints(FightPoint points) { if (points.FighterId == RedFighter.Id) { RedFighter.SetPoints(points); } else { BlueFighter.SetPoints(points); } }
//</Beta> FightPoint SelectNewFightPoint() { if (needsToGoToInitialPoint) { return(initialPoint); } FightPoint fp = mapLogic.RateFightPointsAndSort(fightReg.GetFightPointsOfLane(soldInfo.curFightRegLaneNum), controlledSoldier.gameObject, initialEnemies)[0].fightPoint; return(fp); }
GameObject SelectBestTargetForPoint(FightPoint _fp) { GameObject result = null; List <CharRaycastResult> rayCastResults = mapLogic.GetAttackableEnemiesForFightInfo(_fp.defaultfightInfo, controlledSoldier.gameObject, initialEnemies, _fp.transform.position, _fp.transform.rotation); foreach (CharRaycastResult rayCastRes in rayCastResults) { if (rayCastRes == null) { continue; } if (rayCastRes.isCharacterHitted && rayCastRes.character != null) { result = rayCastRes.character; break; } } return(result); }
public void SetPoints(FightPoint point) { var pointToUpdate = Points.FirstOrDefault(p => p.FighterId == point.FighterId && p.RoundId == point.RoundId && p.JudgeId == point.JudgeId && p.FightId == point.FightId); //Can it be mapped or something? if (pointToUpdate != null) { pointToUpdate.Accepted = point.Accepted; pointToUpdate.Points = point.Points; pointToUpdate.Cautions = point.Cautions; pointToUpdate.Warnings = point.Warnings; pointToUpdate.KnockDown = point.KnockDown; pointToUpdate.X = point.X; pointToUpdate.J = point.J; } else { Points.Add(point); } }
void AddFightRegActToSoldier(GameObject _sold) { GameObject sold = _sold; SetSoldierCurrentLaneNum(soldierCurrentLaneNum, false); curFightInRegAct = sold.AddComponent <SoldierAction_FightInReg>(); curFightInRegAct.Init(sold.transform); FightPoint[] fps = fightReg.GetFightPointsOfLane(soldierCurrentLaneNum); List <FightPoint> highRateFPs = new List <FightPoint>(); for (int i = 0; i < fps.Length; i++) { if (!fps[i].isLowRate) { highRateFPs.Add(fps[i]); } } if (highRateFPs.Count == 0) { Debug.LogError("FightReg hasn't any high rated fight points!"); } FightPoint initialPoint = null; for (int i = 0; i < highRateFPs.Count; i++) { if (highRateFPs[i].isInitialPoint) { initialPoint = highRateFPs[i]; break; } } if (!initialPoint) { initialPoint = highRateFPs[Random.Range(0, highRateFPs.Count)]; } curFightInRegAct.InitForFightReg(fightReg, initialPoint); if (useCampCurves) { if (campCurveInfos == null || (campCurveInfos != null && campCurveInfos.Length == 0)) { Debug.LogError("Using camp curves is requested while no curve infos has been assigned to logic job!"); } curFightInRegAct.InitCampCurveInfos(campCurveInfos); } else { if (campType != SoldierCampType._NotUsed_) { curFightInRegAct.InitCampInfo(campType); } } //actFightInReg.InitAIVoiceSitu(_mlj_NF_IP.voiceSituation); curFightInRegAct.doMoveFight = false; // doMoveFight; curFightInRegAct.SetOwnerLogicJob(this); curFightInRegAct.StartAct(); if (nowReadyForGreandeLaunch) { curFightInRegAct.SetItsNowReadyForLaunchGrenade(); } if (customPropsAreUsed) { soldCharInfo.SetRecievedDamageCoef(customRecievingDamageCoef); soldInfo.SetShouldOnlyTakeDamageFromPlayer(onlyGetDamageFromPlayer); if (gettingDamageArea) { if (canAddGettingDamageAreaToNewSolds) { soldInfo.SetGettingDamageArea(gettingDamageArea); } } } }
public void RegisterPoints(FightPoint points) { _fightState.SetPoints(points); }
bool AreThesePointsClose(FightPoint fp1, FightPoint fp2) { return(Vector3.Distance(fp1.transform.position, fp2.transform.position) < minDistForLongMoves); }
public override void UpdateAct() { base.UpdateAct(); #region Pre if (doPres) { if (ShouldCheckPlayerCriticalSitu()) { soldInfo.SlowlyUpdatePlayerCritic(); } #region FightInPoint if (pre_FightInPoint) { DoPre_FightInPoint(); } #endregion } #endregion StartSteps: #region Start01 if (step == FightInRegStep.Start01) { if (ShouldStartCampMode()) { step = FightInRegStep.Camp01; } else { step = FightInRegStep.TryStartMoving01; } } #endregion #region TryStartMoving01 if (step == FightInRegStep.TryStartMoving01) { if (needsToBeFinished) { SetFinished(true); return; } if (!NeedsDistantMoveToGetToPos(controlledSoldier.transform.position, selectedFightPoint.transform.position)) { step = FightInRegStep.ShortMoving01; goto StartSteps; } step = FightInRegStep.NoramlMoving01; goto StartSteps; //if (IsSoldOnPoint(controlledSoldier.gameObject, selectedFightPoint.transform.position, maxErrorToPos)) //{ // step = FightInRegStep.FightingInPoint01; // goto StartSteps; //} //else //{ // Vector3[] newPath; // if (mapLogic.FindCurvePath(controlledSoldier.transform.position, selectedFightPoint.transform.position, maxErrorToPos, out newPath)) // { // currentMovementPath = newPath; // step = FightInRegStep.NoramlMoving01; // goto StartSteps; // } // else // { // step = FightInRegStep.TryStartMoving02; // goto StartSteps; // } //} } #endregion #region TryStartMoving02 if (step == FightInRegStep.TryStartMoving02) { aStarResultTimeCounter = aStarResultMaxTime; soldInfo.FindNewAStarPath(controlledSoldier.transform.position, selectedFightPoint.transform.position); step = FightInRegStep.TryStartMoving03; goto StartSteps; } #endregion #region TryStartMoving03 if (step == FightInRegStep.TryStartMoving03) { if (needsToBeFinished) { SetFinished(true); return; } if (soldInfo.isAStarPathResultRecievedInThisRun) { if (!soldInfo.isAStarPathError) { currentMovementPath = soldInfo.aStarLastPath; step = FightInRegStep.NoramlMoving01; goto StartSteps; } else { //FightPoint fp; //if (IsSoldierOnAPoint(out fp)) //{ // //<Temp> // Debug.LogError("No path founded to point!"); // //</Temp> // selectedFightPoint = fp; // step = FightInRegStep.FightingInPoint01; // goto StartSteps; //} //<Temp> Debug.LogError("No path founded to point!"); //</Temp> time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max_WhileNoPath; step = FightInRegStep.FightingInPos01; goto StartSteps; } } aStarResultTimeCounter -= Time.deltaTime; if (aStarResultTimeCounter <= 0) { //<Temp> Debug.LogError("No path founded in needed time!"); //</Temp> //FightPoint fp; //if (IsSoldierOnAPoint(out fp)) //{ // selectedFightPoint = fp; // step = FightInRegStep.FightingInPoint01; // goto StartSteps; //} time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max_WhileNoPath; step = FightInRegStep.FightingInPos01; goto StartSteps; } } #endregion #region NoramlMoving01 if (step == FightInRegStep.NoramlMoving01) { if (needsToBeFinished) { SetFinished(true); return; } initialTargetForAfterMovementChecked = false; shouldSetInitialTargForFightInPoint = false; initialTargetForFightInPoint = null; currentMovementType = fightReg.movementType; //GetMovementTypeForMovingToTarget(currentMovementPath); movementAct = controlledSoldier.gameObject.AddComponent <SoldierAction_Movement>(); movementAct.Init(controlledSoldier); movementAct.InitDefaultParams(currentMovementType); movementAct.initialEnemies = initialEnemies; if (doMoveFight) { movementAct.Init_DoFightWhileMove(true); } //SetMovementParams(currentMovementType); movementAct.SetNextActAnimToCrossfade(selectedFightPoint.defaultfightInfo.GetAStartAnim()); movementAct.SetEndingRotNormal(selectedFightPoint.transform.forward); movementAct.Init_PosToFindPath(selectedFightPoint.transform.position); //movementAct.Init_SetPath(currentMovementPath); movementAct.StartAct(); SetCurrentAction(movementAct); step = FightInRegStep.NoramlMoving02; } #endregion #region NoramlMoving02 if (step == FightInRegStep.NoramlMoving02) { if (needsToBeFinished) { movementAct.SetNeedsToBeFinished(evenStopMovingForFinish); step = FightInRegStep.Finishing01; goto StartSteps; } if (!initialTargetForAfterMovementChecked && movementAct.isBeforeEndAnimRun) { initialTargetForAfterMovementChecked = true; GameObject targ = SelectBestTargetForPoint(selectedFightPoint); if (targ != null) { shouldSetInitialTargForFightInPoint = true; initialTargetForFightInPoint = targ; movementAct.SetEndingRotLookTarget(initialTargetForFightInPoint.transform); gunDirForFightInPointInitialTarget = SoldierStats.GetSoldierGunDirectionForTarget(controlledSoldier.gameObject, initialTargetForFightInPoint); movementAct.SetNextActAnimToCrossfade(selectedFightPoint.defaultfightInfo.GetAnimList_FightLookAllBody(gunDirForFightInPointInitialTarget).GetRandomAnimName()); } } if (movementAct.finishReport == FinishReportEnum.FinishedOK) { if (selectedFightPoint == initialPoint) { needsToGoToInitialPoint = false; } Destroy(movementAct); SetCurrentAction(null); step = FightInRegStep.FightingInPoint01; goto StartSteps; } if (!movementAct.isEndingV && SlowlyCheckPlayerCritStateWhileMoving()) { step = FightInRegStep.NoramlMoving_StopMovingAndGoToFightInPos01; goto StartSteps; } } #endregion #region NoramlMoving_StopMovingAndGoToFightInPos01 if (step == FightInRegStep.NoramlMoving_StopMovingAndGoToFightInPos01) { if (IsPlayerStillInCriticSitu()) { shouldSetPlayerAsTargetForFightInPos = true; gunDirForTargettingPlayerInFightInPos = SoldierStats.GetSoldierGunDirectionForTarget(controlledSoldier.gameObject, mapLogic.player); Transform playerTr = null; if (mapLogic.player != null) { playerTr = mapLogic.player.transform; } movementAct.SetNeedsToStop(normalMovementStopTime, onPosFightInPointInfo.GetAnimList_FightLookAllBody(gunDirForTargettingPlayerInFightInPos).GetRandomAnimName(), playerTr); } else { movementAct.SetNeedsToStop(normalMovementStopTime, onPosFightInPointInfo.GetAStartAnim()); } step = FightInRegStep.NoramlMoving_StopMovingAndGoToFightInPos02; } #endregion #region NoramlMoving_StopMovingAndGoToFightInPos02 if (step == FightInRegStep.NoramlMoving_StopMovingAndGoToFightInPos02) { if (movementAct.finishReport == FinishReportEnum.FinishedOK) { Destroy(movementAct); SetCurrentAction(null); step = FightInRegStep.FightingInPos00; } } #endregion #region FightingInPos00 if (step == FightInRegStep.FightingInPos00) { time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max; step = FightInRegStep.FightingInPos01; } #endregion #region FightingInPos01 if (step == FightInRegStep.FightingInPos01) { if (needsToBeFinished) { SetFinished(true); return; } fightInPointAct = controlledSoldier.gameObject.AddComponent <SoldierAction_FightInPoint>(); fightInPointAct.Init(controlledSoldier); fightInPointAct.InitForPos(controlledSoldier.transform.position, controlledSoldier.transform.rotation, onPosFightInPointInfo); fightInPointAct.InitAIVoiceSitu(voiceSituation); fightInPointAct.initialEnemies = initialEnemies; if (shouldSetPlayerAsTargetForFightInPos) { fightInPointAct.Init_StartInShootSituForTarget(mapLogic.player); fightInPointAct.currentGunDirection = gunDirForTargettingPlayerInFightInPos; shouldSetPlayerAsTargetForFightInPos = false; } fightInPointAct.SetOwnerFightInRegAct(this); fightInPointAct.StartAct(); SetCurrentAction(fightInPointAct); step = FightInRegStep.FightingInPos02; } #endregion #region FightingInPos02 if (step == FightInRegStep.FightingInPos02) { if (needsToBeFinished) { fightInPointAct.SetNeedsToBeFinished(evenStopMovingForFinish); step = FightInRegStep.Finishing01; goto StartSteps; } time_SelectNewPointToGoFromFightingInPos_Counter = MathfPlus.DecByDeltatimeToZero(time_SelectNewPointToGoFromFightingInPos_Counter); if (IsPlayerStillInCriticSitu()) { time_CheckPlayerInCritStateWhileInFightInPos_Counter = MathfPlus.DecByDeltatimeToZero(time_CheckPlayerInCritStateWhileInFightInPos_Counter); if (time_CheckPlayerInCritStateWhileInFightInPos_Counter <= 0) { time_CheckPlayerInCritStateWhileInFightInPos_Counter = time_CheckPlayerInCritStateWhileInFightInPos_Max; if (!soldInfo.IsPlayerInView()) { if (time_SelectNewPointToGoFromFightingInPos_Counter == 0) { time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max; //<Temp> newFightPointToGo = SelectBestFightPointForPlayerCritState(); step = FightInRegStep.FightingInPoint_ChangePoint01; //</Temp> goto StartSteps; } } } } else { if (time_SelectNewPointToGoFromFightingInPos_Counter == 0) { time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max; newFightPointToGo = SelectNewFightPoint(); step = FightInRegStep.FightingInPoint_ChangePoint01; goto StartSteps; } } } #endregion #region FightingInPoint01 if (step == FightInRegStep.FightingInPoint01) { if (needsToBeFinished) { SetFinished(true); return; } pre_FightInPoint = true; //ResetDelayTimeToChangePoint(); //ResetTimeToGoToClosePoint(); ResetTimeToCheckAvailableTargets(); ResetTime_ChangePoint(); fightInPointAct = controlledSoldier.gameObject.AddComponent <SoldierAction_FightInPoint>(); fightInPointAct.Init(controlledSoldier); fightInPointAct.InitForFightPoint(selectedFightPoint); fightInPointAct.InitAIVoiceSitu(voiceSituation); fightInPointAct.initialEnemies = initialEnemies; if (shouldSetInitialTargForFightInPoint) { fightInPointAct.Init_StartInShootSituForTarget(initialTargetForFightInPoint); fightInPointAct.currentGunDirection = gunDirForFightInPointInitialTarget; } fightInPointAct.SetOwnerFightInRegAct(this); fightInPointAct.StartAct(); if (nowReadyForGreandeLaunch) { fightInPointAct.SetItsNowReadyForLaunchGrenade(); } SetCurrentAction(fightInPointAct); step = FightInRegStep.FightingInPoint02; } #endregion #region FightingInPoint02 if (step == FightInRegStep.FightingInPoint02) { if (needsToBeFinished) { fightInPointAct.SetNeedsToBeFinished(evenStopMovingForFinish); step = FightInRegStep.Finishing01; goto StartSteps; } if (IsPlayerStillInCriticSitu()) { time_CheckPlayerInCritStateWhileInFightInPoint_Counter = MathfPlus.DecByDeltatimeToZero(time_CheckPlayerInCritStateWhileInFightInPoint_Counter); if (time_CheckPlayerInCritStateWhileInFightInPoint_Counter <= 0) { time_CheckPlayerInCritStateWhileInFightInPoint_Counter = time_CheckPlayerInCritStateWhileInFightInPoint_Max; if (!CheckIsCurrentPointOkForPlayerCritState()) { FightPoint newFP = SelectBestFightPointForPlayerCritState(); if (newFP != selectedFightPoint) { newFightPointToGo = newFP; step = FightInRegStep.FightingInPoint_ChangePoint01; goto StartSteps; } } } } else { bool newPointSelected = false; if (timeToCheckAvailableTargets_Counter == 0) { ResetTimeToCheckAvailableTargets(); List <CharRayCastRsltForFightInPoInf> targsResults; targsResults = mapLogic.GetAllAttackableEnemiesForListOfFightInfos(selectedFightPoint.fightInfos, controlledSoldier.gameObject, initialEnemies, selectedFightPoint.transform.position, selectedFightPoint.transform.rotation); float sumOfRatings = 0; sumOfRatings = mapLogic.GetSumOfRatings(targsResults); if (sumOfRatings == 0) { FightPointWithRating newFPWithRating = SelectNewFightPointWithRating(); if (newFPWithRating != null && newFPWithRating.fightPoint != null && newFPWithRating.fightPoint != selectedFightPoint && newFPWithRating.rating > sumOfRatings) { newPointSelected = true; newFightPointToGo = newFPWithRating.fightPoint; step = FightInRegStep.FightingInPoint_ChangePoint01; goto StartSteps; } } } if (!newPointSelected) { if (time_ChangePoint_Counter == 0) { ResetTime_ChangePoint(); List <FightPointWithRating> fightPointWithRatings = mapLogic.RateFightPointsAndSort(fightReg.GetFightPointsOfLane(soldInfo.curFightRegLaneNum), controlledSoldier.gameObject, initialEnemies); if (fightPointWithRatings.Count == 1) { if (fightPointWithRatings[0].fightPoint != selectedFightPoint) { newPointSelected = true; newFightPointToGo = fightPointWithRatings[0].fightPoint; step = FightInRegStep.FightingInPoint_ChangePoint01; goto StartSteps; } } if (fightPointWithRatings.Count > 1) { if (fightPointWithRatings[0].fightPoint != selectedFightPoint) { newPointSelected = true; newFightPointToGo = fightPointWithRatings[0].fightPoint; step = FightInRegStep.FightingInPoint_ChangePoint01; goto StartSteps; } else { fightPointWithRatings[0].rating *= (1 - Random.Range(0f, maxValueToDecreaseFromCurrentPointRating)); if (fightPointWithRatings[1].rating >= fightPointWithRatings[0].rating) { if (fightPointWithRatings[1].rating > 0) { newPointSelected = true; newFightPointToGo = fightPointWithRatings[1].fightPoint; step = FightInRegStep.FightingInPoint_ChangePoint01; goto StartSteps; } } } } } } } } #endregion #region FightingInPoint_ChangePoint01 if (step == FightInRegStep.FightingInPoint_ChangePoint01) { if (fightInPointAct != null && fightInPointAct.status != ActionStatusEnum.Finished) { fightInPointAct.SetNeedsToBeFinished(evenStopMovingForFinish); } step = FightInRegStep.FightingInPoint_ChangePoint02; } #endregion #region FightingInPoint_ChangePoint02 if (step == FightInRegStep.FightingInPoint_ChangePoint02) { if ((fightInPointAct != null && fightInPointAct.status == ActionStatusEnum.Finished) || fightInPointAct == null) { if (fightInPointAct != null) { Destroy(fightInPointAct); } SetCurrentAction(null); pre_FightInPoint = false; selectedFightPoint = newFightPointToGo; step = FightInRegStep.TryStartMoving01; } } #endregion #region Finishing01 if (step == FightInRegStep.Finishing01) { if (currentAction == null) { SetFinished(true); step = FightInRegStep.Finishing02; goto StartSteps; } //<Alpha> if (needsToBeFinished) { currentAction.SetNeedsToBeFinished(evenStopMovingForFinish); } //</Alpha> if (currentAction.status == ActionStatusEnum.Finished) { Destroy(currentAction); SetCurrentAction(null); SetFinished(true); step = FightInRegStep.Finishing02; goto StartSteps; } } #endregion #region Camp01 if (step == FightInRegStep.Camp01) { if (needsToBeFinished) { SetFinished(true); return; } campAct = controlledSoldier.gameObject.AddComponent <SoldierAction_Camp>(); campAct.Init(controlledSoldier); if (campCurveInfos != null) { campAct.InitCampCurveInfos(campCurveInfos); } else { campAct.InitCampType(campInfo.campType); } campAct.StartAct(); SetCurrentAction(campAct); step = FightInRegStep.Camp02; } #endregion #region Camp02 if (step == FightInRegStep.Camp02) { if (needsToBeFinished) { campAct.SetNeedsToBeFinished(evenStopMovingForFinish); step = FightInRegStep.Finishing01; goto StartSteps; } if (campAct.playerHasBeenDetected) { SetPlayerIsDetectedInCampMode(); } if (isPlayerDetectedInCampMode) { step = FightInRegStep.CampFinishingForStartingNormalMode01; goto StartSteps; } } #endregion #region CampFinishingForStartingNormalMode01 if (step == FightInRegStep.CampFinishingForStartingNormalMode01) { campAct.SetNeedsToBeFinished(true); step = FightInRegStep.CampFinishingForStartingNormalMode02; goto StartSteps; } #endregion #region CampFinishingForStartingNormalMode02 if (step == FightInRegStep.CampFinishingForStartingNormalMode02) { if (campAct == null || (campAct != null && campAct.status == ActionStatusEnum.Finished)) { if (campAct != null) { Destroy(campAct); } SetCurrentAction(null); step = FightInRegStep.TryStartMoving01; } } #endregion }