예제 #1
0
 private void Start()
 {
     transform.localScale = Vector2.zero;
     if (type == PromptType.Ingredient)
     {
         shelfControl = FindObjectOfType <ShelfControl>();
     }
 }
    public override void StartMinigame()
    {
        base.StartMinigame();
        SCORE          = 0;
        debugScoreText = FindObjectOfType <Text>();
        FindObjectOfType <InputManager>().SetMultitouch(false);

        promptControl      = FindObjectOfType <PromptControl>();
        shelfControl       = FindObjectOfType <ShelfControl>();
        ingredients        = new Dictionary <string, Sprite>();
        currentIngredients = new Dictionary <string, int>();

        manager = FindObjectOfType <MinigameManager>();

        totalIngredientsAmount   = 0;
        currentIngredientsAmount = 0;
        currentIngredient        = 0;

        foreach (IngredientNeeded i in ingredientsNeeded)
        {
            totalIngredientsAmount          += i.amount;
            currentIngredients[i.ingredient] = 0;
        }

        Ingredient[] ings = FindObjectsOfType <Ingredient>();
        foreach (Ingredient i in ings)
        {
            if (!ingredients.ContainsKey(i.ingredientName))
            {
                ingredients.Add(i.ingredientName, i.ingredientSprite);
            }
            i.Init();
        }
        //shelfControl.PlaceIngredients();
        if (debugScoreText != null)
        {
            debugScoreText.text = "SCORE: " + SCORE;
        }
        AskForIngredient(ingredientsNeeded[currentIngredient].ingredient, ingredientsNeeded[currentIngredient].amount);
    }
예제 #3
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
                var found = false;
                // ReSharper disable once UnusedVariable
                foreach (var rec in _options.LookupAllIndexKey <DocumentShelfOptionsRecord>(
                             sm.semanticId?.GetAsExactlyOneKey()))
                {
                    found = true;
                }
                if (!found)
                {
                    return(null);
                }

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("DOC", "Document Shelf");

                // ok
                return(cve);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt =
                    Newtonsoft.Json.JsonConvert.DeserializeObject <DocumentShelfOptions>(
                        (args[0] as string));
                if (newOpt != null)
                {
                    _options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                    _options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense = "The CountryFlag library (NuGet) is licensed under the MIT license (MIT).";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && _eventStack != null)
            {
                // try access
                return(_eventStack.PopEvent());
            }

            if (action == "event-return" && args != null &&
                args.Length >= 1 && args[0] is AasxPluginEventReturnBase &&
                _shelfControl != null)
            {
                _shelfControl.HandleEventReturn(args[0] as AasxPluginEventReturnBase);
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "fill-panel-visual-extension")
            {
                // arguments
                if (args == null || args.Length < 3)
                {
                    return(null);
                }

                // call
                _shelfControl = ShelfControl.FillWithWpfControls(
                    _log, args[0], args[1], _options, _eventStack, args[2]);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = _shelfControl;
                return(res);
            }

            if (action == "get-list-new-submodel")
            {
                // prepare list
                var list = new List <string>();
                list.Add("Document (recommended version)");
                list.Add("Document (development version V1.1)");

                // make result
                var res = new AasxPluginResultBaseObject();
                res.obj = list;
                return(res);
            }

            if (action == "generate-submodel" && args != null && args.Length >= 1 && args[0] is string)
            {
                // get arguments
                var smName = args[0] as string;
                if (smName == null)
                {
                    return(null);
                }

                // generate (by hand)
                var sm = new AdminShell.Submodel();
                if (smName.Contains("V1.1"))
                {
                    sm.semanticId = new AdminShell.SemanticId(
                        AasxPredefinedConcepts.VDI2770v11.Static.SM_ManufacturerDocumentation.GetSemanticKey());
                    sm.idShort = "ManufacturerDocumentation";
                }
                else
                {
                    sm.semanticId = new AdminShell.SemanticId(DocuShelfSemanticConfig.Singleton.SemIdDocumentation);
                    sm.idShort    = "Documentation";
                }

                // make result
                var res = new AasxPluginResultBaseObject();
                res.strType = "OK";
                res.obj     = sm;
                return(res);
            }

            // default
            return(null);
        }