Ejemplo n.º 1
0
	// Update is called once per frame
	void Update () {
        if (selected != RPSKind.None)
            return; //선택 됬으므로 아무것도 하지 않는다


        RPSPanel[] panels = transform.GetComponentsInChildren<RPSPanel>();
        foreach(RPSPanel p in panels)
        {
            if (p.IsSelected())
            {
                selected = p.rpsKind;
                Debug.Log("Clickedrps");
                Debug.Log(selected);

              
            }

        }

        if(selected!=RPSKind.None)
        {
            foreach (RPSPanel p in panels)
                p.ChangeSelectedState();
        }
	}
Ejemplo n.º 2
0
    //
    public void Setup(RPSKind kind0, RPSKind kind1) {
        //선택된 가위바위보를 표시하고 싶을 때는 여기서 Instantiate합니다.
        ////캐릭터가 가위바위보 간판을 들고 있게 되어 현재는 사용하지 않습니다.

        //Debug.Log(kind0.ToString());
        //Debug.Log(kind1.ToString());
        //Debug.Log("BattleSelect Setup");
    }
Ejemplo n.º 3
0
    public void SendRPSData(RPSKind rpsKind)
    {
        // 구조체를 byte배열로 변환합니다.
        byte[] data = new byte[1];
        data[0] = (byte)rpsKind;

        // 데이터를 송신합니다.
        network.Send(data, data.Length);
    }
Ejemplo n.º 4
0
    RPSKind m_selected; //가위바위보 선택.

    // Use this for initialization
    void Start() {
        m_selected = RPSKind.None;

        string[] names = { "Daizuya", "Toufuya" };
        foreach (string n in names) {
            GameObject player = GameObject.Find(n);
            player.GetComponent<Player>().ChangeAnimation(Player.Motion.RPSInputWait);
        }
    }
Ejemplo n.º 5
0
    bool m_actionSoundEnable;  //액션의 효과음이 유효하면 true. (대미지 시는 서로 OFF로 되어 있을 것).

    void Awake() {
        GetComponent<AudioSource>().clip = m_landingSE;
        GetComponent<AudioSource>().PlayDelayed(0.2f); //착지음을 늦게 재생시킨다.

        m_currentMotion = Motion.In;
        m_anim = GetComponentInChildren<Animation>();

        m_rps = RPSKind.None;
        m_opponentRps = RPSKind.None;
        m_damage = 0;
        m_actionEffectEnable = false;
        m_actionSoundEnable = false;
    }
Ejemplo n.º 6
0
    //가위바위보 승패를 구합니다.
    public static Winner GetRPSWinner(RPSKind server, RPSKind client) {
        // 1P와 2P의 수를 수치화합니다.
        int serverRPS = (int)server;
        int clientRPS = (int)client;

        if (serverRPS == clientRPS) {
            return Winner.Draw; //무승부.
        }

        // 수치의 차이를 이용해 처리 판정을 합니다.
        if (serverRPS == (clientRPS + 1) % 3) {
            return Winner.ServerPlayer;  //1P 승리.
        }
        return Winner.ClientPlayer; //2P 승리.
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update(){
        if(m_selected != RPSKind.None){
            return;     //선택됐으므로 아무 것도 하지 않습니다.
        }

        RPSPanel[] panels = transform.GetComponentsInChildren<RPSPanel>();
        foreach (RPSPanel p in panels) {
            if (p.IsSelected()) {   // 선택이 끝난 패널이 있다.
                m_selected = p.m_rpsKind;
            }
        }

        if (m_selected != RPSKind.None) {
            //각 패널을 선택 후의 연출로 변경.
            foreach (RPSPanel p in panels) {
                p.ChangeSelectedState();
            }
        }
    }
Ejemplo n.º 8
0
        public static Winner GetRPSWinner(RPSKind my, RPSKind opp)
        {
            // 1P와 2P의 수를 수치화합니다.
            int myRPS = (int)my;
            int oppRPS = (int)opp;

            Debug.Log(myRPS + " 데이터  " + oppRPS);

            if (myRPS == oppRPS)
            {
                return Winner.Draw; //무승부.
            }

            // 수치의 차이를 이용해 처리 판정을 합니다.
            if (myRPS == (oppRPS + 1) % 3)  //내가 바위이고 상대가 가위이면 +1하고 3으로 나머지하면 0이 나오므로 같아지므로 상대가 지게됨
            {
                return Winner.Win;  //내가 승리
            }
            return Winner.Loss; //내가짐
        }
Ejemplo n.º 9
0
    // 가위바위보 수신 함수
    public RPSKind ReceiveRPSData()
    {
#if EMURATE_INPUT
        return(RPSKind.Rock);;           //디버그 중엔 접속한 거로 위장합니다.
#endif

        byte[] data = new byte[1024];

        // 데이터를 수신합니다.
        int recvSize = m_network.Receive(ref data, data.Length);
        if (recvSize < 0)
        {
            // 입력 정보를 수신하지 않음.
            return(RPSKind.None);
        }

        // byte 배열을 구조체로 변환합니다.
        RPSKind rps = (RPSKind)data[0];

        return(rps);
    }
Ejemplo n.º 10
0
    //가위바위보 선택 통신 대기.
    void UpdateWaitRPS()
    {
        //수신대기.
        RPSKind rps = m_networkController.ReceiveRPSData();

        if (rps == RPSKind.None)
        {
            //아직 수신되지 않음.
            return;
        }
        m_inputData[m_playerId ^ 1].rpsKind = rps;

        m_serverPlayer.GetComponent <Player>().SetRPS(m_inputData[0].rpsKind, m_inputData[1].rpsKind);
        m_clientPlayer.GetComponent <Player>().SetRPS(m_inputData[1].rpsKind, m_inputData[0].rpsKind);

        m_gameState = GameState.Shoot;

        //연출은 용도가 끝나면 제거.
        GameObject obj = GameObject.Find("RPSSelector");

        Destroy(obj);
    }
Ejemplo n.º 11
0
    public void SetSprite(RPSKind rps)
    {
        SpriteRenderer renderer = GetComponent <SpriteRenderer>();

        switch (rps)
        {
        case RPSKind.None:
            renderer.sprite = null;
            break;

        case RPSKind.Rock:
            renderer.sprite = m_rockSprite;
            break;

        case RPSKind.Paper:
            renderer.sprite = m_paperSprite;
            break;

        case RPSKind.Scissor:
            renderer.sprite = m_scissorSprite;
            break;
        }
    }
Ejemplo n.º 12
0
    void ClearForDraw()
     {
         isRPSSelected = false;
         isOppSendRPS = false;
         isBgCreated = false;
         isCheckWinner = false;
         selectedRPS = RPSKind.None;
         selectedOppRPS = RPSKind.None;
 
         winner = Winner.None;
     waitTime = 5.0f; //기다리는 시간
          waitThreeSec = 3.0f;
          waitForPlay = 3.0f;
          sendTime = -1.0f;  //보내는 시간
 
 
     }
Ejemplo n.º 13
0
 //자신과 대전 상대의 가위바위보를 세팅한다.
 public void SetRPS(RPSKind rps, RPSKind opponentRps) {
     m_rps = rps;
     m_opponentRps = opponentRps;
 }
Ejemplo n.º 14
0
    void ProcessingRPSSelect()  //가위바위보 골랐으면 그거 없애고 선택한거만 생성
    {
       // 

        try
        {
            //RPSSelector selector = GameObject.Find("RPSSelector").GetComponent<RPSSelector>();
            RPSPanel[] panels = GameObject.Find("RPSSelector").GetComponentsInChildren<RPSPanel>(); //주의 : null이 되버리면 프로그램 멈춰버리므로 try catch 문 이용할것

            foreach (RPSPanel p in panels)
            {
                if (p == null)
                { }

                if (p.IsSelected())
                {
                    selectedRPS = p.rpsKind;
                    isRPSSelected = true;
                    Debug.Log("isselctedchange");
                    Debug.Log(p.rpsKind + " is selected");
                    GameObject obj = GameObject.Find("RPSSelector");
                    Debug.Log("Destroy");
                    Destroy(obj);
                }
            }
        }
        catch
        {

        }
    

     
    
       
        GameObject rps = GameObject.Find("SelectRPS");

        if(rps==null && isRPSSelected)
        {
            int instNum = CastIntFromRPS(selectedRPS);
            rps = Instantiate(rpsPanelPrefab[instNum]) as GameObject;
            rps.name = "SelectRPS";
            nameList.Add(rps.name);
            Debug.Log("select and make one");
           // networkController.SendRPSData(selectedRPS);
            rps.GetComponent<Transform>().position = new Vector3(0, -2, 0);
        }
        sendTime -= Time.deltaTime;

        if (isRPSSelected && sendTime < 0f)
        {
            sendTime = 2f;
            Debug.Log("send rps data");
            networkController.SendRPSData(selectedRPS);

        }
      //  Debug.Log(selectedRps);

    }
Ejemplo n.º 15
0
    private int CastIntFromRPS(RPSKind select) //RPS 중 하나 생성하기위해 바꾸기 용도
    {
        int result=-1;

        switch(select)
        {
            case RPSKind.Rock:
                result = 0;
                break;
                
            case RPSKind.Paper:
                result = 1;
                break;

            case RPSKind.Scissor:
                result = 2;
                break;
        }

        return result;


    }
Ejemplo n.º 16
0
    void ClearAll()
    {
        isBgCreated = false;  //가위바위보를 위한 게임화면 흐릿하게
         isRPSSelected = false; //내가 가위바위보 골랐나
         isOppSendRPS = false; //상대가 가위바위보를 골랐나
        isMyTurn = false;  //내 턴인지 아닌지
        isCheckWinner = false;   //승리보여주는지 아닌지
         isFirst = false;   //처음 공격인지 아닌지
         isReceivePoint = false;  //포인트정보 받았는지 안받았는지
         isShowResult = false;  //첫공격이 결과 화면 기다리기위해
         isGameOver = false;  //게임이 끝났는지 
         ischeck = false;

        nickName = "닉네임"; //내 닉네임
        selectedRPS = RPSKind.None;
        selectedOppRPS = RPSKind.None;
        oppNickName = ""; //상대편 닉네임

        oppPointController.SetPoint(99);
        myPointController.SetPoint(99);

        round = 1; //라운드 수
         oppWin = 0;
         myWin = 0;

        winner = Winner.None;
        waitTime = 5.0f; //기다리는 시간
         waitThreeSec = 3.0f;
         waitForPlay = 3.0f;
        sendTime = -1.0f;  //보내는 시간
      
    }
Ejemplo n.º 17
0
	// Use this for initialization
	void Start () {
        selected = RPSKind.None;
	}
Ejemplo n.º 18
0
    void WaitOppRPS()
    {
       if(selectedOppRPS==RPSKind.None)
        selectedOppRPS = networkController.ReceiveRPSData();


        Debug.Log("waitRPS");
        GameObject obj = GameObject.Find("oppSelector");
        GameObject obj2 = GameObject.Find("OppSelectRPS");
        if (selectedOppRPS == RPSKind.None)
        {
            Debug.Log("Receive none");
        }

        else if (selectedOppRPS != RPSKind.None && obj != null && obj2 == null) 
        {
            
            Destroy(obj);
            isOppSendRPS = true;
            Debug.Log(selectedOppRPS + " wtf");
             obj2 = Instantiate(OppSelectSingleRPS) as GameObject;
            obj2.name="OppSelectRPS";
            nameList.Add(obj2.name);
            obj2.GetComponent<Transform>().position=  new Vector3(0, 4, 0);
        }
    }
Ejemplo n.º 19
0
 //자신과 대전 상대의 가위바위보를 세팅한다.
 public void SetRPS(RPSKind rps, RPSKind opponentRps)
 {
     m_rps         = rps;
     m_opponentRps = opponentRps;
 }
Ejemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     selected = RPSKind.None;
 }