示例#1
0
    public string GetAStartAnim()
    {
        if (fightType == FightInPointTypeEnum.NoCover)
        {
            return(animIdleInFight.GetRandomAnimName());
        }

        return(animCoveringInFight.GetRandomAnimName());
    }
    public override void StartIt()
    {
        base.StartIt();

        if (string.IsNullOrEmpty(nextActAnim))
        {
            if (animInfoForNextActRandomAnim != null)
            {
                nextActAnim = animInfoForNextActRandomAnim.animsList.GetRandomAnimName();
            }
            else
            {
                if (animsListForNextActRandomAnim != null)
                    nextActAnim = animsListForNextActRandomAnim.GetRandomAnimName();
            }
        }

    }
    public override void UpdateAct()
    {
        base.UpdateAct();

        if (!otherSourcePlayerDetectionionProcessFinished)
        {
            if (mapLogic.IsPlayerDetectedInCampMode())
            {
                if (!otherSourcePlayerDetectionionProcessStarted)
                {
                    otherSourcePlayerDetectionionProcessStarted = true;

                    float distToPlayer = (PlayerCharacterNew.Instance.gameObject.transform.position - gameObject.transform.position).magnitude;

                    otherSourcePlayerDetectionTimeCounter = Random.Range(otherSourcePlayerDetectionMaxTimeBaseAmount_Min, otherSourcePlayerDetectionMaxTimeBaseAmount_Max) + otherSourcePlayerDetectionMaxTimeCoefOfDist * distToPlayer;
                }
                else
                {
                    otherSourcePlayerDetectionTimeCounter = MathfPlus.DecByDeltatimeToZero(otherSourcePlayerDetectionTimeCounter);

                    if (otherSourcePlayerDetectionTimeCounter == 0)
                    {
                        SetPlayerHasBeenDetected(false);

                        otherSourcePlayerDetectionionProcessFinished = true;
                    }
                }
            }
        }

Start:

        #region Start01
        if (step == StepEnum.Start01)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            if (useCurves)
            {
                curCurveInfoIndex = 0;

                step = StepEnum.UseCurves01;
            }
            else
            {
                selectedAnim = anims.GetRandomAnimName();

                soldInfo.StartNewMainAnimWithCrossfadeTime(selectedAnim, animToAnimCampCrossfadeTime);
                step = StepEnum.Update01;
            }
        }
        #endregion

        #region Update01
        if (step == StepEnum.Update01)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            if (IsPlayerInView())
            {
                DecPlayerDectectionCounter();
            }
            else
            {
                ResetPlayerDectectionCounter();
            }

            if (IsPlayerDetected())
            {
                SetPlayerHasBeenDetected(true);
            }

            if (IsNearLoudSoundsHappened())
            {
                SetPlayerHasBeenDetected(true);
            }
        }
        #endregion

        #region UseCurves01
        if (step == StepEnum.UseCurves01)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            curCurveInfo                  = curveInfos[curCurveInfoIndex];
            curAntaresCurve               = curCurveInfo.curve;
            selectedAnim                  = curCurveInfo.animsList.GetRandomAnimName();
            curCurveCFTime                = curCurveInfo.crossfadeTime;
            curCurveMaxSpeed              = curCurveInfo.speed;
            curCurvePointToStay           = curCurveInfo.pointToStay;
            curCurveEndMinSpeed           = curCurveInfo.endMinSpeed;
            curCurveEndLengthToDecSpeed   = curCurveInfo.endLengthToStartDecreasingSpeed;
            curCurve_SpeedInc_Speed       = curCurveInfo.speedInc_Speed;
            curCurve_SpeedDec_Speed       = curCurveInfo.speedDec_Speed;
            curCurvePointStayTime         = curCurveInfo.pointStayTime;
            curCurveEndLengthToChangeAnim = curCurveInfo.endLengthToChangeAnim;

            nextCurveInfoIndex = GetNextCurveInfoIndex();


            curCurveInfoCounter = 0;
            curCurve_CurSpeed   = 0;

            if (!nextAnimIsRanBefore)
            {
                soldInfo.StartNewMainAnimWithCrossfadeTime(selectedAnim, curCurveCFTime);
            }

            nextAnimIsRanBefore = false;
            nextAnim            = "";
            nextAnimCFTime      = 0;

            isFirstTickOnCurveInfo = true;

            step = StepEnum.UseCurves02;
        }
        #endregion

        #region UseCurves02
        if (step == StepEnum.UseCurves02)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            if (IsPlayerInView())
            {
                DecPlayerDectectionCounter();
            }
            else
            {
                ResetPlayerDectectionCounter();
            }

            if (IsPlayerDetected())
            {
                SetPlayerHasBeenDetected(true);
            }

            if (IsNearLoudSoundsHappened())
            {
                SetPlayerHasBeenDetected(true);
            }

            //

            if (curCurvePointToStay)
            {
                IncreasePointStayTimeCounter();

                SetPosAndRotByStayPoint();

                CheckIfNeedsStartNextAnimInStayMode();

                if (IsPointStayTimeFinished())
                {
                    step = StepEnum.UseCurves03;
                    goto Finish;
                }
            }
            else
            {
                if (IsSoldierReachedToTheEndMinSpeedArea())
                {
                    DecCurveInfoCurrentSpeedForEnd();
                }
                else
                {
                    IncCurveInfoCurrentSpeed();
                }

                IncreaseCurCurveCounterByCurrentSpeed();

                SetPosAndRotByCurCurve();

                CheckIfNeedsStartNextAnimInCurveMode();

                if (IsCurveCounterReachedToEnd())
                {
                    step = StepEnum.UseCurves03;
                    goto Start;
                }
            }

            isFirstTickOnCurveInfo = false;
        }
        #endregion

        #region UseCurves03
        if (step == StepEnum.UseCurves03)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            if (IsPlayerInView())
            {
                DecPlayerDectectionCounter();
            }
            else
            {
                ResetPlayerDectectionCounter();
            }

            if (IsPlayerDetected())
            {
                SetPlayerHasBeenDetected(true);
            }

            if (IsNearLoudSoundsHappened())
            {
                SetPlayerHasBeenDetected(true);
            }

            //

            curCurveInfoIndex = nextCurveInfoIndex;

            step = StepEnum.UseCurves01;
            goto Start;
        }
        #endregion

Finish:
        return;
    }
示例#4
0
    public override void UpdateAct()
    {
        base.UpdateAct();


Start:

        #region AnimToIdle01
        if (step == StepEnum.AnimToIdle01)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            animToAnimIdleCFTimeFinal = animToAnimIdleCrossfadeTime;
            step = StepEnum.AnimToIdle02;
        }
        #endregion

        #region AnimToIdle02
        if (step == StepEnum.AnimToIdle02)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            if (soldInfo.isDamageRecievedInThisRun)
            {
                dmg = soldInfo.firstDamage;

                if (ShouldTakeDamage(dmg))
                {
                    step = StepEnum.Damage01;
                    goto Start;
                }
            }

            selectedAnim = anims.GetRandomAnimName();
            soldAnimObj.animation[selectedAnim].time = 0;
            soldAnimObj.animation.CrossFade(selectedAnim, animToAnimIdleCFTimeFinal);
            step = StepEnum.Idle;
        }
        #endregion

        #region Damage01
        if (step == StepEnum.Damage01)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            selectedDamageAnim = animPackIdleDamage.GetRandomAnim(dmg);
            soldAnimObj.animation[selectedDamageAnim].time = 0;
            soldAnimObj.animation.CrossFade(selectedDamageAnim, animToAnimDmgCrossfadeTime);
            step = StepEnum.Damage02;
            goto Finish;
        }
        #endregion

        #region Damage02
        if (step == StepEnum.Damage02)
        {
            if (needsToBeFinished)
            {
                SetFinished(false);
                return;
            }

            float passedAnimTime = soldAnimObj.animation[selectedDamageAnim].time;
            if (passedAnimTime >= soldAnimObj.animation[selectedDamageAnim].length - animToAnimIdleCrossfadeTime)
            {
                animToAnimIdleCFTimeFinal = soldAnimObj.animation[selectedDamageAnim].length - passedAnimTime;
                step = StepEnum.AnimToIdle02;
                goto Start;
            }
        }
        #endregion

        #region Idle
        if (step == StepEnum.Idle)
        {
            if (needsToBeFinished)
            {
                SetFinished(true);
                return;
            }

            if (soldInfo.isDamageRecievedInThisRun)
            {
                dmg = soldInfo.firstDamage;

                if (ShouldTakeDamage(dmg))
                {
                    step = StepEnum.Damage01;
                    goto Start;
                }
            }

            float animTime = soldAnimObj.animation[selectedAnim].time;

            if (animTime >= soldAnimObj.animation[selectedAnim].length - animToAnimIdleCrossfadeTime)
            {
                animToAnimIdleCFTimeFinal = soldAnimObj.animation[selectedAnim].length - animTime;
                step = StepEnum.AnimToIdle02;
                goto Start;
            }
        }
        #endregion

Finish:
        return;
    }
示例#5
0
    public string GetRandomAnim(DamageType dmgType, SoldierBodyPart bodyPart)
    {
        AnimsList anims = GetAnimList(dmgType, bodyPart);

        return(anims.GetRandomAnimName());
    }