Beispiel #1
0
        public override void Process(Entity entity)
        {
            HandComponent     handComponent     = entity.GetComponent <HandComponent>();
            PositionComponent positionComponent = entity.GetComponent <PositionComponent>();

            Vector2 target = handComponent.TargetPosition;

            if (handComponent.HeldTool != null)
            {
                ToolComponent toolComponent = handComponent.HeldTool.GetComponent <ToolComponent>();
                target += toolComponent.PositionFunction(handComponent.Timer);
            }

            Vector2 difference = target - positionComponent.Position;

            positionComponent.Position += difference * 10f * (float)DeltaTime.TotalSeconds;

            if (positionComponent.Depth > handComponent.TargetDepth)
            {
                positionComponent.Depth -= 200f * (float)DeltaTime.TotalSeconds;
                positionComponent.Depth  = Math.Max(positionComponent.Depth, handComponent.TargetDepth);
            }
            else if (positionComponent.Depth < handComponent.TargetDepth)
            {
                positionComponent.Depth += 300f * (float)DeltaTime.TotalSeconds;
                positionComponent.Depth  = Math.Min(positionComponent.Depth, handComponent.TargetDepth);
            }
        }
    public void Grab(HandComponent grabbing)
    {
        grabbedBy = grabbing;
        Transform grabPoint;

        if (grabHandle)
        {
            grabPoint = grabHandle;
        }
        else
        {
            grabPoint = grabbedBy.transform;
        }

        switch (moveMode)
        {
        case 0:
            // attached
            break;

        case 1:
            GrabPhysics(grabPoint);
            break;

        case 2:
            GrabLerp(grabPoint);
            break;

        default:
            break;
        }

        grabbed = true;
        //Debug.Log("Object: " + this.name + " , Grabbed By: " + grabbedBy.name);
    }
    public void Release()
    {
        //Debug.Log("Object: " + this.name + " has called Release()");

        switch (moveMode)
        {
        case 0:
            // attached
            break;

        case 1:
            ReleasePhysics();
            break;

        case 2:
            ReleaseLerp();
            break;

        default:
            break;
        }

        grabbed   = false;
        grabbedBy = null;
        SetMoveMode(1);
    }
    private void Start()
    {
        DeckGO     = FindObjectOfType <DeckComponent> ( );
        HandGO     = FindObjectOfType <HandComponent> ( );
        CardViewGO = FindObjectOfType <CardViewComponent> ( );

        cardController = FindObjectOfType <MasterControllerComponent> ( );
        cardController.SetOwner(this);
    }
Beispiel #5
0
        public override void Process(Entity entity)
        {
            HandComponent     handComponent     = entity.GetComponent <HandComponent>();
            PositionComponent positionComponent = entity.GetComponent <PositionComponent>();

            float shoulderHeight = 32f;

            Vector2 difference = positionComponent.Position - handComponent.Shoulder;
            float   distance   = difference.Length();

            Vector2 elbow       = handComponent.Shoulder + difference / 2f;
            float   elbowHeight = Math.Min((positionComponent.Depth + shoulderHeight) / 2f + 10000f / distance, 100f);

            Vector2 hand = positionComponent.Position + Vector2.Normalize(handComponent.Shoulder - positionComponent.Position) * 18f;

            hand -= new Vector2(0f, 6f);

            _arms.Add(new Arm(handComponent.Shoulder, shoulderHeight,
                              elbow, elbowHeight,
                              hand, positionComponent.Depth));
        }
Beispiel #6
0
        public override void Process(Entity entity)
        {
            HandComponent     handComponent     = entity.GetComponent <HandComponent>();
            PositionComponent positionComponent = entity.GetComponent <PositionComponent>();

            if (handComponent.HeldItem != null)
            {
                ObjectComponent heldObjectComponent = handComponent.HeldItem.GetComponent <ObjectComponent>();
                if (heldObjectComponent != null)
                {
                    heldObjectComponent.IsHeld = true;

                    PositionComponent heldPositionComponent = handComponent.HeldItem.GetComponent <PositionComponent>();
                    heldPositionComponent.Position = positionComponent.Position;
                    heldPositionComponent.Depth    = positionComponent.Depth;
                }
            }
            else if (handComponent.HeldTool != null)
            {
                handComponent.Timer += (float)DeltaTime.TotalSeconds;
            }
        }
Beispiel #7
0
    public void Activate(AttachmentTrigger trigger)
    {
        activated = true;

        if (trigger != null)
        {
            attachedObjectTrigger   = trigger;
            attachedObject          = trigger.GetOwningObject();
            attachedObjectMover     = attachedObject.GetObjectMover();
            attachedObjectGrabbedBy = attachedObjectMover.GetGrabbedBy();
        }

        if (attachedObject != null && attachedObjectMover && attachedObjectGrabbedBy)
        {
            attachedObject.SetBusy(true);
            inlineRot = GetLocalInlineRotation(attachedObjectMover.transform);
            attachedObjectGrabbedBy.Release();
            //attachedObjectMover.SetMoveMode(2);
            //attachedObjectGrabbedBy.Grab(attachedObjectMover);
            moveGuide.SetParent(this.transform);
            moveGuide.SetPositionAndRotation(attachedObjectTrigger.transform.position, attachedObjectTrigger.transform.rotation);
            attachedObject.KillCollision();
            attachedObject.KillPhysics();
            attachedObject.IgnoreCollision(owningObject.GetGameObject().GetComponent <BoxCollider>(), true);
            attachedObjectMover.transform.localRotation = inlineRot;
            //moveObjectOffeset = Vector3.Magnitude(attachedObjectMover.transform.position - attachedObjectGrabbedBy.transform.position);
            attachedObjectMover.transform.SetParent(moveGuide);

            //attachedObjectMover.transform.SetParent(moveGuide);
            tracking = true;
            owningObject.SetBusy(true);
        }
        else
        {
            Deactivate();
        }
    }