Beispiel #1
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
 }
    public void InvestDecrease_Func(int id)
    {
        if (isPlayerInvested == true)
        {
            return;
        }

        if (investCoin [id] > 0)
        {
            coinNum++;
            investCoin [id]--;
            goldAmount.text = ((5 - coinNum) * Common_Data.Instance().coinMeasure).ToString();

            Debug.Log("InvestDecrease_Func : " + coinNum);

            for (int i = 0; 5 > i; i++)
            {
                if (investCount[id, i].activeInHierarchy == true)
                {
                    investCount[id, i].SetActive(false);
                    break;
                }
            }
        }
    }
    IEnumerator Fluctuate_Cor()
    {
        fluctuateTrf.localPosition = showPos;
        resultTrf.localPosition    = hidePos;


        for (int companyID = 0; 3 > companyID; companyID++)
        {
            if (Common_Data.Instance().CompanyData[companyID].fluctuateValue[today - 1] > 0f)
            {
                companyFlucData[companyID].SetData_Func(FluctuateDataState.Up, (int)Common_Data.Instance().CompanyData[companyID].fluctuateValue[today - 1]);
            }
            else if (Common_Data.Instance().CompanyData[companyID].fluctuateValue[today - 1] == 0f)
            {
                companyFlucData[companyID].SetData_Func(FluctuateDataState.Steady, (int)Common_Data.Instance().CompanyData[companyID].fluctuateValue[today - 1]);
            }
            else if (0f > Common_Data.Instance().CompanyData[companyID].fluctuateValue[today - 1])
            {
                companyFlucData[companyID].SetData_Func(FluctuateDataState.Down, (int)Common_Data.Instance().CompanyData[companyID].fluctuateValue[today - 1]);
            }
        }

        transform.parent.GetComponent <NetClient> ().RpcStockResultInYesterday(
            (int)Common_Data.Instance().CompanyData [0].fluctuateValue [today - 1],
            (int)Common_Data.Instance().CompanyData [1].fluctuateValue [today - 1],
            (int)Common_Data.Instance().CompanyData [2].fluctuateValue [today - 1]);

        yield return(null);
    }
Beispiel #4
0
    public void Init_Func()
    {
        fluctuateValue = new float[Common_Data.Instance().dayNum];

        fluctuateValue_RecentDay = 0f;
        fluctuateValue_Total     = 0f;
    }
    void MarketOpen_Func()
    {
        // Call :

        // 회사의 주식 변동을 기록

        int   _companyNum = Common_Data.Instance().GetCompanyNum_Func();
        float minValue    = Common_Data.Instance().marketFluctuateValue_Min;
        float maxValue    = Common_Data.Instance().marketFluctuateValue_Max;

        for (int i = 0; _companyNum > i; i++)
        {
            float randValue = Random.Range(minValue, maxValue) * 5;
            if (randValue >= 99f)
            {
                randValue = 99;
            }

            Common_Data.Instance().CompanyData[i].fluctuateValue[today - 1] = randValue;
            Common_Data.Instance().CompanyData[i].fluctuateValue_Total     += randValue;

            PlayerPrefs.SetInt("Change" + i, (int)randValue);
        }

        transform.parent.GetComponent <NetClient> ().CmdGenerateHint();
    }
    public override void SetState_Func(GameState _setState)
    {
        // 위 함수는 오직 딜러(호스트)만이 호출함
        // 따라서 호출 시 모든 플레이어(클라이언트)들도 전원 호출시켜야 함.

        switch (_setState)
        {
        case GameState.None:

            break;

        case GameState.Ready_First:
            ReadyFirstState_Func();
            break;

        case GameState.Ready:
            ReadyState_Func();
            break;

        case GameState.Market:
            MarketState_Func();

            break;

        case GameState.Invest:
            InvestState_Func();

            break;

        case GameState.Fluctuate:
            FluctuateState_Func();
            break;

        case GameState.Result:
            Debug.Log("Test, today : " + today);
            if (today >= Common_Data.Instance().dayNum)
            {
                ResultState_Func(true);
            }
            else
            {
                ResultState_Func(false);
            }
            break;

        case GameState.GameEnd:
//			GameEnd_Func();
            break;
        }

        Debug.Log("!!!!!!!!!!!!!!!!!!!!!!!");
        transform.parent.GetComponent <NetClient>().CmdSetStatePlayer(_setState);
    }
Beispiel #7
0
    public virtual void SetState_Func(GameState _setState)
    {
        // 위 함수는 오직 딜러(호스트)만이 호출함
        // 따라서 호출 시 모든 플레이어(클라이언트)들도 전원 호출시켜야 함.

        switch (_setState)
        {
        case GameState.None:

            break;

        case GameState.Ready_First:
            ReadyFirstState_Func();
            break;

        case GameState.Ready:
            ReadyState_Func();
            break;

        case GameState.Market:
            MarketState_Func();

            break;

        case GameState.Invest:
            InvestState_Func();

            break;

        case GameState.Fluctuate:
            FluctuateState_Func();
            break;

        case GameState.Result:
            Debug.Log("Test, today : " + today);
            if (today >= Common_Data.Instance().dayNum)
            {
                ResultState_Func(true);
            }
            else
            {
                ResultState_Func(false);
            }
            break;

        case GameState.GameEnd:
            GameEnd_Func();
            break;
        }
    }
    public void StartGame_Func()
    {
        // 호스트가 게임 시작 버튼을 눌러서, 이 함수를 호출

        base.Init_Func(PlayerType.Dealer);

        if (true == GameManager.instance.IsAllNicknameSetting())
        {
            Common_Data.Instance().CompanyData = new CompanyDataStr[3];
            for (int companyID = 0; 3 > companyID; companyID++)
            {
                Common_Data.Instance().CompanyData[companyID].Init_Func();

                companyFlucData[companyID].SetData_Func(FluctuateDataState.Steady, 0);
            }

            SetState_Func(GameState.Ready_First);
        }
    }
    protected override void NextDay_Func()
    {
        base.NextDay_Func();

        coinNum          = 5;
        isPlayerInvested = false;
        investedCheckObj.SetActive(false);
        investCoin = new int[Common_Data.Instance().GetCompanyNum_Func()];
        slideAni.Play("HintUnlock");
        lockHintID   = -1;
        isSlideClear = true;
        holdScreenObj.SetActive(false);

        for (int i = 0; 3 > i; i++)
        {
            for (int j = 0; 5 > j; j++)
            {
                investCount[i, j].SetActive(false);
            }
        }
    }
    protected override void ResultState_Func(bool isLast)
    {
        if (isLast == false)
        {
            base.ResultState_Func(false);
        }
        else if (isLast == true)
        {
            base.ResultTotalState_Func();
        }

        fluctuateTrf.localPosition = hidePos;
        resultTrf.localPosition    = showPos;

        // 결과창에 코인 아이콘 개수 0개로 초기화
        for (int playerID = 0; dicInvestData.Count > playerID; playerID++)
        {
            for (int companyID = 0; 3 > companyID; companyID++)
            {
                coinGrid[playerID, companyID].SetCoint_Func(0);
            }
        }

        #region 같은 투자 코인 검색
        NetworkInstanceId[] arrids = new NetworkInstanceId[dicInvestData.Count];
        int i = 0;
        foreach (KeyValuePair <NetworkInstanceId, cPlayerInvestData> target in dicInvestData)
        {
            arrids[i++] = target.Key;
        }

        for (int playerID = 0; arrids.Length > playerID; playerID++)
        {
            playerNickname[playerID].text = arrids[playerID] + " 님";
        }

        // 각 회사 별로...
        for (int companyID = 0; 3 > companyID; companyID++)
        {
            // 플레이어들 중...
            for (int playerID = 0; playerID < arrids.Length; ++playerID)
            {
                // 1~5의 투자횟수가...
                int sameInvestCheck_PlayerID = -1;
                for (int sameValue = 1; 5 >= sameValue; sameValue++)
                {
                    // 동일하다면은...
                    if (dicInvestData[arrids[playerID]].playerInvestAmount[companyID] == sameValue)
                    {
                        // sameInvestCheck_PlayerID에 해당 플레이어 ID 기록
                        // 만약 이미 기록되어 있는데 또 발생한다면...
                        if (sameInvestCheck_PlayerID == -1)
                        {
                            sameInvestCheck_PlayerID = playerID;
                        }
                        else
                        {
                            // 무효 처리!

                            dicInvestData[arrids[playerID]].playerInvestAmount[companyID] = 0;
                            dicInvestData[arrids[sameInvestCheck_PlayerID]].playerInvestAmount[companyID] = 0;
                        }
                    }
                }
            }
        }
        #endregion

        // 결과창에 코인 아이콘 개수 초기화
        // 돈 증가
        for (int playerID = 0; dicInvestData.Count > playerID; playerID++)
        {
            for (int companyID = 0; 3 > companyID; companyID++)
            {
                int investCount = dicInvestData[arrids[playerID]].playerInvestAmount[companyID];

                coinGrid[playerID, companyID].SetCoint_Func(investCount);
                dicInvestData[arrids[playerID]].playerGoldAmount[companyID] = (int)(investCount *
                                                                                    Common_Data.Instance().coinMeasure *
                                                                                    (1 + Common_Data.Instance().CompanyData[companyID].fluctuateValue[today - 1] / 100f)
                                                                                    );
            }
        }

        foreach (KeyValuePair <NetworkInstanceId, cPlayerInvestData> target in dicInvestData)
        {
//			Debug.Log ("플레이어의 재산 : " +

            target.Value.playerGoldAmount_Total += target.Value.playerGoldAmount [0];
            target.Value.playerGoldAmount_Total += target.Value.playerGoldAmount [1];
            target.Value.playerGoldAmount_Total += target.Value.playerGoldAmount [2];
        }

        for (int playerID = 0; dicInvestData.Count > playerID; playerID++)
        {
            Debug.Log("플레이어 " + playerID.ToString() + "의 재산 : " + dicInvestData[arrids[playerID]].playerGoldAmount_Total.ToString());
            transform.parent.GetComponent <NetClient> ().RpcSendScore(arrids[playerID], dicInvestData[arrids[playerID]].playerGoldAmount_Total);
        }

        StartCoroutine(ResultText_Func(isLast));
    }