예제 #1
0
 public void startJourney(Point realStart, Point realEnd, double distThroughJourney)
 {
     this.startPos = (PointF)realStart;
     this.endPos   = (PointF)realEnd;
     if (distThroughJourney >= 1.0)
     {
         this.currentPos = this.endPos;
         this.state      = VillagePeopleStates.STATIONARY;
     }
     else
     {
         TimeSpan span = VillageBuildingsData.calcTravelTime(GameEngine.Instance.LocalWorldData, realStart, realEnd);
         this.startTime = DateTime.Now;
         this.endTime   = DateTime.Now.Add(span);
         if (distThroughJourney != 0.0 && !double.IsNaN(distThroughJourney))
         {
             double num = span.TotalSeconds * distThroughJourney;
             this.startTime = this.startTime.AddSeconds(0.0 - num); // TODO Ex here
             this.endTime   = this.endTime.AddSeconds(0.0 - num);
         }
         this.state  = VillagePeopleStates.MOVING;
         this.facing = SpriteWrapper.getFacing(this.startPos, this.endPos, 8);
         this.updateJourney();
     }
 }
예제 #2
0
    public SpriteWrapper CreateSprite()
    {
        SpriteWrapper wrapper = Game.Objects.CreatePrefab <SpriteWrapper>(sprite);

        wrapper.Visible = false;
        return(wrapper);
    }
예제 #3
0
        public void UpdaterTest()
        {
            SpriteBatch sb = MockedSB;

            UnitTestSprite[] spritestart = new UnitTestSprite[25];

            //Initialize array
            for (int i = 0; i < spritestart.Length; i++)
            {
                spritestart[i] = new UnitTestSprite();
                Assert.IsFalse(spritestart[i].IsUpdated);
                Assert.IsFalse(spritestart[i].IsDrawn);
            }
            SpriteWrapper   target  = new SpriteWrapper(sb, spritestart);
            UnitTestUpdater updater = new UnitTestUpdater(target);

            target.Updater = updater;
            Assert.AreEqual(target.Sprites, updater.AllSprites);
            target.Update();
            Assert.AreEqual(updater.UpdatedSprites, spritestart.Length);
            for (int i = 0; i < spritestart.Length; i++)
            {
                Assert.IsTrue(spritestart[i].IsUpdated);
                Assert.IsFalse(spritestart[i].IsDrawn);
            }
        }
예제 #4
0
        public override void Refresh()
        {
            base.Refresh();
            this.Steps.CollectionChanged -= this.Steps_CollectionChanged;
            this.Steps.Clear();

            if (this.SavableValue.Steps.Any())
            {
                var root    = this.GetRootFolder();
                var sprites = root.GetAssetsOfType <SpriteWrapper>();

                foreach (var step in this.SavableValue.Steps)
                {
                    SpriteWrapper spriteWrapper = null;
                    if (step.Sprite != null)
                    {
                        spriteWrapper = sprites.FirstOrDefault(x => x.Sprite.Id == step.Sprite.Id);
                    }

                    var wrapper = new SpriteAnimationStepWrapper(this, step, spriteWrapper);
                    this.Steps.Add(wrapper);
                    wrapper.PropertyChanged += this.Step_PropertyChanged;
                }
            }

            this.Steps.CollectionChanged += this.Steps_CollectionChanged;
        }
예제 #5
0
 public Building(int buildingType, int mapX, int mapY, int UID)
 {
     this.m_type = buildingType;
     this.m_UID = UID;
     this.m_X = mapX;
     this.m_Y = mapY;
     this.sprite = new SpriteWrapper();
 }
예제 #6
0
 public void initWorkerSpriteInBuilding(SpriteWrapper buildingSprite)
 {
     if (this.workerSprite == null)
     {
         this.workerSprite = new SpriteWrapper();
         buildingSprite.AddChild(this.workerSprite, 1);
     }
 }
예제 #7
0
 public Building(int buildingType, int mapX, int mapY, int UID)
 {
     this.m_type = buildingType;
     this.m_UID  = UID;
     this.m_X    = mapX;
     this.m_Y    = mapY;
     this.sprite = new SpriteWrapper();
 }
예제 #8
0
 public void initWorkerSprite()
 {
     if (this.workerSprite == null)
     {
         this.workerSprite = new SpriteWrapper();
         if (GameEngine.Instance.Village != null)
         {
             GameEngine.Instance.Village.addChildSprite(this.workerSprite, 15);
         }
     }
 }
예제 #9
0
        public void SpriteWrapperConstructorTest()
        {
            ICollection <ISprite> spritestart = new ISprite[3];            // TODO: Initialize to an appropriate value
            SpriteBatch           sb          = MockedSB;                  // TODO: Initialize to an appropriate value
            Updater       updates             = new UnitTestUpdater(null); // TODO: Initialize to an appropriate value
            SpriteWrapper target = new SpriteWrapper(spritestart, sb, updates);

            Assert.AreEqual <Updater>(updates, target.Updater);

            Assert.AreEqual(spritestart.Count, target.Sprites.Count);
        }
예제 #10
0
        private void RemoveSprite()
        {
            var originalValue = this.SelectedSprite;
            var undoCommand   = new UndoCommand(() => {
                this.Asset.RemoveChild(originalValue);
                this.SelectedSprite = this.Asset.Children.FirstOrDefault();
            }, () => {
                if (this.Asset.AddChild(originalValue))
                {
                    this.SelectedSprite = originalValue;
                }
            });

            this._undoService.Do(undoCommand);
        }
예제 #11
0
        public void SpriteWrapperConstructorTest1()
        {
            SpriteBatch sb = null;

            ISprite[]     spritestart = null;
            SpriteWrapper target      = null;

            try
            {
                target = new SpriteWrapper(sb, spritestart);
            }
            catch (ArgumentNullException) { }

            Assert.IsNull(target, "The target constructor did not throw an ArgumentNullException when it should have.");
        }
예제 #12
0
        private void AddSprite()
        {
            SpriteWrapper newValue    = null;
            var           undoCommand = new UndoCommand(() => {
                if (newValue == null)
                {
                    newValue = this.Asset.AddNewSprite();
                }
                else if (this.Asset.AddChild(newValue))
                {
                    this.SelectedSprite = newValue;
                }
            },
                                                        () => {
                this.Asset.RemoveChild(newValue);
                this.SelectedSprite = this.Asset.Children.FirstOrDefault();
            });

            this._undoService.Do(undoCommand);
        }
예제 #13
0
        public void UpdateTest()
        {
            //SpriteBatch sb = new SpriteBatch(new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, new PresentationParameters() { DeviceWindowHandle = GraphicsAdapter.DefaultAdapter.MonitorHandle } ));
            SpriteBatch sb = MockedSB;

            UnitTestSprite[] spritestart = new UnitTestSprite[25];

            //Initialize array
            for (int i = 0; i < spritestart.Length; i++)
            {
                spritestart[i] = new UnitTestSprite();
                Assert.IsFalse(spritestart[i].IsUpdated);
                Assert.IsFalse(spritestart[i].IsDrawn);
            }
            SpriteWrapper target = new SpriteWrapper(sb, spritestart);

            target.Update();
            Assert.IsNull(target.Updater);
            for (int i = 0; i < spritestart.Length; i++)
            {
                Assert.IsTrue(spritestart[i].IsUpdated);
                Assert.IsFalse(spritestart[i].IsDrawn);
            }
        }
 public void initWorkerSpriteInBuilding(SpriteWrapper buildingSprite)
 {
     if (this.workerSprite == null)
     {
         this.workerSprite = new SpriteWrapper();
         buildingSprite.AddChild(this.workerSprite, 1);
     }
 }
 public void initWorkerSprite()
 {
     if (this.workerSprite == null)
     {
         this.workerSprite = new SpriteWrapper();
         if (GameEngine.Instance.Village != null)
         {
             GameEngine.Instance.Village.addChildSprite(this.workerSprite, 15);
         }
     }
 }
예제 #16
0
 public UnitTestUpdater(SpriteWrapper sw)
     : base(sw)
 {
     _id = Guid.NewGuid();
 }
 private ICollection <ISprite> InternalDetectCollisions(AxisAlignedBoundingBoxTree <SpriteWrapper> tree, SpriteWrapper target) =>
 tree.Find(target)
 .Where(collision => _narrowPhase.Overlap(target.Sprite, collision.Sprite))
 .Select(wrapper => wrapper.Sprite)
 .ToList();