コード例 #1
0
ファイル: EntityBuilder.cs プロジェクト: MoyTW/7DRL2017
        private static Entity SlotHolsterForWeapon(Entity mech, BodyPartLocation location, Entity weapon)
        {
            Entity holster;

            switch (weapon.GetComponentOfType <Component_Attachable>().SizeRequired)
            {
            case AttachmentSize.SMALL:
                holster = BlueprintListing.BuildForLabel(Blueprints.SMALL_HOLSTER);
                break;

            case AttachmentSize.MEDIUM:
                holster = BlueprintListing.BuildForLabel(Blueprints.MEDIUM_HOLSTER);
                break;

            case AttachmentSize.LARGE:
                holster = BlueprintListing.BuildForLabel(Blueprints.LARGE_HOLSTER);
                break;

            default:
                throw new ArgumentException("BuildHolsterForWeapon can't handle size: not SMALL, MEDIUM, LARGE");
            }
            SlotAt(mech, location, holster);
            holster.HandleEvent(new GameEvent_Slot(mech, holster, weapon));
            return(holster);
        }
コード例 #2
0
ファイル: EntityBuilder.cs プロジェクト: MoyTW/7DRL2017
 private static Entity GetBodyPart(Entity mech, BodyPartLocation location)
 {
     return(mech.HandleQuery(new GameQuery_SubEntities(SubEntitiesSelector.BODY_PART))
            .SubEntities
            .Where(e => e.GetComponentOfType <Component_BodyPartLocation>().Location == location)
            .First());
 }
コード例 #3
0
ファイル: EntityBuilder.cs プロジェクト: MoyTW/7DRL2017
        private static Entity BuildMountForWeapon(Entity mech, BodyPartLocation location, Entity weapon)
        {
            Entity mount;

            switch (weapon.GetComponentOfType <Component_Attachable>().SizeRequired)
            {
            case AttachmentSize.SMALL:
                mount = BlueprintListing.BuildForLabel(Blueprints.SMALL_MOUNT);
                break;

            case AttachmentSize.MEDIUM:
                mount = BlueprintListing.BuildForLabel(Blueprints.MEDIUM_MOUNT);
                break;

            case AttachmentSize.LARGE:
                mount = BlueprintListing.BuildForLabel(Blueprints.LARGE_MOUNT);
                break;

            default:
                throw new ArgumentException("BuildMountForWeapon can't handle size: not SMALL, MEDIUM, LARGE");
            }

            SlotAt(mech, location, mount);
            mount.HandleEvent(new GameEvent_Slot(mech, mount, weapon));
            return(mount);
        }
コード例 #4
0
 public GameEvent_ReceiveAttack(Entity target, BodyPartLocation subTarget, DamageType damageType, int damage)
 {
     this.Target             = target;
     this.SubTarget          = subTarget;
     this.DamageType         = damageType;
     this.BaseIncomingDamage = damage;
 }
コード例 #5
0
 public EquipmentSlotDetails(EquipmentSlot slot, BodyPartType bodyPartType, BodyPartLocation location, int index)
 {
     EquipmentSlot    = slot;
     BodyPartType     = bodyPartType;
     BodyPartLocation = location;
     Index            = index;
 }
コード例 #6
0
ファイル: EntityBuilder.cs プロジェクト: MoyTW/7DRL2017
 public static Entity BuildBodyPart(BodyPartLocation location, int slotSpace, int internalStructure)
 {
     return(new Entity(label: location.ToString(), typeLabel: "BodyPart")
            .AddComponent(new Component_BodyPartLocation(location))
            .AddComponent(new Component_SlottedContainer(slotSpace))
            .AddComponent(new Component_SlottedStructure())
            .AddComponent(new Component_InternalStructure(internalStructure)));
 }
コード例 #7
0
 public CommandStub_PrepareTargetedAttack(string attackerEID, string targetEID, string targetLabel,
                                          BodyPartLocation subTarget) : base(attackerEID)
 {
     this.AttackerEID = attackerEID;
     this.TargetLabel = targetLabel;
     this.TargetEID   = targetEID;
     this.SubTarget   = subTarget;
 }
コード例 #8
0
 public CommandStub_PrepareDirectionalAttack(string attackerEID, int x, int y, BodyPartLocation subTarget)
     : base(attackerEID)
 {
     this.AttackerEID = attackerEID;
     this.x           = x;
     this.y           = y;
     this.SubTarget   = subTarget;
 }
コード例 #9
0
        public void Deserialize(string value)
        {
            var splits = value.Split('|');

            EquipmentSlot    = (EquipmentSlot)Enum.Parse(typeof(EquipmentSlot), splits[0]);
            BodyPartType     = (BodyPartType)Enum.Parse(typeof(BodyPartType), splits[1]);
            BodyPartLocation = (BodyPartLocation)Enum.Parse(typeof(BodyPartLocation), splits[2]);
            Index            = int.Parse(splits[3]);
        }
コード例 #10
0
ファイル: EntityBuilder.cs プロジェクト: MoyTW/7DRL2017
        public static Entity MountOntoArm(Entity mech, BodyPartLocation location, Entity mountable)
        {
            var armActuator = GetBodyPart(mech, location)
                              .TryGetSubEntities(SubEntitiesSelector.SWAPPABLE_ATTACH_POINTS)
                              .Where(e => e.Label == Blueprints.HAND)
                              .First();

            armActuator.HandleEvent(new GameEvent_Slot(mech, armActuator, mountable));
            return(mech);
        }
コード例 #11
0
ファイル: EntityBuilder.cs プロジェクト: MoyTW/7DRL2017
        private static void FillLocationWith(Entity mech, BodyPartLocation location, Func <Entity> buildFn)
        {
            var container = GetBodyPart(mech, location).GetComponentOfType <Component_SlottedContainer>();
            var toAdd     = buildFn();

            while (container.SlotsRemaining >= toAdd.GetComponentOfType <Component_Slottable>().SlotsRequired)
            {
                SlotAt(mech, location, toAdd);
                toAdd = buildFn();
            }
        }
コード例 #12
0
 public Entity InspectBodyPart(BodyPartLocation location)
 {
     if (this.bodyParts.ContainsKey(location))
     {
         return(this.bodyParts[location]);
     }
     else
     {
         return(null);
     }
 }
コード例 #13
0
        public GameEvent_PrepareAttack(int commandTick, int APCost, Entity attacker, Entity target, Entity weapon,
                                       IMap gameMap, BodyPartLocation subTarget) : base(commandTick, APCost, attacker, weapon)
        {
            if (!weapon.HasComponentOfType <Component_Weapon>())
            {
                throw new ArgumentException("Can't build attack event - weapon has no Weapon component!");
            }

            this.Target    = target;
            this.SubTarget = subTarget;
            this.GameMap   = gameMap;
        }
コード例 #14
0
 public Component_BodyPartLocation(BodyPartLocation location)
 {
     this.Location = location;
 }
コード例 #15
0
ファイル: EntityBuilder.cs プロジェクト: MoyTW/7DRL2017
        public static void SlotAt(Entity mech, BodyPartLocation location, Entity slottable)
        {
            var bodyPart = GetBodyPart(mech, location);

            bodyPart.HandleEvent(new GameEvent_Slot(mech, bodyPart, slottable));
        }