public static Action getAction(GameObject gameobject, Vector3 dist, float during)
    {
        RotateToAction ac = ScriptableObject.CreateInstance <RotateToAction>();

        ac.targetPos  = dist;
        ac.gameobject = gameobject;
        ac.during     = during;
        return(ac);
    }
예제 #2
0
    public override void ApplyBehaviour()
    {
        if (Vector3.Distance(Owner.transform.position, target.position) < 0.4f)
        {
            return;
        }
        GoToAction newAction = Owner.gameObject.AddComponent <GoToAction>();

        newAction.target           = target;
        newAction.actionPriority   = 20;
        newAction.distanceToTarget = 0.4f;
        Owner.ScheduleNewAction(newAction);
        RotateToAction rotateAction = Owner.gameObject.AddComponent <RotateToAction>();

        rotateAction.target         = -target.rotation.eulerAngles;
        rotateAction.actionPriority = 10;
        Owner.ScheduleNewAction(rotateAction);
        GoToIdleAction newIdleAction = Owner.gameObject.AddComponent <GoToIdleAction>();

        newIdleAction.actionPriority = 0;
        Owner.ScheduleNewAction(newIdleAction);
    }
예제 #3
0
    // Card pos should be 0 - 4
    private void DrawCardTo(int _cardSlotID, CardType _type, CardTier _tier)
    {
        // Replace card sprite with card back.
        mCards[_cardSlotID].ToggleCard(true);
        mCards[_cardSlotID].SetCardDraggable(false);
        mCards[_cardSlotID].CardImage.sprite = CardBackSprite;
        mCards[_cardSlotID].SetCard(_type, _tier);

        // Move the card to slot
        mCardTransforms[_cardSlotID].position = svec3DrawPos;
        mCardTransforms[_cardSlotID].SetAsLastSibling();
        MoveToAction moveToSlot = new MoveToAction(mCardTransforms[_cardSlotID], Graph.InverseExponential, mCards[_cardSlotID].OriginPos, 0.6f);

        moveToSlot.OnActionFinish += () => {
            mCardTransforms[_cardSlotID].SetSiblingIndex(mCards[_cardSlotID].OriginSiblingIndex);
        };

        // Flip the Card
        // 0 to 90, snap -90, -90 to 0
        mCardTransforms[_cardSlotID].localEulerAngles = Vector3.zero;
        RotateToAction rotHide = new RotateToAction(mCardTransforms[_cardSlotID], Graph.Linear, Vector3.up * 90.0f, 0.5f);

        rotHide.OnActionFinish += () => {
            mCardTransforms[_cardSlotID].localEulerAngles = Vector3.up * 270.0f;
            mCards[_cardSlotID].UpdateSprite();
        };
        RotateToAction rotReveal   = new RotateToAction(mCardTransforms[_cardSlotID], Graph.Linear, Vector3.up * 360.0f, 0.5f);
        ActionSequence cardFlipSeq = new ActionSequence(rotHide, rotReveal);

        // Combine all actions here.
        ActionSequence drawCardSeq = new ActionSequence(moveToSlot, cardFlipSeq);

        drawCardSeq.OnActionFinish += () => {
            mCards[_cardSlotID].SetCardDraggable(true);
        };

        ActionHandler.RunAction(drawCardSeq);
    }