// Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            if (_cardDisplayedCount < _cards.Length)
            {
                _cards [_cardDisplayedCount++].SetActive(true);
            }
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            GameObject prefab  = (GameObject)Resources.Load("Prefab/Card");
            GameObject cardObj = Instantiate(prefab, Vector3.zero, Quaternion.identity);
            CardMain   card    = cardObj.GetComponent <CardMain> ();
            card.loadID = _id;
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            _card = _deck.Draw();
            Vector3 effectPosition = _card.transform.position;
            effectPosition.z = -9;
            Instantiate(_summonEffect, effectPosition, Quaternion.identity);
            _card.Reverse(true);             //裏返す
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            if (_card)
            {
                _card.Damage(3);
            }
        }

        if (Input.GetKeyDown(KeyCode.P))           //これでは音は鳴らせない(Scene上にないとダメらしい)
        {
            AudioSource audioSource = new AudioSource();
            audioSource.clip = _clip;
            audioSource.loop = true;
            audioSource.Play();
        }

        if (Input.GetMouseButtonDown(0))
        {
            Vector3 effectPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            effectPosition.z = -9;
            Instantiate(_tapEffect, effectPosition, Quaternion.identity);
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            GameObject             battleSpaceObj = Instantiate(_battleSpacePrefab, Vector3.zero, Quaternion.identity);
            AutoDestroyBattleSpace battleSpace    = battleSpaceObj.GetComponent <AutoDestroyBattleSpace> ();
            battleSpace.StartLeftWinAnim(_cardSprite[0], _cardSprite[1]);
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            AutoDestroyBattleSpace battleSpace = Instantiate <AutoDestroyBattleSpace> (_battleSpace, Vector3.zero, Quaternion.identity);
            battleSpace.StartRightWinAnim(_cardSprite[0], _cardSprite[1]);
        }
        if (Input.GetKeyDown(KeyCode.G))
        {
            GameObject             battleSpaceObj = Instantiate(_battleSpacePrefab, Vector3.zero, Quaternion.identity);
            AutoDestroyBattleSpace battleSpace    = battleSpaceObj.GetComponent <AutoDestroyBattleSpace> ();
            battleSpace.StartBothDeathAnim(_cardSprite[0], _cardSprite[1]);
        }
        if (Input.GetKeyDown(KeyCode.H))
        {
            AutoDestroyBattleSpace battleSpace = Instantiate <AutoDestroyBattleSpace> (_battleSpace, Vector3.zero, Quaternion.identity);
            battleSpace.StartBothAliveAnim(_cardSprite[0], _cardSprite[1]);
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            _lifeSpace.StartDirectAttackAnimation();
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            Instantiate <AutoDestroyEffect> (_blackDamageEffect, Vector3.zero, Quaternion.identity);
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            Instantiate <AutoDestroyEffect> (_recoveryEffect, Vector3.zero, Quaternion.identity);
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            _deck.Shuffle();
        }
    }
Beispiel #2
0
    //カードを移動させる(返り値に移動できたかをboolで返す)-----------------------------------------------------------------------------------------------------------------------------
    public bool MoveCard(CardMain card, List <Field.DIRECTION> direction, int ap, Square nowSquare, Square moveSquare, int distans = 1)
    {
        List <Square> squares = new List <Square>( );

        //移動できるマスだけ格納
        squares = _field.MovePossibleSquare(card, direction, nowSquare, distans);

        CardDamageManager.BATTLE_RESULT result = CardDamageManager.BATTLE_RESULT.NOT_BATTLE;
        //移動できるマスの中に移動したいマスがあるか探す
        for (int i = 0; i < squares.Count; i++)
        {
            if (squares[i].Index != moveSquare.Index)
            {
                continue;
            }

            if (squares[i].On_Card != null)
            {
                if (squares[i].On_Card.gameObject.tag != card.gameObject.tag)                                   //移動したマスに自分のじゃないカードがあったら
                {
                    Texture2D moveingCardTexture = nowSquare.On_Card.Card_Sprite_Renderer.sprite.texture;
                    Sprite    movingCardSprite   = Sprite.Create(moveingCardTexture,                                                                                                            //Sprite のグラフィックスとして適用させるテクスチャ
                                                                 new Rect(0, 0, moveingCardTexture.width, moveingCardTexture.height),                                                           //Sprite に適用させるテクスチャの Rect 領域
                                                                 new Vector2(0.5f, 0.5f));                                                                                                      //グラフィックスの Rect に対するピボット地点の相対位置 //中心
                    movingCardSprite = nowSquare.On_Card.Card_Sprite_Renderer.sprite;

                    Texture2D notMovingCardTexture = squares[i].On_Card.Card_Sprite_Renderer.sprite.texture;
                    Sprite    notMoveCardSprite    = Sprite.Create(notMovingCardTexture,
                                                                   new Rect(0, 0, notMovingCardTexture.width, notMovingCardTexture.height),
                                                                   new Vector2(0.5f, 0.5f));
                    notMoveCardSprite = squares[i].On_Card.Card_Sprite_Renderer.sprite;

                    result = _cardDamageManager.CardBattleDamage(nowSquare, squares[i]);

                    //戦闘アニメーション処理-------------------------------------------------------------------------------------------------------------
                    AutoDestroyBattleSpace battleSpace = Instantiate <AutoDestroyBattleSpace>(_battleSpacePrefab, Vector3.zero, Quaternion.identity);
                    switch (result)
                    {
                    case CardDamageManager.BATTLE_RESULT.PLAYER_WIN:
                        battleSpace.StartRightWinAnim(notMoveCardSprite, movingCardSprite);
                        break;

                    case CardDamageManager.BATTLE_RESULT.PLAYER_LOSE:
                        battleSpace.StartLeftWinAnim(notMoveCardSprite, movingCardSprite);
                        break;

                    case CardDamageManager.BATTLE_RESULT.BOTH_DEATH:
                        battleSpace.StartBothDeathAnim(notMoveCardSprite, movingCardSprite);
                        break;

                    case CardDamageManager.BATTLE_RESULT.BOTH_ALIVE:
                        battleSpace.StartBothAliveAnim(notMoveCardSprite, movingCardSprite);
                        break;

                    default:
                        Debug.Log("想定外の戦闘結果になりました");
                        break;
                    }
                    //----------------------------------------------------------------------------------------------------------------------------------

                    Debug.Log(result);
                }
            }

            //戦闘の結果によって移動処理を変える
            switch (result)
            {
            case CardDamageManager.BATTLE_RESULT.BOTH_DEATH:
            case CardDamageManager.BATTLE_RESULT.PLAYER_LOSE:
            case CardDamageManager.BATTLE_RESULT.BOTH_ALIVE:
                break;

            case CardDamageManager.BATTLE_RESULT.NOT_BATTLE:
            case CardDamageManager.BATTLE_RESULT.PLAYER_WIN:
                nowSquare.On_Card  = null;
                moveSquare.On_Card = card;
                card.gameObject.transform.position = moveSquare.transform.position;
                break;

            default:
                Debug.Log("予期せぬ勝敗が起きている");
                return(false);
            }

            card.Action_Count++;
            _activePoint.DecreasePoint(ap);
            return(true);
        }
        return(false);
    }