Beispiel #1
0
        static void Main(string[] args)
        {
            Platypus ornitorinc           = new Platypus("Ornitorinc", 20, 4, 2);
            WildDuck rata                 = new WildDuck("Donald", 20, 6, 35, 500);
            Piranha  piranha              = new Piranha("Nemo", 25, 250);
            AhkistrodonPiscivorus mocasin = new AhkistrodonPiscivorus("Boa", 20, 15, "frogs");
            Ladybug gargarita             = new Ladybug("Gargarita", 0.5, 15, Ladybug.LadybugColor.Black, 12);

            Animal[] animals = { ornitorinc, rata, piranha, mocasin, gargarita };
            Console.WriteLine("\t\tInitialy\n");
            foreach (Animal a in animals)
            {
                Console.WriteLine($"{a}\n");
            }

            Console.WriteLine("Press enter to continue");
            Console.ReadLine();

            ornitorinc.MakeAnEgg();
            ornitorinc.MakeAnEgg();
            ornitorinc.BreakAnEgg();
            ornitorinc.Hatch();

            rata.GainWeight(45);
            piranha.Grow(10);
            mocasin.AddFavouriteFood(" trout triton");
            mocasin.RemoveFavouriteFood("frogs");

            Console.WriteLine("\t\tAfter the changes\n");
            foreach (Animal a in animals)
            {
                Console.WriteLine($"{a}\n");
            }
        }
Beispiel #2
0
 public PiranhaEntity(Vector2 loc) : base(loc)
 {
     _initalPos      = loc;
     EntityCollision = new BlockCollision(this);//not collidable
     Sprite          = new Piranha(loc);
     State           = new HiddenState(this);
 }
Beispiel #3
0
        public override void Paint(Level level, Room room)
        {
            Fill(level, room, Terrain.WALL);
            Fill(level, room, 1, Terrain.WATER);

            var door = room.Entrance();

            door.Set(Room.Door.DoorType.REGULAR);

            var x = -1;
            var y = -1;

            if (door.X == room.Left)
            {
                x = room.Right - 1;
                y = room.Top + room.Height() / 2;
            }
            else if (door.X == room.Right)
            {
                x = room.Left + 1;
                y = room.Top + room.Height() / 2;
            }
            else if (door.Y == room.Top)
            {
                x = room.Left + room.Width() / 2;
                y = room.Bottom - 1;
            }
            else if (door.Y == room.Bottom)
            {
                x = room.Left + room.Width() / 2;
                y = room.Top + 1;
            }

            var pos = x + y * Level.Width;

#if !DEBUG
            level.Drop(Prize(level), pos).HeapType = pdsharp.utils.Random.Int(3) == 0 ? Heap.Type.Chest : Heap.Type.Heap;
#endif
            Set(level, pos, Terrain.PEDESTAL);

            level.AddItemToSpawn(new PotionOfInvisibility());

            for (var i = 0; i < Npiranhas; i++)
            {
                var piranha = new Piranha();
                do
                {
                    piranha.pos = room.Random();
                }while (level.map[piranha.pos] != Terrain.WATER || Actor.FindChar(piranha.pos) != null);

                level.mobs.Add(piranha);

                Actor.OccupyCell(piranha);
            }
        }
Beispiel #4
0
    public void DisableSuperSkill()
    {
        isUsingSuperFlight = false;
        isUsingSuperSpeed  = false;
        isUsingSuperTime   = false;

        // Remove the superskill trail
        TrailRenderer trailRenderer = gameObject.GetComponentInChildren <TrailRenderer>();

        trailRenderer.enabled = false;

        // Reset gravity to its orignal value
        gameObject.GetComponent <Rigidbody2D>().gravityScale = oriGravityScale;
        PteraMover.DeactivateTimeFreeze();
        CaveFlamePit.DeactivateTimeFreeze();
        Fireball.DeactivateTimeFreeze();
        DestroyByTime.DeactivateTimeFreeze();
        LaserBeam.DeactivateTimeFreeze();
        Saw.DeactivateTimeFreeze();
        LaserTurret.DeactivateTimeFreeze();
        Bat.DeactivateTimeFreeze();
        SwingingBoulder[] sb = FindObjectsOfType <SwingingBoulder>();
        sb[0].DeactivateTimeFreeze();
        sb[1].DeactivateTimeFreeze();
        sb[2].DeactivateTimeFreeze();
        sb[3].DeactivateTimeFreeze();
        sb[4].DeactivateTimeFreeze();
        sb[5].DeactivateTimeFreeze();
        sb[6].DeactivateTimeFreeze();
        RockController.DeactivateTimeFreeze();
        Turret.DeactivateTimeFreeze();
        PlayerController[] players = FindObjectsOfType <PlayerController>();
        foreach (PlayerController p in players)
        {
            p.timeFreezeActivated = false;
            p.GetComponent <Rigidbody2D>().isKinematic = false;
            p.anim.enabled = true;
        }
        GameObject[] FXs = GameObject.FindGameObjectsWithTag("FX");
        foreach (GameObject fx in FXs)
        {
            fx.GetComponent <ParticleSystem>().Play();
        }
        Arrow.DeactivateTimeFreeze();
        Puma.DeactivateTimeFreeze();
        Piranha.DeactivateTimeFreeze();
        Cobra.DeactivateTimeFreeze();
        Saw.DeactivateTimeFreeze();
        Banana.DeactivateTimeFreeze();
        BananaSpawn[] bs = FindObjectsOfType <BananaSpawn>();
        bs[0].DeactivateTimeFreeze();
        bs[1].DeactivateTimeFreeze();
        bs[2].DeactivateTimeFreeze();
    }
Beispiel #5
0
    public void SuperTime()
    {
        // Next iteration
        PteraMover.ActivateTimeFreeze();
        CaveFlamePit.ActivateTimeFreeze();
        Fireball.ActivateTimeFreeze();
        DestroyByTime.ActivateTimeFreeze();
        LaserBeam.ActivateTimeFreeze();
        Saw.ActivateTimeFreeze();
        LaserTurret.ActivateTimeFreeze();
        SwingingBoulder[] sb = FindObjectsOfType <SwingingBoulder>();
        sb[0].ActivateTimeFreeze();
        sb[1].ActivateTimeFreeze();
        sb[2].ActivateTimeFreeze();
        sb[3].ActivateTimeFreeze();
        sb[4].ActivateTimeFreeze();
        sb[5].ActivateTimeFreeze();
        sb[6].ActivateTimeFreeze();
        RockController.ActivateTimeFreeze();
        Turret.ActivateTimeFreeze();
        PlayerController[] players = FindObjectsOfType <PlayerController>();
        foreach (PlayerController p in players)
        {
            if (p.playerNumber != playerNumber)
            {
                p.timeFreezeActivated = true;
                p.GetComponent <Rigidbody2D>().isKinematic = true;
                p.anim.enabled = false;
            }
        }
        GameObject[] FXs = GameObject.FindGameObjectsWithTag("FX");
        foreach (GameObject fx in FXs)
        {
            fx.GetComponent <ParticleSystem>().Pause();
        }
        Arrow.ActivateTimeFreeze();
        Puma.ActivateTimeFreeze();
        Piranha.ActivateTimeFreeze();
        Cobra.ActivateTimeFreeze();
        Saw.ActivateTimeFreeze();
        Banana.ActivateTimeFreeze();
        BananaSpawn[] bs = FindObjectsOfType <BananaSpawn>();
        Bat.ActivateTimeFreeze();
        bs[0].ActivateTimeFreeze();
        bs[1].ActivateTimeFreeze();
        bs[2].ActivateTimeFreeze();

        // Add a trail to show the use of a super skill
        TrailRenderer trailRenderer = gameObject.GetComponentInChildren <TrailRenderer>();

        trailRenderer.enabled = true;
    }
		/// <summary>
		/// Localizes the client page model depending on the current UI culture.
		/// </summary>
		/// <param name="model">The page model</param>
		public static void LocalizePageModel(Piranha.Models.PageModel model) {
			var def = Utils.GetDefaultCulture();
			
			//
			// Check that we have a culture other than the default culture
			//
			if (def.Name != CultureInfo.CurrentUICulture.Name) {
				var js = new JavaScriptSerializer();

				using (var db = new Db()) {
					var translation = db.PageTranslations
						.Include(p => p.Regions)
						.Where(p => p.PageId == model.Page.Id && !p.IsDraft)
						.SingleOrDefault();

					// Map page values
					((Piranha.Models.Page)model.Page).Title = translation.Title;
					((Piranha.Models.Page)model.Page).NavigationTitle = translation.NavigationTitle;
					((Piranha.Models.Page)model.Page).Keywords = translation.Keywords;
					((Piranha.Models.Page)model.Page).Description = translation.Description;

					// Map regions
					foreach (var reg in translation.Regions) {
						var template = Piranha.Models.RegionTemplate.GetSingle(reg.TemplateId);
						if (template != null) {
							var internalId = template.InternalId;
							var type = Extend.ExtensionManager.Current.GetType(reg.Type);
							object val = null;

							if (typeof(IHtmlString).IsAssignableFrom(type)) {
								val = new HtmlString(reg.Body);
							} else {
								val = js.Deserialize(reg.Body, type);

								val = ((Extend.IExtension)val).GetContent(model);
							}
							((IDictionary<string, object>)model.Regions)[internalId] = val;
						}
					}
				}
			}
		}
		/// <summary>
		/// Loads the localized content depending on the current UI culture
		/// </summary>
		/// <param name="model">The page edit model</param>
		public static void LocalizePageOnLoad(Piranha.Models.Manager.PageModels.EditModel model) {
			var def = Utils.GetDefaultCulture();
			
			//
			// Check that we have a culture other than the default culture
			//
			if (def.Name != CultureInfo.CurrentUICulture.Name) {
				var js = new JavaScriptSerializer();

				using (var db = new Db()) {
					var translation = db.PageTranslations
						.Include(p => p.Regions)
						.Where(p => p.PageId == model.Page.Id && p.IsDraft)
						.SingleOrDefault();

					if (translation != null) {
						// Map page values
						model.Page.Title = translation.Title;
						model.Page.NavigationTitle = translation.NavigationTitle;
						model.Page.Keywords = translation.Keywords;
						model.Page.Description = translation.Description;

						for (var n = 0; n < model.Regions.Count; n++) {
							var region = model.Regions[n];

							// Get the translated region
							var reg = translation.Regions
								.Where(r => r.RegionId == region.Id && r.IsDraft == region.IsDraft)
								.SingleOrDefault();
							if (reg != null) {
								if (region.Body is IHtmlString) {
									region.Body = new Piranha.Extend.Regions.HtmlRegion(reg.Body);
								} else {
									region.Body = (Piranha.Extend.IExtension)js.Deserialize(reg.Body, region.Body.GetType());
								}
							}
						}
					}
				}
			}
		}
		public virtual ActionResult Add(Piranha.Models.Comment model) {
			if (ModelState.IsValid) {
				using (var api = new Api()) {
					model.IP = HttpContext.Request.UserHostAddress;
					model.UserAgent = HttpContext.Request.UserAgent.Substring(0, Math.Min(HttpContext.Request.UserAgent.Length, 128));
					model.SessionID = Session.SessionID;
					model.IsApproved = true;
					if (User.Identity.IsAuthenticated)
						model.UserId = User.Identity.Name;

					if (User.Identity.IsAuthenticated && Config.Comments.ModerateAuthorized)
						model.IsApproved = false;
					else if (!User.Identity.IsAuthenticated && Config.Comments.ModerateAnonymous)
						model.IsApproved = false;

					api.Comments.Add(model);
					api.SaveChanges();
				}
				var post = PostModel.GetById(model.PostId);

				return Redirect("~/" + post.Type + "/" + post.Slug);
			}
			return null;
		}
Beispiel #9
0
		/// <summary>
		/// Renders the thumbnail url to the given media file.
		/// </summary>
		/// <param name="media">The media file</param>
		/// <returns>The url</returns>
		public string Thumbnail(Piranha.Models.Media media, int? size) {
			return App.Env.Url("~/media.ashx/" + Utils.FormatMediaSlug(media.Slug, size, size));
		}
Beispiel #10
0
		/// <summary>
		/// Attaches the entity to the given context.
		/// </summary>
		/// <param name="db">The db context</param>
		public void Attach(Piranha.DataContext db) {
			if (this.Id == Guid.Empty || db.Set<Comment>().Count(t => t.Id == this.Id) == 0)
				db.Entry(this).State = EntityState.Added ;
			else db.Entry(this).State = EntityState.Modified ;
		}
 protected void _RenderItemLink(UIHelper ui, StringBuilder str, Piranha.Models.Sitemap page)
 {
     str.AppendLine(String.Format("<a class=\"element\" href=\"{0}\">{1}</a>", GenerateUrl(page),
                 !String.IsNullOrEmpty(page.NavigationTitle) ? page.NavigationTitle : page.Title));
 }
Beispiel #12
0
		/// <summary>
		/// Renders the thumbnail url to the given media file.
		/// </summary>
		/// <param name="media">The media file</param>
		/// <returns>The url</returns>
		public static IHtmlString Thumbnail(Piranha.Models.Media media, int? size) {
			return new HtmlString(helper.Thumbnail(media, size));
		}
 protected void _RenderItemStart(Piranha.Web.UIHelper ui, StringBuilder str, Piranha.Models.Sitemap page, bool active, bool activechild)
 {
 }
Beispiel #14
0
		/// <summary>
		/// Renders the url to the given media file.
		/// </summary>
		/// <param name="media">The media file</param>
		/// <returns>The url</returns>
		public static IHtmlString Media(Piranha.Models.Media media, int? width, int? height) {
			return new HtmlString(helper.Media(media, width, height));
		}
		/// <summary>
		/// Stores the localized content depending on the current UI culture.
		/// </summary>
		/// <param name="model">The page edit model</param>
		/// <param name="publish">If the page should be published</param>
		public static void LocalizePageBeforeSave(Piranha.Models.Manager.PageModels.EditModel model, bool publish) {
			var def = Utils.GetDefaultCulture();
			
			//
			// Check that we have a culture other than the default culture
			//
			if (def.Name != CultureInfo.CurrentUICulture.Name) {
				var old = Piranha.Models.Manager.PageModels.EditModel.GetById(model.Page.Id);

				SaveModel(model, false);
				if (publish)
					SaveModel(model, true);

				// Restore original values
				if (!model.Page.IsNew) {
					model.Page.Title = old.Page.Title;
					model.Page.NavigationTitle = old.Page.NavigationTitle;
					model.Page.Keywords = old.Page.Keywords;
					model.Page.Description = old.Page.Description;
				}

				// Restore original regions
				if (!model.Page.IsNew) {
					for (var n = 0; n < model.Regions.Count; n++) {
						model.Regions[n].Body = old.Regions[n].Body;
					}
				}	
			}
		}
Beispiel #16
0
		/// <summary>
		/// Generates the cache name for the current region on the current page.
		/// </summary>
		/// <param name="page">The page</param>
		/// <param name="reg">The region</param>
		/// <returns>The cache name</returns>
		public static string CacheName(Piranha.Models.IPage page, Piranha.Models.Region reg) {
			return "CACHE_" + page.Permalink.ToUpper() + "_" + reg.Type.ToUpper().Replace(".", "_") + "_" + reg.InternalId.ToUpper();
		}
		/// <summary>
		/// Saves the given model.
		/// </summary>
		/// <param name="model">The model</param>
		/// <param name="publish">The state of the model</param>
		private static void SaveModel(Piranha.Models.Manager.PageModels.EditModel model, bool publish) {
			var js = new JavaScriptSerializer();

			using (var db = new Db()) {
				var translation = db.PageTranslations
					.Include(p => p.Regions)
					.Where(p => p.PageId == model.Page.Id && p.IsDraft != publish)
					.SingleOrDefault();

				if (translation == null) {
					translation = new Entities.PageTranslation() {
						Id = Guid.NewGuid(),
						PageId = model.Page.Id,
						IsDraft = !publish,
						Culture = CultureInfo.CurrentUICulture.Name
					};
					db.PageTranslations.Add(translation);
				}

				// Map page values
				translation.Title = model.Page.Title;
				translation.NavigationTitle = model.Page.NavigationTitle;
				translation.Keywords = model.Page.Keywords;
				translation.Description = model.Page.Description;

				// Delete old region translations for simplicity
				while (translation.Regions.Count > 0)
					db.RegionTranslations.Remove(translation.Regions[0]);

				// Map regions
				for (var n = 0; n < model.Regions.Count; n++) {
					var region = model.Regions[n];

					var reg = new Entities.RegionTranslation() {
						Id = Guid.NewGuid(),
						PageId = translation.Id,
						RegionId = region.Id,
						TemplateId = region.RegiontemplateId,
						IsDraft = !publish,
						Type = region.Body.GetType().FullName,
						Culture = CultureInfo.CurrentUICulture.Name
					};
					translation.Regions.Add(reg);

					if (region.Body is IHtmlString)
						reg.Body = ((IHtmlString)region.Body).ToHtmlString();
					else reg.Body = js.Serialize(region.Body);
				}
				db.SaveChanges();
			}
		}
Beispiel #18
0
		/// <summary>
		/// Renders the url to the given media file.
		/// </summary>
		/// <param name="media">The media file</param>
		/// <param name="width">Optional width</param>
		/// <param name="height">Optional height</param>
		/// <returns>The url</returns>
		public string Media(Piranha.Models.Media media, int? width, int? height) {
			return App.Env.Url("~/media.ashx/" + media.Slug);
		}
Beispiel #19
0
		/// <summary>
		/// Return the site structure as an ul/li list with the current page selected.
		/// </summary>
		/// <param name="StartLevel">The start level of the menu</param>
		/// <param name="StopLevel">The stop level of the menu</param>
		/// <param name="Levels">The number of levels. Use this if you don't know the start level</param>
		/// <param name="RootNode">Optional rootnode for the menu to start from</param>
		/// <param name="CssClass">Optional css class for the outermost container</param>
		/// <param name="Current">Optional current page</param>
		/// <returns>A html string</returns>
		public static IHtmlString Menu(int StartLevel = 1, int StopLevel = Int32.MaxValue, int Levels = 0,
			string RootNode = "", string CssClass = "menu", Piranha.Models.Page Current = null) 
		{
			return Helper.Menu(StartLevel, StopLevel, Levels, RootNode, CssClass, Current) ;
		}
Beispiel #20
0
		/// <summary>
		/// Renders the permalink for the given post.
		/// </summary>
		/// <param name="post">The post</param>
		/// <returns>The generated permalink</returns>
		public string Permalink(Piranha.Models.Post post) {
			if (post.Type != null)
				return App.Env.Url("~/" + post.Type.Slug + "/" + post.Slug);
			return Permalink(Models.PostModel.GetById(post.Id));
		}
Beispiel #21
0
		/// <summary>
		/// Clears the cache for the given page & region.
		/// </summary>
		/// <param name="page">The page</param>
		/// <param name="reg">The region</param>
		public void ClearCache(Piranha.Models.IPage page, Piranha.Models.Region reg) {
			ClearCache(CacheName(page, reg));
		}
Beispiel #22
0
		/// <summary>
		/// Renders the permalink for the given post.
		/// </summary>
		/// <param name="post">The post</param>
		/// <returns>The generated permalink</returns>
		public static IHtmlString Permalink(Piranha.Models.Post post) {
			return new HtmlString(helper.Permalink(post));
		}