Esempio n. 1
0
    public void OnDrop(PointerEventData data)
    {
        Debug.Log(gameObject.name);

        DragObj dragObj = data.pointerDrag.GetComponent <DragObj>();

        if (dragObj != null)
        {
            dragObj.parentTransform = this.transform;
            Debug.Log(gameObject.name + "に" + data.pointerDrag.name + "をドロップ");
        }
    }
Esempio n. 2
0
    }//end Update

    void FixedUpdate()
    {
        if (thePlayer.hit.collider != null)
        {
            //if(thePlayer.hit.collider.gameObject.GetComponent<DragObj>() != null){
            draggedObjectScript = thePlayer.hit.collider.gameObject.GetComponent <DragObj>();
            objectRestrictions  = thePlayer.hit.collider.gameObject.GetComponent <PhysicsRestrictions>();
            //}
            //if(thePlayer.hit.collider.gameObject.GetComponent<Rigidbody>() != null){
            draggedObjectRb = thePlayer.hit.collider.gameObject.GetComponent <Rigidbody>();
            //}
        }
    }//end FixedUpdate
Esempio n. 3
0
    void OnGUI()
    {
        float per1x = 65f;
        float per1y = 65f;
        float basex = 735f + per1x;
        float basey = 590f + per1y;

        if (this.step == EFFECT.STEP.ATTACK)
        {
            //EFFECT EFFECT = GetComponentInParent<EFFECT>();
            //int[,] position = EFFECT.A_1(); // ここで座標のみを受け取っているため受け取りもとで行っている作業を下でもしている

            /*
             * Type t = this.GetType();
             * MethodInfo mi = t.GetMethod(cardname);
             * object o = mi.Invoke(this, null);
             * int[,] position = mi.Invoke(null, null);
             */



            int[,] position = A_1();

            /*
             *
             * ここに個別の処理をそれぞれ埋め込む
             *
             */
            if (cardname == "A_1")
            {
                position = A_1();
            }
            if (cardname == "A_2")
            {
                position = A_2();
            }
            if (cardname == "A_3")
            {
                position = A_3();
            }
            if (cardname == "A_4")
            {
                position = A_4();
            }
            if (cardname == "A_5")
            {
                position = A_5();
            }
            if (cardname == "A_6")
            {
                position = A_6();
            }
            if (cardname == "A_7")
            {
                position = A_7();
            }
            if (cardname == "A_8")
            {
                position = A_8();
            }
            if (cardname == "A_9")
            {
                position = A_9();
            }
            if (cardname == "A_10")
            {
                position = A_10();
            }
            if (cardname == "A_11")
            {
                position = A_11();
            }

            int damage   = position[0, 2];
            int distance = position[0, 3];
            int cost     = position[0, 4];
            int[,] own_dice_position = Get_own_diceposition();
            int[,] opp_dice_position = Get_opp_diceposition();
            int enable_cost = GetHand() - 1; // 発動中のカードを除くため-1
            //int in_distance_dicenum = Get_in_distance_dicenum(distance); // distance内存在する相手のダイス数  distanceを渡せばいいのかな?
            int dice_x;
            int dice_y;
            int attacker_dice_x;
            int attacker_dice_y;
            int target_dice_x;
            int target_dice_y;

            void attack_processing()
            {
                GameObject gameOb     = GameObject.Find("GameMaster");
                GameMaster gamemaster = gameOb.GetComponent <GameMaster>();
                player1    player     = gamemaster.currentPlayer;
                Card       card       = this.GetComponent <Card>();

                player.PushSettingCardOnFieldFromHand(card);
                //List<GameObject> attackers = own_diceList();
                List <GameObject> attackers = Attackable_dice_object(distance);
                //List<GameObject> targets = opp_diceList();

                bool activate_dice     = DiceExistActivate();
                int  selected_dice_num = DiceExistSelected();

                if (activate_dice == false)
                {
                    foreach (GameObject attacker in attackers)
                    {
                        attacker_dice_x = attacker.GetComponent <Dice>().x;
                        attacker_dice_y = attacker.GetComponent <Dice>().y;
                        bool attacker_i = GUI.Button(new Rect(basex - 33f - per1x * (attacker_dice_x), basey - 432f + per1y * (attacker_dice_y), 66, 66), "");
                        if (attacker_i == true)
                        {
                            attacker.GetComponent <Dice>().activate = true;
                        }
                    }
                }

                GameObject attackerObj = diceExistActivate();
                GameObject selectedObj = diceExistSelected();

                attacker_dice_x = attackerObj.GetComponent <Dice>().x;
                attacker_dice_y = attackerObj.GetComponent <Dice>().y;
                target_dice_x   = selectedObj.GetComponent <Dice>().x;
                target_dice_y   = selectedObj.GetComponent <Dice>().y;
                List <GameObject> targets = Target_dice_object(attackerObj, distance);

                if (activate_dice == true)
                {
                    bool attacker_ = GUI.Button(new Rect(basex - 33f - per1x * (attacker_dice_x), basey - 432f + per1y * (attacker_dice_y), 66, 66), "att");
                    foreach (GameObject target in targets)
                    {
                        target_dice_x = target.GetComponent <Dice>().x;
                        target_dice_y = target.GetComponent <Dice>().y;
                        bool atrget_i = GUI.Button(new Rect(basex - 33f - per1x * (target_dice_x), basey - 432f + per1y * (target_dice_y), 66, 66), "");
                        if (atrget_i == true)
                        {
                            target.GetComponent <Dice>().selected = true;
                        }
                    }
                }

                if (activate_dice == true && selected_dice_num > 0)
                {
                    bool attacker_ = GUI.Button(new Rect(basex - 33f - per1x * (attacker_dice_x), basey - 432f + per1y * (attacker_dice_y), 66, 66), "att");
                    bool target_   = GUI.Button(new Rect(basex - 33f - per1x * (target_dice_x), basey - 432f + per1y * (target_dice_y), 66, 66), "tar");

                    GameObject target  = diceExistSelected();
                    Dice       dice    = target.GetComponent <Dice>();
                    DragObj    dragObj = dice.GetComponent <DragObj>();
                    dragObj.eee();
                    dice.hp      -= damage;
                    step          = EFFECT.STEP.IDLE;
                    activate_step = ACTIVATE.STEP.NONE;
                    DiceFlagrestore();
                }
            }

            // 手札が発動コストを満たしているか確認
            if (cost <= enable_cost || activate_step == ACTIVATE.STEP.IDLE)
            {
                List <GameObject> attackers = Attackable_dice_object(distance);
                if (attackers.Count == 0)
                {
                    bool card_choose = GUI.Button(new Rect(350, 220, 500, 450), "有効射程範囲に敵ダイスが存在しません");
                    if (card_choose == true)
                    {
                        step = EFFECT.STEP.IDLE;
                    }
                }
                else if (attackers.Count > 0)
                {
                    activate_step = ACTIVATE.STEP.IDLE;
                    if (cost == 1 && activate_cost != EFFECT.COST.ONE)
                    {
                        bool card_choose = GUI.Button(new Rect(350, 220, 500, 450), "捨てるカードを1枚選択してください");
                        if (card_choose == true)
                        {
                            //enable_cost = GetHand();
                            activate_cost = EFFECT.COST.ONE;
                            CardObj _cardobj = GetComponentInParent <CardObj>();
                            _cardobj.GetCardCost(cost);
                            Card card = GetComponentInParent <Card>();
                            card.activate = true;
                        }
                    }
                    if (cost == 2 && activate_cost != EFFECT.COST.TWO)
                    {
                        bool card_choose = GUI.Button(new Rect(350, 220, 500, 450), "捨てるカードを2枚選択してください");
                        if (card_choose == true)
                        {
                            //enable_cost = GetHand();
                            activate_cost = EFFECT.COST.TWO;
                            CardObj _cardobj = GetComponentInParent <CardObj>();
                            _cardobj.GetCardCost(cost);
                            Card card = GetComponentInParent <Card>();
                            card.activate = true;
                        }
                    }
                    if (cost > 3)
                    {
                        bool card_choose = GUI.Button(new Rect(550, 350, 500, 450), "捨てるカードを選択してください");
                    }

                    if (activate_cost == EFFECT.COST.ONE)
                    {
                        // カードの発動コストを支払い終えたか確認
                        if (this.CardExistActivate() == false)
                        {
                            attack_processing();
                        }
                    }

                    if (activate_cost == EFFECT.COST.TWO)
                    {
                        // カードの発動コストを支払い終えたか確認
                        if (this.CardExistActivate() == false)
                        {
                            attack_processing();
                        }
                    }

                    if (cost == 0)
                    {
                        attack_processing();
                    }
                }
            }
            else
            {
                Debug.Log("cost:" + cost + "enable_cost:" + enable_cost);
                bool card_choose = GUI.Button(new Rect(350, 220, 500, 450), "このカードの発動に必要なコストが足りていません");
                if (card_choose == true)
                {
                    step = EFFECT.STEP.IDLE;
                }
            }
        }

        if (step == EFFECT.STEP.MANA)
        {
            GameObject gameOb     = GameObject.Find("GameMaster");
            GameMaster gamemaster = gameOb.GetComponent <GameMaster>();
            player1    player     = gamemaster.currentPlayer;
            Card       card       = this.GetComponent <Card>();
            player.PushSettingCardOnFieldFromHand(card);
            int dice_x;
            int dice_y;
            List <GameObject> targets = own_diceList();
            foreach (GameObject target in targets)
            {
                dice_x = target.GetComponent <Dice>().x;
                dice_y = target.GetComponent <Dice>().y;
                ;
                bool activate_i = GUI.Button(new Rect(basex - 33f - per1x * (dice_x), basey - 432f + per1y * (dice_y), 66, 66), "");
                if (activate_i == true)
                {
                    Dice    dice    = target.GetComponent <Dice>();
                    DragObj dragObj = dice.GetComponent <DragObj>();
                    dragObj.ddd();
                    step = EFFECT.STEP.IDLE;
                }
            }
        }

        /*
         * if (step == EFFECT.STEP.MANA)
         * {
         *  GameObject gameOb = GameObject.Find("GameMaster");
         *  GameMaster gamemaster = gameOb.GetComponent<GameMaster>();
         *  player1 player = gamemaster.currentPlayer;
         *  Card card = this.GetComponent<Card>();
         *  player.PushSettingCardOnFieldFromHand(card);
         *
         *  int[,] position = M_1();
         *  int damage = position[0, 2];
         *  int distance = position[0, 3];
         *  int dice_x;
         *  int dice_y;
         *
         *  List<GameObject> targets = own_diceList();
         *
         *  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;
         *          Debug.Log("aaaaaaaaaaaaaaaaaaaaa");
         *          var gameObj = GameObject.FindGameObjectsWithTag("DICE");
         *          for (int j = 0; j < position.GetLength(0); j++) // A_1でtargetobjごと受け取っていれば同じことをせずに済んだ
         *          {
         *              Dice dice = gameObj[j].GetComponent<Dice>();
         *              Debug.Log("dice.x:" + dice.x + "dice_x:" + dice_x);
         *              Debug.Log("dice.y:" + dice.y + "dice_y:" + dice_y);
         *              if (dice.x == dice_x && dice.y == dice_y) // 再び座標と一致するオブジェクトを探している、後で絶対直す
         *              {
         *                  Debug.Log("bbbbbbbbbbbbbbb");
         *                  DragObj dragObj = dice.GetComponent<DragObj>();
         *                  dragObj.ddd();
         *                  step = EFFECT.STEP.IDLE;
         *              }
         *          }
         *      }
         *  }
         * }
         */
    }