Exemplo n.º 1
0
        public void CreateTrigger()
        {
            this.Body.CollidesWith        = PhysicistCategory.Player;
            this.Body.CollisionCategories = PhysicistCategory.Physical;

            AABB aabb;

            this.Body.FixtureList[0].GetAABB(out aabb, 0);
            using (Body triggerBody = new Body(this.World))
            {
                Fixture doorFixture = FixtureFactory.AttachRectangle(aabb.Width, aabb.Height, 0, Vector2.Zero, triggerBody);
                this.doorTrigger = new ProximityTrigger(this.Body, doorFixture, this.World);
                this.doorTrigger.Initialize(null);
                this.doorTrigger.IsSensor     = true;
                this.doorTrigger.IsContinuous = true;
                triggerBody.DestroyFixture(doorFixture);

                Fixture layerFixture = FixtureFactory.AttachRectangle(aabb.Width / 7, aabb.Height, 0, Vector2.Zero, triggerBody);
                this.layerTrigger = new ProximityTrigger(this.Body, layerFixture, this.World);
                this.layerTrigger.Initialize(null);
                this.layerTrigger.IsSensor     = true;
                this.layerTrigger.IsContinuous = true;
                triggerBody.DestroyFixture(layerFixture);
            }

            this.Body.FixtureList[0].CollisionCategories = PhysicistCategory.None;
            this.Body.FixtureList[0].CollidesWith        = PhysicistCategory.None;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Checks if the player is within the range of the notorious MagmaBreath()
 /// </summary>
 void CheckPlayerProximity()
 {
     if (ProximityTrigger.GetComponent <Proximity>().playerInRange == true && magmaBreathActive == false)
     {
         MagmaBreath();
     }
 }
Exemplo n.º 3
0
        private void CreateButtons()
        {
            this.Body.CollisionCategories = PhysicistCategory.Player1;
            AABB aabb;

            this.Body.FixtureList[0].GetAABB(out aabb, 0);

            if (this.Position != null)
            {
                using (var headBody = new Body(this.World))
                    using (var footBody = new Body(this.World))
                    {
                        Fixture headButtonFixture = FixtureFactory.AttachRectangle(aabb.Width * 9f / 10f, 1, 0, new Vector2(0, -aabb.Height).ToSimUnits(), headBody);
                        Fixture footButtonFixture = FixtureFactory.AttachRectangle(aabb.Width * 9f / 10f, 1, 0, new Vector2(0, aabb.Height).ToSimUnits(), footBody);

                        this.headButton = new ProximityTrigger(this.Body, headButtonFixture, null);
                        this.headButton.Initialize(null);

                        this.footButton = new ProximityTrigger(this.Body, footButtonFixture, null);
                        this.footButton.Initialize(null);
                    }

                this.Body.BodyType      = BodyType.Dynamic;
                this.Body.FixedRotation = true;

                this.Body.CollidesWith        = PhysicistCategory.Physical;
                this.Body.CollisionCategories = PhysicistCategory.Physical;
            }
        }
Exemplo n.º 4
0
        public void CreateTrigger()
        {
            var shape = this.Body.FixtureList[0].Shape as FarseerPhysics.Collision.Shapes.ChainShape;

            if (shape != null)
            {
                Vector2 svert = shape.Vertices[0];
                for (int i = 1; i < shape.Vertices.Count; i++)
                {
                    if (Math.Abs(shape.Vertices[i].X - svert.X) > this.width)
                    {
                        this.width = (int)Math.Abs(shape.Vertices[i].X - svert.X);
                    }

                    if (Math.Abs(shape.Vertices[i].Y - svert.Y) > this.height)
                    {
                        this.height = (int)Math.Abs(shape.Vertices[i].Y - svert.Y);
                    }
                }
            }

            this.Body.CollidesWith        = PhysicistCategory.Physical;
            this.Body.CollisionCategories = PhysicistCategory.Physical;

            using (var boxBody = new Body(this.World))
            {
                Fixture boxFixture = FixtureFactory.AttachRectangle(this.width, this.height, 0, new Vector2((this.width / 2) + 2, (this.height / 2) + 5), boxBody);
                this.elevatorTrigger = new ProximityTrigger(this.Body, boxFixture, this.World);
                this.elevatorTrigger.Initialize(null);
                this.elevatorTrigger.IsSensor     = true;
                this.elevatorTrigger.IsContinuous = true;
                boxBody.DestroyFixture(boxFixture);
            }
        }
Exemplo n.º 5
0
    public void Start()
    {
        base.Start();

        Follow = GetComponent <Follow>();

        TFE     = GetComponent <TriggerFuseExploder>();
        Trigger = GetComponent <ProximityTrigger>();

        ParticleSystem = GetComponent <ParticleSystem>();

        SetTarget(Player.transform);
    }
Exemplo n.º 6
0
        public int AddProximityTrigger(WPos pos, WDist range, WDist vRange, Action <Actor> onEntry, Action <Actor> onExit)
        {
            var id = nextTriggerId++;
            var t  = new ProximityTrigger(pos, range, vRange, onEntry, onExit);

            proximityTriggers.Add(id, t);

            foreach (var bin in BinsInBox(t.TopLeft, t.BottomRight))
            {
                bin.ProximityTriggers.Add(t);
            }

            return(id);
        }
Exemplo n.º 7
0
        private void CreateButtons()
        {
            AABB aabb;

            this.Body.FixtureList[0].GetAABB(out aabb, 0);

            if (this.Position != null)
            {
                using (var buttonBody = new Body(this.World))
                {
                    buttonBody.CollidesWith        = PhysicistCategory.AllIgnoreFields;
                    buttonBody.CollisionCategories = PhysicistCategory.Enemy1;

                    Fixture rightButtonFixture = FixtureFactory.AttachRectangle(1, aabb.Height * 0.8f, 0, new Vector2(aabb.Width, 0) / 2f, buttonBody);
                    this.rightButton = new ProximityTrigger(this.Body, rightButtonFixture, this.World);
                    this.rightButton.Initialize(null);
                    this.rightButton.IsSensor     = false;
                    this.rightButton.IsContinuous = false;
                    buttonBody.DestroyFixture(rightButtonFixture);

                    Fixture leftButtonFixture = FixtureFactory.AttachRectangle(1, aabb.Height * 0.8f, 0, new Vector2(-aabb.Width, 0) / 2f, buttonBody);
                    this.leftButton = new ProximityTrigger(this.Body, leftButtonFixture, this.World);
                    this.leftButton.Initialize(null);
                    this.leftButton.IsSensor     = false;
                    this.leftButton.IsContinuous = false;
                    buttonBody.DestroyFixture(leftButtonFixture);

                    Fixture topButtonFixture = FixtureFactory.AttachRectangle(aabb.Width * 0.8f, 1, 0, new Vector2(0, -aabb.Height) / 2f, buttonBody);
                    this.topButton = new ProximityTrigger(this.Body, topButtonFixture, this.World);
                    this.topButton.Initialize(null);
                    this.topButton.IsSensor     = false;
                    this.topButton.IsContinuous = false;
                    buttonBody.DestroyFixture(topButtonFixture);

                    Fixture bottomButtonFixture = FixtureFactory.AttachRectangle(aabb.Width * 0.8f, 1, 0, new Vector2(0, aabb.Height) / 2f, buttonBody);
                    this.bottomButton = new ProximityTrigger(this.Body, bottomButtonFixture, this.World);
                    this.bottomButton.Initialize(null);
                    this.bottomButton.IsSensor     = false;
                    this.bottomButton.IsContinuous = false;
                    buttonBody.DestroyFixture(bottomButtonFixture);
                }
            }
        }
Exemplo n.º 8
0
        public int AddProximityTrigger(WPos pos, WRange range, Action<Actor> onEntry, Action<Actor> onExit)
        {
            var id = nextTriggerId++;
            var t = new ProximityTrigger(id, pos, range, onEntry, onExit);
            proximityTriggers.Add(id, t);

            foreach (var bin in BinsInBox(t.TopLeft, t.BottomRight))
                bin.ProximityTriggers.Add(t);

            return id;
        }
Exemplo n.º 9
0
 public override void Start()
 {
     base.Start();
     Trigger = GetComponent <ProximityTrigger>();
 }