示例#1
0
        private bool ReFundChatCommand(IcPlayer player, string command, IDATokenClass text, TextMessageEnum chatType, object data)
        {
            // Acronym for a building is specified
            if (text.Size > 0)
            {
                string acronym = text[1];
                MappedBuildingDefinition       mappedDefinition = FindMappedDefinition(acronym);
                ICollection <IDefinitionClass> validatedDefinitions;
                if (mappedDefinition == null || (validatedDefinitions = mappedDefinition.ValidatedDefinitions) == null)
                {
                    DA.PagePlayer(player, $"No building found for acronym '{acronym}'.");

                    return(false);
                }

                IScriptableGameObj destroyedBuilding = FindDestroyedBuilding(validatedDefinitions, player.PlayerType);
                if (destroyedBuilding == null)
                {
                    DA.PagePlayer(player, $"No destroyed building found for acronym '{acronym}'.");

                    return(false);
                }

                if (!buildingFunds.TryGetValue(destroyedBuilding.ID, out BuildingFund fund) || fund.Refund(player) <= 0.0f)
                {
                    DA.PagePlayer(player, $"You haven't funded the {DATranslationManager.Translate(destroyedBuilding)}.");

                    return(false);
                }

                DA.TeamColorMessageWithTeamColor(player.PlayerType, $"{DA.MessagePrefix}{(int)(fund.TotalFunds + 0.5f)} out of {(int)(mappedDefinition.CalculateTotalRestoreCost(Engine.GetTeamPlayerCount(player.PlayerType)) + 0.5f)} credit(s) gathered to restore the {DATranslationManager.Translate(destroyedBuilding)}.");

                return(true);
            }
            else //  Assume they want all their money back
            {
                int playerCount = Engine.GetTeamPlayerCount(player.PlayerType);

                float totalRefundAmount = 0.0f;
                foreach (BuildingFund fund in buildingFunds.Values)
                {
                    float currentRefundAmount = fund.Refund(player);
                    if (currentRefundAmount > 0.0f)
                    {
                        totalRefundAmount += currentRefundAmount;

                        DA.TeamColorMessageWithTeamColor(player.PlayerType, $"{DA.MessagePrefix}{(int)(fund.TotalFunds + 0.5f)} out of {(int)(fund.MappedDefinition.CalculateTotalRestoreCost(playerCount) + 0.5f)} credit(s) gathered to restore the {DATranslationManager.Translate(fund.BuildingObj)}.");
                    }
                }

                if (totalRefundAmount <= 0.0f)
                {
                    DA.PagePlayer(player, "You haven't funded anything.");

                    return(false);
                }

                return(true);
            }
        }
        public override bool VehicleEntryRequest(IScriptableGameObj obj, IcPlayer player, ref int seat)
        {
            if (player.PlayerType != DAVehicleManager.GetTeam(Owner))
            {
                return(false); //Prevent the enemy from stealing this vehicle.
            }

            return(true);
        }
示例#3
0
        private bool TotalFundChatCommand(IcPlayer player, string command, IDATokenClass text, TextMessageEnum chatType, object data)
        {
            if (!BRFEnabled)
            {
                DA.PagePlayer(player, "Building funding is not enabled for this map.");

                return(false);
            }

            string acronym = text[1];
            MappedBuildingDefinition       mappedDefinition = FindMappedDefinition(acronym);
            ICollection <IDefinitionClass> validatedDefinitions;

            if (mappedDefinition == null || (validatedDefinitions = mappedDefinition.ValidatedDefinitions) == null)
            {
                DA.PagePlayer(player, $"No building found for acronym '{acronym}'.");

                return(false);
            }

            IScriptableGameObj destroyedBuilding = FindDestroyedBuilding(validatedDefinitions, player.PlayerType);

            if (destroyedBuilding == null)
            {
                DA.PagePlayer(player, $"No destroyed building found for acronym '{acronym}'.");

                return(false);
            }

            if (mappedDefinition.RestoreCountExceeded)
            {
                DA.PagePlayer(player, $"The maximum amount of restores per map for the {DATranslationManager.Translate(destroyedBuilding)} is exceeded.");

                return(false);
            }

            if (!buildingFunds.TryGetValue(destroyedBuilding.ID, out BuildingFund fund))
            {
                fund = new BuildingFund(mappedDefinition, destroyedBuilding.ID);
                buildingFunds.Add(destroyedBuilding.ID, fund);
            }

            float totalRestoreCost = mappedDefinition.CalculateTotalRestoreCost(Engine.GetTeamPlayerCount(player.PlayerType));

            fund.NotifyPlayerContribution(player);
            DA.TeamColorMessageWithTeamColor(player.PlayerType, $"{DA.MessagePrefix}{(int)(fund.TotalFunds + 0.5f)} out of {(int)(totalRestoreCost + 0.5f)} credit(s) gathered to restore the {DATranslationManager.Translate(destroyedBuilding)}.");

            return(true);
        }
示例#4
0
        public override void CustomEvent(IScriptableGameObj obj, int type, int param, IScriptableGameObj sender)
        {
            // If a building gets restored outside of our control, we have to handle it
            if (type == (int)CustomEventType.CustomEventBuildingRevived)
            {
                if (buildingFunds.TryGetValue(Commands.GetID(obj), out BuildingFund fund))
                {
                    // If refunds are allowed, refund all players
                    if (BRFAllowRefund)
                    {
                        fund.RefundAll(); // TODO?: If a player left should we 'remember' the funds they put in the building and give them back when they rejoin later?
                    }

                    // Remove this building from the funds mapping
                    buildingFunds.Remove(fund.BuildingId);
                }
            }
        }
 public override void CustomEvent(IScriptableGameObj obj, int type, int param, IScriptableGameObj sender)
 {
 }
示例#6
0
 public override void Custom(IScriptableGameObj sender, int type, int param)
 {
 }
示例#7
0
 public override void VehicleEnter(IScriptableGameObj obj, IVehicleGameObj vehicle, int seat)
 {
 }
示例#8
0
 public override bool VehicleEntryRequest(IScriptableGameObj obj, IVehicleGameObj vehicle, ref int seat)
 {
     return(true);
 }
示例#9
0
 public override void Entered(IScriptableGameObj obj, IScriptableGameObj enterer)
 {
 }
示例#10
0
 public override void AnimationComplete(IScriptableGameObj obj, string animationName)
 {
 }
示例#11
0
 public override void PowerUpGrant(IScriptableGameObj obj, IcPlayer player)
 {
 }
示例#12
0
 public override bool PowerUpGrantRequest(IScriptableGameObj obj, IPowerUpGameObjDef powerUp, IPowerUpGameObj powerUpObj)
 {
     return(true);
 }
示例#13
0
 public override bool PowerUpGrantRequest(IScriptableGameObj obj, IcPlayer player)
 {
     return(true);
 }
示例#14
0
 public override void KillReceived(IScriptableGameObj obj, IArmedGameObj killer, float damage, uint warhead, float scale, RenSharp.DADamageType type)
 {
 }
示例#15
0
 public override void KillDealt(IScriptableGameObj obj, IDamageableGameObj victim, float damage, uint warhead, float scale, RenSharp.DADamageType type)
 {
 }
示例#16
0
 public override void EnemySeen(IScriptableGameObj obj, IScriptableGameObj enemy)
 {
 }
示例#17
0
 public override void ActionComplete(IScriptableGameObj obj, int actionId, ActionCompleteReason completeReason)
 {
 }
示例#18
0
 public override void PowerUpGrant(IScriptableGameObj obj, IPowerUpGameObjDef powerUp, IPowerUpGameObj powerUpObj)
 {
 }
示例#19
0
 public override void Poked(IScriptableGameObj obj, IScriptableGameObj poker)
 {
 }
示例#20
0
 public override bool AddWeaponRequest(IScriptableGameObj obj, IWeaponDefinitionClass weapon)
 {
     return(true);
 }
示例#21
0
 public override void Exited(IScriptableGameObj obj, IScriptableGameObj exiter)
 {
 }
示例#22
0
 public override void RemoveWeapon(IScriptableGameObj obj, IWeaponClass weapon)
 {
 }
示例#23
0
 public override void VehicleEnter(IScriptableGameObj obj, IcPlayer player, int seat)
 {
 }
示例#24
0
 public override void ClearWeapons(IScriptableGameObj obj)
 {
 }
示例#25
0
 public override void ObjectCreatedEvent(IScriptableGameObj obj)
 {
     Engine.ConsoleOutput($"{nameof(ExampleEventClass)}.{nameof(ObjectCreatedEvent)}: Created object {obj.Definition}.\n");
 }
示例#26
0
 public override void Init(IScriptableGameObj obj)
 {
 }
示例#27
0
 public override void ObjectCreatedEvent(IScriptableGameObj obj)
 {
     obj.AddObserver(new RenSharpExampleObserver());
 }
示例#28
0
 public override void Destroyed(IScriptableGameObj obj)
 {
 }
示例#29
0
 public override void ObjectDestroyedEvent(IScriptableGameObj obj)
 {
 }
示例#30
0
 public override void SoundHeard(IScriptableGameObj obj, ICombatSound sound)
 {
 }