public void AddInputWidget(Job job, Transform target)
    {
        UI_Input uiInput = Instantiate(inputPrefab, transform).GetComponent <UI_Input>();

        uiInput.jobReference = job;
        uiInput.Init(target);
    }
	void Start ()
	{
		stepCounter = 0;
		gData = GameObject.FindGameObjectWithTag ("GlobalData").GetComponent<GlobalData> ();
		sceneGen = GameObject.FindGameObjectWithTag ("GameController").GetComponent<SceneGen> ();
		uiInput = GameObject.FindGameObjectWithTag ("GameController").GetComponent<UI_Input> ();
	}
Exemple #3
0
    void Start()
    {
        gData = GameObject.FindGameObjectWithTag ("GlobalData").GetComponent<GlobalData> ();

        if (!gData.victory) {

        }

        blockX = groundPrefabs [0].GetComponent<SpriteRenderer> ().bounds.size.x * 15 / 16;
        blockY = groundPrefabs [0].GetComponent<SpriteRenderer> ().bounds.size.y * 15 / 16;

        enemyTypes = new List<Enemy> ();
        currentSceneInfo = new SceneInfo ();
        ablePos = new List<Vector3> ();
        addedPos = new List<Vector3> ();
        blockList = new List<GameObject> ();
        itemList = new List<GameObject> ();
        enemyList = new List<GameObject> ();
        digList = new List<GameObject> ();
        blockData = new List<ElementData> ();
        itemData = new List<ElementData> ();
        enemyData = new List<ElementData> ();
        digData = new List<ElementData> ();
        genPos = new Vector3 (0, 0, 0);

        int currentFloor = gData.currentFloor;
        int scenesNum = gData.currentTomb.sceneList.Count;

        //根据KEY从服务器加载物品掉落列表
        //返回挖掘掉落,敌人掉落,棺材掉落列表(key: tombLevel_currentFloor)
        fallList = getFallList (gData.currentTomb.tombLevel + "_" + gData.currentFloor);
        getEnemyTypes (gData.currentTomb.tombLevel + "_" + gData.currentFloor);

        digPrefab = Resources.Load ("Dig", typeof(GameObject)) as GameObject;
        digSide = digPrefab.GetComponent<SpriteRenderer> ().bounds.size.x;
        playerSide = player.GetComponent<SpriteRenderer> ().bounds.size.x;
        uiInput = GameObject.FindGameObjectWithTag ("GameController").GetComponent<UI_Input> ();

        preEntryPrefab = Resources.Load ("PreEntry", typeof(GameObject)) as GameObject;
        coffinPrefab = Resources.Load ("Coffin", typeof(GameObject)) as GameObject;

        //不论是新的场景或是原来保存的场景,通往上一层的入口的位置总是在玩家(0,0,0)的位置,所以这个数据不用保存到全局数据的场景数据里
        //在玩家位置生成上一层入口,由于该位置处不应该有敌人或场景物品,所以放在其他元素之前生成
        Instantiate (preEntryPrefab, player.position, Quaternion.identity);

        if (scenesNum >= currentFloor) {
            GenerateSceneFromSceneInfo (gData.currentTomb.sceneList [currentFloor - 1]);
        } else {
            //生成场景
            GenerateSceneRandom ();
        }

        //场景信息
        Transform sceneInfoUI = GameObject.FindGameObjectWithTag ("UI").transform.FindChild ("SceneInfo");
        sceneInfoUI.FindChild ("TombName").GetComponent<Text> ().text = gData.currentTomb.tombName;
        sceneInfoUI.FindChild ("FloorLable").GetComponent<Text> ().text = StringCollection.FLOOR;
        sceneInfoUI.FindChild ("Floor").GetComponent<Text> ().text = gData.currentFloor.ToString ();

        //自动上传当前记录
    }