コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (!GameData.isEnd)
        {
            if (Time.time - lastUseCardTime > useCardDelay)
            {
                Card[] cardArr = GameData.cardArr;

                Card selectedCard = cardArr[Random.Range(0, cardArr.Length)];
                if (selectedCard is SpellCard)
                {
                    selectedCard.Active(GameData.player[(int)Team.TEAM_ENEMY]
                                        , new Vector2(GameData.playerRect.xMin + Random.Range(0, GameData.playerRect.width), GameData.playerRect.yMin + Random.Range(0, GameData.playerRect.height)));
                }
                else if (selectedCard is SpawnCard)
                {
                    selectedCard.Active(GameData.player[(int)Team.TEAM_ENEMY]
                                        , new Vector2(GameData.enemyRect.xMin + Random.Range(0, GameData.enemyRect.width), GameData.enemyRect.yMin + Random.Range(0, GameData.enemyRect.height)));
                }
                lastUseCardTime = Time.time;
            }
        }
    }
コード例 #2
0
    public void UseCard(int index)
    {
        Card card = uiCardList[index].card;

        card.cardGuide.Disable();
        ObjectPoolManager.GetObjectPool(uiCardPrefab).PushItem(uiCardList[index].gameObject);
        uiCardList.RemoveAt(index);
        card.Active(GameData.player[(int)Team.TEAM_PLAYER], CameraUtil.GetMouseWorldPosition(Camera.main));

        for (int i = index; i < uiCardList.Count; i++)
        {
            Rect newCardRect = GetCardPosition(i);
            CoroutineManager.RegisterCoroutine(AnimationUtil
                                               .MoveAnimationCoroutine(uiCardList[i].gameObject, uiCardList[i].gameObject.transform.localPosition, newCardRect.center, 0.5f));
            uiCardList[i].index = i;
        }

        GameData.player[(int)Team.TEAM_PLAYER].RemoveCardInHand(index);
    }