コード例 #1
0
    IEnumerator TimerPayDay()
    {
        m_timerFinished = false;
        yield return(new WaitForSeconds(m_timeBetweenPayDay));

        FactionRED.GoldReserves    += FactionRED.NbrTerritories * m_incomePerTerritory;
        FactionBLUE.GoldReserves   += FactionBLUE.NbrTerritories * m_incomePerTerritory;
        FactionGREEN.GoldReserves  += FactionGREEN.NbrTerritories * m_incomePerTerritory;
        FactionYELLOW.GoldReserves += FactionYELLOW.NbrTerritories * m_incomePerTerritory;
        m_timerFinished             = true;
        FactionRED.DispatchMoney();
        FactionBLUE.DispatchMoney();
        FactionGREEN.DispatchMoney();
        FactionYELLOW.DispatchMoney();
    }
コード例 #2
0
    public void AssignFactionToPlayers(List <string> ListOfPlayerNames)         //JEROME HERE ! Give me a list of player names, or ID in string format, thx buddy ;-)
    {
        if (m_isInitialized)
        {
            return;
        }
        m_isInitialized = true;


        FactionRED = gameObject.AddComponent <Faction>();
        FactionRED.FactionColor    = Color.red;
        FactionRED.RespawnPosition = new Vector3(0f, 0f, 0f);
        FactionBLUE = gameObject.AddComponent <Faction>();
        FactionBLUE.FactionColor    = Color.blue;
        FactionBLUE.RespawnPosition = new Vector3(m_nbrXTerritories - 1, m_nbrYTerritories - 1, 0f);

        if (ListOfPlayerNames.Count > 8)
        {
            FactionGREEN = gameObject.AddComponent <Faction>();
            FactionGREEN.FactionColor    = Color.green;
            FactionGREEN.RespawnPosition = new Vector3(m_nbrXTerritories - 1, 0f, 0f);
            FactionYELLOW = gameObject.AddComponent <Faction>();
            FactionYELLOW.FactionColor    = Color.yellow;
            FactionYELLOW.RespawnPosition = new Vector3(0f, m_nbrYTerritories - 1, 0f);
        }

        int PlayerNum = 0;

        for (int faction = 0; PlayerNum < ListOfPlayerNames.Count; PlayerNum++)
        {
            GameObject NewPlayerGameObject = Instantiate(m_playerCharPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity, transform);
            NewPlayerGameObject.name = ListOfPlayerNames[PlayerNum];
            NewPlayerGameObject.GetComponentInChildren <TextMesh>().text = "" + PlayerNum;
            PlayerCharacter NewPlayerScript = NewPlayerGameObject.GetComponent <PlayerCharacter>();
            NewPlayerScript.MyManager  = this;
            NewPlayerScript.NumPlayer  = PlayerNum;
            NewPlayerScript.PlayerName = ListOfPlayerNames[PlayerNum];

            if (faction == 0)

            {
                NewPlayerScript.Faction = FactionRED;
                FactionRED.AddPlayer(NewPlayerScript);

                NewPlayerGameObject.transform.position = FactionRED.RespawnPosition;
                NewPlayerScript.CurrentTerritory       = m_AxeY[0][0].gameObject;
            }
            else if (faction == 1)
            {
                NewPlayerScript.Faction = FactionBLUE;
                FactionBLUE.AddPlayer(NewPlayerScript);

                NewPlayerGameObject.transform.position = FactionBLUE.RespawnPosition;
                NewPlayerScript.CurrentTerritory       = m_AxeY[m_nbrXTerritories - 1][m_nbrYTerritories - 1].gameObject;
            }
            else if (faction == 2)
            {
                NewPlayerScript.Faction = FactionGREEN;
                FactionGREEN.AddPlayer(NewPlayerScript);

                NewPlayerGameObject.transform.position = FactionGREEN.RespawnPosition;
                NewPlayerScript.CurrentTerritory       = m_AxeY[m_nbrXTerritories - 1][0].gameObject;
            }
            else if (faction == 3)
            {
                NewPlayerScript.Faction = FactionYELLOW;
                FactionYELLOW.AddPlayer(NewPlayerScript);

                NewPlayerGameObject.transform.position = FactionYELLOW.RespawnPosition;
                NewPlayerScript.CurrentTerritory       = m_AxeY[0][m_nbrYTerritories - 1].gameObject;
            }
            faction++;
            if (ListOfPlayerNames.Count > 8)
            {
                if (faction > 3)
                {
                    faction = 0;
                }
            }
            else if (faction > 1)
            {
                faction = 0;
            }
            NewPlayerScript.MyManager = this;
            m_listPlayer.Add(NewPlayerGameObject);
        }
    }