public void OnDrop(PointerEventData eventData)
    {
        if (Input.GetMouseButtonUp(0))
        {
            canCreate = false;
            Vector3    wordPos;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            int        layer_mask = LayerMask.GetMask("area_create");
            if (Physics.Raycast(ray, out hit, 1000f, layer_mask))
            {
                wordPos = hit.point;

                GameObject clone = Instantiate(gameobject, wordPos, Quaternion.identity);
                clone.tag = gameController.i_am_a;

                if (netconnection != null)
                {
                    attack_info attack_Info_ = new attack_info();
                    attack_Info_.name      = "Shower";
                    attack_Info_.tag       = gameController.i_am_a;
                    attack_Info_.room_name = gameController.room_name;
                    attack_Info_.position  = slashcheck(Round(wordPos.x, 4) + "," + Round(wordPos.y, 4) + "," + Round(wordPos.z, 4));
                    netconnection.attackReq(attack_Info_);
                }
            }
        }
        cameraHandler.enabled = true;
        area_create.SetActive(false);
    }
    public void directCreate(attack_info attack_Info_)
    {
        Vector3    new_pos = JsonToVec(attack_Info_.position);
        GameObject clone   = Instantiate(gameobject, new_pos, Quaternion.identity);

        clone.tag = attack_Info_.tag;
    }
예제 #3
0
    public void attackReq(attack_info attack_Info_)
    {
        Debug.Log("other attack recived");
        Dictionary <string, string> data = new Dictionary <string, string>();
        string attack_Info_str           = JsonUtility.ToJson(attack_Info_, true);

        Debug.Log(attack_Info_str);
        debuger.text += "get :" + attack_Info_str;
        socket.Emit("attack", new JSONObject(attack_Info_str));
    }
예제 #4
0
    public void directCreate(attack_info attack_Info_)
    {
        Vector3 new_pos = JsonToVec(attack_Info_.position);

        Debug.Log(new_pos);
        GameObject clone = Instantiate(gameobject, new_pos, Quaternion.identity);

        clone.name = attack_Info_.object_name;
        clone.tag  = attack_Info_.tag;
        clone.GetComponent <Soldier>().current_level = attack_Info_.level;
    }
예제 #5
0
    void onOtherAttack(SocketIOEvent evt)
    {
        Debug.Log("new other attack");
        Debug.Log(evt.data);
        attack_info attack_Info_ = new attack_info();

        attack_Info_.name     = jsonToString(evt.data.GetField("name").ToString(), "\"");
        attack_Info_.tag      = jsonToString(evt.data.GetField("tag").ToString(), "\"");
        attack_Info_.position = jsonToString(evt.data.GetField("position").ToString(), "\"");

        if (attack_Info_.name == "Shower")
        {
            ShowerGenarator_.directCreate(attack_Info_);
        }
        else if (attack_Info_.name == "Soldier")
        {
            SoldierGenerator_.directCreate(attack_Info_);
        }
    }
    public void OnDrop(PointerEventData eventData)
    {
        if (Input.GetMouseButtonUp(0))
        {
            canCreate = false;
            Vector3    wordPos;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            int        layer_mask = LayerMask.GetMask("area_create");
            if (Physics.Raycast(ray, out hit, 1000f, layer_mask))
            {
                Debug.Log("hit");
                wordPos = hit.point;

                GameObject clone = Instantiate(gameobject, wordPos, Quaternion.identity);
                clone.tag  = gameController.i_am_a;
                clone.name = character_name + "_" + gameController.i_am_a + "_" + Create_count;
                //  clone.GetComponent<AgentInfo>().current_level = current_level;

                if (netconnection != null)
                {
                    attack_info attack_Info_ = new attack_info();
                    attack_Info_.name        = character_name;
                    attack_Info_.object_name = clone.name;
                    attack_Info_.tag         = gameController.i_am_a;
                    attack_Info_.room_name   = gameController.room_name;
                    attack_Info_.level       = current_level;


                    Debug.Log("send : " + wordPos.x + "," + wordPos.y + "," + wordPos.z);
                    attack_Info_.position = wordPos.x.ToString("F4") + "," + wordPos.y.ToString("F4") + "," + wordPos.z.ToString("F4");

                    netconnection.attackReq(attack_Info_);
                }
                Create_count++;
            }
        }
        cameraHandler.enabled = true;
        area_create.SetActive(false);
    }