public void UpdatePlayerResourcesUI(ICardGamePlayer localPlayer, ICardGamePlayer opponentPlayer)
    {
        if (localPlayer == null)
        {
            Debug.LogError("Can't show resources for null player.");
            return;
        }

        if (opponentPlayer == null)
        {
            Debug.LogError("Can't show resources for null opponent.");
            return;
        }

        if (localResourcesRenderer == null)
        {
            Debug.LogError("No access to local resources renderer.");
        }
        else
        {
            localResourcesRenderer.RenderResources(localPlayer.GetResourcesPerTurn(), localPlayer.GetCurrentResources());
        }

        if (opponentResourcesRenderer == null)
        {
            Debug.LogError("No access to opponent resources renderer.");
        }
        else
        {
            opponentResourcesRenderer.RenderResources(opponentPlayer.GetResourcesPerTurn(), opponentPlayer.GetCurrentResources());
        }
    }
Пример #2
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var resourceManager = context.ResourceManager;

            if (resourceManager.HeadRendered)
            {
                return;
            }
            // set the flag before the resources are rendered, so they can't add more resources to the list during the render
            resourceManager.HeadRendered = true;

            // render resource links and preloads
            ResourcesRenderer.RenderResources(resourceManager, writer, context, ResourceRenderPosition.Head);
        }
Пример #3
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            // render resource links
            var resourceManager = context.ResourceManager;
            if (resourceManager.BodyRendered) return;
            resourceManager.BodyRendered = true;  // set the flag before the resources are rendered, so they can't add more resources to the list during the render
            ResourcesRenderer.RenderResources(resourceManager, writer, context, ResourceRenderPosition.Body);

            // render the serialized viewmodel
            var serializedViewModel = ((DotvvmRequestContext) context).GetSerializedViewModel();
            writer.AddAttribute("type", "hidden");
            writer.AddAttribute("id", "__dot_viewmodel_root");
            writer.AddAttribute("value", serializedViewModel);
            writer.RenderSelfClosingTag("input");

            // init on load
            writer.RenderBeginTag("script");
            writer.WriteUnencodedText($@"
window.dotvvm.domUtils.onDocumentReady(function () {{
    window.dotvvm.init('root', {JsonConvert.ToString(CultureInfo.CurrentCulture.Name, '"', StringEscapeHandling.EscapeHtml)});
}});");
            writer.RenderEndTag();
        }
Пример #4
0
 protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     ResourcesRenderer.RenderResources(context.ResourceManager, writer, context, ResourceRenderPosition.Body);
     base.RenderContents(writer, context);
 }