public bool overLapszZ(ZzfragView zZfrag, Vector3 mousePos) //based on view { if (zZfrag.GetComponent <ZzfragView> ()._ZzFragModel.pieceType == ZzFragModel.PieceType.rectangle) { if ( mousePos.x > zZfrag.transform.position.x - (zZfrag.transform.lossyScale.x / 2) && mousePos.x < zZfrag.transform.position.x + (zZfrag.transform.lossyScale.x / 2) && mousePos.z > zZfrag.transform.position.z - (zZfrag.transform.lossyScale.y / 2) && //this is f****d, don't mess with it until total redo mousePos.z < zZfrag.transform.position.z + (zZfrag.transform.lossyScale.y / 2)) //of the view stuff { return(true); } } else //circle { if (Vector3.Distance(mousePos, zZfrag.transform.position) < zZfrag.transform.localScale.x / 2) { Debug.Log(Vector3.Distance(mousePos, zZfrag.transform.position) < zZfrag.transform.localScale.x); return(true); } } Debug.Log("mousePos : " + mousePos); Debug.Log("y " + zZfrag.transform.position.y); Debug.Log("y sub" + zZfrag.transform.lossyScale.y / 2); return(false); }
void placeUnit(WorldPosition mouseWP, Vector3 mouseVect) //VIEW BASED APPROACH { foreach (GameObject zoneObj in mapView.zonesDict.Keys) //currently non in here { Debug.Log(zoneObj); ZoneView zoneView = zoneObj.GetComponent <ZoneView> (); if (zoneView._zoneModel._party == currentParty) { foreach (GameObject zoneFragObj in mapView.zonesDict[zoneObj]) { ZzfragView zzFrag = zoneFragObj.GetComponent <ZzfragView> (); if (overLapszZ(zzFrag, mouseVect)) { UnitPrep unitPrep = _unitPrepManager.SpawnUnitPrep(currentUnit.Id, zoneView._zoneModel._alliance, mouseWP); StaticAllData.currentMap._formationUnits.Add(unitPrep); Debug.Log("unit placed attempt : " + currentUnit.Name + " " + mouseWP.ToString()); pickedUpUnit = false; break; } else { Debug.Log("didn't overlap with this zzfrag"); } } } } }