Beispiel #1
0
 private void SendBetaClickData()
 {
     if (thisType.valence == 6 && (!thisType.elementName.StartsWith("Sc")))
     {
         List <GameObject> activeOxygens = new List <GameObject>();
         foreach (var t in from el in Info.allElements
                  where el.valence == 0
                  select el)
         {
             foreach (var e in t.allInstases)
             {
                 if (e.activeSelf)
                 {
                     activeOxygens.Add(e);
                 }
             }
         }
         GameObject[] oxygens   = activeOxygens.ToArray();
         float[]      distances = new float[oxygens.Length];
         for (int i = 0; i < oxygens.Length; i++)
         {
             distances[i] = Vector3.Distance(transform.localPosition, oxygens[i].transform.localPosition);
         }
         Array.Sort(distances, oxygens);
         GameObject a = oxygens[0];
         GameObject b = null;
         for (int i = 1; i < 6; i++)
         {
             if (oxygens[i].transform.position.y == a.transform.position.y)
             {
                 continue;
             }
             if (b == null)
             {
                 b = oxygens[i];
                 continue;
             }
             if ((a.transform.position - b.transform.position).magnitude > (a.transform.position - oxygens[i].transform.position).magnitude)
             {
                 b = oxygens[i];
             }
         }
         CoordScript scr  = GetComponent <CoordScript>();
         float       z    = scr.z;
         ClickData   beta = new ClickData(Info.a, Info.b, Info.c, scr.x, scr.y, z);
         beta.name = this.name;
         beta.beta = true;
         scr       = a.GetComponent <CoordScript>();
         beta.ang1 = new ClickData(Info.a, Info.b, Info.c, scr.x, scr.y, z);
         scr       = b.GetComponent <CoordScript>();
         beta.ang3 = new ClickData(Info.a, Info.b, Info.c, scr.x, scr.y, z);
         Info.sendClickDatatoWin(beta);
     }
 }
Beispiel #2
0
    void Update()
    {
        bool n = Input.GetMouseButton(0);

        if (!n)
        {
            f = n;
            return;
        }
        if (f)
        {
            return;
        }
        f = n;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit[] hits = Physics.RaycastAll(ray);
        bool         flag = false;

        foreach (var h in hits)
        {
            if (h.transform.gameObject.name != "triangle")
            {
                flag = true;
            }
        }

        if (flag) //&& hit.collider.gameObject.name == "Yify")
        {
            float      distance = float.MaxValue;
            GameObject target   = null;
            foreach (var h in hits)
            {
                if (h.transform.gameObject.name != "triangle" && h.distance < distance)
                {
                    distance = h.distance;
                    target   = h.transform.gameObject;
                }
            }
            ClickData c = new ClickData();
            c.name = target.name;
            CoordScript scr = target.GetComponent <CoordScript>();
            c.a    = Info.a;
            c.b    = Info.b;
            c.c    = Info.c;
            c.x    = scr.x;
            c.y    = scr.y;
            c.z    = scr.z;
            c.beta = false;
            Info.sendClickDatatoWin(c);
        }
    }
    private bool HaveElement(Vector3 el, List <GameObject> list)
    {
        foreach (var e in list)
        {
            CoordScript scr = e.GetComponent <CoordScript>();
            if (Math.Abs(scr.x - el.x) < 0.05 &&
                Math.Abs(scr.y - el.y) < 0.05 &&
                Math.Abs(scr.z - el.z) < 0.05)
            {
                return(true);
            }
        }

        return(false);
    }
    List <GameObject> ReplicateItem(GameObject obj, Vector3 locate, bool addHiden, string Name)
    {
        List <GameObject> thisAtoms = new List <GameObject>();
        List <Vector3>    list      = new List <Vector3>();
        List <int>        listInd   = new List <int>();

        foreach (var rep in replications)
        {
            list.Add(rep(locate));
        }
        for (int i = 1; i <= replications.Count; i++)
        {
            listInd.Add(i);
        }

        list = addAxesElement(list, listInd);
        for (int i = 1; i <= list.Count; i++)
        {
            Vector3 el = list[i - 1];
            Info.normalize(ref el);
            if (HaveElement(el, thisAtoms))
            {
                continue;
            }
            Info.Scale(ref el);
            Info.transToUSC(ref el);
            Info.YZSwap(ref el);

            if (addHiden == false)
            {
                GameObject NewObj = (GameObject)Instantiate(obj, el, Quaternion.identity);
                NewObj.name             = "";
                NewObj.name             = Name + " " + listInd[i - 1].ToString();
                NewObj.transform.parent = this.transform;
                thisAtoms.Add(NewObj);
            }
            else
            {
                for (float x = -1; x <= 1; x++)
                {
                    for (float y = -1; y <= 1; y++)
                    {
                        for (float z = -1; z <= 1; z++)
                        {
                            Vector3 add = new Vector3(x, y, z);
                            Info.Scale(ref add);
                            Info.transToUSC(ref add);
                            Info.YZSwap(ref add);
                            add += el;
                            GameObject NewObj = (GameObject)Instantiate(obj, add, Quaternion.identity);
                            NewObj.name = "";
                            Vector3 addSc = new Vector3(add.x, add.y, add.z);
                            Info.YZSwap(ref addSc);
                            Info.transToOrt(ref addSc);
                            Info.deScale(ref addSc);
                            if (addSc.x >= -0.001 && addSc.x <= 1.001 && addSc.y >= -0.001 &&
                                addSc.y <= 1.001 && addSc.z >= -0.001 && addSc.z <= 1.001)
                            {
                                NewObj.SetActive(true);
                            }
                            else
                            {
                                NewObj.SetActive(false);
                            }
                            NewObj.name             = Name + " " + listInd[i - 1].ToString();
                            NewObj.transform.parent = this.transform;
                            CoordScript scr = NewObj.GetComponentInChildren <CoordScript>();
                            Vector3     el1 = list[i - 1];
                            Info.normalize(ref el1);
                            scr.x = el1.x + x; scr.y = el1.y + y; scr.z = el1.z + z;
                            thisAtoms.Add(NewObj);
                        }
                    }
                }
            }
        }
        return(thisAtoms);
    }