Exemplo n.º 1
0
    TextPrint_Chara FindChara(string _charaName)
    {
        for (int i = 0; i < charaList.Count; i++)
        {
            if (charaList[i].charaName == _charaName)
            {
                if (!charaList[i].firstUse)
                {
                    charaList[i].firstUse = true;
                }
                return(charaList[i]);
            }
        }

        Debug.Log(_charaName + " (이)라는 이름을 가진 캐릭터 객체가 없어 따로 생성합니다...");

        GameObject newObj = Instantiate(origChara.gameObject, Vector3.zero, Quaternion.identity);

        newObj.name = "[" + _charaName + "]";
        newObj.transform.localScale = new Vector3(1, 1, 1);
        newObj.transform.SetParent(charaParent.transform);
        TextPrint_Chara newChara = newObj.GetComponent <TextPrint_Chara>();

        newChara.charaName = _charaName;
        charaList.Add(newChara);

        return(newChara);
    }
Exemplo n.º 2
0
    void FaceImgSet(CharacterImg _character, string _faceName, int _pos)
    {
        CharacterImg.CharaFace nowChara = new CharacterImg.CharaFace();
        Sprite faceSprite = _character.faceList[0].faceImg;

        //아무런 스프라이트가 없을 경우, 기본적으로 0번에 있는 face를 리턴.
        for (int i = 0; i < _character.faceList.Count; i++)
        {
            nowChara = _character.faceList[i];
            if (nowChara.name == _faceName)
            {
                faceSprite = nowChara.faceImg;
                break;
            }
        }

        if (faceSprite == null)
        {
            Debug.LogWarning(_character.name + "라는 이름의 캐릭터도, "
                             + _faceName + "라는 페이스 이미지도 없습니다.");
            return;
        }

        TextPrint_Chara targetChara = FindChara(_character.name);

        if (targetChara == null)
        {
            return;                      //버그방지용
        }
        targetChara.ChangeImg(faceSprite);
        targetChara.img.SetNativeSize();
        if (!targetChara.firstUse && _pos == 999)
        {
            _pos = 0;
        }
        NoDupliLocation(_pos, targetChara.charaName);
        Vector3 nextPos = charaImgPos.GetPosition(_pos);

        if (nextPos != new Vector3(999, 999)) //Vector3 999, 999는 위치값이 존재하지 않다는 뜻
        {
            targetChara.ChangeTransform(_pos, nextPos);
        }
        targetChara.transform.position = new Vector3(targetChara.transform.position.x + nowChara.facePos.x,
                                                     targetChara.transform.position.y + nowChara.facePos.y,
                                                     targetChara.transform.position.z);
        targetChara.transform.localScale = new Vector3(
            nowChara.faceScale.x * (nowChara.faceFlipX ? -1 : 1) * (_pos < 0 ? -1 : 1),
            nowChara.faceScale.y, 1);

        for (int i = 0; i < charaList.Count; i++)
        {
            if (charaList[i] == targetChara)
            {
                charaList[i].ImgEffect();
            }
            else
            {
                charaList[i].ImgEffect(Mathf.Abs(charaList[i].nowPos) + 1);
            }
        }
    }