Ejemplo n.º 1
0
        public void RefreshIcons()
        {
            icons = new Dictionary <Rectangle, ProductionIcon>();
            var producer = CurrentQueue != null?CurrentQueue.MostLikelyProducer() : default(TraitPair <Production>);

            if (CurrentQueue == null || producer.Trait == null)
            {
                if (DisplayedIconCount != 0)
                {
                    OnIconCountChanged(DisplayedIconCount, 0);
                    DisplayedIconCount = 0;
                }

                return;
            }

            var oldIconCount = DisplayedIconCount;

            DisplayedIconCount = 0;

            var rb      = RenderBounds;
            var faction = producer.Trait.Faction;

            foreach (var item in AllBuildables.Skip(IconRowOffset * Columns).Take(MaxIconRowOffset * Columns))
            {
                var x    = DisplayedIconCount % Columns;
                var y    = DisplayedIconCount / Columns;
                var rect = new Rectangle(rb.X + x * (IconSize.X + IconMargin.X), rb.Y + y * (IconSize.Y + IconMargin.Y), IconSize.X, IconSize.Y);

                var rsi  = item.TraitInfo <RenderSpritesInfo>();
                var icon = new Animation(World, rsi.GetImage(item, World.Map.Rules.Sequences, faction));
                var bi   = item.TraitInfo <BuildableInfo>();
                icon.Play(bi.Icon);

                var pi = new ProductionIcon()
                {
                    Actor             = item,
                    Name              = item.Name,
                    Sprite            = icon.Image,
                    Palette           = worldRenderer.Palette(bi.IconPalette),
                    IconClockPalette  = worldRenderer.Palette(ClockPalette),
                    IconDarkenPalette = worldRenderer.Palette(NotBuildablePalette),
                    Pos             = new Vector2(rect.Location),
                    Queued          = currentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
                    ProductionQueue = currentQueue
                };

                icons.Add(rect, pi);
                DisplayedIconCount++;
            }

            eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty;

            if (oldIconCount != DisplayedIconCount)
            {
                OnIconCountChanged(oldIconCount, DisplayedIconCount);
            }
        }
Ejemplo n.º 2
0
        protected bool PickUpCompletedBuildingIcon(ProductionIcon icon, ProductionItem item)
        {
            var actor = World.Map.Rules.Actors[icon.Name];

            if (item != null && item.Done && actor.HasTraitInfo <BuildingInfo>())
            {
                World.OrderGenerator = new PlaceBuildingOrderGenerator(currentQueue, icon.Name, worldRenderer);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        bool HandleEvent(ProductionIcon icon, GestureSample gs)
        {
            var item = icon.Queued.FirstOrDefault();

            if (gs.GestureType == GestureType.Tap)
            {
                var startCount = 1;
                var handled    = HandlClick(item, icon, startCount);
            }
            return(true);
        }
Ejemplo n.º 4
0
        bool HandlClick(ProductionItem item, ProductionIcon icon, int handleCount)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                return(true);
            }

            if (currentQueue.BuildableItems().Any(a => a.Name == icon.Name))
            {
                //Queue a new item
                WarGame.Sound.Play(SoundType.UI, TabClick);
                WarGame.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.StartProduction(currentQueue.Actor, icon.Name, handleCount));
            }

            return(false);
        }