Beispiel #1
0
        /// <summary>
        /// renders the thumbnail of the uploaded file using the given imageName and configured uploadDirectory. This Action can be used as a
        /// location of the image, defined within src attribute of the <img/> tag.
        /// </summary>
        /// <param name="imageName">the name of the image File.</param>
        /// <returns>an ImageResult</returns>
        public ActionResult UploadedImageThumbnail(string imageName)
        {
            string path    = this.Configuration.GetPhysicalUploadPath();
            string imgPath = Path.Combine(path, imageName);

            return(this.Image(RessourceHelper.CreateThumbnail(imgPath, new Size(30, 30)), "image/jpeg"));
        }
Beispiel #2
0
    public override void FixedUpdate()
    {
        base.FixedUpdate();

        if (this.isBusy())
        {
            if (counter % 180 == 0 && !this.GetComponent <inventory>().isFull())
            {
                RessourceHelper.deliverTo(this.gameObject, false, ressources.Trees);
            }
            //check if it has scrap, if true then recycle INFO: 1 Scrap = 3 Energy
            if (this.GetComponent <inventory>().getAmount(ressources.Trees) >= 1 && this.getCurEnergy() > 3)
            {
                this.addEnergy(-energyPerSecond * Time.deltaTime, this);
                this.GetComponent <inventory>().add(new ressourceStack(WoodPerSecond * Time.deltaTime, ressources.Wood));
                this.GetComponent <inventory>().remove(new ressourceStack(treesPerSecond * Time.deltaTime, ressources.Trees));
            }

            if (this.GetComponent <inventory>().getAmount(ressources.Trees) >= 1 && this.getCurEnergy() > 3)
            {
                this.GetComponent <Animator>().SetBool("working", true);
                if (!this.transform.Find("CFX3_Fire_Shield").GetComponent <ParticleSystem>().isPlaying)
                {
                    this.transform.Find("CFX3_Fire_Shield").GetComponent <ParticleSystem>().Play();
                }
            }
            else
            {
                this.GetComponent <Animator>().SetBool("working", false);
                this.transform.Find("CFX3_Fire_Shield").GetComponent <ParticleSystem>().Stop();
            }
        }
    }
Beispiel #3
0
        /// <summary>
        /// renders the the uploaded image file using the given imageName and configured uploadDirectory. This Action can be used as a
        /// location of the image, defined within src attribute of the <img/> tag.
        /// </summary>
        /// <param name="imageName">the name of the image File.</param>
        /// <returns>an ImageResult</returns>
        public ActionResult UploadedImage(string imageName)
        {
            string path    = this.Configuration.GetPhysicalUploadPath();
            string imgPath = Path.Combine(path, imageName);
            string context = "";
            Stream stream  = RessourceHelper.CreateImageStream(imgPath, ref context);

            return(this.Image(stream, context));
        }
Beispiel #4
0
        /// <summary>
        /// renders the startup script, using plupload.startup.js.
        /// all placeholders within js template file will be resolved.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="html"></param>
        /// <param name="resPath"></param>
        /// <param name="onCompleteFunction"></param>
        /// <returns></returns>
        public static MvcHtmlString ScriptContent <T>(this HtmlHelper <T> html, string resPath, string onCompleteFunction)
        {
            string scriptContent = RessourceHelper.GetTextResource(PluploadConstants.JS_PLUPLOAD_STARTUP);

            PluploadConfiguration config = PluploadContext.Instance.GetConfiguration();

            scriptContent = scriptContent.Replace("[SCRIPT_URL]", resPath.GetAbsoluteWebPathForRessource()).
                            Replace("[ON_COMPLETE_FUNCTION]", onCompleteFunction).
                            Replace("[SCRIPT_JQUERY_URL]", config.JSjQuery.GetAbsoluteWebPath());

            return(new MvcHtmlString(scriptContent));

            //html.Action("EmbeddedTextRessource", "Ressource", new { textPath = resPath, contentType = "text/javascript" });
        }
        /// <summary>
        /// creates a new context.
        /// loads all configuration files.
        /// </summary>
        private PluploadContext()
        {
            this.CustomConfiguration = XMLSerializer <PluploadConfiguration> .Load();

            string      config = RessourceHelper.GetTextResource(PluploadConstants.CONFIGURATION_MAIN);
            XmlDocument xdoc   = new XmlDocument();

            xdoc.LoadXml(config);
            this.GlobalEmbedConfiguration = XMLSerializer <PluploadConfiguration> .Load(xdoc);

            this.MergedConfiguration = (this.CustomConfiguration != null) ? this.GlobalEmbedConfiguration.Merge(this.CustomConfiguration) : this.GlobalEmbedConfiguration;

            this.Initialize();
        }
Beispiel #6
0
 /// <summary>
 /// renders the binary embedded ressource.
 /// </summary>
 /// <param name="streamPath">an embedded dot separated path to the ressource. For example:
 /// ~/Ressource/EmbeddedBinaryRessource?streamPath=Plupload.Net.Scripts.plupload.flash.swf</param>
 /// <param name="contentType">a type of the content</param>
 /// <returns>file content result</returns>
 public FileContentResult EmbeddedBinaryRessource(string streamPath, string contentType = "application/octet-stream")
 {
     byte[] buffer = new byte[16 * 1024];
     using (MemoryStream ms = new MemoryStream())
     {
         using (Stream input = RessourceHelper.GetResourceStream(streamPath))
         {
             int read;
             while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
             {
                 ms.Write(buffer, 0, read);
             }
             return(File(ms.ToArray(), contentType));
         }
     }
 }
    public override void FixedUpdate()
    {
        base.FixedUpdate();

        if (this.isBusy())
        {
            //ProcessingPlant_Anim
            if (this.getCurEnergy() > 3)
            {
                //request both ores
                if (counter % 180 == 0 && !this.GetComponent <inventory>().isFull())
                {
                    RessourceHelper.deliverTo(this.gameObject, false, ressources.OreIron);
                    RessourceHelper.deliverTo(this.gameObject, false, ressources.OreGold);
                }

                //select right ore
                var ore = ressources.OreIron;
                if (this.GetComponent <inventory>().getAmount(ressources.OreIron) < 0.2f)
                {
                    ore = ressources.OreGold;
                    if (this.GetComponent <inventory>().getAmount(ressources.OreGold) < 0.2f)
                    {
                        this.transform.Find("ProcessingPlant_Anim").GetComponent <ParticleSystem>().Stop();
                        return;
                    }
                }


                if (!this.transform.Find("ProcessingPlant_Anim").GetComponent <ParticleSystem>().isPlaying)
                {
                    this.transform.Find("ProcessingPlant_Anim").GetComponent <ParticleSystem>().Play();
                }

                this.addEnergy(-energyPerSecond * Time.deltaTime, this);
                this.GetComponent <inventory>().remove(new ressourceStack(OrePerSecond * Time.deltaTime, ore));

                var ingot = ore.Equals(ressources.OreIron) ? ressources.Iron : ressources.Gold;
                this.GetComponent <inventory>().add(new ressourceStack(IngotsPerSecond * Time.deltaTime, ingot));
            }
            else
            {
                this.transform.Find("ProcessingPlant_Anim").GetComponent <ParticleSystem>().Stop();
            }
        }
    }
Beispiel #8
0
    new void FixedUpdate()
    {
        base.FixedUpdate();

        if (workLight == null)
        {
            workLight = this.transform.Find("DrillSparks").transform.Find("Point Light").gameObject;
        }

        if (counter % 5 == 0)
        {
            handleConnections();
        }

        if (this.isBusy())
        {
            //check if it has scrap, if true then recycle INFO: 1 Scrap = 3 Energy
            if (this.GetComponent <inventory>().getAmount(ressources.Scrap) >= 1)
            {
                this.addEnergy(energyPerSecond * Time.deltaTime, this);
                this.GetComponent <inventory>().remove(new ressourceStack(scrapPerSecond * Time.deltaTime, ressources.Scrap));
            }

            if (this.GetComponent <inventory>().getAmount(ressources.Scrap) >= 1)
            {
                this.GetComponent <Animator>().SetBool("working", true);
                workLight.GetComponent <Light>().enabled = true;
                this.transform.Find("DrillSparks").GetComponent <ParticleSystem>().Play();
            }
            else
            {
                this.GetComponent <Animator>().SetBool("working", false);
                workLight.GetComponent <Light>().enabled = false;
                this.transform.Find("DrillSparks").GetComponent <ParticleSystem>().Stop();
            }
            //send for moar scrap!!
            if (counter % 60 == 0 && !this.GetComponent <inventory>().isFull())
            {
                RessourceHelper.deliverTo(this.gameObject, false, ressources.Scrap);
            }
        }
    }
    private new void FixedUpdate()
    {
        base.FixedUpdate();

        if (!busy)
        {
            return;
        }

        //request resources
        if (useMovers)
        {
            foreach (var data in getProduceData())
            {
                foreach (var kind in data.consume)
                {
                    if (counter % 180 == 0 && this.inventory.getFillPercent() < 0.9f)
                    {
                        RessourceHelper.deliverTo(this.gameObject, false, kind.getRessource());
                    }
                }
            }
        }

        //consume goods
        var dataList = this.getProduceData();
        var workDone = false;

        foreach (var data in dataList)
        {
            if (handleProduceData(data))
            {
                workDone = true;
            }
        }

        if (hasAnimation)
        {
            animator.SetBool(Work, workDone);
        }
    }
Beispiel #10
0
    void FixedUpdate()
    {
        counter++;
        if (!active)
        {
            return;
        }

        var   inv       = this.gameObject.GetComponent <inventory>();
        float availUran = inv.getAmount(ressources.Uranium);

        if (!inv.isFull() && counter % 60 == 0)
        {
            RessourceHelper.deliverTo(this.gameObject, false, ressources.Uranium);
        }

        //update heat items
        foreach (var item in allStructures)
        {
            item.update(availUran);
        }
    }
Beispiel #11
0
    /// <summary>
    /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
    /// </summary>
    new void FixedUpdate()
    {
        base.FixedUpdate();
        if (this.salvaging && this.getHP().HP < 3)
        {
            print("structure salvaged!");
            var pickup = Instantiate(GameObject.Find("Terrain").GetComponent <Scene_Controller>().pickupBox,
                                     this.transform.position, Quaternion.identity);
            pickup.GetComponent <inventory>().add(new ressourceStack(this.getHP().getInitialHP(), ressources.Scrap));
            GameObject.Destroy(this.gameObject);
        }

        if (salvaging)
        {
            this.getHP().HP -= 2.5f;
            return;
        }

        if (steamAmount > 10)
        {
            this.addEnergy(10 * Time.deltaTime, this);
            steamAmount -= 10 * Time.deltaTime;
            this.getInv().add(ressources.Water, -10f * Time.deltaTime);
        }

        if ((this.getInv().getAmount(ressources.Water) < 50 || this.steamAmount > 10) && counter % 60 == 0 &&
            !this.GetComponent <inventory>().isFull())
        {
            RessourceHelper.deliverTo(this.gameObject, false, ressources.Water);
        }

        if (counter % 5 == 0)
        {
            handleConnections();
        }
    }
Beispiel #12
0
 /// <summary>
 /// gets the content of the embedded text ressource.
 /// </summary>
 /// <param name="textPath">an embedded dot separated path to the ressource. For example:
 /// Plupload.Net.Content.css.plupload.net.css</param>
 /// <param name="contentType">a type of the content</param>
 /// <returns>a contenResult of the embedded ressource</returns>
 public ContentResult EmbeddedTextRessource(string textPath, string contentType = "application/octet-stream")
 {
     return(Content(RessourceHelper.GetTextResource(textPath), contentType));
 }
Beispiel #13
0
 /// <summary>
 /// renders the embedded stylesheet as contentResult. This Action can be used as a
 /// location of the css file, defined within hre attribute of the style tag.
 /// </summary>
 /// <param name="cssPath">an embedded dot separated path to the stylesheet ressource for example:
 /// ~/Ressource/EmbeddedCSS?cssPath=Plupload.Net.Content.css.plupload.net.css </param>
 /// <returns>the content of embedded css ressource</returns>
 public ContentResult EmbeddedCSS(string cssPath)
 {
     return(Content(RessourceHelper.GetTextResource(cssPath), "text/css"));
 }
Beispiel #14
0
 /// <summary>
 /// renders the embedded javascript as JavaScriptResult. This Action can be used as a
 /// location of the script, defined within src attribute of the script tag.
 /// </summary>
 /// <param name="scriptPath">an embedded dot separated path to the script ressource for example:
 /// ~/Ressource/EmbeddedJavaScript?scriptPath=Plupload.Net.Scripts.plupload.net.js</param>
 /// <returns>the content of embedded javascript ressource</returns>
 public JavaScriptResult EmbeddedJavaScript(string scriptPath)
 {
     return(JavaScript(RessourceHelper.GetTextResource(scriptPath)));
 }
Beispiel #15
0
 /// <summary>
 /// renders the embedde image. This Action can be used as a
 /// location of the image, defined within src attribute of the <img/> tag.
 /// </summary>
 /// <param name="imagePath">an embedded dot separated path to the ressource. For example:
 /// Plupload.Net.Content.img.buttons.png</param>
 /// <returns>an ImageResult</returns>
 public ActionResult EmbeddedImage(string imagePath)
 {
     return(this.Image(RessourceHelper.GetResourceStream(imagePath), "image/" + imagePath.Substring(imagePath.LastIndexOf('.') + 1)));
 }