Beispiel #1
0
    /*
     * // 攻撃を行うダイスを選択する際のみ機能する関数
     * public void AttackDice_select()
     * {
     *  Debug.Log("cost1:");
     *  if (this.reference != CARD.EFFECT.CANCEL)
     *  {
     *      Card card = GetComponentInParent<Card>();
     *      CardEffect cardeffect = GetComponentInParent<CardEffect>();
     *      bool self_activate = card.activate;
     *      activate = cardeffect.ExistActivate();
     *      if (activate == true && self_activate == false)
     *      {
     *          this.step = CARD.STEP.COST;
     *          card_position = this.transform.position;
     *          Debug.Log("card_position.x:" + card_position.x);
     *          Debug.Log("card_position.y:" + card_position.y);
     *          card.selected = true;
     *      }
     *  }
     *  this.reference = CARD.EFFECT.NONE;
     * }
     */

    void OnGUI()
    {
        float per1x = 65f;
        float per1y = 65f;
        float basex = 735f + per1x;
        float basey = 590f + per1y;

        if (dice_step == DICE.STEP.TOUCHE)
        {
            Dice       dice       = GetComponentInParent <Dice>();
            Dice_move1 dice_move1 = GetComponentInParent <Dice_move1>();

            //List<KomaMove> moves = new List<KomaMove>();
            int[,] moves = new int[4, 2];
            bool[] koma_able = new bool[4];
            float[,] koma_position = new float[4, 2];

            moves = dice_move1.GetMoves();
            Vector3 tmp = this.transform.position;

            for (int i = 0; i < 4; i++)
            {
                if (dice.x + moves[i, 0] > 5 || dice.x + moves[i, 0] < 1)
                {
                    koma_able[i] = false;  
                        koma_position[i, 0] = 0.0f;
                    koma_position[i, 1] = 0.0f;
                    continue;
                }
                if (dice.y + moves[i, 1] > 5 || dice.y + moves[i, 1] < 1)
                {
                    koma_able[i]        = false;
                    koma_position[i, 0] = 0.0f;
                    koma_position[i, 1] = 0.0f;
                    continue;
                }
                if (dice.flag == true)
                {
                    bool activate_i = GUI.Button(new Rect(basex - 33f - per1x * (dice.x + moves[i, 0]), basey - 432f + per1y * (dice.y + moves[i, 1]), 66, 66), "");
                    koma_position[i, 0] = basex - per1x * (dice.x + moves[i, 0]);
                    koma_position[i, 1] = basey - per1y * (dice.y + moves[i, 1]);

                    koma_able[i] = activate_i;
                }
                else if (dice.flag == false)
                {
                    bool activate_i = GUI.Button(new Rect(basex - 33f - per1x * (dice.x + moves[i, 0]), basey - 432f + per1y * (dice.y + moves[i, 1]), 66, 66), "");
                    koma_position[i, 0] = basex - per1x * (dice.x + moves[i, 0]);
                    koma_position[i, 1] = basey - per1y * (dice.y + moves[i, 1]);

                    koma_able[i] = activate_i;
                }
            }

            if (koma_able[0] == true)
            {
                Debug.Log("0 BUTTON WAS CLICKED!!!!!!");

                this.dice_step            = DICE.STEP.NONE;
                this.step                 = CARD.STEP.IDLE;
                this.transform.localScale = new Vector3(0.5f, 0.5f, 0.0f);
                this.transform.position   = new Vector3(koma_position[0, 0], koma_position[0, 1], 0);

                dice.x = dice.x + moves[0, 0];
                dice.y = dice.y + moves[0, 1];
                Debug.Log("x:" + dice.x + "y:" + dice.y);
                Debug.Log("koma_position[0, 0]:" + koma_position[0, 0] + "koma_position[0, 1]:" + koma_position[0, 1]);

                /*
                 * GameObject gameObj = GameObject.Find("GameMaster");
                 * GameMaster gamemaster = gameObj.GetComponent<GameMaster>();
                 * player1 player = gamemaster.currentPlayer;
                 *
                 * Card card = this.GetComponent<Card>();
                 * player.PushSettingCardOnFieldFromHand(card);
                 *
                 * //スプライトの差し替えはいらないが、移動先のマスにほかの駒が存在するなら大きさを小さくして同じマスに表示させる。
                 *              if (card.type == (int)Type.REFLECT)
                 * {
                 *  sprite = Resources.Load<Sprite>("back_1");
                 *  image = this.GetComponent<Image>();
                 *  image.sprite = sprite;
                 * }
                 */
            }
            if (koma_able[1] == true)
            {
                Debug.Log("1 BUTTON WAS CLICKED!!!!!!");

                this.dice_step            = DICE.STEP.NONE;
                this.step                 = CARD.STEP.IDLE;
                this.transform.localScale = new Vector3(0.5f, 0.5f, 0.0f);
                this.transform.position   = new Vector3(koma_position[1, 0], koma_position[1, 1], 0);

                dice.x = dice.x + moves[1, 0];
                dice.y = dice.y + moves[1, 1];
                Debug.Log("x:" + dice.x + "y:" + dice.y);
                Debug.Log("koma_position[1, 0]:" + koma_position[1, 0] + "koma_position[1, 1]:" + koma_position[1, 1]);
            }
            if (koma_able[2] == true)
            {
                Debug.Log("2 BUTTON WAS CLICKED!!!!!!");

                this.dice_step            = DICE.STEP.NONE;
                this.step                 = CARD.STEP.IDLE;
                this.transform.localScale = new Vector3(0.5f, 0.5f, 0.0f);
                this.transform.position   = new Vector3(koma_position[2, 0], koma_position[2, 1], 0);

                dice.x = dice.x + moves[2, 0];
                dice.y = dice.y + moves[2, 1];
                Debug.Log("x:" + dice.x + "y:" + dice.y);
                Debug.Log("koma_position[2, 0]:" + koma_position[2, 0] + "koma_position[2, 1]:" + koma_position[2, 1]);
            }
            if (koma_able[3] == true)
            {
                Debug.Log("3 BUTTON WAS CLICKED!!!!!!");

                this.dice_step            = DICE.STEP.NONE;
                this.step                 = CARD.STEP.IDLE;
                this.transform.localScale = new Vector3(0.5f, 0.5f, 0.0f);
                this.transform.position   = new Vector3(koma_position[3, 0], koma_position[3, 1], 0);

                dice.x = dice.x + moves[3, 0];
                dice.y = dice.y + moves[3, 1];
                Debug.Log("x:" + dice.x + "y:" + dice.y);
                Debug.Log("koma_position[3, 0]:" + koma_position[3, 0] + "koma_position[3, 1]:" + koma_position[3, 1]);
            }
        }

        else if (dice_step == DICE.STEP.DAMAGED)
        {
            Debug.Log("SUCCEED!!!!");
            Dice dice = GetComponentInParent <Dice>();
            //dice.hp -= 1;
            this.dice_step = DICE.STEP.NONE;
        }

        else if (dice_step == DICE.STEP.TARGET)
        {
            CardEffect cardeffect = GetComponentInParent <CardEffect>();
            Dice       dice       = GetComponentInParent <Dice>();
            //int hand_num;
            //int cost;
            //cost = cardeffect.Getcost();
            //hand_num = cardeffect.GetHand();
            int selected_cost;
            selected_cost = cardeffect.DiceExistSelected();

            //bool ret = GUI.Button(new Rect(550, 350, 100, 90), "コストとして支払うカード");
            // タップされた手札にボタンを生成したい
            //bool ret = GUI.Button(new Rect(card_position.x + 500f, card_position.y - 500f, 200, 300), "コストとして選択されたカード");
            //bool ret = GUI.Button(new Rect(card_position.x + 620f, card_position.y + 640f, 80, 120), "select");
            //bool ret = GUI.Button(new Rect(dice_position.x - 40f, dice_position.y + 700f, 80, 120), "select");
            bool ret = GUI.Button(new Rect(basex - 33f - per1x * dice.x, basey - 432f + per1y * dice.y, 66, 66), "select");
            if (ret == true)
            {
                Debug.Log("RETURN BUTTON WAS CLICKED!!!!!!");
                this.dice_step            = DICE.STEP.IDLE;
                this.transform.localScale = new Vector3(0.8f, 1.2f, 0.0f);
                this.reference            = DICE.EFFECT.CANCEL;
                dice.selected             = false;
            }
            if (selected_cost == 2)
            {
                //this.step = CARD.STEP.DISCAHRGE;
                bool card_choose = GUI.Button(new Rect(350, 220, 500, 450), "選択したダイスを攻撃します。よろしいですか?");
                int  checkcost   = cardeffect.Getcost();
                if (card_choose == true || checkcost == 0)
                {
                    var targets = GameObject.FindGameObjectsWithTag("DICE");
                    this.dice_step = DICE.STEP.IDLE;
                    foreach (GameObject target in targets)
                    {
                        if (target.GetComponent <Dice>().selected == true)
                        {
                            GameObject gameObj    = GameObject.Find("GameMaster");
                            GameMaster gamemaster = gameObj.GetComponent <GameMaster>();
                            //player1 player = gamemaster.currentPlayer;
                            //player.ActivationCostFromHand(target.GetComponent<Card>());
                        }
                    }
                    cardeffect.DiceFlagrestore();
                }
            }
        }


        /*
         * else if (dice_step == DICE.STEP.ATTACK)
         * {
         *  CardEffect cardeffect = GetComponentInParent<CardEffect>();
         *  Card card = GetComponentInParent<Card>();
         *  int hand_num;
         *  int selected_cost;
         *  int cost;
         *  cost = cardeffect.Getcost();
         *  hand_num = cardeffect.GetHand();
         *  selected_cost = cardeffect.ExistSelected();
         *
         *  bool ret = GUI.Button(new Rect(card_position.x - 40f, card_position.y + 700f, 80, 120), "select");
         *  if (ret == true)
         *  {
         *      Debug.Log("RETURN BUTTON WAS CLICKED!!!!!!");
         *      this.step = CARD.STEP.IDLE;
         *      this.transform.localScale = new Vector3(0.8f, 1.2f, 0.0f);
         *      this.reference = CARD.EFFECT.CANCEL;
         *      card.selected = false;
         *
         *      //card.activate = true;
         *      //card_position = new Vector3();
         *  }
         *  if (selected_cost == cost)
         *  {
         *      //this.step = CARD.STEP.DISCAHRGE;
         *      bool card_choose = GUI.Button(new Rect(350, 220, 500, 450), "選択したカードを捨てます。よろしいですか?");
         *      int checkcost = cardeffect.Getcost();
         *      if (card_choose == true || checkcost == 0)
         *      {
         *          var targets = GameObject.FindGameObjectsWithTag("CARD");
         *          this.step = CARD.STEP.IDLE;
         *          foreach (GameObject target in targets)
         *          {
         *              if (target.GetComponent<Card>().selected == true)
         *              {
         *                  GameObject gameObj = GameObject.Find("GameMaster");
         *                  GameMaster gamemaster = gameObj.GetComponent<GameMaster>();
         *                  player1 player = gamemaster.currentPlayer;
         *                  player.ActivationCostFromHand(target.GetComponent<Card>());
         *              }
         *          }
         *          cardeffect.Flagrestore();
         *      }
         *  }
         * }
         */
    }
Beispiel #2
0
    void OnGUI()
    {
        float per1x = 65f;
        float per1y = 65f;
        float basex = 735f + per1x;
        float basey = 590f + per1y;

        /*
         * if (this.step == CARD.STEP.ACTIVATE)
         * {
         *  CardEffect cardeffect = GetComponentInParent<CardEffect>();
         *  int[,] position = cardeffect.A_1(); // ここで座標のみを受け取っているため受け取りもとで行っている作業を下でもしている
         *  int dice_x;
         *  int dice_y;
         *  for (int i = 0; i < position.GetLength(0); i++)
         *  {
         *      dice_x = position[i, 0];
         *      dice_y = position[i, 1];
         *
         *      bool activate_i = GUI.Button(new Rect(basex - 33f - per1x * (dice_x), basey - 432f + per1y * (dice_y), 66, 66), "");
         *      if (activate_i == true)
         *      {
         *          //dice_step = DICE.STEP.TOUCHE;
         *          var gameObj = GameObject.FindGameObjectsWithTag("DICE");
         *          for (int j = 0; j < position.GetLength(0); j++) // A_1でtargetobjごと受け取っていれば同じことをせずに済んだ
         *          {
         *              Dice dice = gameObj[j].GetComponent<Dice>();
         *              if (dice.x == dice_x && dice.y == dice_y) // 再び座標と一致するオブジェクトを探している、後で絶対直す
         *              {
         *                  DragObj dragObj = dice.GetComponent<DragObj>();
         *                  //dragObj.ddd();
         *                  dragObj.eee();
         *                  step = CARD.STEP.IDLE;
         *              }
         *          }
         *      }
         *  }
         * }
         */

        if (this.step == CARD.STEP.TOUCHE)
        {
            bool activate = GUI.Button(new Rect(400, 350, 100, 90), "発動");
            bool ret      = GUI.Button(new Rect(700, 350, 100, 90), "戻る");

            if (activate == true)
            {
                Debug.Log("ACTIVATE BUTTON WAS CLICKED!!!!!!");
                this.step = CARD.STEP.IDLE;
                //this.step = CARD.STEP.EXPAND;
                this.transform.localScale = new Vector3(0.8f, 1.2f, 0.0f);

                Card card = this.GetComponent <Card>();


                // ##########################################################
                // カードの発動条件を満たしたものを手札からフィールドに移動させる。
                // 発動コスト、その他特殊な発動条件のカードがあり実行タイミングは要検討
                // 下4行のコメントアウトをとったことにより、
                // 発動コストちょうどの手札枚数のときコスト不足が表示されてしまうので注意


                GameObject gameObj    = GameObject.Find("GameMaster");
                GameMaster gamemaster = gameObj.GetComponent <GameMaster>();
                player1    player     = gamemaster.currentPlayer;
                //Card card = this.GetComponent<Card>();
                player.PushSettingCardOnFieldFromHand(card);


                // ##########################################################

                if (card.type == (int)Type.REFLECT)
                {
                    sprite       = Resources.Load <Sprite>("back_1");
                    image        = this.GetComponent <Image>();
                    image.sprite = sprite;
                }
                // カード効果の発動
                else
                {
                    Card       cardObj       = GetComponentInParent <Card>();
                    CardEffect cardeffectObj = GetComponentInParent <CardEffect>();
                    cardeffectObj.Activate(cardObj);
                }
            }
            if (ret == true)
            {
                Debug.Log("RETURN BUTTON WAS CLICKED!!!!!!");
                this.step = CARD.STEP.IDLE;
                this.transform.localScale = new Vector3(0.8f, 1.2f, 0.0f);
            }
        }
        else if (this.step == CARD.STEP.EXPAND)
        {
            bool activate = GUI.Button(new Rect(400, 350, 100, 90), "確認");
            bool ret      = GUI.Button(new Rect(700, 350, 100, 90), "戻る");
            if (activate == true)
            {
                Debug.Log("CHECK BUTTON WAS CLICKED!!!!!!");
                this.transform.localScale = new Vector3(8f, 12f, -3f);
                this.step = CARD.STEP.CHECK;
            }
            if (ret == true)
            {
                Debug.Log("RETURN BUTTON WAS CLICKED!!!!!!");
                this.step = CARD.STEP.IDLE;
                this.transform.localScale = new Vector3(0.8f, 1.2f, 0.0f);
            }
        }
        else if (this.step == CARD.STEP.CHECK)
        {
            bool ret = GUI.Button(new Rect(550, 350, 100, 90), "戻る");
            if (ret == true)
            {
                Debug.Log("RETURN BUTTON WAS CLICKED!!!!!!");
                this.step = CARD.STEP.IDLE;
                this.transform.localScale = new Vector3(0.8f, 1.2f, 0.0f);
            }
        }
        else if (this.step == CARD.STEP.COST)
        {
            CardEffect cardeffect = GetComponentInParent <CardEffect>();
            Card       card       = GetComponentInParent <Card>();
            int        hand_num;
            int        selected_cost;
            int        cost;
            cost          = cardeffect.Getcost();
            hand_num      = cardeffect.GetHand();
            selected_cost = cardeffect.CardExistSelected();

            //Debug.Log("card_position.x2:" + card_position.x);
            //Debug.Log("card_position.y2:" + card_position.y);

            //bool ret = GUI.Button(new Rect(550, 350, 100, 90), "コストとして支払うカード");
            // タップされた手札にボタンを生成したい
            //bool ret = GUI.Button(new Rect(card_position.x + 500f, card_position.y - 500f, 200, 300), "コストとして選択されたカード");
            //bool ret = GUI.Button(new Rect(card_position.x + 620f, card_position.y + 640f, 80, 120), "select");
            bool ret = GUI.Button(new Rect(card_position.x - 40f, card_position.y + 700f, 80, 120), "select");
            if (ret == true)
            {
                Debug.Log("RETURN BUTTON WAS CLICKED!!!!!!");
                this.step = CARD.STEP.IDLE;
                this.transform.localScale = new Vector3(0.8f, 1.2f, 0.0f);
                this.reference            = CARD.EFFECT.CANCEL;
                card.selected             = false;

                //card.activate = true;
                //card_position = new Vector3();
            }
            if (selected_cost == cost)
            {
                //this.step = CARD.STEP.DISCAHRGE;
                bool card_choose = GUI.Button(new Rect(350, 220, 500, 450), "選択したカードを捨てます。よろしいですか?");
                int  checkcost   = cardeffect.Getcost();
                if (card_choose == true || checkcost == 0)
                {
                    var targets = GameObject.FindGameObjectsWithTag("CARD");
                    this.step = CARD.STEP.IDLE;
                    foreach (GameObject target in targets)
                    {
                        if (target.GetComponent <Card>().selected == true)
                        {
                            GameObject gameObj    = GameObject.Find("GameMaster");
                            GameMaster gamemaster = gameObj.GetComponent <GameMaster>();
                            player1    player     = gamemaster.currentPlayer;
                            player.ActivationCostFromHand(target.GetComponent <Card>());
                        }
                    }
                    cardeffect.CardFlagrestore();
                }
            }
        }

        /*
         * else if (this.step == CARD.STEP.DISCAHRGE)
         * {
         *  bool card_choose = GUI.Button(new Rect(350, 220, 500, 450), "選択したカードを捨てます。よろしいですか?");
         *  if(card_choose == true)
         *  {
         *      Card card = GetComponentInParent<Card>();
         *      CardEffect cardeffect = GetComponentInParent<CardEffect>();
         *      var targets = GameObject.FindGameObjectsWithTag("CARD");
         *      this.step = CARD.STEP.IDLE;
         *      foreach (GameObject target in targets)
         *      {
         *          if (target.GetComponent<Card>().selected == true)
         *          {
         *              GameObject gameObj = GameObject.Find("GameMaster");
         *              GameMaster gamemaster = gameObj.GetComponent<GameMaster>();
         *              player1 player = gamemaster.currentPlayer;
         *              player.ActivationCostFromHand(card);
         *          }
         *      }
         *      cardeffect.Flagrestore();
         *  }
         * }
         */
    }