public ProductionPaletteWidget([ObjectCreator.Param] World world,
		                               [ObjectCreator.Param] WorldRenderer worldRenderer)
        {
            this.world = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer = new Lazy<TooltipContainerWidget>(() =>
                Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));

            cantBuild = new Animation("clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation("clock");

            iconSprites = Rules.Info.Values
                .Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
                .ToDictionary(
                    u => u.Name,
                    u => Game.modData.SpriteLoader.LoadAllSprites(
                        u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);

            overlayFont = Game.Renderer.Fonts["TinyBold"];
            holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2;
            readyOffset = new float2(32,24) - overlayFont.Measure("Ready") / 2;
            timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
            queuedOffset = new float2(4,2);
        }
示例#2
0
        public RenderUnitTurreted(Actor self)
            : base(self)
        {
            var facing = self.Trait<IFacing>();
            var turreted = self.Trait<Turreted>();
            var attack = self.TraitOrDefault<AttackBase>();
            var attackInfo = self.Info.Traits.Get<AttackBaseInfo>();

            var turretAnim = new Animation(GetImage(self), () => turreted.turretFacing );
            turretAnim.Play( "turret" );

            for( var i = 0; i < attack.Turrets.Count; i++ )
            {
                var turret = attack.Turrets[i];
                anims.Add( "turret_{0}".F(i),
                    new AnimationWithOffset( turretAnim,
                        () => Combat.GetTurretPosition( self, facing, turret ),
                        null));

                if (attackInfo.MuzzleFlash)
                {
                    var muzzleFlash = new Animation(GetImage(self), () => turreted.turretFacing);
                    muzzleFlash.PlayFetchIndex("muzzle",
                        () => (int)(turret.Recoil * 5.9f)); /* hack: dumb crap */
                    anims.Add("muzzle_flash_{0}".F(i),
                        new AnimationWithOffset(muzzleFlash,
                            () => Combat.GetTurretPosition(self, facing, turret),
                            () => turret.Recoil <= 0));
                }
            }
        }
示例#3
0
        public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            // Show a static frame instead of animating all of the fullness states
            var anim = new Animation(init.World, image, () => 0);
            anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence), () => 0);

            yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
        }
示例#4
0
        public Parachute(Player owner, string image, float2 location, int altitude, Actor cargo)
        {
            this.location = location;
            this.altitude = altitude;
            this.cargo = cargo;
            this.owner = owner;

            anim = new Animation(image);
            if (anim.HasSequence("idle"))
                anim.PlayFetchIndex("idle", () => 0);
            else
                anim.PlayFetchIndex("stand", () => 0);
            anim.Tick();

            paraAnim = new Animation("parach");
            paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));
        }
        void DrawControlGroup(WorldRenderer wr, Actor self, float2 basePosition)
        {
            var group = self.World.Selection.GetControlGroupForActor(self);
            if (group == null) return;

            var pipImages = new Animation("pips");
            pipImages.PlayFetchIndex("groups", () => (int)group);
            pipImages.Tick();
            pipImages.Image.DrawAt(basePosition + new float2(-8, 1), wr.Palette("chrome"));
        }
示例#6
0
文件: Rank.cs 项目: ushardul/OpenRA
        public Rank(Actor self, string paletteName)
        {
            this.self = self;
            this.paletteName = paletteName;

            var xp = self.Trait<GainsExperience>();
            anim = new Animation(self.World, "rank");
            anim.PlayRepeating("rank");
            anim.PlayFetchIndex("rank", () => xp.Level == 0 ? 0 : xp.Level - 1);
        }
        public ProductionPaletteWidget(World world, WorldRenderer worldRenderer)
        {
            this.World = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer = Lazy.New(() =>
                Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

            cantBuild = new Animation("clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation("clock");
        }
示例#8
0
        public BuildPaletteWidget(World world, WorldRenderer worldRenderer)
        {
            this.world = world;
            this.worldRenderer = worldRenderer;

            cantBuild = new Animation("clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation("clock");
            VisibleQueues = new List<ProductionQueue>();
            CurrentQueue = null;
        }
示例#9
0
        public Parachute(Player owner, float2 location, int altitude, Actor cargo)
        {
            this.location = location;
            this.altitude = altitude;
            this.cargo = cargo;

            var rs = cargo.Trait<RenderSimple>();
            var image = rs.anim.Name;
            palette = rs.Palette(owner);

            anim = new Animation(image);
            if (anim.HasSequence("idle"))
                anim.PlayFetchIndex("idle", () => 0);
            else
                anim.PlayFetchIndex("stand", () => 0);
            anim.Tick();

            paraAnim = new Animation("parach");
            paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));
        }
示例#10
0
        public ProductionPaletteWidget(OrderManager orderManager, World world, WorldRenderer worldRenderer)
        {
            this.orderManager = orderManager;
            this.World = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer = Exts.Lazy(() =>
                Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

            cantBuild = new Animation(world, "clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation(world, "clock");
        }
示例#11
0
        void DrawControlGroup(WorldRenderer wr, Actor self, int2 basePosition)
        {
            var group = self.World.Selection.GetControlGroupForActor(self);
            if (group == null) return;

            var pipImages = new Animation("pips");
            pipImages.PlayFetchIndex("groups", () => (int)group);
            pipImages.Tick();

            var pos = wr.Viewport.WorldToViewPx(basePosition) - (0.5f * pipImages.Image.size).ToInt2() + new int2(9, 5);
            Game.Renderer.SpriteRenderer.DrawSprite(pipImages.Image, pos, wr.Palette("chrome"));
        }
示例#12
0
        IEnumerable<IRenderable> DrawControlGroup(WorldRenderer wr, Actor self, int2 basePosition)
        {
            var group = self.World.Selection.GetControlGroupForActor(self);
            if (group == null)
                yield break;

            var pipImages = new Animation(self.World, "pips");
            var pal = wr.Palette(Info.Palette);
            pipImages.PlayFetchIndex("groups", () => (int)group);
            pipImages.Tick();

            var pos = basePosition - (0.5f * pipImages.Image.Size).ToInt2() + new int2(9, 5);
            yield return new UISpriteRenderable(pipImages.Image, pos, 0, pal, 1f);
        }
示例#13
0
        public RenderUnitMuzzleFlash(Actor self)
            : base(self)
        {
            var unit = self.traits.Get<Unit>();
            var attack = self.traits.Get<AttackBase>();
            var attackInfo = self.Info.Traits.Get<AttackBaseInfo>();

            var muzzleFlash = new Animation(GetImage(self), ()=>unit.Facing);
            muzzleFlash.PlayFetchIndex("muzzle",
                () => (int)(attack.primaryRecoil * 5.9f));
            anims.Add( "muzzle", new AnimationWithOffset(
                muzzleFlash,
                () => attackInfo.PrimaryOffset.AbsOffset(),
                () => attack.primaryRecoil <= 0 ) );
        }
示例#14
0
        public RenderBuildingRefinery(ActorInitializer init, RenderBuildingInfo info)
            : base(init, info)
        {
            playerResources = init.self.Owner.PlayerActor.Trait<PlayerResources>();

            lights = new Animation(GetImage(init.self));
            lights.PlayFetchIndex("lights",
                () => playerResources.OreCapacity != 0
                    ? (59 * playerResources.Ore) / (10 * playerResources.OreCapacity)
                    : 0);

            var offset = new float2(-32,-21);
            anims.Add("lights", new AnimationWithOffset( lights, wr => offset, () => !buildComplete )
                { ZOffset = 24 });
        }
示例#15
0
        public Parachute(Player owner, PPos location, int altitude, Actor cargo)
        {
            this.location = location;
            this.altitude = altitude;
            this.cargo = cargo;

            var rs = cargo.Trait<RenderSimple>();
            var image = rs.anim.Name;
            palette = rs.Palette(owner);

            anim = new Animation(image);
            if (anim.HasSequence("idle"))
                anim.PlayFetchIndex("idle", () => 0);
            else
                anim.PlayFetchIndex("stand", () => 0);
            anim.Tick();

            var pai = cargo.Info.Traits.GetOrDefault<ParachuteAttachmentInfo>();

            paraAnim = new Animation(pai != null ? pai.ParachuteSprite : "parach");
            paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));

            if (pai != null) offset = pai.Offset;
        }
示例#16
0
		public override void Initialize(WidgetArgs args)
		{
			base.Initialize(args);

			if (Unit != null && Sequence != null)
			{
				var anim = new Animation(worldRenderer.world, Unit, () => Facing);
				anim.PlayFetchIndex(Sequence, () => Frame);
				GetAnimation = () => anim;
			}

			GetSprite = () =>
			{
				var anim = GetAnimation();
				return anim != null ? anim.Image : null;
			};
		}
示例#17
0
文件: Beacon.cs 项目: ushardul/OpenRA
        // Support power beacons are expected to clean themselves up
        public Beacon(Player owner, WPos position, string palettePrefix, string posterType, string posterPalette, Func<float> clockFraction)
            : this(owner, position, -1, palettePrefix)
        {
            this.posterPalette = posterPalette;

            if (posterType != null)
            {
                poster = new Animation(owner.World, "beacon");
                poster.Play(posterType);

                if (clockFraction != null)
                {
                    clock = new Animation(owner.World, "beacon");
                    clock.PlayFetchIndex("clock", () => Exts.Clamp((int)(clockFraction() * (clock.CurrentSequence.Length - 1)), 0, clock.CurrentSequence.Length - 1));
                }
            }
        }
示例#18
0
        public ProductionPaletteWidget(World world, WorldRenderer worldRenderer)
        {
            this.world = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer = Lazy.New(() =>
                Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

            cantBuild = new Animation("clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation("clock");

            iconSprites = Rules.Info.Values
                .Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
                .ToDictionary(
                    u => u.Name,
                    u => Game.modData.SpriteLoader.LoadAllSprites(
                        u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
        }
示例#19
0
文件: Beacon.cs 项目: OpenRA/OpenRA
        // Support power beacons are expected to clean themselves up
        public Beacon(Player owner, WPos position, bool isPlayerPalette, string palette, string posterCollection, string posterType, string posterPalette,
			string arrowSequence, string circleSequence, string clockSequence, Func<float> clockFraction)
            : this(owner, position, -1, palette, isPlayerPalette, posterCollection, arrowSequence, circleSequence)
        {
            this.posterPalette = posterPalette;

            if (posterType != null)
            {
                poster = new Animation(owner.World, posterCollection);
                poster.Play(posterType);

                if (clockFraction != null)
                {
                    clock = new Animation(owner.World, posterCollection);
                    clock.PlayFetchIndex(clockSequence, () => Exts.Clamp((int)(clockFraction() * (clock.CurrentSequence.Length - 1)), 0, clock.CurrentSequence.Length - 1));
                }
            }
        }
示例#20
0
        public BuildPaletteWidget(World world, WorldRenderer worldRenderer)
        {
            this.world = world;
            this.worldRenderer = worldRenderer;

            cantBuild = new Animation("clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation("clock");
            paletteOrigin = paletteClosedOrigin;
            VisibleQueues = new List<ProductionQueue>();
            CurrentQueue = null;

            iconSprites = Rules.Info.Values
                .Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
                .ToDictionary(
                    u => u.Name,
                    u => Game.modData.SpriteLoader.LoadAllSprites(
                        u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
        }
示例#21
0
		public ProductionPaletteWidget(OrderManager orderManager, World world, WorldRenderer worldRenderer)
		{
			this.orderManager = orderManager;
			World = world;
			this.worldRenderer = worldRenderer;
			tooltipContainer = Exts.Lazy(() =>
				Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

			cantBuild = new Animation(world, NotBuildableAnimation);
			cantBuild.PlayFetchIndex(NotBuildableSequence, () => 0);
			clock = new Animation(world, ClockAnimation);
		}
示例#22
0
		public Chrome(Renderer r, Manifest m)
		{
			this.renderer = r;
			rgbaRenderer = new SpriteRenderer(renderer, true, renderer.RgbaSpriteShader);
			lineRenderer = new LineRenderer(renderer);
			shpRenderer = new SpriteRenderer(renderer, true, renderer.WorldSpriteShader);
			
			optionsButton = new Animation("tabs");
			optionsButton.PlayRepeating("left-normal");

			tabSprites = Rules.Info.Values
				.Where(u => u.Traits.Contains<BuildableInfo>())
				.ToDictionary(
					u => u.Name,
					u => SpriteSheetBuilder.LoadAllSprites(u.Traits.Get<BuildableInfo>().Icon ?? (u.Name + "icon"))[0]);

			spsprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface<SupportPowerInfo>() )
				.ToDictionary(
					u => u.Image,
					u => SpriteSheetBuilder.LoadAllSprites(u.Image)[0]);

			var groups = Rules.Categories();
			
			tabImageNames = groups.Select(
				(g, i) => Pair.New(g,
					OpenRA.Graphics.Util.MakeArray(3,
						n => i.ToString())))
				.ToDictionary(a => a.First, a => a.Second);

			cantBuild = new Animation("clock");
			cantBuild.PlayFetchIndex("idle", () => 0);

			ready = new Animation("pips");
			ready.PlayRepeating("ready");
			clock = new Animation("clock");
			
			var widgetYaml = m.ChromeLayout.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge);

			rootWidget = WidgetLoader.LoadWidget( widgetYaml.FirstOrDefault() );
			rootWidget.Initialize();
		}
示例#23
0
        public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            var anim = new Animation(init.World, image);
            anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequences.First()), () => 0);

            yield return new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale);
        }
示例#24
0
        public override void Initialize()
        {
            base.Initialize();

            cantBuild = new Animation("clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            ready = new Animation("pips");
            ready.PlayRepeating("ready");
            clock = new Animation("clock");

            iconSprites = Rules.Info.Values
                .Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
                .ToDictionary(
                    u => u.Name,
                    u => SpriteSheetBuilder.LoadAllSprites(u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);

            IsVisible = () => { return CurrentQueue != null || (CurrentQueue == null && !paletteOpen); };
        }
示例#25
0
 public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
 {
     var anim = new Animation(init.World, image);
     var sequence = init.World.Type == WorldType.Editor ? EditorSequence : Sequence;
     var palette = init.World.Type == WorldType.Editor ? init.WorldRenderer.Palette(EditorPalette) : p;
     anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), sequence), () => 0);
     yield return new SpriteActorPreview(anim, () => WVec.Zero, () => 0, palette, rs.Scale);
 }
示例#26
0
 public UnitStanceAggressive(Actor self, UnitStanceAggressiveInfo info)
     : base(self, info)
 {
     RankAnim = new Animation("rank");
     RankAnim.PlayFetchIndex("rank", () => 3 - 1);
 }