Esempio n. 1
0
    IEnumerator DoReturn()
    {
        enemy.ReturnCardSet();
        yield return(new WaitForSeconds(1f));

        UIManager.instance.SettingText(false);
        Debug.Log("ReturnCardP " + returnPlayerCards.Count);
        Debug.Log("ReturnCardE " + returnEnemyCards.Count);
        if (RandomSelecter.m_isMyTurn)
        {
            RandomSelecter.RandomActive();
            bool[] ran = { RandomSelecter.GetRandomValue(0), RandomSelecter.GetRandomValue(1), RandomSelecter.GetRandomValue(2),
                           RandomSelecter.GetRandomValue(3), RandomSelecter.GetRandomValue(4) };
            GameClient.instance.SendRandInfo(ran);
        }
        for (int i = 0; i < returnCount; i++)
        {
            int playerFieldNum = 6;
            int enemyFieldNum  = 6;

            returnPlayerCards.Sort(new CardTurnSort());
            returnEnemyCards.Sort(new CardTurnSort());
            if (returnPlayerCards.Count != 0)
            {
                playerFieldNum = returnPlayerCards[0].GetComponent <Card>().FieldNumber;
            }
            if (returnEnemyCards.Count != 0)
            {
                enemyFieldNum = returnEnemyCards[0].GetComponent <Card>().FieldNumber;
            }
            if (playerFieldNum < enemyFieldNum)
            {
                returnPlayerCards[0].GetComponent <Card>().ChangePosition(new InHand());
                returnPlayerCards[0].GetComponent <Card>().FieldNumber = 0;
                returnPlayerCards[0].GetComponent <Card>().Heal(true, 0);
                returnPlayerCards.RemoveAt(0);
            }
            else if (playerFieldNum > enemyFieldNum)
            {
                returnEnemyCards[0].GetComponent <Card>().ChangePosition(new InHand());
                returnEnemyCards[0].GetComponent <Card>().FieldNumber = 0;
                returnEnemyCards[0].GetComponent <Card>().Heal(true, 0);
                returnEnemyCards.RemoveAt(0);
            }
            else
            {
                if (RandomSelecter.GetRandomValue_n())
                {
                    returnPlayerCards[0].GetComponent <Card>().ChangePosition(new InHand());
                    returnPlayerCards[0].GetComponent <Card>().FieldNumber = 0;
                    returnPlayerCards[0].GetComponent <Card>().Heal(true, 0);
                    returnPlayerCards.RemoveAt(0);
                }
                else
                {
                    returnEnemyCards[0].GetComponent <Card>().ChangePosition(new InHand());
                    returnEnemyCards[0].GetComponent <Card>().FieldNumber = 0;
                    returnEnemyCards[0].GetComponent <Card>().Heal(true, 0);
                    returnEnemyCards.RemoveAt(0);
                }
            }
            yield return(new WaitForSeconds(turnDelay));
        }
        player.LockAction();
        returnPlayerCards.Clear();
        returnEnemyCards.Clear();
        returnCount = 0;
        stateMachine.ChangeState(new SummonLogic());
    }
Esempio n. 2
0
    IEnumerator TurnStart()
    {
        BattleNum = 0;
        int playerFieldNum = 6;
        int enemyFieldNum  = 6;

        player.m_mana++;
        turnText.text = presentTurn.ToString();
        GameObject.Find("TurnImage").GetComponent <TurnRound>().TurnEnd();
        if (RandomSelecter.m_isMyTurn)
        {
            RandomSelecter.RandomActive();
            bool[] ran = { RandomSelecter.GetRandomValue(0), RandomSelecter.GetRandomValue(1), RandomSelecter.GetRandomValue(2),
                           RandomSelecter.GetRandomValue(3), RandomSelecter.GetRandomValue(4) };
            GameClient.instance.SendRandInfo(ran);
        }
        yield return(new WaitForSeconds(0.5f));

        foreach (GameObject card in player.cards)
        {
            card.GetComponent <Card>().TurnStart();
        }
        foreach (GameObject card in enemy.cards)
        {
            card.GetComponent <Card>().TurnStart();
        }
        yield return(new WaitForSeconds(0.5f));

        foreach (GameObject card in player.cards)
        {
            if (card.GetComponent <Card>().IsAttackReady)
            {
                BattleNum++;
            }
        }
        foreach (GameObject card in enemy.cards)
        {
            if (card.GetComponent <Card>().IsAttackReady)
            {
                BattleNum++;
            }
        }
        for (int i = 0; i < BattleNum; i++)
        {
            foreach (GameObject card in player.cards)
            {
                card.GetComponent <Card>().AttackReady();
            }
            foreach (GameObject card in enemy.cards)
            {
                card.GetComponent <Card>().AttackReady();
            }
            turnEnablePlayerCards.Sort(new CardTurnSort());
            turnEnableEnemyCards.Sort(new CardTurnSort());
            //foreach (GameObject obj in turnEnablePlayerCards)
            //{
            //    yield return new WaitForSeconds(turnDelay);
            //    obj.GetComponent<Card>().AttackOrder = true;
            //}
            if (turnEnablePlayerCards.Count != 0)
            {
                playerFieldNum = turnEnablePlayerCards[0].GetComponent <Card>().FieldNumber;
            }
            if (turnEnableEnemyCards.Count != 0)
            {
                enemyFieldNum = turnEnableEnemyCards[0].GetComponent <Card>().FieldNumber;
            }
            // compare field number
            if (playerFieldNum < enemyFieldNum)
            {
                turnEnablePlayerCards[0].GetComponent <Card>().AttackOrder = true;
            }
            else if (playerFieldNum > enemyFieldNum)
            {
                turnEnableEnemyCards[0].GetComponent <Card>().AttackOrder = true;
            }
            else
            {
                if (RandomSelecter.GetRandomValue_n())
                {
                    turnEnablePlayerCards[0].GetComponent <Card>().AttackOrder = true;
                }
                else
                {
                    turnEnableEnemyCards[0].GetComponent <Card>().AttackOrder = true;
                }
            }
            yield return(new WaitForSeconds(turnDelay));

            turnEnablePlayerCards.Clear();
            turnEnableEnemyCards.Clear();
            playerFieldNum = 6;
            enemyFieldNum  = 6;
        }
        presentTurn++;
        if (presentTurn < 7)
        {
            StartCoroutine(TurnStart());
        }
    }
Esempio n. 3
0
    private void SetP2PRmiStub()
    {
        m_C2CStub.Init = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, int hostNum) =>
        {
            if (m_myhostID == remote)
            {
                return(true);
            }
            m_enemyID = remote;
            if ((int)m_myhostID > (int)m_enemyID)
            {
                RandomSelecter.m_isMyTurn = true;
            }
            else
            {
                RandomSelecter.m_isMyTurn = false;
            }
            return(true);
        };
        m_C2CStub.HandCardCount = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, int num) =>
        {
            if (m_myhostID == remote)
            {
                return(true);
            }

            LogicManager.instance.Enemy.m_cardNum = num;
            Debug.Log("Enemy Card Num: " + num);
            return(true);
        };
        m_C2CStub.SettingOK = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext) =>
        {
            if (m_myhostID != remote)
            {
                LogicManager.instance.EnemySettingEnd();
            }
            return(true);
        };
        m_C2CStub.CardInfo = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, CardInfo_send info) =>
        {
            if (m_myhostID == remote)
            {
                return(true);
            }
            LogicManager.instance.EnemyInfoUpdate(info);
            return(true);
        };
        m_C2CStub.SummonInfo = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, CardInfo_send info) =>
        {
            if (m_myhostID == remote)
            {
                return(true);
            }
            LogicManager.instance.EnemySummonInfoUpdate(info);
            return(true);
        };
        m_C2CStub.ClearInfo = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext) =>
        {
            if (m_myhostID != remote)
            {
                LogicManager.instance.ClearInfo();
            }
            return(true);
        };
        m_C2CStub.ReturnInfo = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, int fieldNum) =>
        {
            if (m_myhostID != remote)
            {
                LogicManager.instance.EnemyReturnInfoUpdate(fieldNum);
            }
            return(true);
        };
        m_C2CStub.RandomInfo = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, bool ran1, bool ran2, bool ran3, bool ran4, bool ran5) =>
        {
            bool[] ranValue = { ran1, ran2, ran3, ran4, ran5 };
            RandomSelecter.ReceiveValue(ranValue);
            return(true);
        };
        m_C2CStub.InitInfo = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, int cardNum) =>
        {
            if (m_myhostID != remote)
            {
                CardDatabase.Instance().AddEnemyDeck(cardNum);
            }
            return(true);
        };
    }
Esempio n. 4
0
    IEnumerator DoSummon()
    {
        UIManager.instance.SettingText(true, "- 소환 단계 진행중 -");
        foreach (var obj in summonEnableEnemyCards)
        {
            obj.GetComponent <Card>().CardTextSet(true);
        }
        yield return(new WaitForSeconds(0.5f));

        if (RandomSelecter.m_isMyTurn)
        {
            RandomSelecter.RandomActive();
            bool[] ran = { RandomSelecter.GetRandomValue(0), RandomSelecter.GetRandomValue(1), RandomSelecter.GetRandomValue(2),
                           RandomSelecter.GetRandomValue(3), RandomSelecter.GetRandomValue(4) };
            GameClient.instance.SendRandInfo(ran);
        }

        for (int i = 0; i < summonCount; i++)
        {
            int playerFieldNum = 6;
            int enemyFieldNum  = 6;

            summonEnablePlayerCards.Sort(new CardTurnSort());
            summonEnableEnemyCards.Sort(new CardTurnSort());
            if (summonEnablePlayerCards.Count != 0)
            {
                playerFieldNum = summonEnablePlayerCards[0].GetComponent <Card>().FieldNumber;
            }
            if (summonEnableEnemyCards.Count != 0)
            {
                enemyFieldNum = summonEnableEnemyCards[0].GetComponent <Card>().FieldNumber;
            }
            if (playerFieldNum < enemyFieldNum)
            {
                summonEnablePlayerCards[0].gameObject.GetComponentInChildren <SpriteRenderer>().color = Color.white;
                summonEnablePlayerCards.RemoveAt(0);
            }
            else if (playerFieldNum > enemyFieldNum)
            {
                summonEnableEnemyCards[0].gameObject.GetComponentInChildren <SpriteRenderer>().color = Color.white;
                Card card = summonEnableEnemyCards[0].GetComponent <Card>();
                card.Init();
                card.ChangeState(new Summon());
                card.ChangePosition(new InField());
                LogicManager.instance.Enemy.AddCard(card.gameObject);
                enemy.RemoveCardHand(null);
                summonEnableEnemyCards.RemoveAt(0);
            }
            else
            {
                if (RandomSelecter.GetRandomValue_n())
                {
                    summonEnablePlayerCards[0].gameObject.GetComponentInChildren <SpriteRenderer>().color = Color.white;
                    summonEnablePlayerCards.RemoveAt(0);
                }
                else
                {
                    summonEnableEnemyCards[0].gameObject.GetComponentInChildren <SpriteRenderer>().color = Color.white;
                    Card card = summonEnableEnemyCards[0].GetComponent <Card>();
                    card.Init();
                    card.ChangeState(new Summon());
                    card.ChangePosition(new InField());
                    LogicManager.instance.Enemy.AddCard(card.gameObject);
                    enemy.RemoveCardHand(null);
                    summonEnableEnemyCards.RemoveAt(0);
                }
            }
            yield return(new WaitForSeconds(turnDelay));
        }
        Debug.Log("Summon End");
        summonCount = 0;
        yield return(new WaitForSeconds(0.5f));

        presentlevel = Level.Battle;
        summonCards.Clear();

        ObjectPool objpool = GameObject.Find("CardPool").GetComponent <ObjectPool>();

        foreach (CardInfo_send soul in player.GetTrashCards())
        {
            GameObject    card = objpool.GetObject();
            CardInfo_send newInfo;
            newInfo = soul;
            newInfo.FieldLocation = 0;
            newInfo.isEnemyCard   = false;
            newInfo.isReturn      = false;
            card.GetComponent <Card>().SetInfo(newInfo);
            card.GetComponent <Card>().Init();
            card.GetComponent <Card>().ChangePosition(new InHand());
            player.cards.Add(card);
        }
        player.GetTrashCards().Clear();
        foreach (CardInfo_send soul in enemy.GetTrashCards())
        {
            GameObject    card = objpool.GetObject();
            CardInfo_send newInfo;
            newInfo = soul;
            newInfo.FieldLocation = 0;
            newInfo.isEnemyCard   = true;
            newInfo.isReturn      = false;
            card.GetComponent <Card>().SetInfo(newInfo);
            card.GetComponent <Card>().Init();
            card.GetComponent <Card>().ChangePosition(new InHand());
            enemy.cards.Add(card);
        }
        enemy.GetTrashCards().Clear();
        ChangeState(new BattleLogic());
    }