コード例 #1
0
        protected override EquipmentUseResult ActualUseEquipmentItem(BoonBotBase targetBot, EquipmentUseDetails eud)
        {
            EquipmentUseRequestContext euc = new EquipmentUseRequestContext();

            euc.OwningBotIdentity          = targetBot.PublicId;
            euc.RequestedEquipmentInstance = eud.InstanceIdentity;
            euc.IParam = eud.IParam;

            var msg = new Message_BotPerformAction(MainMessageKind.BotActivity, KnownSubkinds.UseEquipment)
            {
                PublicBotId    = targetBot.PublicId,
                RequestContext = euc
            };

            hub.Launch <Message_BotPerformAction>(msg);

            EquipmentUseResult eur = (EquipmentUseResult)msg.ResponseContext;

            return(eur);
        }
コード例 #2
0
        private EquipmentUseResult PerformEquipmentUsage(EquipmentUseRequestContext ctxt)
        {
            var bot = GetMappedBotByPublicId(ctxt.OwningBotIdentity);
            var activeEquipmentInstance = GetActiveEquipmentByInstanceId(ctxt);
            var equipTemplate           = equipment.GetEquipmentTypeById(activeEquipmentInstance.EquipmentId);

            activeEquipmentInstance.UseCount++;

            if (equipTemplate.Classification == ItemClassification.Scanner)
            {
                ScannerEquipmentItem sci = (ScannerEquipmentItem)equipTemplate;
                return(PerformScannerUsage(sci, activeEquipmentInstance, bot));
            }
            if (equipTemplate.Classification == ItemClassification.OffsensiveWeapon)
            {
                OffensiveWeaponEquipmentItem owi = (OffensiveWeaponEquipmentItem)equipTemplate;
                return(PerformFireWeapon(owi, activeEquipmentInstance, bot, ctxt));
            }
            b.Warning.Log("Unknown equipment usage type, result being returned is a dummy");
            EquipmentUseResult result = new EquipmentUseResult();

            result.State = UsageEndState.Success;
            return(result);
        }
コード例 #3
0
        private EquipmentUseResult PerformFireWeapon(OffensiveWeaponEquipmentItem owi, ActiveEquipment activeEquipmentInstance, MappedBot attacker, EquipmentUseRequestContext ctxt)
        {
            EquipmentUseResult result = new EquipmentUseResult();

            if (activeEquipmentInstance.CooldownTicksRemaining > 0)
            {
                result.State = UsageEndState.Fail_CooldownActive;
                return(result);
            }

            MappedBot victim = ConvertTemporaryScanKeyToBot(attacker.EngineId, ctxt.IParam);

            if (victim == null)
            {
                result.State = UsageEndState.Fail_InvalidTarget;
                b.Warning.Log("The bot tried to target an invalid key.  This shouldnt happen");
                return(result);
            }

            b.Assert.True(attacker.EngineId != victim.EngineId, "You cant shoot at yourself.");

            activeEquipmentInstance.RoundsRemaining -= 1;
            if (activeEquipmentInstance.RoundsRemaining <= 0)
            {
                result.State = UsageEndState.Fail_NoAmmo;
                return(result);
            }

            if (!attacker.ConsumeCharge(owi.BaseChargeCost))
            {
                result.State = UsageEndState.Fail_NoCharge;
                return(result);
            }

            CombatAttack ca = new CombatAttack();

            ca.Attacker       = attacker;
            ca.Victim         = victim;
            ca.Weapon         = owi;
            ca.WeaponInstance = activeEquipmentInstance;
            CombatResult cr = combatCore.ResolveAttack(ca);

            UICombatContext context = new UICombatContext();

            context.AggressorId  = attacker.EngineId;
            context.VictimId     = victim.EngineId;
            context.WeaponTypeId = owi.UniqueId;
            context.DidHit       = cr.DidHit;
            context.Damage       = cr.TotalDamage;

            hub.Launch <Message_Ui>(new Message_Ui(MainMessageKind.UIMessage, KnownSubkinds.WeaponFire)
            {
                RequestContext = context
            });

            if (cr.DidHit)
            {
                ApplyWeaponfireHit(victim, cr);
            }

            result.State = UsageEndState.Success;
            return(result);
        }