Пример #1
0
    void Awake()
    {
        // Connecting everything
        sr = GetComponent <SpriteRenderer>();
        lr = GetComponentInChildren <LineRenderer>();
        lr.sortingLayerName = "AboveEverything";
        triangle            = transform.Find("ArrowEnd");
        triangleSR          = triangle.GetComponent <SpriteRenderer>();

        cardManager    = GetComponentInParent <PlayedCreatureDisplay>();
        whereIsTheCard = GetComponentInParent <WhereIsTheCard>();
    }
Пример #2
0
    // method to create a new creature and add it to the table
    public void AddCreatureAtIndex(CardTemplate ct, int UniqueID, int index)
    {
        // create a new creature from prefab
        GameObject creature = GameObject.Instantiate(GameManager.Instance.PlayedCreaturePrefab, slots.Slots[index].transform.position, Quaternion.identity) as GameObject;

        // apply the look from CardAsset
        PlayedCreatureDisplay manager = creature.GetComponent <PlayedCreatureDisplay>();

        manager.cardTemplate = ct;
        manager.LoadCreature();

        // add tag according to owner
        foreach (Transform t in creature.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Creature";
        }

        // parent a new creature gameObject to table slots
        creature.transform.SetParent(slots.transform);

        // add a new creature to the list
        CreaturesOnTable.Insert(index, creature);

        // let this creature know about its position
        WhereIsTheCard w = creature.GetComponent <WhereIsTheCard>();

        w.Slot = index;
        if (owner == AreaPositions.Bottom)
        {
            w.VisualState = VisualStates.LowTable;
        }
        else
        {
            w.VisualState = VisualStates.TopTable;
        }

        // add our unique ID to this creature
        IDHolder id = creature.AddComponent <IDHolder>();

        id.UniqueID = UniqueID;

        // after a new creature is added update placing of all the other creatures
        ShiftSlotsGameObjectAccordingToNumberOfCreatures();
        PlaceCreaturesOnNewSlots();

        // end command execution
        Action.ActionExecutionComplete();
    }
Пример #3
0
    public void AttackTarget(int targetUniqueID, int damageTakenByTarget, int damageTakenByAttacker, int attackHealthAfter, int targetHealthAfter)
    {
        Debug.Log(targetUniqueID);
        cardManager.CanAttackNow = false;
        GameObject target = IDHolder.GetGameObjectWithID(targetUniqueID);

        // Bring the creature to the front layer
        whereIsTheCard.BringToFront();

        // Store a temp state for later
        VisualStates tempstate = whereIsTheCard.VisualState;

        // Set state to transition
        whereIsTheCard.VisualState = VisualStates.Transition;

        transform.DOMove(target.transform.position, 0.5f).SetLoops(2, LoopType.Yoyo).SetEase(Ease.InCubic).OnComplete(() =>
        {
            // Which player is the target?
            if (targetUniqueID == GameManager.Instance.BottomPlayer.PlayerID)
            {
                // Change players values
                GameManager.Instance.BottomPlayer.Health = targetHealthAfter;
            }
            else if (targetUniqueID == GameManager.Instance.TopPlayer.PlayerID)
            {
                // Change players values
                GameManager.Instance.TopPlayer.Health = targetHealthAfter;
            }
            else
            {
                PlayedCreatureDisplay tempCardTarget = target.GetComponent <PlayedCreatureDisplay>();
                tempCardTarget.HealthText.text       = targetHealthAfter.ToString();
            }
            whereIsTheCard.SetTableSortingOrder();
            // revert back to the original state
            whereIsTheCard.VisualState = tempstate;

            cardManager.HealthText.text = attackHealthAfter.ToString();
            Sequence s = DOTween.Sequence();
            s.AppendInterval(1f);
            s.OnComplete(Action.ActionExecutionComplete);
        });
    }
Пример #4
0
 void Awake()
 {
     // Assigning
     cardManager    = GetComponent <PlayedCreatureDisplay>();
     whereIsTheCard = GetComponent <WhereIsTheCard>();
 }