Example #1
0
        public void Initialise(ServerTeam team, ServerPlayer player)
        {
            if (player.clientID.Equals(CurrentGame.Instance.LocalPlayer.clientID))
            {
                SetupLocalPlayer(team, player);
                m_IsLocalPlayer = true;
            }
            else
            {
                SetupOtherPlayer(team, player);
                m_IsLocalPlayer = false;
            }

            m_IsMasterClient = CurrentGame.Instance.isHost && CurrentGame.Instance.LocalPlayer.ClientId.Equals(player.ClientId);

            if (m_IsMasterClient)
            {
                transform.SetAsFirstSibling();
            }
            else if (m_IsLocalPlayer)
            {
                transform.SetSiblingIndex(1);
            }

            SetupStyling();
        }
Example #2
0
    /// <summary>
    ///  Updates the value fields of the UI.
    /// </summary>

    public void UpdateUI()
    {
        ServerTeam playerTeam = CurrentGame.Instance.PlayerTeam;

        m_AmountOwnMoney.text  = "" + CurrentGame.Instance.LocalPlayer.money;
        m_AmountBankMoney.text = "" + playerTeam.bankAccount;
    }
Example #3
0
        /// <summary>
        /// Gets called when the player is the local player. Sets up the lobbyplayer behaviour.
        /// </summary>
        private void SetupLocalPlayer(ServerTeam team, ServerPlayer player)
        {
            Color c = new Color(0, 0, 0);

            ColorUtility.TryParseHtmlString(team.customColor, out c);

            m_TeamBtn.GetComponent <Image>().color = c;

            GetComponent <Image>().color = m_LocalPlayerColor;

            string namePlayer = LoadEncodedName();

            m_playerNameText.text = namePlayer;
            player.name           = namePlayer;

            m_TeamBtn.interactable = true;
            m_TeamBtn.onClick.AddListener(() =>
            {
                ServerTeam nextTeam = CurrentGame.Instance.getNextTeam(team);
                CurrentGame.Instance.Ws.SendPlayerTeamUpdate(nextTeam.teamName);
            });

            //m_Name.interactable = true;
            //m_Name.onEndEdit.AddListener(val =>
            //{
            //	CurrentGame.Instance.Ws.SendPlayerNameUpdate(val);
            //});

            m_KickPlayerBtn.interactable = true;
            m_KickPlayerBtn.onClick.AddListener(() => {
                //todo change ready state G: is this needed in server?
            });
        }
Example #4
0
    public void Update()
    {
        if (m_TeamOrder == null && CurrentGame.Instance.TeamScores != null)
        {
            SortTeams();

            for (int i = 0; i < m_TeamOrder.Count; i++)
            {
                GameObject scoreEntryInstance = Instantiate(m_ScoreEntryPrefab);
                scoreEntryInstance.transform.SetParent(m_Content, false);
                scoreEntryInstance.transform.Find("Place").GetComponent <Text>().text = (i + 1).ToString();

                Color      c  = new Color();
                ServerTeam st = CurrentGame.Instance.FindTeamByName(m_TeamOrder[i].name);
                ColorUtility.TryParseHtmlString(st.customColor, out c);
                scoreEntryInstance.transform.Find("Team").GetComponent <Image>().color = c;

                scoreEntryInstance.transform.Find("Money").GetComponent <Text>().text = ((int)m_TeamOrder[i].score).ToString();
            }
        }
        else
        {
            //todo show loading scores popup
        }
    }
Example #5
0
    /// <summary>
    /// Transfers all the bank's money to the player.
    /// </summary>
    public void SelectAllBankMoney()
    {
        ServerTeam playerTeam = CurrentGame.Instance.PlayerTeam;

        m_AmountField.text = "" + playerTeam.bankAccount;
        RetractMoney();
    }
Example #6
0
        /// <summary>
        /// Starts the game for the DistrictManager for a given amount of teams.
        /// </summary>
        public void StartGame(int amountOfTeams)
        {
            m_DistrictColliders = new PolygonCollider2D[gameObject.transform.childCount];
            for (int i = 0; i < gameObject.transform.childCount; i++)
            {
                m_DistrictColliders[i] = gameObject.transform.GetChild(i).gameObject.GetComponent <PolygonCollider2D>();
            }

            // Loops trough all district groups and allocates the teams and types.
            for (int i = 0; i < transform.childCount; i++)
            {
                Transform          child = transform.GetChild(i);
                CapturableDistrict cd    = child.GetComponent <CapturableDistrict>();
                if (cd != null)
                {
                    int  teamIndex    = CurrentGame.Instance.GetTeamIndex(transform.GetChild(i).gameObject.name);
                    bool mainDistrict = CurrentGame.Instance.isHeadDistrict(transform.GetChild(i).gameObject.name);

                    if (transform.GetChild(i).gameObject.name.Equals("4a", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Debug.Log("DSITRICT FOUND");
                    }

                    //find team if any
                    ServerTeam team = null;
                    if (teamIndex >= 0)
                    {
                        team = CurrentGame.Instance.gameDetail.GetTeamByIndex(teamIndex);
                    }

                    //check for main district and assign
                    if (mainDistrict)
                    {
                        HeadDistrict district = transform.GetChild(i).gameObject.GetComponent <HeadDistrict>();
                        district.Team    = team;
                        district.enabled = true;
                        m_HeadDistricts.Add(district);
                        Destroy(district.GetComponent <CapturableDistrict>());
                        Treasure square = district.transform.GetChild(0).gameObject.GetComponent <Treasure>();
                        square.Team    = team;
                        square.enabled = true;
                        Destroy(district.transform.GetChild(0).GetComponent <CapturePoint>());
                    }
                    else
                    {
                        CapturableDistrict district = transform.GetChild(i).gameObject.GetComponent <CapturableDistrict>();
                        district.Team    = team;
                        district.enabled = true;
                        Destroy(district.GetComponent <HeadDistrict>());
                        CapturePoint square = district.transform.GetChild(0).gameObject.GetComponent <CapturePoint>();
                        square.Team    = team;
                        square.enabled = true;
                        Destroy(district.transform.GetChild(0).GetComponent <Treasure>());
                        district.OnTeamChanged();
                    }
                }
            }
        }
Example #7
0
 /// <summary>
 /// Searches for the index of a specific team.
 /// Returns -1 if the requested team is not found.
 /// </summary>
 /// <param name="team"></param>
 /// <returns></returns>
 public int IndexOfTeam(ServerTeam team)
 {
     for (int i = 0; i < teams.Count; i++)
     {
         if (team.teamName.Equals(teams[i].teamName))
         {
             return(i);
         }
     }
     return(-1);
 }
Example #8
0
    public ServerTeam getNextTeam(ServerTeam team)
    {
        int index     = gameDetail.teams.FindIndex(t => t.teamName.Equals(team.teamName));
        int nextIndex = ++index;

        if (nextIndex >= gameDetail.teams.Count)
        {
            nextIndex = 0;
        }
        return(gameDetail.teams[nextIndex]);
    }
Example #9
0
    /// <summary>
    /// Verifies if transaction is valid and performs retraction transaction.
    /// </summary>
    public void RetractMoney()
    {
        ServerTeam playerTeam = CurrentGame.Instance.PlayerTeam;

        if (playerTeam.bankAccount >= (double.Parse(m_AmountField.text) - 0.000001))
        {
            CurrentGame.Instance.Ws.SendBankWithdrawal(double.Parse(m_AmountField.text), CurrentGame.Instance.nearBank);
        }

        UpdateUI();
    }
Example #10
0
    protected void HandleInfoNotification(MessageWrapper message)
    {
        InfoNotification info = JsonUtility.FromJson <InfoNotification>(message.message);

        Debug.Log(message.message);
        string text = info.GameEventType.ToString();

        //notification containing extra info about a recently passed event (currently only robbery)
        switch (info.GameEventType)
        {
        case GameEventType.BANK_DEPOSIT:
            break;

        case GameEventType.BANK_WITHDRAWAL:
            break;

        case GameEventType.PLAYER_TAGGED:
            break;

        case GameEventType.DISTRICT_CONQUERED:
            break;

        case GameEventType.TRADEPOST_LEGAL_SALE:
            break;

        case GameEventType.TRADEPOST_LEGAL_PURCHASE:
            break;

        case GameEventType.TRADEPOST_ILLEGAL_SALE:
            break;

        case GameEventType.TRADEPOST_ILLEGAL_PURCHASE:
            break;

        case GameEventType.TREASURY_WITHDRAWAL:
            break;

        case GameEventType.TRADEPOST_ALL_SALE:
            break;

        case GameEventType.TREASURY_ROBBERY:
            ServerTeam st   = CurrentGame.Instance.FindTeamByName(info.by);
            string     name = "team " + CurrentGame.Instance.ColorNames[st.customColor];
            //text = "Je schatkist is bestolen door " + info.by;
            text = "Je schatkist is bestolen door " + name;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        InGameUIManager.s_Singleton.LogUI.AddToLog(text, new object[] { });
    }
Example #11
0
    /// <summary>
    /// Initialises the class before Start.
    /// </summary>
    private void Awake()
    {
        transform.SetParent(GameManager.s_Singleton.transform);

        //m_TeamID = CurrentGame.Instance.gameDetail.GetTeamByIndex(transform.GetSiblingIndex()); todo re-enable
        m_TeamID             = new ServerTeam();
        m_TeamID.bankAccount = 0;
        m_TeamID.customColor = "#FF0000";
        m_TeamID.teamName    = "TEST TEAM";
        m_TeamID.treasury    = 0;

        name = TeamID.ToString();
    }
Example #12
0
    public string FindPlayerById(string id)
    {
        ServerTeam team = gameDetail.teams.Find(st => st.ContainsPlayer(id));

        if (team == null)
        {
            return(null);
        }
        ServerPlayer player = team.players.Find(pl => pl.ClientId.Equals(id));

        if (player == null)
        {
            return(null);
        }
        return(player.Name);
    }
Example #13
0
    public void StartTutorial(TouchCamera tc, ServerTeam team)
    {
        TCamera          = tc;
        TCamera.enabled  = false;
        m_team           = team;
        instructionState = InstructionsState.confirmIfInstructionsNeeded;
        InstructionExecution();
        //if (LoadEncodedFile() == textToWrite)
        //{
        //	StopInstructions();
        //}
        //else
        //{
        //	Debug.Log("No File Founded");
        //	instructionState = InstructionsState.confirmIfInstructionsNeeded;
        //	InstructionExecution();

        //}
    }
Example #14
0
        /// <summary>
        /// Gets called when the player is not a local player. Sets up the lobbyplayer behaviour.
        /// </summary>
        private void SetupOtherPlayer(ServerTeam team, ServerPlayer player)
        {
            Color c = new Color(0, 0, 0);

            ColorUtility.TryParseHtmlString(team.customColor, out c);

            m_TeamBtn.GetComponent <Image>().color = c;
            m_playerNameText.text = player.Name;
            SetReadyButton(m_IsReady);

            if (CurrentGame.Instance.isHost)
            {
                m_NameInpRect.offsetMax = new Vector2(-150, m_NameInpRect.offsetMax.y);
                m_KickPlayerBtn.gameObject.SetActive(true);
                m_KickPlayerBtn.onClick.AddListener(() =>
                {
                    Rest.KickPlayer(CurrentGame.Instance.GameId, CurrentGame.Instance.HostingLoginToken, player.clientID);
                });
            }
        }
Example #15
0
        public EarningDto RunServerTeamCheckout(RunServerTeamCheckoutDto data, List <CheckoutEntity> checkouts)
        {
            TeamEntity teamEntity = teamRepository.GetTeamById(data.ServerTeamId);

            //Check for the team to have an existing tipout, if it does remove it to not have incorrect tipout data.
            if (teamEntity.CheckoutHasBeenRun == true)
            {
                teamRepository.DeleteTipOut(data.ServerTeamId);
                teamEntity.CheckoutHasBeenRun = false;
            }

            ServerTeam team = new ServerTeam(teamEntity.ShiftDate);

            Mapper.Map(teamEntity, team);

            foreach (CheckoutEntity c in checkouts)
            {
                Checkout x = Mapper.Map <Checkout>(c);
                team.CheckOuts.Add(x);
            }

            //The earning is returned from the method called, and a tipout property is set on the team
            Earnings earning = team.RunCheckout()[0];

            //The teams tipout is accessed here and saved to the database
            //The earning is tied to the server and not the checkout, so the earning
            //gets added and saved once this method returns an earning DTO
            TipOutEntity tipOutEntity = Mapper.Map <TipOutEntity>(team.TipOut);

            tipOutEntity.Team = teamEntity;
            teamRepository.AddTipOut(tipOutEntity);
            teamEntity.CheckoutHasBeenRun = true;

            if (!teamRepository.Save())
            {
                throw new Exception("An unexpected error occured while saving the tipout for the team's checkout");
            }

            return(Mapper.Map <EarningDto>(earning));
        }
Example #16
0
        static void Main(string[] args)
        {
            //each server prints a their  indiv checkout
            //once all servers that are on a team have printed  their checkouts they bring to manager
            //mgr is going to create the server tip out for each server on the team
            //  a server tip out keeps track of date, server name, gross sales, etc


            Job server = new Job()
            {
                Title = "Server"
            };

            StaffMember Grant = new StaffMember()
            {
                FirstName = "Grant",
                LastName  = "Elmer",
                Id        = 1,
            };

            StaffMember Alyson = new StaffMember()
            {
                FirstName = "Alyson",
                LastName  = "Elmer",
                Id        = 2,
            };

            StaffMember Lauren = new StaffMember()
            {
                FirstName = "Lauren",
                LastName  = "Wine",
                Id        = 3,
            };

            ServerTeam team = new ServerTeam(DateTime.Today);

            Checkout grantsCheckOut = new Checkout(Grant, DateTime.Today, server)
            {
                GrossSales          = 962.92m,
                Sales               = 900,
                BarSales            = 181,
                LunchOrDinner       = "dinner",
                CashAutoGrat        = 10,
                CcAutoGrat          = 47.39m,
                CcTips              = 83.64m,
                NonTipOutBarSales   = 0,
                Hours               = 6,
                CashTips            = 0,
                NumberOfBottlesSold = 1
            };

            Checkout alysonsCheckOut = new Checkout(Alyson, DateTime.Today, server)
            {
                GrossSales          = 1680.78m,
                Sales               = 800,
                BarSales            = 308.50m,
                LunchOrDinner       = "dinner",
                CashAutoGrat        = 0,
                CcAutoGrat          = 0,
                CcTips              = 323,
                NonTipOutBarSales   = 0,
                Hours               = 6,
                CashTips            = 0,
                NumberOfBottlesSold = 2
            };

            Checkout laurensCheckOut = new Checkout(Alyson, DateTime.Today, server)
            {
                GrossSales          = 2187.03m,
                Sales               = 800,
                BarSales            = 354,
                LunchOrDinner       = "dinner",
                CashAutoGrat        = 0,
                CcAutoGrat          = 354.88m,
                CcTips              = 1541,
                NonTipOutBarSales   = 0,
                Hours               = 6,
                CashTips            = 0,
                NumberOfBottlesSold = 0
            };

            team.CheckOuts.Add(grantsCheckOut);
            team.CheckOuts.Add(alysonsCheckOut);
            team.CheckOuts.Add(laurensCheckOut);
            //Earnings teamMemberEarnings;
            decimal barSpecialLine = grantsCheckOut.NumberOfBottlesSold + alysonsCheckOut.NumberOfBottlesSold;
            //teamMemberEarnings = team.RunCheckout(barSpecialLine, 0);

            //Console.WriteLine("CC Tips: " + teamMemberEarnings.CcTips.ToString());

            /* Console.WriteLine("AutoGrat: " + teamMemberEarnings.AutoGratuity.ToString());
             * Console.WriteLine("Total Tips: " + teamMemberEarnings.TotalTipsForPayroll.ToString());
             *
             * Console.WriteLine("Teams TipOut Numbers: ");
             * Console.WriteLine("Team Gross Sales: " + team.TipOut.TeamGrossSales.ToString());
             * Console.WriteLine("Team Bottles Sold: " + barSpecialLine.ToString());
             * Console.WriteLine("Bar: " + team.TipOut.BarTipOut.ToString());
             * Console.WriteLine("SA: " + team.TipOut.SaTipOut.ToString());
             *
             *
             * Console.ReadLine();*/
        }
Example #17
0
    protected void HandleTeamNotification(MessageWrapper message)
    {
        bool             treasuryTax = false, treasuryRob = false, bankUpdateDep = false, bankUpdateWith = false, districtUpdate = false, tradepostUpdate = false;
        TeamNotification tn = JsonUtility.FromJson <TeamNotification>(message.message);
        ServerTeam       st = CurrentGame.Instance.PlayerTeam;

        st.TotalPlayerMoney = tn.totalPlayerMoney;
        st.visitedTadeposts = tn.VisitedTradeposts;        //todo validate

        if (st.bankAccount < (tn.bankAccount - 0.0001))
        {
            st.bankAccount = tn.bankAccount;
            bankUpdateDep  = true;
        }
        else if (st.bankAccount > (tn.bankAccount + 0.0001))
        {
            st.bankAccount = tn.bankAccount;
            bankUpdateWith = true;
        }


        if (st.treasury > (tn.treasury + 0.0001))
        {
            st.treasury = tn.treasury;
            treasuryRob = true;
        }
        else if (st.treasury < (tn.treasury - 0.0001))
        {
            st.treasury = tn.treasury;
            treasuryTax = true;
        }

        //todo check for differences
        st.districts = new List <AreaLocation>();
        foreach (AreaLocation areaLocation in tn.districts)
        {
            st.districts.Add(areaLocation);
        }

        //todo check for differences
        st.tradePosts = tn.tradeposts;


        if (treasuryTax)
        {
            InGameUIManager.s_Singleton.LogUI.AddToLog("Er zijn belastingen binnen gekomen", new object[] { });
        }

        if (treasuryRob)
        {
            InGameUIManager.s_Singleton.LogUI.AddToLog("Er is geld uit je schatkist genomen", new object[] { });
        }
        if (bankUpdateDep)
        {
            InGameUIManager.s_Singleton.LogUI.AddToLog("Er is geld op de bank gezet", new object[] { });
        }
        if (bankUpdateWith)
        {
            InGameUIManager.s_Singleton.LogUI.AddToLog("Er is geld van de bank afgehaald", new object[] { });
        }
        if (districtUpdate)
        {
            InGameUIManager.s_Singleton.LogUI.AddToLog("WIJK UPDATE", new object[] { });
        }
        if (tradepostUpdate)
        {
            InGameUIManager.s_Singleton.LogUI.AddToLog("HANDELSPOST UPDATE", new object[] { });
        }
    }