예제 #1
0
        public void OnMoraleChanged(float morale)
        {
            for (int index = 0; index < 2; ++index)
            {
                float num = (float)(((double)morale + 1.0) / 2.0);
                if (index == 0)
                {
                    Action <BattleSideEnum, float> moraleChangedEvent = this.OnMoraleChangedEvent;
                    if (moraleChangedEvent != null)
                    {
                        moraleChangedEvent(BattleSideEnum.Defender, 1f - num);
                    }
                }
                else if (index == 1)
                {
                    Action <BattleSideEnum, float> moraleChangedEvent = this.OnMoraleChangedEvent;
                    if (moraleChangedEvent != null)
                    {
                        moraleChangedEvent(BattleSideEnum.Attacker, num);
                    }
                }
            }
            if (this._myRepresentative?.MissionPeer.Team == null || this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.None)
            {
                return;
            }
            float num1 = Math.Abs(morale);

            if ((double)this._remainingTimeForBellSoundToStop < 0.0)
            {
                this._remainingTimeForBellSoundToStop = (double)num1 < 0.600000023841858 || (double)num1 >= 1.0 ? float.MinValue : float.MaxValue;
                if ((double)this._remainingTimeForBellSoundToStop <= 0.0)
                {
                    return;
                }
                BattleSideEnum side = this._myRepresentative.MissionPeer.Team.Side;
                this._bellSoundEvent = side == BattleSideEnum.Defender && (double)morale >= 0.600000023841858 || side == BattleSideEnum.Attacker && (double)morale <= -0.600000023841858 ? SoundEvent.CreateEventFromString("event:/multiplayer/warning_bells_defender", this.Mission.Scene) : SoundEvent.CreateEventFromString("event:/multiplayer/warning_bells_attacker", this.Mission.Scene);
                MatrixFrame globalFrame = this.AllCapturePoints.Where <FlagCapturePoint>((Func <FlagCapturePoint, bool>)(cp => !cp.IsDeactivated)).GetRandomElementInefficiently <FlagCapturePoint>().GameEntity.GetGlobalFrame();
                this._bellSoundEvent.PlayInPosition(globalFrame.origin + globalFrame.rotation.u * 3f);
            }
            else
            {
                if ((double)num1 < 1.0 && (double)num1 >= 0.600000023841858)
                {
                    return;
                }
                this._remainingTimeForBellSoundToStop = float.MinValue;
            }
        }
        public void OnMoraleChanged(
            int attackerMorale,
            int defenderMorale,
            int[] capturePointRemainingMoraleGains)
        {
            float num1 = (float)attackerMorale / 360f;
            float num2 = (float)defenderMorale / 360f;

            if (this._myRepresentative?.MissionPeer.Team != null && this._myRepresentative.MissionPeer.Team.Side != BattleSideEnum.None)
            {
                if ((this._capturePointOwners[this._masterFlag.FlagIndex] == null || this._capturePointOwners[this._masterFlag.FlagIndex].Side != BattleSideEnum.Defender) && (double)this._remainingTimeForBellSoundToStop < 0.0)
                {
                    if ((double)num2 > (double)this._lastBellSoundPercentage)
                    {
                        this._lastBellSoundPercentage += 0.2f;
                    }
                    if ((double)num2 <= 0.400000005960464)
                    {
                        if ((double)this._lastBellSoundPercentage > 0.400000005960464)
                        {
                            this._remainingTimeForBellSoundToStop = float.MaxValue;
                            this._lastBellSoundPercentage         = 0.4f;
                        }
                    }
                    else if ((double)num2 <= 0.600000023841858)
                    {
                        if ((double)this._lastBellSoundPercentage > 0.600000023841858)
                        {
                            this._remainingTimeForBellSoundToStop = 8f;
                            this._lastBellSoundPercentage         = 0.6f;
                        }
                    }
                    else if ((double)num2 <= 0.800000011920929 && (double)this._lastBellSoundPercentage > 0.800000011920929)
                    {
                        this._remainingTimeForBellSoundToStop = 4f;
                        this._lastBellSoundPercentage         = 0.8f;
                    }
                    if ((double)this._remainingTimeForBellSoundToStop > 0.0)
                    {
                        switch (this._myRepresentative.MissionPeer.Team.Side)
                        {
                        case BattleSideEnum.Defender:
                            this._bellSoundEvent = SoundEvent.CreateEventFromString("event:/multiplayer/warning_bells_defender", this.Mission.Scene);
                            break;

                        case BattleSideEnum.Attacker:
                            this._bellSoundEvent = SoundEvent.CreateEventFromString("event:/multiplayer/warning_bells_attacker", this.Mission.Scene);
                            break;
                        }
                        MatrixFrame globalFrame = this._masterFlag.GameEntity.GetGlobalFrame();
                        this._bellSoundEvent.PlayInPosition(globalFrame.origin + globalFrame.rotation.u * 3f);
                    }
                }
                if (!this._battleEndingNotificationGiven || !this._battleEndingLateNotificationGiven)
                {
                    float       num3        = !this._battleEndingNotificationGiven ? 0.25f : 0.15f;
                    MatrixFrame cameraFrame = Mission.Current.GetCameraFrame();
                    Vec3        position    = cameraFrame.origin + cameraFrame.rotation.u;
                    if ((double)num1 <= (double)num3 && (double)num2 > (double)num3)
                    {
                        MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString(this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.Attacker ? "event:/alerts/report/battle_losing" : "event:/alerts/report/battle_winning"), position);
                        if (this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.Attacker)
                        {
                            MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/multiplayer/retreat_horn_attacker"), this._retreatHornPosition);
                        }
                        else if (this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.Defender)
                        {
                            MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/multiplayer/retreat_horn_defender"), this._retreatHornPosition);
                        }
                        if (this._battleEndingNotificationGiven)
                        {
                            this._battleEndingLateNotificationGiven = true;
                        }
                        this._battleEndingNotificationGiven = true;
                    }
                    if ((double)num2 <= (double)num3 && (double)num1 > (double)num3)
                    {
                        MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString(this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.Defender ? "event:/alerts/report/battle_losing" : "event:/alerts/report/battle_winning"), position);
                        if (this._battleEndingNotificationGiven)
                        {
                            this._battleEndingLateNotificationGiven = true;
                        }
                        this._battleEndingNotificationGiven = true;
                    }
                }
            }
            Action <BattleSideEnum, float> moraleChangedEvent1 = this.OnMoraleChangedEvent;

            if (moraleChangedEvent1 != null)
            {
                moraleChangedEvent1(BattleSideEnum.Attacker, num1);
            }
            Action <BattleSideEnum, float> moraleChangedEvent2 = this.OnMoraleChangedEvent;

            if (moraleChangedEvent2 != null)
            {
                moraleChangedEvent2(BattleSideEnum.Defender, num2);
            }
            Action <int[]> gainsChangedEvent = this.OnCapturePointRemainingMoraleGainsChangedEvent;

            if (gainsChangedEvent == null)
            {
                return;
            }
            gainsChangedEvent(capturePointRemainingMoraleGains);
        }