Beispiel #1
0
        protected override void OnUpdate(GameTime gameTime)
        {
            MouseState State = Mouse.GetState();

            if (State.LeftButton == ButtonState.Pressed && OldState.LeftButton != ButtonState.Pressed)
            {
                var Entity = SceneManager.ActiveScene.GetEntityAtPosition(new Point(State.X + (int)Player.Camera.Position.X, State.Y + (int)Player.Camera.Position.Y));
                if (Entity != null)
                {
                    if (!CurrentCamera.IsDisposed)
                    {
                        CurrentCamera.Dispose();
                    }
                    CurrentCamera = new ChaseCameraComponent(Player.Camera);
                    Entity.Components.Add(CurrentCamera);
                }
            }
            if (State.RightButton == ButtonState.Pressed && OldState.RightButton != ButtonState.Pressed)
            {
                var Entity = SceneManager.ActiveScene.GetEntityAtPosition(new Point(State.X + (int)Player.Camera.Position.X, State.Y + (int)Player.Camera.Position.Y));
                if (Entity != null)
                {
                    foreach (var OtherEntity in SceneManager.ActiveScene.Entities.ToArray())
                    {
                        if (OtherEntity != Entity && !CorvusGame.Instance.Players.Any(c => c.Character == OtherEntity))
                        {
                            OtherEntity.Dispose();
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void Test()
        {
            // Creation of a new entity.
            var sample1 = new SampleEntity1();

            sample1.Value = 3;

            //// EntityGate support and database registration.
            var gate = new EntityGateObject <SampleEntity1>(sample1);

            if (gate.Save())
            {
                // New data saved in database.
            }

            // Creation of a new entity.
            gate.NewEntity();
            gate.Entity.Value = 4;
            gate.Save();

            // Loading the primary key "10" and obtaining the entity.
            gate.Load(identifier: 10);
            sample1 = gate.Entity;

            // Support for another entity.
            var gate2 = new EntityGateObject <OtherEntity>();

            // Loading the primary key "33"...
            if (gate2.Load(33))
            {
                // ...and obtaining the entity.
                OtherEntity sample2 = gate2.Entity;
            }
        }
 public void should_save_the_referenced_list_items()
 {
     foreach (var reference in referencedEntities)
     {
         OtherEntity entity = reference;
         session.AssertWasCalled(x => x.Save(entity));
     }
 }
 public void should_save_the_referenced_list_items()
 {
     foreach (var reference in referencedEntities)
     {
         OtherEntity entity = reference;
         A.CallTo(() => session.Save(entity))
         .MustHaveHappened();
     }
 }
Beispiel #5
0
        public void CanProveInequalityWithOtherEntity()
        {
            var id = Guid.NewGuid();

            var firstEntity  = new ConcreteEntity(id);
            var secondEntity = new OtherEntity(id);

            firstEntity.Equals(secondEntity).Should().BeFalse();
        }
        public void persist()
        {
            var entity = new OtherEntity();
            var persistor = new InMemoryPersistor();

            persistor.Persist(entity);

            persistor.LoadAll<OtherEntity>().Single().ShouldBeTheSameAs(entity);
        }
Beispiel #7
0
        public void persist()
        {
            var entity    = new OtherEntity();
            var persistor = new InMemoryPersistor();

            persistor.Persist(entity);

            persistor.LoadAll <OtherEntity>().Single().ShouldBeTheSameAs(entity);
        }
Beispiel #8
0
        public void persist()
        {
            var entity = new OtherEntity();

            persistor.Persist(entity);

            boundary.SaveChanges();

            persistor.LoadAll <OtherEntity>().Single().ShouldBeTheSameAs(entity);
        }
        public static RootEntity TestData()
        {
            var child1 = new ChildEntity("CHILD_1");
            var child2 = new ChildEntity("CHILD_2");

            var other = new OtherEntity("OTHER", new List <ChildEntity> {
                child1, child2
            });

            return(new RootEntity("NAME_1", other));
        }
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression <Func <ReferenceEntity, OtherEntity> >)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = A.Fake <ISession>();
            A.CallTo(() => session.BeginTransaction()).Returns(A.Dummy <ITransaction>());
            specification = new PersistenceSpecification <PropertyEntity>(session);

            sut = new ReferenceProperty <PropertyEntity, OtherEntity>(property, referencedEntity);
        }
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression<Func<ReferenceEntity, OtherEntity>>)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = A.Fake<ISession>();
            A.CallTo(() => session.BeginTransaction()).Returns(A.Dummy<ITransaction>());
            specification = new PersistenceSpecification<PropertyEntity>(session);

            sut = new ReferenceProperty<PropertyEntity, OtherEntity>(property, referencedEntity);
        }
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression<Func<ReferenceEntity, OtherEntity>>)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = MockRepository.GenerateStub<ISession>();
            session.Stub(x => x.BeginTransaction()).Return(MockRepository.GenerateStub<ITransaction>());
            specification = new PersistenceSpecification<PropertyEntity>(session);

            sut = new ReferenceProperty<PropertyEntity, OtherEntity>(property, referencedEntity);
        }
Beispiel #13
0
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression <Func <ReferenceEntity, OtherEntity> >)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = MockRepository.GenerateStub <ISession>();
            session.Stub(x => x.BeginTransaction()).Return(MockRepository.GenerateStub <ITransaction>());
            specification = new PersistenceSpecification <PropertyEntity>(session);

            sut = new ReferenceProperty <PropertyEntity, OtherEntity>(property, referencedEntity);
        }
Beispiel #14
0
        public void Comparing_To_Other_Entity_Should_Always_Return_False()
        {
            var entity1 = new TestableEntity1()
            {
                Id = 1
            };
            var entity2 = new OtherEntity()
            {
                Id = 1
            };

            Assert.False(entity1.Equals(entity2));
            Assert.False((IBaseEntity)entity1 == (IBaseEntity)entity2);
        }
        public void persist()
        {
            var entity = new OtherEntity();

            transaction.WithRepository(repo => repo.Update(entity));


            bool wasCalled = false;

            transaction.WithRepository(repo => {
                repo.All <OtherEntity>().ShouldContain(entity);
                wasCalled = true;
            });

            wasCalled.ShouldBeTrue();
        }
Beispiel #16
0
    // TODO: AI behavior for equipping weapons

    // Start is called before the first frame update
    new void Start()
    {
        base.Start();
        OnFirstScan.AddListener(ScanCells);

        gameManager = GameObject.Find("Grid Camera").GetComponent <GameManager>();

        entity = this.gameObject.GetComponent <Entity>();
        if (this.gameObject.tag == "Enemy")
        {
            enemy = this.gameObject.GetComponent <EnemyEntity>();
        }
        else if (this.gameObject.tag == "Other")
        {
            otherEntity = this.gameObject.GetComponent <OtherEntity>();
        }
    }
        public void persist()
        {
            var entity = new OtherEntity();

            transaction.WithRepository(repo => repo.Update(entity));

            transaction.Execute <IDocumentSession>(session => session.Query <OtherEntity>().Customize(x => x.WaitForNonStaleResults()).Any().ShouldBeTrue());

            bool wasCalled = false;

            transaction.WithRepository(repo => {
                repo.All <OtherEntity>().ShouldContain(entity);
                wasCalled = true;
            });

            wasCalled.ShouldBeTrue();
        }
        public void persist()
        {
            var entity = new OtherEntity();

            persistor.Persist(entity);

            boundary.SaveChanges();

            persistor.LoadAll<OtherEntity>().Single().ShouldBeTheSameAs(entity);
        }
 public RootEntity(string name, OtherEntity other)
 {
     Name  = name;
     Other = other;
 }
Beispiel #20
0
 public override void establish_context()
 {
     base.establish_context();
     entity     = new ReferenceEntity();
     referenced = new OtherEntity();
 }
        public void persist()
        {
            var entity = new OtherEntity();

            transaction.WithRepository(repo => repo.Update(entity));

            transaction.Execute<IDocumentSession>(session => session.Query<OtherEntity>().Customize(x => x.WaitForNonStaleResults()).Any().ShouldBeTrue());

            bool wasCalled = false;
            transaction.WithRepository(repo => {
                repo.All<OtherEntity>().ShouldContain(entity);
                wasCalled = true;
            });

            wasCalled.ShouldBeTrue();
        }
 public void SetReference(OtherEntity value)
 {
     Reference = value;
 }
        private void SaveOperation(string selectedPath, [CanBeNull] Template baseTemplate = null)
        {
            var template = new Template();

            // get the name
            template.Name = ViewModel.TemplateName ?? "undefined";

            // get the size
            template.Info.Size.X = ViewModel.Cells.Where(x => x.TileEntities[0].Classification != TileType.Null && x.TileEntities[0].Classification != null).Max(x => x.Column);
            template.Info.Size.Y = ViewModel.Cells.Where(x => x.TileEntities[0].Classification != TileType.Null && x.TileEntities[0].Classification != null).Max(x => x.Row);
            if (ViewModel.Cells.Where(x => x.TileEntities[0].Classification != TileType.Null && x.TileEntities[0].Classification != null).Min(x => x.Column) == 0)
            {
                template.Info.Size.X++;
            }
            if (ViewModel.Cells.Where(x => x.TileEntities[0].Classification != TileType.Null && x.TileEntities[0].Classification != null).Min(x => x.Row) == 0)
            {
                template.Info.Size.Y++;
            }

            // get list of cells that aren't null
            foreach (var cell in ViewModel.Cells)
            {
                if (cell.TileEntities[0].Classification == TileType.Null || cell.TileEntities[0].Classification == null)
                {
                    continue;
                }
                var  existingCell = baseTemplate?.Cells.FirstOrDefault(t => t.location_x == cell.Column && t.location_y == cell.Row);
                Cell templateCell = existingCell ?? new Cell();
                templateCell.DiseaseCount     = cell.TileEntities[0].TileProperty.DiseaseCount;
                templateCell.DiseaseName      = cell.TileEntities[0].TileProperty.DiseaseName;
                templateCell.Element          = ElementConverter.Convert(cell.TileEntities[0].ElementType.Value);
                templateCell.Mass             = cell.TileEntities[0].TileProperty.MassKiloGrams;
                templateCell.Temperature      = cell.TileEntities[0].TileProperty.TemperatureKelvin;
                templateCell.location_x       = cell.Column;
                templateCell.location_y       = cell.Row;
                templateCell.preventFoWReveal = null;
                template.Cells.Add(templateCell);
            }

            // get a list of entities that need to be added - plant specific
            foreach (var plant in ViewModel.Cells)
            {
                if (plant.TileEntities[1].Classification != TileType.Plant || plant.TileEntities[1].Classification == null)
                {
                    continue;
                }
                var         existingEntity = baseTemplate?.OtherEntities.FirstOrDefault(t => t.location_x == plant.Column && t.location_y == plant.Row);
                OtherEntity entity         = existingEntity ?? new OtherEntity();
                entity.Id          = EntityConverter.Convert(plant.TileEntities[1].EntityType.Value);
                entity.location_x  = plant.Column;
                entity.location_y  = plant.Row;
                entity.Element     = "Creature";
                entity.Type        = "Other";
                entity.Temperature = plant.TileEntities[1].TileProperty.TemperatureKelvin;
                entity.Units       = 1;
                entity.Storage     = new List <Storage>();
                entity.Rottable    = new Rottable();
                entity.Amounts     = new List <Amount>();
                entity.Amounts.Add(new Amount {
                    Id = "AirPressure", Value = 0.5
                });
                entity.Amounts.Add(new Amount {
                    Id = "Maturity", Value = plant.TileEntities[1].TileProperty.Maturity
                });
                entity.Amounts.Add(new Amount {
                    Id = "Temperature", Value = plant.TileEntities[1].TileProperty.TemperatureKelvin
                });
                entity.Amounts.Add(new Amount {
                    Id = "OldAge"
                });
                entity.Amounts.Add(new Amount {
                    Id = "Fertilization"
                });
                entity.Amounts.Add(new Amount {
                    Id = "Irrigation"
                });
                template.OtherEntities.Add(entity);
            }

            // get a list of entities that need to be added - creature specific
            foreach (var creature in ViewModel.Cells)
            {
                if (creature.TileEntities[1].Classification != TileType.Creature || creature.TileEntities[1].Classification == null)
                {
                    continue;
                }
                var         existingEntity = baseTemplate?.OtherEntities.FirstOrDefault(t => t.location_x == creature.Column && t.location_y == creature.Row);
                OtherEntity entity         = existingEntity ?? new OtherEntity();
                entity.Id          = EntityConverter.Convert(creature.TileEntities[1].EntityType.Value);
                entity.location_x  = creature.Column;
                entity.location_y  = creature.Row;
                entity.Element     = "Creature";
                entity.Type        = "Other";
                entity.Temperature = creature.TileEntities[1].TileProperty.TemperatureKelvin;
                entity.Units       = 1;
                entity.Storage     = new List <Storage>();
                entity.Rottable    = new Rottable();
                entity.Amounts     = new List <Amount>();
                entity.Amounts.Add(new Amount {
                    Id = "HitPoints", Value = creature.TileEntities[1].TileProperty.HitPoints
                });
                entity.Amounts.Add(new Amount {
                    Id = "Temperature", Value = creature.TileEntities[1].TileProperty.TemperatureKelvin
                });
                entity.Amounts.Add(new Amount {
                    Id = "OldAge"
                });
                entity.Amounts.Add(new Amount {
                    Id = "Fertilization"
                });
                entity.Amounts.Add(new Amount {
                    Id = "Irrigation"
                });
                template.OtherEntities.Add(entity);
            }

            // serialize all the things
            var serializer = new SerializerBuilder()
                             .WithNamingConvention(new CamelCaseNamingConvention())
                             .Build();

            var yaml     = serializer.Serialize(template);
            var filePath = selectedPath;

            File.WriteAllText(filePath, yaml);
            MessageBox.Show($"Saved {template.Name} to {filePath}");
        }
 public void SetReference(OtherEntity value)
 {
     Reference = value;
 }