Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!isFirstRun)
        {
            if (shouldPlayVoice)
            {
                shouldPlayVoice = false;

                if (playerCharNew.isCampPlayer)
                {
                    dieVoicesToPlay = initialInfo.voiceInfo.CampModeDie;
                }
                else
                {
                    dieVoicesToPlay = initialInfo.voiceInfo.Die;
                }

                AudioInfo dieNewAudInf = GameObject.Instantiate(dieAudioInfo, transform.position, transform.rotation) as AudioInfo;
                dieNewAudInf.Init();
                dieNewAudInf.PlayClip(dieVoicesToPlay);

                DieInTime dieAudInfDieInTime = dieNewAudInf.gameObject.AddComponent <DieInTime>();
                dieAudInfDieInTime.time = SoldierStats.MaxTimeOfDeadSoldVoice;
            }
        }

        if (isFirstRun)
        {
            isFirstRun = false;
        }

        if (isEnabled)
        {
            if (!startingAnimDone)
            {
                timeCounter += Time.deltaTime;
                if (timeCounter > delayToStartDeadAnim)
                {
                    startingAnimDone = true;

                    animation[initialInfo.deadSoldAnim.animName].time = 0;
                    animation.CrossFade(initialInfo.deadSoldAnim.animName, initialInfo.deadSoldAnim.initialCrossfadeTime);
                }
            }
            else
            {
                if (GeneralStats.IsUnloopedAnimFinishedOnObject(gameObject, initialInfo.deadSoldAnim.animName, 0))
                {
                    StopThisZombie();
                }
            }
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        minLifeTimeCounter = MathfPlus.DecByDeltatimeToZero(minLifeTimeCounter);

        if (minLifeTimeCounter == 0)
        {
            if (!IsInPlayerView())
            {
                DestroyIt();
                return;
            }
        }

        maxLifeTimeCounter = MathfPlus.DecByDeltatimeToZero(maxLifeTimeCounter);

        if (!isPhysicsSleeped)
        {
            if (maxLifeTimeCounter <= GeneralStats.deadNash_maxLifeTime - timeToSleepPhysics)
            {
                isPhysicsSleeped = true;

                Rigidbody[] rigids = GetComponentsInChildren <Rigidbody>();

                for (int i = 0; i < rigids.Length; i++)
                {
                    rigids[i].active = false;
                }
            }
        }

        //if (!isGoingToHideBecauseOfHittingNewNash)
        //{
        //    if (maxLifeTimeCounter <= GeneralStats.deadNash_maxLifeTime - GeneralStats.deadNash_minLifeTimeWhileTouchingAnotherNash)
        //    {
        //        for (int i = 0; i < mapLogic.mapDeadSoldierBMWs.Count; i++)
        //        {
        //            if (mapLogic.mapDeadSoldierBMWs[i] == this)
        //                continue;

        //            if (mapLogic.mapDeadSoldierBMWs[i].isGoingToHideBecauseOfHittingNewNash)
        //                continue;

        //            if (Vector3.Magnitude(transform.position - mapLogic.mapDeadSoldierBMWs[i].transform.position) <= GeneralStats.deadNash_HittingNewNashMaxDist)
        //            {
        //                isGoingToHideBecauseOfHittingNewNash = true;
        //                hittingNewNashStartingTime = maxLifeTimeCounter;
        //                break;
        //            }
        //        }
        //    }
        //}
        //else
        //{
        //    if (maxLifeTimeCounter <= hittingNewNashStartingTime - GeneralStats.deadNash_maxLifeTimeAfterTouchingAnotherNash)
        //    {
        //        DestroyIt();
        //        return;
        //    }
        //}

        if (maxLifeTimeCounter == 0)
        {
            DestroyIt();
            return;
        }

        if (!isFirstRun)
        {
            if (shouldPlayVoice)
            {
                shouldPlayVoice = false;

                if (playerCharNew.isCampPlayer)
                {
                    dieVoicesToPlay = initialInfo.voiceInfo.CampModeDie;
                }
                else
                {
                    dieVoicesToPlay = initialInfo.voiceInfo.Die;
                }

                AudioInfo dieNewAudInf = GameObject.Instantiate(dieAudioInfo, transform.position, transform.rotation) as AudioInfo;
                dieNewAudInf.Init();
                dieNewAudInf.PlayClip(dieVoicesToPlay);

                DieInTime dieAudInfDieInTime = dieNewAudInf.gameObject.AddComponent <DieInTime>();
                dieAudInfDieInTime.time = SoldierStats.MaxTimeOfDeadSoldVoice;
            }
        }

        if (isFirstRun)
        {
            isFirstRun = false;
        }
    }