Inheritance: MonoBehaviour
 public override void CollidedWith(Entity e)
 {
     base.CollidedWith (e);
     if (e is TerrainEntity && e.Collidable && !(e is PitEntity)) {
         alive = false;
     }
 }
 /// <summary>
 /// Constructs a new constraint which allows relative angular motion around a hinge axis and a twist axis.
 /// </summary>
 /// <param name="connectionA">First connection of the pair.</param>
 /// <param name="connectionB">Second connection of the pair.</param>
 /// <param name="worldHingeAxis">Hinge axis attached to connectionA.
 /// The connected entities will be able to rotate around this axis relative to each other.</param>
 /// <param name="worldTwistAxis">Twist axis attached to connectionB.
 /// The connected entities will be able to rotate around this axis relative to each other.</param>
 public SwivelHingeAngularJoint(Entity connectionA, Entity connectionB, Vector3 worldHingeAxis, Vector3 worldTwistAxis)
 {
     ConnectionA = connectionA;
     ConnectionB = connectionB;
     WorldHingeAxis = worldHingeAxis;
     WorldTwistAxis = worldTwistAxis;
 }
    public override bool OnCollisionSolid(Entity other)
    {
        Debug.Log("In Collision");
        ChatController.Show ("Hello welcome to college, I will be you're advisor");

        return true;
    }
Example #4
0
        /// <summary>
        /// Splits a single compound collidable into two separate compound collidables and computes information needed by the simulation.
        /// </summary>
        /// <param name="childContributions">List of distribution information associated with each child shape of the whole compound shape used by the compound being split.</param>
        /// <param name="splitPredicate">Delegate which determines if a child in the original compound should be moved to the new compound.</param>
        /// <param name="a">Original compound to be split.  Children in this compound will be removed and added to the other compound.</param>
        /// <param name="b">Compound to receive children removed from the original compound.</param>
        /// <param name="distributionInfoA">Volume, volume distribution, and center information about the new form of the original compound collidable.</param>
        /// <param name="distributionInfoB">Volume, volume distribution, and center information about the new compound collidable.</param>
        /// <returns>Whether or not the predicate returned true for any element in the original compound and split the compound.</returns>
        public static bool SplitCompound(IList<ShapeDistributionInformation> childContributions, Func<CompoundChild, bool> splitPredicate,
                        Entity<CompoundCollidable> a, out Entity<CompoundCollidable> b,
                        out ShapeDistributionInformation distributionInfoA, out ShapeDistributionInformation distributionInfoB)
        {
            var bCollidable = new CompoundCollidable { Shape = a.CollisionInformation.Shape };
            b = null;


            float weightA, weightB;
            if (SplitCompound(childContributions, splitPredicate, a.CollisionInformation, bCollidable, out distributionInfoA, out distributionInfoB, out weightA, out weightB))
            {
                //Reconfigure the entities using the data computed in the split.
                float originalMass = a.mass;
                if (a.CollisionInformation.children.Count > 0)
                {
                    float newMassA = (weightA / (weightA + weightB)) * originalMass;
                    Matrix3x3.Multiply(ref distributionInfoA.VolumeDistribution, newMassA * InertiaHelper.InertiaTensorScale, out distributionInfoA.VolumeDistribution);
                    a.Initialize(a.CollisionInformation, newMassA, distributionInfoA.VolumeDistribution, distributionInfoA.Volume);
                }
                if (bCollidable.children.Count > 0)
                {
                    float newMassB = (weightB / (weightA + weightB)) * originalMass;
                    Matrix3x3.Multiply(ref distributionInfoB.VolumeDistribution, newMassB * InertiaHelper.InertiaTensorScale, out distributionInfoB.VolumeDistribution);
                    b = new Entity<CompoundCollidable>();
                    b.Initialize(bCollidable, newMassB, distributionInfoB.VolumeDistribution, distributionInfoB.Volume);
                }

                SplitReposition(a, b, ref distributionInfoA, ref distributionInfoB, weightA, weightB);
                return true;
            }
            else
                return false;
        }
Example #5
0
        /// <summary>
        /// Constructs the query manager for a character.
        /// </summary>
        public QueryManager(Entity characterBody, CharacterContactCategorizer contactCategorizer)
        {
            this.characterBody = characterBody;
            this.contactCategorizer = contactCategorizer;

            SupportRayFilter = SupportRayFilterFunction;
        }
 private WorkitemPropertyDescriptor(Entity entity, string name, string attribute, Attribute[] attrs, PropertyUpdateSource updateSource)
     : base(name, attrs) {
     this.entity = entity;
     this.attribute = attribute;
     this.updateSource = updateSource;
     readOnly = entity.IsPropertyDefinitionReadOnly(Attribute) || entity.IsPropertyReadOnly(Attribute);
 }
		public void Initialize()
		{
			_tokenizer = new Tokenizer();
			_tokenizedBufferEntity = new Entity<LinkedList<Token>>();
			_textBuffer = MockRepository.GenerateStub<ITextBufferAdapter>();
			_finder = new MatchingBraceFinder(_textBuffer, _tokenizedBufferEntity);
		}
 public override void Process(Entity e)
 {
     Health health = healthMapper.Get(e);
     Transform transform = transformMapper.Get(e);
     Vector2 textPosition = new Vector2((float)transform.X + 20, (float)transform.Y - 30);
     spriteBatch.DrawString(font,health.HealthPercentage + "%",textPosition,Color.White);
 }
Example #9
0
 private static void MapAllColumns(MappingSet set, ITable table, Entity entity)
 {
     for(int i = 0; i < table.Columns.Count; i++)
     {
         set.ChangeMappedColumnFor(entity.ConcreteProperties[i]).To(table.Columns[i]);
     }
 }
 public void Before() {
     var pool = Helper.CreatePool();
     _e = pool.CreateEntity();
     _e.AddComponent(CP.ComponentA, new ComponentA());
     _e.AddComponent(CP.ComponentB, new ComponentB());
     _e.AddComponent(CP.ComponentC, new ComponentC());
 }
Example #11
0
        public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
        {
            EntityWorld entityWorld = bullet.Entity.EntityWorld;
            IZombieSpatialMap zombieSpatialMap = entityWorld.Services.Get<IZombieSpatialMap>();

            // if the message has not listeners, then there's no point in doing in broadcasting it.
            RocketExplodedMessage explodedMessage = entityWorld.HasListeners<RocketExplodedMessage>() ? entityWorld.FetchMessage<RocketExplodedMessage>() : null; // AAWFFUUULL!!
            foreach (Entity zombie in zombieSpatialMap.GetAllIntersecting(bullet.Entity.Transform, RocketLauncher.ExplosionRange))
            {
                if (zombie.Get<CHealth>().IsAlive && ZombieHelper.TakeDamage(zombie, 25, Vector2.Zero))
                {
                    // if the message has not listeners, then there's no point in doing in broadcasting it.
                    if (explodedMessage != null)
                    {
                        explodedMessage.Add(zombie);
                    }
                }
            }

            // if the message has not listeners, then there's no point in doing in broadcasting it.
            if (explodedMessage != null)
            {
                entityWorld.BroadcastMessage(explodedMessage);
            }

            IParticleEngine particleEngine = entityWorld.Services.Get<IParticleEngine>();
            particleEngine[ParticleEffectID.RocketExplosion].Trigger(bullet.Entity.Transform);

            bullet.Entity.Delete();
            return true;
        }
        public RecordsSource_EnumEntityFilters()
        {
            DB.EntityChanges.Insert(new
            {
                EntityName = "Entity",
                EntityKey = "1",
                ChangedOn = DateTime.Now,
                ChangeType = EntityChangeType.Insert
            });
            DB.EntityChanges.Insert(new
            {
                EntityName = "Entity",
                EntityKey = "1",
                ChangedOn = DateTime.Now,
                ChangeType = EntityChangeType.Update
            });
            DB.EntityChanges.Insert(new
            {
                EntityName = "Entity",
                EntityKey = "1",
                ChangedOn = DateTime.Now,
                ChangeType = EntityChangeType.Delete
            });

            _source = new RecordsSource(new Notificator());
            Admin.AddEntity<EntityChange>();
            Admin.SetForeignKeysReferences();
            Admin.ConnectionStringName = ConnectionStringName;
            _entity = Admin.ChangeEntity;
            _property = _entity["ChangeType"];
        }
Example #13
0
 public void Add(Entity e, int distance) {
     var v = new Vertebra();
     v.SetEntity(e);
     v.Distance = distance;
     v.Snake = this;
     Add(v);
 }
Example #14
0
        public override bool intersect(Entity e)
        {
            if (base.intersect(e))
            {
                if (e is Player)
                    ((Player)e).die();
                else if (e is Explosion)
                    die();

                return true;
            }

            bool intersect = false;

            for(int a = 0; a < 10; a++)
            {
                if (neck[a] != null)
                {
                    if (neck[a].intersect(e))
                    {
                        neck[a] = null;
                        intersect = true;
                    }
                }
            }

            return intersect;
        }
Example #15
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cooldown;
            if (state == null) cooldown = 1000;
            else cooldown = (int)state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;

            var player = (Player)host.GetNearestEntity(distance, null);
            if (player != null)
            {
                Vector2 vect;
                vect = new Vector2(player.X - host.X, player.Y - host.Y);
                vect.Normalize();
                float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
                host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist);
                host.UpdateCount++;

                if (cooldown <= 0)
                {
                    Status = CycleStatus.Completed;
                    cooldown = 1000;
                }
                else
                {
                    Status = CycleStatus.InProgress;
                    cooldown -= time.thisTickTimes;
                }
            }

            state = cooldown;
        }
Example #16
0
 public override void onCollide(Entity entity, Game1 game)
 {
     if (entity is Enemy)
     {
         health--;
     }
 }
Example #17
0
        public static bool insertPicture(Entity.Picture picture)
        {
            try
            {

                string sqlInsert = @"INSERT INTO Picture(Album_ID,Picture_Name,Picture_Detail,Picture_Path, Picture_Status, Create_date)
                                   VALUES(@albunID,@pictureName,@pictureDetail,@picturePath,'A',GetDate())";
                ConnectDB connpath = new ConnectDB();
                objConn = new SqlConnection();
                objConn.ConnectionString = connpath.connectPath();
                objConn.Open();
                objCmd = new SqlCommand(sqlInsert, objConn);
                objCmd.Parameters.Add("@albunID", SqlDbType.Int).Value = picture.Album_ID;
                objCmd.Parameters.Add("@pictureName", SqlDbType.NVarChar).Value = picture.Picture_Name.ToString();
                objCmd.Parameters.Add("@pictureDetail", SqlDbType.NVarChar).Value = picture.Picture_Detail.ToString();
                objCmd.Parameters.Add("@picturePath", SqlDbType.NVarChar).Value = picture.Picture_Path.ToString();

                objCmd.ExecuteNonQuery();
                objConn.Close();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }


        }
 public override void OnCollideWith(Entity e)
 {
     if (e is PlayerEntity)
     {
         UserInterface.Message("Present Clearance Level (Press E to interact)", Color.Red);
     }
 }
 public void LoadScript(string scriptType, string scriptName, string script, Entity ent)
 {
     if(this.scriptEngines.ContainsKey(scriptType))
     {
         this.scriptEngines[scriptType].LoadScript(script, scriptName, ent.localid);
     }
 }
 public PhysicsSimulationComponent(Entity parent)
     : base(parent, "PhysicsSimulationComponent")
 {
     space = new Space();
     space.ForceUpdater.Gravity = GRAVITY;
     space.TimeStepSettings.TimeStepDuration = TIME_STEP_DURATION;
 }
 public ProposeAttributeChangeEventArgs(Entity entity, string componentName, string attributeName, object value)
 {
     this.entity = entity;
     this.componentName = componentName;
     this.attributeName = attributeName;
     this.value = value;
 }
Example #22
0
        internal void AddEntity(Entity mEntity)
        {
            OrderedEntities.Add(mEntity);
            OrderedEntities.Sort((a, b) => a.Layer.CompareTo(b.Layer));

            Repository.AddEntity(mEntity);
        }
Example #23
0
        public void SpawnEntity(World world, Entity entity)
        {
            entity.Id = nextEntityId++;
            world.Entities.Add(entity);
            // Get nearby clients in the same world
            var clients = GetClientsInWorld(world)
                .Where(c => !c.IsDisconnected && c.Entity.Position.DistanceTo(entity.Position) < (c.ViewDistance * Chunk.Width));
            entity.PropertyChanged += EntityOnPropertyChanged;

            if (clients.Count() != 0)
            {
                // Spawn entity on relevant clients
                if (entity is PlayerEntity)
                {
                    // Isolate the client being spawned
                    var client = clients.First(c => c.Entity == entity);
                    client.Entity.BedStateChanged += EntityOnUpdateBedState;
                    client.Entity.BedTimerExpired += EntityOnBedTimerExpired;
                    clients = clients.Where(c => c.Entity != entity);
                    clients.ToList().ForEach(c => {
                        c.SendPacket(new SpawnNamedEntityPacket(client));
                        c.KnownEntities.Add(client.Entity.Id);
                    });
                }
            }
            server.ProcessSendQueue();
        }
	static public void ShootCircleBullets(Pool pool, Entity e)
	{
		for(int i = 0; i < 12; ++i)
		{
			ShootCircleBullet(pool, e, i, 12);
		}
	}
Example #25
0
        public void Insert_LowFare(Entity.LowFare o_LowFare)
        {
            if (o_LowFare == null)
                return;

            Entity.LowFare e_LowFare = new Entity.LowFare();
            e_LowFare.LowFare_ID = o_LowFare.LowFare_ID;
            e_LowFare.LowFare_Type = o_LowFare.LowFare_Type;
            e_LowFare.LowFare_Detail_ID = o_LowFare.LowFare_Detail_ID;
            e_LowFare.LowFare_Adults = o_LowFare.LowFare_Adults;
            e_LowFare.LowFare_Children = o_LowFare.LowFare_Children;
            e_LowFare.LowFare_Infants = o_LowFare.LowFare_Infants;
            e_LowFare.LowFare_Passengers = FilterUtility.FilterSQL(o_LowFare.LowFare_Passengers);
            e_LowFare.LowFare_Airline = FilterUtility.FilterSQL(o_LowFare.LowFare_Airline);
            e_LowFare.LowFare_Class = FilterUtility.FilterSQL(o_LowFare.LowFare_Class);
            e_LowFare.LowFare_Member_ID = o_LowFare.LowFare_Member_ID;
            e_LowFare.LowFare_AdminUser_ID = o_LowFare.LowFare_AdminUser_ID;
            e_LowFare.LowFare_Status = o_LowFare.LowFare_Status;
            e_LowFare.LowFare_AddTime = o_LowFare.LowFare_AddTime;
            e_LowFare.LowFare_SubmitTime = o_LowFare.LowFare_SubmitTime;

            BLL.LowFare_Detail b_LowFare_Detail = new LowFare_Detail();
            b_LowFare_Detail.Insert_LowFare_Detail(e_LowFare.LowFare_Detail_ID);

            d_LowFare.Insert_LowFare(e_LowFare);
        }
	    public static bool npcAttack(Npc npc, Entity target) {
		    if (npcHasAttack(npc)) {
			    doNpcAttack(npc, target);
			    return true;
		    }
		    return false;
	    }
Example #27
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            WanderStorage storage;
            if (state == null) storage = new WanderStorage();
            else storage = (WanderStorage)state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;

            Status = CycleStatus.InProgress;
            if (storage.RemainingDistance <= 0)
            {
                storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2));
                storage.Direction.Normalize();
                storage.RemainingDistance = period.Next(Random) / 1000f;
                Status = CycleStatus.Completed;
            }
            float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
            host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist);
            host.UpdateCount++;

            storage.RemainingDistance -= dist;

            state = storage;
        }
 public override void OnInteract(Entity e)
 {
     if (e is PlayerEntity)
     {
         if (!opened)
         {
             PlayerEntity p = e as PlayerEntity;
             if (this.level <= p.GetSecurityLevel())
             {
                 opened = true;
                 UserInterface.Message("Inside is a " + itemInside.Name + " (Interact again to take)", Color.SkyBlue);
             }
             else
             {
                 UserInterface.Message("You need to be atleast " + level.name + " to use this chest", Color.Red);
             }
         }
         else
         {
             if (itemInside != null)
             {
                 PlayerEntity p = e as PlayerEntity;
                 bool success = p.PickUpItem(itemInside);
                 if (success)
                 {
                     UserInterface.Message("Took " + itemInside.Name, Color.SkyBlue);
                     itemInside = null;
                 }
             }
             else UserInterface.Message("The chest is Empty!", Color.Red);
         }
     }
 }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cool = (int) state;

            if (cool <= 0)
            {
                if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) return;

                Position target = new Position
                {
                    X = host.X + (float) (range*Math.Cos(angle.Value)),
                    Y = host.Y + (float) (range*Math.Sin(angle.Value)),
                };
                host.Owner.Timers.Add(new WorldTimer(0, (world, t) =>
                {
                    Entity entity = Entity.Resolve(world.Manager, child);
                    entity.Move(target.X, target.Y);
                    (entity as Enemy).Terrain = (host as Enemy).Terrain;
                    world.EnterWorld(entity);
                }));
                cool = coolDown.Next(Random);
            }
            else
                cool -= time.thisTickTimes;

            state = cool;
        }
Example #30
0
        //-----------------------------------------------------------------------------
        // Ledge Passing
        //-----------------------------------------------------------------------------
        // Update ledge passing, handling changes in altitude.
        public void CheckLedges(Entity entity)
        {
            if (!entity.Physics.PassOverLedges)
                return;

            Point2I prevLocation = entity.RoomControl.GetTileLocation(entity.PreviousPosition + entity.Physics.CollisionBox.Center);
            Point2I location = entity.RoomControl.GetTileLocation(entity.Position + entity.Physics.CollisionBox.Center);

            // When moving over a new tile, check its ledge state.
            if (location != prevLocation) {
                entity.Physics.LedgeTileLocation = new Point2I(-1, -1);

                if (entity.RoomControl.IsTileInBounds(location)) {
                    Tile tile = entity.RoomControl.GetTopTile(location);

                    if (tile != null && tile.IsLedge) {
                        entity.Physics.LedgeTileLocation = location;
                        // Adjust ledge altitude.
                        if (IsMovingUpLedge(entity, tile))
                            entity.Physics.LedgeAltitude--;
                        else if (IsMovingDownLedge(entity, tile))
                            entity.Physics.LedgeAltitude++;
                    }
                }
            }
        }