コード例 #1
0
    public void OnPlayerDied(PlayerGameplay player)
    {
        uint?stocks  = player.GetRemainingStocks();
        int  arrayId = (int)(player.playerEnum);

        if (null != stocks && null != PlayerArray[arrayId].Player)
        {
            PlayerArray[arrayId].UiPercentage.text = 0.ToString("D3") + "%";
            if (3 < stocks)
            {
                PlayerArray[arrayId].UiTextStockX.text = ((int)(stocks)).ToString("D2");
            }
            else if (2 < stocks)             // 3+ -> 3 = only panel 3 images
            {
                PlayerArray[arrayId].UiPanelStockX.SetActive(false);
                PlayerArray[arrayId].UiPanelStock3.SetActive(true);
            }
            else if (1 < stocks)             // 3 -> 2 = only panel 3 images
            {
                PlayerArray[arrayId].UiPanelStock3.GetComponent <StockDisplay>().Image3.enabled = false;
            }
            else if (0 < stocks)             // 2 -> 1, can be 3/2
            {
                if (PlayerArray[arrayId].UiPanelStock3.activeInHierarchy)
                {
                    PlayerArray[arrayId].UiPanelStock3.GetComponent <StockDisplay>().Image2.enabled = false;
                }
                else
                {
                    PlayerArray[arrayId].UiPanelStock2.GetComponent <StockDisplay>().Image2.enabled = false;
                }
            }
            else
            {
                bFinished = true;
                foreach (PlayerUI playerUI in PlayerArray)
                {
                    if (null != playerUI.Player)
                    {
                        playerUI.UiPanelStock3.SetActive(false);
                        playerUI.UiPanelStock2.SetActive(false);
                        playerUI.UiPanelStock1.SetActive(false);
                    }
                }
            }

            if (!bFinished)
            {
                Transform newPose = Spawner.GetSpawnLocation();
                PlayerArray[arrayId].Player.SetNextSpawnLocation(newPose);
            }
        }
    }