Example #1
0
        private Entity BulletBase(int mX, int mY, float mDegrees, int mSpeed, string mTextureName, bool mEnemy)
        {
            var result = new Entity(_manager);

            var cBody = Body(new SSVector2I(mX, mY), 250, 250);
            var cMovement = Movement(cBody);
            var cRender = Render(cBody, mTextureName);

            cBody.Body.AddGroupsToCheck(Groups.Obstacle, Groups.Character);
            cBody.Body.AddGroupsToIgnoreResolve(Groups.Obstacle, Groups.Character);
            cBody.OnCollision += (mCollisionInfo) =>
                                 {
                                     var entity = (Entity) mCollisionInfo.UserData;
                                     var cHealth = entity.GetComponent<CHealth>();

                                     if (entity.HasTag(Tags.DamagedByAny))
                                     {
                                         cHealth.Health--;
                                         result.Destroy();
                                     }
                                     else if (result.HasTag(Tags.BulletFriendly) &&
                                              entity.HasTag(Tags.DamagedByFriendly))
                                     {
                                         cHealth.Health--;
                                         result.Destroy();
                                     }
                                     else if (result.HasTag(Tags.BulletEnemy) &&
                                              entity.HasTag(Tags.DamagedByEnemy))
                                     {
                                         cHealth.Health--;
                                         result.Destroy();
                                     }

                                     if (entity.HasTag(Tags.DestroysBullets)) result.Destroy();
                                 };

            cMovement.Angle = mDegrees;
            cMovement.Speed = mSpeed;

            cRender.Torque = 8;

            result.AddComponents(cBody, cMovement, cRender);
            result.AddTags(Tags.Bullet);

            return result;
        }
Example #2
0
 public static void Kill(Entity mEntity)
 {
     mEntity.Destroy();
     TDLSounds.Play("SoundKill1");
 }
Example #3
0
        private Entity SporeBase(int mX, int mY, float mDegrees, int mSpeed, string mTextureName, bool mEnemy)
        {
            var result = new Entity(_manager);

            var cBody = Body(new SSVector2I(mX, mY), 250, 250);
            var cMovement = Movement(cBody);
            var cRender = Render(cBody, mTextureName);

            cBody.Body.AddGroupsToCheck(Groups.Obstacle, Groups.Character);
            cBody.Body.AddGroupsToIgnoreResolve(Groups.Obstacle, Groups.Character);
            cBody.OnCollision += (mCollisionInfo) =>
                                 {
                                     var entity = (Entity)mCollisionInfo.UserData;

                                     var cHealth = entity.GetComponent<CHealth>();

                                     if (result.HasTag(Tags.SporeBlack) && entity.HasTag(Tags.DamagedByWhite))
                                     {
                                         cHealth++;
                                         result.Destroy();
                                     }
                                     else if (result.HasTag(Tags.SporeWhite) && entity.HasTag(Tags.DamagedByBlack))
                                     {
                                         cHealth++;
                                         result.Destroy();
                                     }

                                     if (entity.HasTag(Tags.DestroysBullets)) result.Destroy();
                                 };

            cMovement.Angle = mDegrees;
            cMovement.Speed = mSpeed;
            cMovement.Acceleration = -0.1f;

            cRender.Torque = 8;

            result.AddComponents(cBody, cMovement, cRender);
            result.AddTags(Tags.Spore);

            cRender.Sprite.Color = new Color(255, 255, 255, 125);

            return result;
        }