Ejemplo n.º 1
0
	public static void StartPlacingDemand (string name) {
		//TODO
		//Debug.Log ("Demand: " + name);

		currentDemand = name;
		
		state = editingState.demands;
	}
Ejemplo n.º 2
0
	// Update is called once per frame
	void Update () {
		//mouse
		Vector3 pz = Camera.main.ScreenToWorldPoint(Input.mousePosition);
		pz.z = 0;
		if (useGrid && state == editingState.planets) {
			pz.x = (int)pz.x;
			pz.y = (int)pz.y;
		}
		if (underCursor != null) {
			underCursor.transform.position = pz;
		}

		//right click escapes
		if (Input.GetMouseButton (1)) {
			GameObject.Destroy (currentlyPlacing);
			GameObject.Destroy (underCursor);
			End ();
		}

		switch (state) {
		case editingState.planets:
			if (Input.GetMouseButton (0)) {
				if (currentlyTyped != null) {
					var pd = new PlacementDetails (currentlyTyped, currentlyPlacing.transform.position);
					pd.thePlanetGob = currentlyPlacing;
					record.Add (pd);
				}
				currentlyPlacing = null;
				currentlyTyped = null;
				underCursor = null;
				state = editingState.none;
			}
			break;
		case editingState.vine:
			//TODO stretch
			if (vineEnd1 != null) {
				Vector3 end2 = Vector3.zero;
				if (vineEnd2 != null)
					end2 = vineEnd2.transform.position;
				else 
					end2 = pz;
				FlowerDragManager.PlaceVine (vineEnd1.transform.position, end2, vine);
			}

			if (Input.GetMouseButtonDown (0) && currentPlanetByMouse != null) {
				if (vineEnd1 == null) {
					//Debug.Log ("Vine1");
					vineEnd1 = currentPlanetByMouse;
					
					vine.gameObject.transform.SetAsFirstSibling ();
					//startPos = flo.gameObject.transform.parent.position;
				} else if (currentPlanetByMouse != vineEnd1) {
					//Debug.Log ("Vine2");
					vineEnd2 = currentPlanetByMouse;
					
					//record vine
					PlacementDetails p1 = null;
					PlacementDetails p2 = null;
					foreach (var p in record) {
						if (p.thePlanetGob == currentPlanetByMouse.gameObject)
							p1 = p;
						if (p.thePlanetGob == vineEnd1.gameObject)
							p2 = p;
					}
					if (p1 != null && p2 != null)
						p1.AddVineNeighbor (p2);
					else
						Debug.Log ("Vine recording problem: " + p1 + "-" + p2);

					//straighten out the end
					Vector3 end2 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
					FlowerDragManager.PlaceVine (vineEnd1.transform.position, end2, vine);

					//end
					vineEnd1 = null;
					vineEnd2 = null;
					vine = null;
					state = editingState.none;
					currentlyPlacing = null;
					underCursor = null;
				}
			}
			break;
		case editingState.flower:
			if (Input.GetMouseButtonDown (0) && currentPlanetByMouse != null) {
				//give the planet a flower
				//record flower
				foreach (var p in record) {
					if (p.thePlanetGob == currentPlanetByMouse.gameObject)
						p.hasFlower = true;
				}

				End ();
			}
			break;
		case editingState.demands:
			if (Input.GetMouseButtonDown (0) && currentPlanetByMouse != null && currentDemand != "") {
				//TODO record demand
				//Debug.Log ("Adding demand: "+ currentDemand);
				currentPlanetByMouse.hasDemands.AddDemand (currentDemand, false, false);
			}
			break;
		}
	}
Ejemplo n.º 3
0
	public static void StartPlacingVine (string name) {
		//Debug.Log ("Vine: " + name);

		vine = GameObject.Instantiate (Resources.Load <GameObject> ("Vine"));
		underCursor = vine;

		state = editingState.vine;
	}
Ejemplo n.º 4
0
	public static void StartPlacingFlower (string name) {
		//Debug.Log ("Flower: " + name);

		flower = GameObject.Instantiate (Resources.Load <GameObject> ("Flower2D")) as GameObject;
		underCursor = flower;

		Debug.Log (flower);
		
		state = editingState.flower;
	}
Ejemplo n.º 5
0
	public static void StartPlacingSeedizen (string name) {
		//TODO
		Debug.Log ("Seedizen: " + name);
		
		state = editingState.seedizens;
	}
Ejemplo n.º 6
0
	public static void StartPlacingPlanet (string name) {
		PlanetType pt = new PlanetType (name);

		currentlyPlacing = pt.GetInstance ();
		currentlyTyped = pt;
		underCursor = currentlyPlacing;
		currentlyPlacing.AddComponent <HasDemands> ().startWithNoDemands = true;

		state = editingState.planets;
	}
Ejemplo n.º 7
0
	void End () {
		state = editingState.none;
		currentlyPlacing = null;
		currentlyTyped = null;
		underCursor = null;
		vineEnd1 = null;
		vineEnd2 = null;
		vine = null;
		currentDemand = "";
	}