void IDirectionSwitch.Switch(Entity.Entity entity, Random rnd)
            {
                //basic bounce behavior : at the end of the path, just turn around and move in the opposite direction
                switch (entity.Movement.Direction)
                {
                case StartDirection.Left:
                    entity.Movement.Direction = StartDirection.Right;
                    break;

                case StartDirection.Top:
                    entity.Movement.Direction = StartDirection.Bottom;
                    break;

                case StartDirection.Right:
                    entity.Movement.Direction = StartDirection.Left;
                    break;

                case StartDirection.Bottom:
                    entity.Movement.Direction = StartDirection.Top;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
Ejemplo n.º 2
0
        private Entity.Entity[] search(string searchPhrase, TYPE type)
        {

            string scheme = "http://amp.fm/";

            Entity.Entity[] entityList = new Entity.Entity[] {
                new Entity.Entity{ Label = searchPhrase, Term = "search", Scheme = scheme},
                new Entity.Entity{ Label = "Pearl Jam", Term = "pearljam", Scheme = scheme},
                new Entity.Entity{ Label = "FooBar Fighters", Term = "foobarfighters", Scheme = scheme},
                new Entity.Entity{ Label = "Elliotte Smith", Term = "elliottesmith", Scheme = scheme},
            };

            switch (type)
            {
                case TYPE.ARTIST:
                    return entityList;
                    break;
                case TYPE.GENRE:
                    return entityList;
                    break;
                case TYPE.LYRICS:
                    return entityList;
                    break;
                case TYPE.TITLE:
                    return entityList;
                    break;
                default:
                    return entityList;
                    break;
            }
        }
Ejemplo n.º 3
0
        override public Boolean Load(Int64 forId)
        {
            StringBuilder selectStatement = new StringBuilder();

            System.Data.DataTable tableInsurer;

            if (base.application.EnvironmentDatabase == null)
            {
                return(false);
            }

            selectStatement.Append("EXEC dal.Insurer_Select " + forId.ToString());

            tableInsurer = base.application.EnvironmentDatabase.SelectDataTable(selectStatement.ToString());

            if (tableInsurer.Rows.Count == 1)
            {
                MapDataFields(tableInsurer.Rows[0]);

                entity = new Entity.Entity(base.application, entityId);

                return(true);
            }

            else
            {
                return(false);
            }
        }
        public void Interact(Entity.Entity entitySource, Entity.Entity entityTarget, Random random)
        {
            lock (_interLock)
            {
                //do not interact if both already interacting
                if (entitySource.State == EntityState.Talking && entityTarget.State == EntityState.Talking)
                {
                    return;
                }

                //do not interact if social latency is not elapsed
                if (entitySource.Social.CurrentSocialLatency < entitySource.Social.SocialLatencyThreshold || entityTarget.Social.CurrentSocialLatency < entityTarget.Social.SocialLatencyThreshold)
                {
                    return;
                }

                float interactProbability  = entitySource.Social.NeedForSociability * entityTarget.Social.Charisma;
                float interactionIntensity = (float)(interactProbability - random.NextDouble());
                bool  willInteract         = interactionIntensity > 0;
                _logger.Log($"Entity {entitySource.Id} & Entity {entityTarget.Id} will interact = {willInteract}");
                if (willInteract)
                {
                    _logger.Log($"Entity {entitySource.Id} & Entity {entityTarget.Id} interact intensity = {interactionIntensity}");
                    entitySource.State = entityTarget.State = EntityState.Talking;

                    entitySource.RegisterCurrentMovement();
                    entityTarget.RegisterCurrentMovement();
                    entitySource.MovementType = entityTarget.MovementType = MovementType.Stopped;
                    Interaction i = new Interaction(entitySource, entityTarget, interactionIntensity);
                    _interactions.Add(i.InteractionId, i);
                    i.InteractionEnded += EndInteraction;
                    _logger.Log($"Entity {entitySource.Id} & Entity {entityTarget.Id} are interacting");
                }
            }
        }
        /// <summary>
        /// changes vector to to a cell point
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Point PositionToCell(Entity.Entity entity)
        {
            int cellX = (int)(entity.GetEntityPosition().X / (partitionSize * ((partitionSize * partitionSize) * 8)) / partitionSize);
            int cellY = (int)(entity.GetEntityPosition().Y / (partitionSize * ((partitionSize * partitionSize) * 8)) / partitionSize);

            return(new Point(cellX, cellY));
        }
Ejemplo n.º 6
0
        public void Kill(Entity.Entity food, PositionComponent sourcePosition)
        {
            world.eatingSystem.CreateFrom(food.gameObject, food.position, sourcePosition);

            world.entitySystem.RemoveEntity(food);
            world.entitySystem.AddRandomEntity();
        }
 /// <summary>
 /// Adds a dynamic entity to the proper cell
 /// </summary>
 /// <param name="entity"></param>
 public void AddEntity(Entity.Entity entity)
 {
     entity.SetPartitionCell(PositionToCell(entity).X, PositionToCell(entity).Y);
     entity.SetCellIndex(PositionToIndex(entity));
     dynamicCells[PositionToIndex(entity)].AddEntity(entity);
     //Console.WriteLine("Added dynamic entity of type " + entity.GetType());
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates the ray
        /// </summary>
        /// <param name="entity">entity making the ray</param>
        /// <param name="distance">max distance</param>
        /// <param name="step">incremental checks</param>
        /// <returns></returns>
        public bool MakeRay(Entity.Entity entity, int distance, int step = 5)
        {
            points = new List <Point>();
            float cosX = (float)(Math.Cos(Microsoft.Xna.Framework.MathHelper.ToRadians(angle)));
            float cosY = (float)(Math.Sin(Microsoft.Xna.Framework.MathHelper.ToRadians(angle)));

            for (int i = 0; i < distance; i += step)
            {
                int x = (int)(cosX * i) + (int)entity.position.X;
                int y = (int)(cosY * i) + (int)entity.position.Y;

                Point rayPoint = new Point(x, y);

                rayP1 = rayPoint;

                rayEvent.parameters["Ray"] = rayPoint;

                points.Add(rayPoint);
                //Game1.world.FireGlobal()
                if (Game1.world.FireGlobalEvent(rayEvent, entity))
                {
                    //Console.WriteLine("hit " + rayPoint  + " "+ Game1.world.FireGlobalEvent(rayEvent, entity));
                    hit = rayPoint;
                    return(true);
                }
            }
            //Console.WriteLine("didnt hit " + false);
            return(false);
        }
Ejemplo n.º 9
0
        public bool Insert(Vector3 point, Entity.Entity entity)
        {
            if (Entities.Count < Capacity)
            {
                if (Rectangle.Contains(point))
                {
                    Entities.Add(entity);
                    entity.ParentQuadTree = this;
                    return(true);
                }
            }
            else
            {
                if (!divided)
                {
                    Subdivide();
                }
                if (_topLeft.Insert(point, entity) || _topRight.Insert(point, entity) ||
                    _bottomLeft.Insert(point, entity) || _bottomRight.Insert(point, entity))
                {
                    return(true);
                }
            }

            return(false);
        }
            public void AddEntity(Entity.Entity entity)
            {
                if (members != null)
                {
                    //members.Add(entity);
                    int x = ((int)entity.position.X % (16 * 128)) / 128;
                    int y = ((int)entity.position.Y % (16 * 128)) / 128;

                    members[x, y] = entity;
                }
                else
                {
                    members = new Entity.Entity[16, 16];
                    for (int y = 0; y < members.GetLength(1); y++)
                    {
                        for (int x = 0; x < members.GetLength(0); x++)
                        {
                            members[x, y] = new Entity.Entity();
                        }
                    }
                    x = entity.cellX;
                    y = entity.cellY;
                    AddEntity(entity);
                }
            }
Ejemplo n.º 11
0
 public Collider(Entity.Entity attachee) : base(attachee)
 {
     rb    = attachee.FindComponent <Main.Component.Physics.RigidBodies.Rigidbody>();
     hasRB = rb != null;
     Main.Systems.ColiderSystem.CS.colliders.Add(this);
     Main.Rendering.Renderer.VDs.Add(this);
 }
Ejemplo n.º 12
0
 private void button1_Click(object sender, EventArgs e)
 {
     mainForm.dbv.dgv.DataSource = null;
     bool m_check;
     Control.Control control = new Control.Control();
     Entity.Entity entity = new Entity.Entity();
     entity.setM_Username(this.textBox1.Text);
     entity.setM_Password(this.textBox2.Text);
     m_check = control.checkM_Users(entity.getM_Username(), entity.getM_Password());
     
     if (m_check)
     {
         
         this.Visible = false;
         mainForm main = new mainForm();
         main.ShowDialog();
         this.Close();
     }
     else
     {
         this.textBox1.Text = "";
         this.textBox2.Text = "";
         MessageBox.Show("密码错误或管理员不存在");
     }
      
 }
Ejemplo n.º 13
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lstwProducts.SelectedItems)
            {
                pro = item.Tag as Entity.Products;
            }
            pro.ProductName  = txtProductName.Text;
            pro.UnitPrice    = nudUnitPrice.Value;
            pro.UnitsInStock = int.Parse(nudUnitsInStock.Value.ToString());
            pro.id           = pro.id;

            Entity.Categories seciliCat = cbCategori.SelectedItem as Entity.Categories;
            pro.CategoryID = seciliCat.id;

            Entity.Suppliers seciliSup = cbSupplier.SelectedItem as Entity.Suppliers;
            pro.SupplierID = seciliSup.id;

            int result = proDAL.Update(pro);

            MessageBox.Show(result.ToString() + " satır etkilendi.");
            pro.ListViewDoldur(lstwProducts);
            Entity.Entity en = new Entity.Entity();
            en.Temizle(groupBox1);
            en.Temizle(groupBox2);
        }
Ejemplo n.º 14
0
 public void RemoveEntity(Entity.Entity entity)
 {
     if (Entities.Contains(entity))
     {
         Entities.Remove(entity);
     }
 }
        public Vector2 InitiateDirectionGoal(Entity.Entity entity, GlobalSimulationParameters parameters)
        {
            Vector2 end;

            switch (entity.Movement.Direction)
            {
            case StartDirection.Left:
                //move left = goal is the left border of surface, keeping top position constant
                end = new Vector2(0, entity.Position.Y);
                break;

            case StartDirection.Top:
                //move top = goal is the top border of surface, keeping left position constant
                end = new Vector2(entity.Position.X, 0);
                break;

            case StartDirection.Right:
                //move right = goal is the right border of surface, keeping top position constant
                end = new Vector2(parameters.SurfaceWidth - entity.SelfSize, entity.Position.Y);
                break;

            case StartDirection.Bottom:
                //move bottom = goal is the bottom border of surface, keeping left position constant
                end = new Vector2(entity.Position.X, parameters.SurfaceHeight - entity.SelfSize);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            _logger.Log($"Basic goal :{end}");
            _logger.Log($"Starting to move in straight line");
            return(end);
        }
Ejemplo n.º 16
0
 public Transform2D(Vector2 pos, float scale, Entity.Entity attachee, float rot = 0)
     : base(attachee)
 {
     this.position  = pos;
     this.scale     = scale;
     this.rotationZ = rot;
 }
Ejemplo n.º 17
0
 public PathingChase(Game game, Entity.Entity parent, Entity.Entity entityToChase, float speed,bool alwaysChase = false)
     : base(game, parent)
 {
     this.speed = speed;
     chasing = entityToChase;
     this.alwaysChase = alwaysChase;
 }
Ejemplo n.º 18
0
 public void Update(Entity.Entity entity)
 {
     foreach (var entityBehavior in _behaviors.Select(b => b()))
     {
         entityBehavior.Behave(entity, _simParams, _rnd);
     }
 }
Ejemplo n.º 19
0
 public void AddEntity(Entity.Entity entity)
 {
     Entity.Entity tempEntity = entity;
     tempEntity.components.Remove(entity.GetComponent("PhysicsComponent"));
     Console.WriteLine(entity.GetComponent("PhysicsComponent"));
     tempEntity.AddComponent(new PhysicsComponent());
     dynamicCellSpacePartition.AddEntity(entity);
 }
Ejemplo n.º 20
0
 public void Render(Graphics g)
 {
     for (int i = 0; i < entitiesList.Count; i++)
     {
         Entity.Entity tempEntity = entitiesList[i];
         tempEntity.Render(g);
     }
 }
Ejemplo n.º 21
0
 public override void execute(Entity.Entity executer, int x, int y)
 {
     if (executer is Entity.Player)
     {
         executer.setLocation(new Location(executer.World, this.x * GFX.Tile.STANDARD_GTILE_WIDTH, this.y * GFX.Tile.STANDARD_GTILE_HEIGHT));
         executer.World.WorldCamera.Update(new Microsoft.Xna.Framework.GameTime());
     }
 }
Ejemplo n.º 22
0
        public Member(Application applicationReference)
        {
            BaseConstructor(applicationReference);

            entity = null;

            return;
        }
Ejemplo n.º 23
0
        public Provider(Application applicationReference)
        {
            BaseConstructor(applicationReference);

            entity = new Entity.Entity(application);

            return;
        }
Ejemplo n.º 24
0
        public Insurer(Application applicationReference)
        {
            BaseConstructor(applicationReference);

            entity = new Entity.Entity(base.application);

            return;
        }
Ejemplo n.º 25
0
 public void Update()
 {
     for (int i = 0; i < entitiesList.Count; i++)
     {
         Entity.Entity tempEntity = entitiesList[i];
         tempEntity.Update();
     }
 }
 /// <summary>
 /// adds entity to the list of entity types
 /// </summary>
 /// <param name="entity"></param>
 public static void AddEntityType(Entity.Entity entity)
 {
     // adds this entity type to the list of entity types
     if (!EntityTypes.ContainsKey(entity.GetType().UnderlyingSystemType))
     {
         EntityTypes.Add(entity.GetType().UnderlyingSystemType, entity.EntityData);
     }
 }
Ejemplo n.º 27
0
 public override void execute()
 {
     if (spawnedEntity == null || spawnedEntity.Destroyed)
     {
         spawnedEntity = world.EntityManager.createEntity(id);
         spawnedEntity.setLocation(new Location(world, x * GFX.Tile.STANDARD_GTILE_WIDTH, y * GFX.Tile.STANDARD_GTILE_HEIGHT));
     }
 }
Ejemplo n.º 28
0
 public Sprite(Texture2D txt, Entity.Entity attachee, int index = 0)
     : base(attachee)
 {
     texture    = txt;
     _hastxt    = true;
     layerIndex = index;
     Main.Rendering.Renderer.sprites.Add(this);
 }
Ejemplo n.º 29
0
 public override void execute(Entity.Entity executer, int x, int y)
 {
     if (executer is Entity.IEntityAI)
     {
         Entity.IEntityAI iai = (Entity.IEntityAI)executer;
         iai.AI.notify(AI.AICommunicationSymbols.AI_STOP, false);
     }
 }
Ejemplo n.º 30
0
        public void AddEntity(Entity.Entity entity)
        {
            if (entity.Health <= 0)
            {
                return;
            }

            _entityBuffer.Add(entity);
        }
Ejemplo n.º 31
0
        public CheckpointContainer(Checkpoint checkpoint_, Entity.Entity entity_)
        {
            // CheckpointContainer constructor
            // ================

            m_checkpoint = checkpoint_;
            m_entity     = entity_;
            m_entity.GetBody().IsSensor = true;
        }
Ejemplo n.º 32
0
        public INetworkingEntity Create(ulong id, IEntityStreamer entityStreamer, Entity.Entity streamedEntity,
                                        StreamingType streamingType = StreamingType.Default)
        {
            streamedEntity.Id = id;
            var entity = factory.Create(entityStreamer, streamedEntity, streamingType);

            Add(entity);
            return(entity);
        }
Ejemplo n.º 33
0
 public PathingEvade(Game game, Entity.Entity parent, Entity.Entity entityToWanderAround, float speed)
     : base(game, parent)
 {
     Spatial sp = getComponent<Spatial>();
     heading = Vector3.Transform(sp.focus - sp.position,Matrix.CreateFromAxisAngle(new Vector3(rand(),rand(),rand()),rand(-10,10)/10.0f));
     heading = Vector3.Normalize(heading);
     this.speed = speed;
     target = entityToWanderAround;
 }
        public void ComputeCollision(Entity.Entity entity, List <Entity.Entity> copy)
        {
            var collidingOthers =
                copy.Where(c => c != entity)
                .Where(o => Collide(entity.PersonalSpace.Bound, o.PersonalSpace.Bound))
                .ToList();

            entity.CollidingEntities = collidingOthers;
        }
Ejemplo n.º 35
0
        private Entity.Entity[] search ( string regularExpression ) {
            string scheme = "http://amp.fm/";
            Entity.Entity[] entityArray = new Entity.Entity[] {
                new Entity.Entity{ Label = "SeaFair", Term = "seafair", Scheme = scheme},
                new Entity.Entity{ Label = "Seattle", Term = "seattle", Scheme = scheme},
                new Entity.Entity{ Label = "PSeattle Symphony", Term = "seattlesymphony", Scheme = scheme},
            };

            return entityArray;
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            currentScene = new Scene.Scene("level1", this);
            var tester = new Entity.Entity("tester", new Vector2(0f,0f));
            var uselessComponent = new Component.Component();
            tester.Add(uselessComponent);
            currentScene.Add(tester);

            //currentScene.Add(level);

            base.Initialize();
        }
Ejemplo n.º 37
0
 public PathingWander(Game game, Entity.Entity parent, Entity.Entity entityToWanderAround, float speed)
     : base(game, parent)
 {
     this.speed = speed;
     target = entityToWanderAround;
 }
Ejemplo n.º 38
0
 //constructor
 public QuestItem(string name, Entity.Entity entity = null)
 {
     this.name = name;
     this.entity = entity;
 }