コード例 #1
0
ファイル: TradeEnvoy.cs プロジェクト: polytronicgr/dwarfcorp
        public void MakeTradeWidget(WorldManager World)
        {
            var liveCreatures = Creatures.Where(creature => creature != null && !creature.IsDead);

            if (!liveCreatures.Any())
            {
                return;
            }

            var zones = World.PlayerFaction.RoomBuilder.DesignatedRooms.OfType <BalloonPort>();

            CreatureAI closestCreature = null;
            float      closestDist     = float.MaxValue;

            if (zones.Any())
            {
                var zoneCenter = zones.First().GetBoundingBox().Center();
                foreach (var creature in liveCreatures)
                {
                    float dist = (creature.Position - zoneCenter).LengthSquared();
                    if (dist < closestDist)
                    {
                        closestDist     = dist;
                        closestCreature = creature;
                    }
                }
            }
            else
            {
                closestCreature = liveCreatures.First();
            }

            TradeWidget = World.MakeWorldPopup(new Goals.TimedIndicatorWidget()
            {
                Text    = string.Format("Click here to trade with the {0}!", OwnerFaction.Race.Name),
                OnClick = (gui, sender) =>
                {
                    OpenDiplomacyConversation(World);
                },
                ShouldKeep = () => { return(this.ExpiditionState == Expedition.State.Trading && !this.ShouldRemove); }
            }, closestCreature.Physics, new Vector2(0, -10));
            World.MakeAnnouncement(String.Format("Click here to trade with the {0}!", OwnerFaction.Race.Name), (gui, sender) =>
            {
                OpenDiplomacyConversation(World);
            }, () => { return(this.ExpiditionState == Expedition.State.Trading && !this.ShouldRemove); }, false);
            SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_positive_generic, 0.15f);
        }
コード例 #2
0
ファイル: TradeEnvoy.cs プロジェクト: johan74/dwarfcorp
        public void MakeTradeWidget(WorldManager World)
        {
            var liveCreatures = Creatures.Where(creature => creature != null && !creature.IsDead);

            if (!liveCreatures.Any())
            {
                return;
            }

            TradeWidget = World.MakeWorldPopup(new Goals.TimedIndicatorWidget()
            {
                Text    = string.Format("Click here to trade with the {0}!", OwnerFaction.Race.Name),
                OnClick = (gui, sender) =>
                {
                    OpenDiplomacyConversation(World);
                },
                ShouldKeep = () => { return(this.ExpiditionState == Expedition.State.Trading && !this.ShouldRemove); }
            }, liveCreatures.First().Physics, new Vector2(0, -10));
            World.MakeAnnouncement(String.Format("Click here to trade with the {0}!", OwnerFaction.Race.Name), (gui, sender) =>
            {
                OpenDiplomacyConversation(World);
            }, () => { return(this.ExpiditionState == Expedition.State.Trading && !this.ShouldRemove); }, false);
            SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_positive_generic, 0.15f);
        }