示例#1
0
	public void LoadBlueprint (ProgramBlueprint blueprint)
	{

		antType = blueprint.antType;
		myAnts = blueprint.ants;

		foreach(Ant ant in myAnts){
			ant.SpawnPopup("YOU");
		}

		functions = new AntFunction[blueprint.availableFunctions.Length];
		for (int i = 0; i< blueprint.availableFunctions.Length; i++) {
			AntFunction func = new AntFunction ();
			func.LoadBlueprint (blueprint.availableFunctions [i]);
			functions [i] = func;
		}
	}
示例#2
0
	public void BuildUIFromBlueprint (ProgramBlueprint blueprint)
	{
		int numFunctions = blueprint.availableFunctions.Length;

		commandDock = GameObject.Instantiate (commandDockPrefab);
		commandDock.transform.SetParent (canvas.transform, false);
		commandDock.GetComponent<GridLayoutGroup> ().cellSize = Vector2.one * tileSize;


		//ADD BASIC ANT COMMANDS
		foreach (Command com in antCommands) {
			AddTileBankToCommandDock (com, commandDock, 0);
		}

		//ADD LOCAL FUNCTIONS
		for (int i = 1; i<localProgramManager.functions.Length; i++) {
			//if(!localProgramManager.functions[i].isGlobal){
			int arg = PlayerManager.Instance.localPlayer.playerNum * 10 + i;
			AddTileBankToCommandDock (Command.FUNCTION, commandDock, arg);
			//}
		}


		//ADD GLOBAL FUNCTIONS
		for (int i = 0; i<GameManager.Instance.programProfiles.Length; i++) {
			if (i != localProgramManager.GetComponent<Player> ().playerNum) {
				for (int j =0; j< GameManager.Instance.programProfiles[i].availableFunctions.Length; j++) {
					if (GameManager.Instance.programProfiles [i].availableFunctions [j].isGlobal) {
						int arg = i * 10 + j;
						AddTileBankToCommandDock (Command.FUNCTION, commandDock, arg);
					}
				}
			}
		}




		//ADD CLASS COMMANDS
		switch (localProgramManager.antType) {
		case AntType.FIRE:
			foreach (Command com in fireCommands) {
				AddTileBankToCommandDock (com, commandDock, 0);
			}
			break;
		case AntType.CARPENTER:
			foreach (Command com in carpenterCommands) {
				AddTileBankToCommandDock (com, commandDock, 0);
			}
			break;
		case AntType.WARRIOR:
			foreach (Command com in warriorCommands) {
				AddTileBankToCommandDock (com, commandDock, 0);
			}
			break;
		case AntType.SCOUT:
			foreach (Command com in scoutCommands) {
				AddTileBankToCommandDock (com, commandDock, 0);
			}
			break;
		case AntType.DEFAULT:
			break;

		case AntType.ALL:
			foreach (Command com in fireCommands) {
				AddTileBankToCommandDock (com, commandDock, 0);
			}
			foreach (Command com in carpenterCommands) {
				AddTileBankToCommandDock (com, commandDock, 0);
			}
			foreach (Command com in warriorCommands) {
				AddTileBankToCommandDock (com, commandDock, 0);
			}
			foreach (Command com in scoutCommands) {
				AddTileBankToCommandDock (com, commandDock, 0);
			}
			break;
		default:
			break;
		}


		for (int i = 0; i< numFunctions; i++) {
			Text funcTitle = GameObject.Instantiate (textPrefab) as Text;
			funcTitle.text = blueprint.availableFunctions [i].funcName;
			funcTitle.transform.SetParent (functionsPanel.transform, false);
			GameObject func = GameObject.Instantiate (functionZonePrefab);
			functionZones.Add (func.GetComponent<FunctionZone> ());
			func.transform.SetParent (functionsPanel.transform, false);
			func.GetComponent<FunctionZone> ().Init (localProgramManager, blueprint.availableFunctions [i].numSlots, i);
			func.GetComponent<GridLayoutGroup> ().cellSize = Vector2.one * tileSize;
		}

		Rect playRect = playHead.GetComponent<RectTransform> ().rect;
		playRect.width = tileSize;
		playRect.height = tileSize;
		playHead.GetComponent<RectTransform> ().sizeDelta = Vector2.one * tileSize;
		playHead.AddSlot (functionZones [0].GetSlot (0));
		playHead.SetHome (functionZones [0].GetSlot (0));
	
	}