Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit = new RaycastHit();

        if (PieceNum != 0)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << 9))
                {
                    select_piece = Instantiate(hit.collider.gameObject);
                }
            }
            if (select_piece)
            {
                if (Input.GetMouseButton(0))
                {
                    Vector3 pos = Input.mousePosition;
                    pos.z = 0.8f;
                    select_piece.transform.position = Camera.main.ScreenToWorldPoint(pos);
                }
                if (Input.GetMouseButtonUp(0))
                {
                    if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << 8))
                    {
                        SaveInfomation buff = hit.collider.gameObject.GetComponent <SaveInfomation>();
                        if (buff.piece == null)
                        {
                            buff.piece = select_piece;
                            select_piece.transform.position = hit.collider.gameObject.transform.position + new Vector3(0, 0, -0.1f);
                            select_piece.layer = LayerMask.NameToLayer("Default");
                            //hit.collider.gameObject.GetComponent<SellDate>().on_pise = select_piece;
                            PieceNum -= 1;
                            text.text = "×" + PieceNum.ToString();
                        }
                        else
                        {
                            Destroy(select_piece);
                        }
                    }
                    else
                    {
                        Destroy(select_piece);
                    }
                    select_piece = null;
                }
            }
        }
    }
Exemple #2
0
 private void check_btnDongY()
 {
     if (inputName.text != "" && inputAge.text != "")
     {
         GameInfomation.Playername = inputName.text;
         GameInfomation.Playerage  = int.Parse(inputAge.text);
         SaveInfomation.SaveAllInfomation();
         scenesManager scm = new scenesManager();
         scm.scenesLoad(1);
     }
     else
     {
         Debug.Log("Name hoac Age khong duoc de trong");
     }
 }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < 3; i++)
     {
         List <SaveInfomation> line = new List <SaveInfomation>();
         for (int j = 0; j < 9; j++)
         {
             GameObject obj = Instantiate(boardobj);
             //Vector3 pinPos =
             obj.transform.position = new Vector3(j * 1.5f, i * 1.5f, 5);
             SaveInfomation _sell_date = obj.GetComponent <SaveInfomation>();
             _sell_date.sellnum = new Vector2(j, i);
             boardObjList.Add(new List <SaveInfomation>(line));
         }
         line.Clear();
     }
 }