Ejemplo n.º 1
0
    void Custom(GameObject nowObj, sCharInfo charInfo) //정보에 따라 캐릭터를 커스텀하는 함수
    {
        HeroCustomize       custom = nowObj.GetComponent <HeroCustomize>();
        AnimationController aniMgr = nowObj.GetComponent <AnimationController>();
        string genderStr           = "";

        if (charInfo.gender == 1)
        {
            genderStr = "Male";
        }
        else if (charInfo.gender == 2)
        {
            genderStr = "Female";
        }
        custom.Gender = genderStr;
        custom.IndexWeapon.CurrentType     = charInfo.weapon;
        custom.IndexWeapon.CurrentIndex    = 5;
        custom.IndexSuit.CurrentIndex      = charInfo.armor;
        custom.IndexHair.CurrentIndex      = charInfo.hair;
        custom.IndexColorHair.CurrentIndex = charInfo.hairColor;
        custom.IndexFace.CurrentIndex      = charInfo.face;
        custom.UpdateVisual();
        custom.UpdateWeapon();
        aniMgr.weaponIndex = charInfo.weapon; //무기에 따른 애니메이션도 설정
    }
Ejemplo n.º 2
0
    private void Update()
    {
        if (matchingImg == null && SceneManager.GetActiveScene().name == "WaitScene")
        {
            matchingImg = GameObject.Find("WinCanvas/MatchingImg");
            matchingImg.SetActive(false);
        }

        if (matchingImg != null && matchingImg.activeSelf == false) //매칭중이라는 이미지 띄우기
        {
            matchingImg.SetActive(matchActive);
        }

        if (matchSuccess == true) //매칭이 성공되었을 때
        {
            matchSuccess = false;
            MSGWin.SetActive(true);
            MSGWin.GetComponentInChildren <Text>().text = "대전으로 입장합니다.";
            MSGWin.transform.GetChild(1).gameObject.SetActive(false);
            int gender = 0;
            if (heroCustomize.Gender.Equals("Male"))
            {
                gender = (int)eGENDER.MALE;
            }
            else if (heroCustomize.Gender.Equals("Female"))
            {
                gender = (int)eGENDER.FEMALE;
            }
            savCharInfo = new sCharInfo(0, 0, gender, heroCustomize.IndexHair.CurrentIndex,
                                        heroCustomize.IndexColorHair.CurrentIndex, heroCustomize.IndexFace.CurrentIndex, -1, -1, -1);

            StartCoroutine(GameStartDelay());
        }
    }
Ejemplo n.º 3
0
 public void SpawnInfo(string playerParent, string enemyParent, sCharInfo charInfo)
 { //스폰될 정보를 받아오는 함수
     playerPname = playerParent;
     enemyPname  = enemyParent;
     enemyInfo   = charInfo;
 }
Ejemplo n.º 4
0
    private static void ReceiveCallBack(IAsyncResult ar)    //서버에게 신호를 받았을 때
    {
        RecvData recvData = (RecvData)ar.AsyncState;        //리시브된 데이터
        int      receive  = recvData.socket.EndReceive(ar); //리시브된 정보가 있는지 체크

        if (receive <= 0)                                   //서버 종료
        {
            recvData.socket.Close();                        //소켓을 닫음
            Application.Quit();
            return;
        }
        IntPtr buff = Marshal.AllocHGlobal(recvData.buffer.Length); //받은 byte 데이터를 struct로 변환

        Marshal.Copy(recvData.buffer, 0, buff, recvData.buffer.Length);
        Type type = typeof(sGameRoom);

        room = (sGameRoom)Marshal.PtrToStructure(buff, type);

        if (room.flag == (int)eMSG.em_LOGIN)
        {
            Type   m_type    = typeof(sLogin);
            sLogin loginInfo = (sLogin)Marshal.PtrToStructure(buff, m_type);
            userScript.LoginResult(loginInfo.nick, loginInfo.loginSucc);
        }
        else if (room.flag == (int)eMSG.em_LOGINCHECK)
        {
            Type        m_type   = typeof(sLoginCheck);
            sLoginCheck loginChk = (sLoginCheck)Marshal.PtrToStructure(buff, m_type);
            fScript.FriendAccCheck(loginChk.nick, loginChk.loginChk);
        }
        else if (room.flag == (int)eMSG.em_MATCHREQUEST)
        {
            Type      m_type   = typeof(sMatchReq);
            sMatchReq matchReq = (sMatchReq)Marshal.PtrToStructure(buff, m_type);
            fScript.MatchReqResult(matchReq.sendUserNick, matchReq.matchSucc);
        }
        else if (room.flag == (int)eMSG.em_ENTER) //매칭 버튼을 눌렀다는 정보
        {
            if (room.userNum == 0)                //상대가 없음
            {
                gScript.Matching();
            }
            else //상대가 접속
            {
                enterNum = room.userNum;
                gScript.MatchSucc();
            }
        }
        else if (room.flag == (int)eMSG.em_CHARINFO) //아이템 선택이 끝났다는 정보
        {
            Type      m_type   = typeof(sCharInfo);
            sCharInfo charInfo = (sCharInfo)Marshal.PtrToStructure(buff, m_type);
            if (enterNum == 1) //내가 먼저 입장
            {
                sScript.SpawnInfo("Spawn1", "Spawn2", charInfo);
            }
            else if (enterNum == 2) //상대가 먼저 입장
            {
                sScript.SpawnInfo("Spawn2", "Spawn1", charInfo);
            }
        }
        else if (room.flag == (int)eMSG.em_READY) //두 유저 모두 준비되었다는 정보
        {
            sScript.SpawnReady();
        }
        else if (eScript != null && room.flag == (int)eMSG.em_MOVE) //적의 좌표, 회전 정보
        {
            Type       m_type   = typeof(sMove);
            sMove      move     = (sMove)Marshal.PtrToStructure(buff, m_type);
            Vector3    enemyPos = new Vector3(move.x, move.y, move.z);
            Quaternion enemyRot = new Quaternion(move.rotX, move.rotY, move.rotZ, move.rotW);
            eScript.EnemyMove(enemyPos, enemyRot);
        }
        else if (room.flag == (int)eMSG.em_ATK) //적이 공격했다는 정보
        {
            Type m_type = typeof(sAtk);
            sAtk atk    = (sAtk)Marshal.PtrToStructure(buff, m_type);
            eScript.EnemyAtk(atk.atkAni);
        }
        else if (room.flag == (int)eMSG.em_HIT) //내가 공격을 성공함
        {
            Type m_type = typeof(sHit);
            sHit hit    = (sHit)Marshal.PtrToStructure(buff, m_type);
            pScript.ChangePlayerHp(hit.hp);
            pScript.PlayerDamage(hit);
        }
        else if (room.flag == (int)eMSG.em_INFO) //적의 hp정보가 변한경우
        {
            Type        m_type = typeof(sChangeInfo);
            sChangeInfo hpInfo = (sChangeInfo)Marshal.PtrToStructure(buff, m_type);
            eScript.ChangeEnemyHp(hpInfo.hp);
        }
        else if (room.flag == (int)eMSG.em_ITEMSPAWN)
        {
            Type       m_type    = typeof(sItemSpawn);
            sItemSpawn itemSpawn = (sItemSpawn)Marshal.PtrToStructure(buff, m_type);
            pScript.passOnItemSpawnInfo(itemSpawn.itemKind);
            pScript.GetAtkMgrFromServer(true);
        }
        else if (room.flag == (int)eMSG.em_USEITEM) //아이템 사용
        {
            Type     m_type  = typeof(sUseItem);
            sUseItem useItem = (sUseItem)Marshal.PtrToStructure(buff, m_type);
            pScript.ChangeItemImg(useItem.itemNum, true);
            pScript.ChangePlayerHp(useItem.hp);
            pScript.ChangePlayerSpeed(useItem.speed);
        }
        else if (room.flag == (int)eMSG.em_ENDITEM) //아이템 시간 끝
        {
            Type     m_type  = typeof(sEndItem);
            sEndItem endItem = (sEndItem)Marshal.PtrToStructure(buff, m_type);
            pScript.ChangeItemImg(endItem.itemNum, false);
            pScript.ChangePlayerSpeed(endItem.speed);
        }
        else if (room.flag == (int)eMSG.em_GETOBJ) //던질 물건 잡기
        {
            Type    m_type = typeof(sGetObj);
            sGetObj getObj = (sGetObj)Marshal.PtrToStructure(buff, m_type);
            Debug.Log("from server get succ");
            eScript.GetThrowObj(getObj.itemNum);
        }
        else if (room.flag == (int)eMSG.em_THROWOBJ) //물건 던지기
        {
            eScript.ThrowObj();
            Debug.Log("from server throw succ");
        }
        else if (room.flag == (int)eMSG.em_END) //게임이 종료되었을 경우
        {
            Type m_type = typeof(sEnd);
            sEnd esc    = (sEnd)Marshal.PtrToStructure(buff, m_type);
            gameResult = esc.result;
            enemyNick  = esc.enemyNick;
            if (pScript == null)
            {
                sScript.GameEndTrue();
            }
            else
            {
                pScript.GameEndTrue();
            }
        }
        else if (room.flag == (int)eMSG.em_CHAT) //채팅
        {
            Type   m_type  = typeof(sChat);
            sChat  chat    = (sChat)Marshal.PtrToStructure(buff, m_type);
            string nowChat = new string(chat.chat);
            chatScript.ChatRecv(nowChat);
        }
    }