Beispiel #1
0
    static public void ChangeCharTransform(string strName, CharForWhat eForWhat = CharForWhat.eInterior)
    {
        GameObject   cMainChar = GameObject.Find(strName);
        SceneManager mgr       = Singlton.getInstance("SceneManager") as SceneManager;
        Vector3      posTemp   = posCharPos[(int)eForWhat];

        if (eForWhat == CharForWhat.eDresser && mgr.cShareData.eUserSex == CharSex.eMan)
        {
            posTemp.y -= 0.25f;
        }

        cMainChar.transform.localPosition = posTemp;
        cMainChar.transform.localScale    = scaCharSca[(int)eForWhat];

        DcCharAnim cCharAnim = cMainChar.GetComponent(typeof(DcCharAnim)) as DcCharAnim;

        if (cCharAnim)
        {
            if (eForWhat == CharForWhat.eDresser)
            {
                //cCharAnim.PlayIdle();
                //cCharAnim.bIsAutoPlaySpecialIdle = false;
            }
            else
            {
                //cCharAnim.bIsAutoPlaySpecialIdle = true;
                //cCharAnim.PlaySpecialIdle();
            }
        }
    }
    void Start()
    {
        SceneManager mgr      = Singlton.getInstance("SceneManager") as SceneManager;
        GameObject   cCharObj = DcGlobalFunc.CreateChar(mgr.cShareData.eUserSex, CharModel.eOne, CharForWhat.eDancingMain, false);

        cMainChar = cCharObj.GetComponent(typeof(DcCharAnim)) as DcCharAnim;

        if (mgr.cShareData.nDancingEntranceType == 2)
        {
            if (mgr.cShareData.cCurRoomData.litPeopleSex.Count >= 1)
            {
                cCharObj = DcGlobalFunc.CreateChar(mgr.cShareData.cCurRoomData.litPeopleSex[0] == 0 ? CharSex.eMan : CharSex.eWoman,
                                                   mgr.cShareData.cCurRoomData.litPeopleSex[0] == 0 ? CharModel.eOne : CharModel.eTwo,
                                                   CharForWhat.eDancingLeft, false, false);
            }
        }
        else
        {
            cCharObj = DcGlobalFunc.CreateChar(mgr.cShareData.eUserSex == CharSex.eMan ? CharSex.eWoman : CharSex.eMan,
                                               CharModel.eOne, CharForWhat.eDancingLeft, false, false);
        }
        cCostar[0] = cCharObj.GetComponent(typeof(DcCharAnim)) as DcCharAnim;

        if (mgr.cShareData.nDancingEntranceType == 2)
        {
            if (mgr.cShareData.cCurRoomData.litPeopleSex.Count >= 2)
            {
                cCharObj = DcGlobalFunc.CreateChar(mgr.cShareData.cCurRoomData.litPeopleSex[1] == 0 ? CharSex.eMan : CharSex.eWoman,
                                                   mgr.cShareData.cCurRoomData.litPeopleSex[1] == 0 ? CharModel.eOne : CharModel.eTwo,
                                                   CharForWhat.eDancingRight, false, false);
            }
        }
        else
        {
            cCharObj = DcGlobalFunc.CreateChar(CharSex.eWoman, CharModel.eTwo, CharForWhat.eDancingRight, false, false);
        }
        cCostar[1] = cCharObj.GetComponent(typeof(DcCharAnim)) as DcCharAnim;

        posCurMainCharPos = cMainChar.transform.localPosition;
    }
    void Start()
    {
        SceneManager mgr = Singlton.getInstance("SceneManager") as SceneManager;
        GameObject cCharObj = DcGlobalFunc.CreateChar(mgr.cShareData.eUserSex,CharModel.eOne,CharForWhat.eDancingMain,false);
        cMainChar = cCharObj.GetComponent(typeof(DcCharAnim)) as DcCharAnim;

        if(mgr.cShareData.nDancingEntranceType == 2)
        {
            if(mgr.cShareData.cCurRoomData.litPeopleSex.Count >= 1)
            {
                cCharObj = DcGlobalFunc.CreateChar(mgr.cShareData.cCurRoomData.litPeopleSex[0] == 0 ? CharSex.eMan : CharSex.eWoman,
                                                    mgr.cShareData.cCurRoomData.litPeopleSex[0] == 0 ? CharModel.eOne : CharModel.eTwo,
                                                    CharForWhat.eDancingLeft,false,false);
            }
        }
        else
        {
            cCharObj = DcGlobalFunc.CreateChar(mgr.cShareData.eUserSex == CharSex.eMan ? CharSex.eWoman : CharSex.eMan,
                                            CharModel.eOne,CharForWhat.eDancingLeft,false,false);
        }
        cCostar[0] = cCharObj.GetComponent(typeof(DcCharAnim)) as DcCharAnim;

        if(mgr.cShareData.nDancingEntranceType == 2)
        {
            if(mgr.cShareData.cCurRoomData.litPeopleSex.Count >= 2)
            {
                cCharObj = DcGlobalFunc.CreateChar(mgr.cShareData.cCurRoomData.litPeopleSex[1] == 0 ? CharSex.eMan : CharSex.eWoman,
                                                    mgr.cShareData.cCurRoomData.litPeopleSex[1] == 0 ? CharModel.eOne : CharModel.eTwo,
                                                    CharForWhat.eDancingRight,false,false);
            }
        }
        else
        {
            cCharObj = DcGlobalFunc.CreateChar(CharSex.eWoman,CharModel.eTwo,CharForWhat.eDancingRight,false,false);
        }
        cCostar[1] = cCharObj.GetComponent(typeof(DcCharAnim)) as DcCharAnim;

        posCurMainCharPos = cMainChar.transform.localPosition;
    }
Beispiel #4
0
    static public GameObject CreateChar(CharSex eSex         = CharSex.eWoman,
                                        CharModel eModel     = CharModel.eOne,
                                        CharForWhat eForWhat = CharForWhat.eInterior,
                                        bool bNeedCollider   = false,
                                        bool bNeedLight      = true)
    {
        GameObject cGO       = Resources.Load("player/Char/" + strPrefabName[(int)eSex, (int)eModel]) as GameObject;
        GameObject cMainChar = Utility.Instantiate(cGO) as GameObject;

        cMainChar.name            = cGO.name + (++nNameSerial).ToString();
        strCurMainCharGameObjName = cMainChar.name;

        ChangeCharTransform(strCurMainCharGameObjName, eForWhat);

        if (eForWhat == CharForWhat.eDancingLeft)
        {
            cMainChar.transform.Rotate(new Vector3(0, 160, 0));
        }
        else if (eForWhat == CharForWhat.eDancingRight)
        {
            cMainChar.transform.Rotate(new Vector3(0, -160, 0));
        }
        else
        {
            cMainChar.transform.Rotate(new Vector3(0, 180, 0));
        }

        if ((int)eForWhat <= (int)CharForWhat.eWaitingRoomRight)
        {
            cMainChar.AddComponent <DcCharacterShadow>();
            DcCharAnim cCharAnim = cMainChar.GetComponent(typeof(DcCharAnim)) as DcCharAnim;
            if (cCharAnim)
            {
                //cCharAnim.bIsAutoPlaySpecialIdle = true;
            }
        }

        if (bNeedCollider)
        {
            cMainChar.layer = LayerMask.NameToLayer("GameUILayout");
            for (int i = 0; i < cMainChar.transform.childCount; i++)
            {
                GameObject child = cMainChar.transform.GetChild(i).gameObject;
                child.layer = LayerMask.NameToLayer("GameUILayout");
            }
            BoxCollider cBoxColl = cMainChar.AddComponent <BoxCollider>();
            //BoxCollider cBoxColl = gameObject.GetComponent<BoxCollider>();
            if (eSex == CharSex.eMan)
            {
                cBoxColl.center = new Vector3(0, 34.8f, 0);
                cBoxColl.size   = new Vector3(20f, 72.1f, 15f);
            }
            else
            {
                cBoxColl.center = new Vector3(0, 30.7f, 0);
                cBoxColl.size   = new Vector3(20f, 62.7f, 15f);
            }
        }
        else
        {
            cMainChar.layer = LayerMask.NameToLayer("Default");
            for (int i = 0; i < cMainChar.transform.childCount; i++)
            {
                GameObject child = cMainChar.transform.GetChild(i).gameObject;
                child.layer = LayerMask.NameToLayer("Default");
            }
        }

        if (bNeedLight)
        {
            GameObject cL = GameObject.Find("DirLight");
            if (!cL)
            {
                cGO = Resources.Load("player/Light/DirLight") as GameObject;
                GameObject cDirLight = Utility.Instantiate(cGO) as GameObject;
                cDirLight.name = cGO.name;
            }
        }

        return(cMainChar);
    }