示例#1
0
        public WithHarvestAnimation(Actor self, WithHarvestAnimationInfo info)
        {
            this.info = info;
            var rs   = self.Trait <RenderSprites>();
            var body = self.Trait <IBodyOrientation>();

            anim = new Animation(self.World, rs.GetImage(self), RenderSimple.MakeFacingFunc(self));
            anim.IsDecoration = true;
            anim.Play(info.Sequence);
            rs.Add(new AnimationWithOffset(anim,
                                           () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
                                           () => !visible,
                                           () => false,
                                           p => ZOffsetFromCenter(self, p, 0)), info.Palette);
        }
示例#2
0
        public WithResources(Actor self, WithResourcesInfo info)
        {
            this.info       = info;
            rs              = self.Trait <RenderSimple>();
            playerResources = self.Owner.PlayerActor.Trait <PlayerResources>();

            var a = new Animation(self.World, rs.GetImage(self));

            a.PlayFetchIndex(info.Sequence, () =>
                             playerResources.ResourceCapacity != 0 ?
                             ((10 * a.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity) :
                             0);

            anim = new AnimationWithOffset(a, null, () => !buildComplete, 1024);
            rs.Add(anim);
        }
 public WithBuildingPlacedAnimation(Actor self, WithBuildingPlacedAnimationInfo info)
 {
     this.info     = info;
     renderSimple  = self.Trait <RenderSimple>();
     buildComplete = !self.HasTrait <Building>();
 }