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");
                        }
                    }
                }
            }
        }
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && pickedUpUnit == true)
     {
         pickedUpUnit = false;
         Vector3       mouseVect = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10));
         WorldPosition mouseWP   = new WorldPosition(mouseVect.x * 3, mouseVect.z * 3);                //the *3 is to callibrate for the computer screen
         UnitPrep      unitPrep  = _unitPrepManager.SpawnUnitPrep(currentUnit.Id, currentAlliance, mouseWP);
         StaticMapCreateData._currentMap._preFormationUnits.Add(unitPrep);
         Debug.Log("unit placed : " + currentUnit.Name + " " + mouseWP.ToString());
     }
 }
Esempio n. 3
0
        public UnitPrep SpawnUnitPrep(string unitID, AllianceType alliance, WorldPosition position)
        {
            UnitPrep unit = _unitPrepFactory.Create(unitID, alliance, position);

            return(unit);
        }