示例#1
0
    public void createCharacters(loadCharacters characters)
    {
        int length = characters.names.Length;
        List <List <Equip> > equips = (List <List <Equip> >)Tools.byteArrayToObject(characters.itemsEquip);
        List <string[]>      colors = (List <string[]>)Tools.byteArrayToObject(characters.colorScheme);

        Debug.Log("Equips size:" + equips.Count);
        for (int i = 0; i < length; i++)
        {
            GameObject   child = (GameObject)Instantiate(playerModel, Vector3.zero, Quaternion.identity);
            GameObject[] skin  = Tools.getChildren(child.transform.GetChild(1).gameObject, "BodyModel", "HeadModel");
            GameObject[] eyes  = Tools.getChildren(child.transform.GetChild(1).gameObject, "Eye_L_Model", "Eye_R_Model");
            setSkinColor(skin, colors[i][2]);
            setEyeColor(eyes, colors[i][1]);
            child.transform.SetParent(this.charSelect.transform.GetChild(i));
            child.transform.localPosition = Vector3.zero;
            this.charSelect.transform.GetChild(i).transform.localRotation = Quaternion.Euler(0, 135, 0);
            PickCharacter pickChar = this.charSelect.transform.GetChild(i).GetChild(0).gameObject.AddComponent <PickCharacter>();
            pickChar.name = characters.names[i];
            pickChar.setLogin(this);
            equipItems(equips[i], pickChar);
            this.gameObject.transform.parent.GetComponent <RectTransform>().localPosition = new Vector3(1200, 0, 0);
            this.charSelect.transform.GetChild(i).GetChild(0).GetChild(0).gameObject.GetComponent <TextMesh>().text = characters.names[i];
            pickChar.camera = camera.gameObject.GetComponent <Camera>();
        }
        for (int i = length; i < this.charSelect.transform.childCount; i++)
        {
            GameObject child = (GameObject)Instantiate(signModel, Vector3.zero, Quaternion.identity);
            child.transform.SetParent(this.charSelect.transform.GetChild(i));
            child.transform.localPosition = new Vector3(0, -3, 0);
            child.transform.localRotation = Quaternion.Euler(0, -108, 0);
            child.transform.localScale    = new Vector3(0.7f, 0.7f, 0.7f);
            this.charSelect.transform.GetChild(i).transform.localRotation = Quaternion.Euler(0, 135, 0);
            CreateCharacter charCreate = this.charSelect.transform.GetChild(i).GetChild(0).gameObject.AddComponent <CreateCharacter>();
            charCreate.setCamera(this.camera);
            charCreate.setCharacter(this.charCreate, playerModel);
            charCreate.setUI(createCharacterUI);
        }
    }