Beispiel #1
0
    void Grab()
    {
        if (!target)
        {
            return;
        }
        Grippable grippable = target.GetComponentInParent <Grippable>();

        if (!grippable)
        {
            return;
        }
        rayGrabber.transform.position = targetPoint;
        rayGrabber.GrabObject(grippable);
    }
Beispiel #2
0
    void Grab()
    {
        if (!sender.CurrTargetData.hitting)
        {
            return;
        }
        //Grippable grippable = sender.CurrTargetData.target.GetComponentInParent<Grippable>();
        Grippable grippable = sender.CurrTargetData.target.GetComponent <Grippable>();

        if (!grippable)
        {
            return;
        }
        rayGrabber.transform.position = sender.TargetPoint;
        rayGrabber.GrabObject(grippable);
    }
Beispiel #3
0
    public void AddGrippable(Grippable g)
    {
        switch (g.priority)
        {
        case Grippable.PRIORITY.LOW:
            gripOptionsLow.Add(g);
            break;

        case Grippable.PRIORITY.MEDIUM:
            gripOptionsMedium.Add(g);
            break;

        case Grippable.PRIORITY.HIGH:
            gripOptionsHigh.Add(g);
            break;
        }
    }
Beispiel #4
0
    public void RemoveGrippable(Grippable g)
    {
        switch (g.priority)
        {
        case Grippable.PRIORITY.LOW:
            gripOptionsLow.Remove(g);
            DropObject(g);
            break;

        case Grippable.PRIORITY.MEDIUM:
            gripOptionsMedium.Remove(g);
            DropObject(g);
            break;

        case Grippable.PRIORITY.HIGH:
            gripOptionsHigh.Remove(g);
            DropObject(g);
            break;
        }
    }
Beispiel #5
0
        private void UpdateGrip()
        {
            if (Gripping == GripState.SHOULD_GRIP && Range.WithinRange)
            {
                var shapeInRange = Range.ShapesWithinRange
                                   .FirstOrDefault(s => s.Parent.GameObj.GetComponent <Grippable>() != null);
                if (shapeInRange != null)
                {
                    gripped = shapeInRange.Parent.GameObj.GetComponent <Grippable>();
                    if (gripped != null)
                    {
                        Gripping             = GripState.GRIPPING;
                        Body.LinearVelocity  = new Vector2();
                        Body.AngularVelocity = 0;
                        //Body.BodyType = BodyType.Kinematic;

                        Rect grabbedShape = gripped.RectangularBody.LoopShape.AABB;
                        Rect soldierShape = Soldier.Shape.AABB;
                        int  side         = gripped.FindSide(GameObj.Transform, Soldier.Shape);

                        if ((side & Grippable.IN) > 0)
                        {
                            topLimit    = gripped.GameObj.Transform.Pos.Y - grabbedShape.H / 2 + soldierShape.H / 2;
                            bottomLimit = gripped.GameObj.Transform.Pos.Y + grabbedShape.H / 2 - soldierShape.H / 2;
                            leftLimit   = gripped.GameObj.Transform.Pos.X - grabbedShape.W / 2 + soldierShape.W / 2;
                            rightLimit  = gripped.GameObj.Transform.Pos.X + grabbedShape.W / 2 - soldierShape.W / 2;
                        }
                        else if ((side & Grippable.OUT) > 0)
                        {
                            topLimit    = gripped.GameObj.Transform.Pos.Y - grabbedShape.H / 2 - soldierShape.H / 2;
                            bottomLimit = gripped.GameObj.Transform.Pos.Y + grabbedShape.H / 2 + soldierShape.H / 2;
                            leftLimit   = gripped.GameObj.Transform.Pos.X - grabbedShape.W / 2 - soldierShape.W / 2;
                            rightLimit  = gripped.GameObj.Transform.Pos.X + grabbedShape.W / 2 + soldierShape.W / 2;
                        }
                    }
                }
            }
        }
Beispiel #6
0
 protected void DropObject(Grippable g, ControllerComponentArgs e)
 {
     g.ReleaseController(this, e);
     grabbed.Remove(g);
 }
Beispiel #7
0
 public void DropObject(Grippable g)
 {
     DropObject(g, dummyArgs);
 }
Beispiel #8
0
 public void GrabObject(Grippable g)
 {
     GrabObject(g, dummyArgs);
 }
Beispiel #9
0
 protected void GrabObject(Grippable g, ControllerComponentArgs e)
 {
     g.RegisterController(this, e);
     grabbed.Add(g);
 }