示例#1
0
    public void OnClickOperatorCard(int operatorNumber)
    {
        if (CurrGameState != GameState.SELECT_OPERATOR)
        {
            return;
        }

        // Operator 생성 및 삭제
        KeyValuePair <int, int> prevCam = tablet.GetCamPlacedOperator(operatorNumber);
        KeyValuePair <int, int> currCam = tablet.GetCurrCam();

        if (prevCam.Equals(currCam))
        {
            tablet.ClearOperatorPair(operatorNumber);
            Destroy(operators[operatorNumber]);
            operators[operatorNumber] = null;
            operatorCards[operatorNumber].transform.Find("Depoyed").gameObject.SetActive(false);
        }
        else
        {
            // 현재 캠에 존재하는 다른 대원 삭제
            int prevOperatorNumber = tablet.GetOperatorAtCam(currCam);
            if (prevOperatorNumber != -1)
            {
                tablet.ClearOperatorPair(prevOperatorNumber);
                Destroy(operators[prevOperatorNumber]);
                operators[prevOperatorNumber] = null;
                operatorCards[prevOperatorNumber].transform.Find("Depoyed").gameObject.SetActive(false);
            }

            if (operators[operatorNumber] == null)
            {
                operators[operatorNumber] = Instantiate(operatorPrefabs[operatorNumber]);
                operatorCards[operatorNumber].transform.Find("Depoyed").gameObject.SetActive(true);
            }
            operators[operatorNumber].transform.position = tablet.GetCurrCamPos();
            operators[operatorNumber].GetComponent <Charactor>().Floor = tablet.GetCurrFloor();
            tablet.SetOperatorPair(operatorNumber, currCam);
        }
    }