// Update is called once per frame private void Start() { snail = GetComponentInParent(typeof(Snail)) as Snail; weaponSprite.sprite = rifle; //rifle = Resources.Load("rifle", typeof(Sprite)) as Sprite; //rocketLauncher = Resources.Load("rocket_launcher", typeof(Sprite)) as Sprite; }
public static int[] Snail(int[][] array) { var snail = new Snail { Array = array }; return(snail.GetAnswers()); }
public void Create(Snail snail) { if (Snails.ContainsKey(snail.Id)) { throw new Exception("Id already exists"); // TODO: Should be BadRequestException } Snails[snail.Id] = snail; }
public void Update(Snail snail) { if (!Snails.ContainsKey(snail.Id)) { throw new NotFoundException("Can't find snail"); } Snails[snail.Id] = snail; }
private void OnTriggerEnter2D(Collider2D collision) { Snail snail = collision.GetComponent <Snail>(); if (snail != null) { snail.getHit(100); } Destroy(gameObject); }
private void OnTriggerEnter2D(Collider2D collision) { Snail snail = collision.GetComponent <Snail>(); if (snail != null) { snail.getHit(25); } flyAway(collision.GetComponent <Rigidbody2D>(), this.transform.position); }
private void button1AddMullusk_Click(object sender, EventArgs e) { string molluskType; string name = textBox1Name.Text; int sizeInCm = int.Parse(textBox2Size.Text); int minTemp = int.Parse(textBox3MinTemp.Text); int maxTemp = int.Parse(textBox4MaxTemp.Text); string color = textBox5Color.Text; if (radioButton3Starfish.Checked) { molluskType = radioButton3Starfish.Text; starFish = new Starfish(); aquarium.AllAnimalsCollection.Add(starFish); aquarium.MolluskCollection.Add(starFish); starFish.Img = FishGUI.Properties.Resources.starfish_icon; starFish.XPossition = locationGenerator.Next(Аquarium.xMinValue + 100, Аquarium.xMaxValue); starFish.YPossition = locationGenerator.Next(Аquarium.yMaxValue - 20, Аquarium.yMaxValue); } if (radioButton1Octopus.Checked) { molluskType = radioButton1Octopus.Text; octopus = new Octopus(); octopus.AnimalName = name; aquarium.AllAnimalsCollection.Add(octopus); aquarium.MolluskCollection.Add(octopus); octopus.Img = FishGUI.Properties.Resources.octopus_icon; octopus.XPossition = locationGenerator.Next(Аquarium.xMinValue + 300, Аquarium.xMaxValue); octopus.YPossition = locationGenerator.Next(Аquarium.yMaxValue - 200, Аquarium.yMaxValue); } if (radioButton2Snail.Checked) { molluskType = radioButton2Snail.Text; snail = new Snail(); aquarium.AllAnimalsCollection.Add(snail); aquarium.MolluskCollection.Add(snail); snail.Img = FishGUI.Properties.Resources.Snail_icon; snail.XPossition = locationGenerator.Next(Аquarium.xMinValue + 500, Аquarium.xMaxValue); snail.YPossition = locationGenerator.Next(Аquarium.yMaxValue - 400, Аquarium.yMaxValue); } this.DialogResult = DialogResult.OK; }
// Adds a series of enemies to the level randomly. public async Task SpawnEnemies() { // spawn snails in the level for (var x = 0; x < TileMap.Width; x++) { // flag for whether there's ground on this column of the level var groundFound = false; for (var y = 0; y < TileMap.Height; y++) { if (!groundFound) { if (TileMap.Tiles[y, x].Id == Super50Bros.Instance.TileIdGround) { groundFound = true; // random chance, 1, in 20 if (Super50Bros.Instance.Random.Next(20) == 0) { // instantiate snail, ceclaring in advane so we can pass it into state machine var snail = new Snail( "creatures", x * Super50Bros.Instance.TileSize, (y - 1) * Super50Bros.Instance.TileSize + 2, 16, 16, null, TileMap, Level); snail.StateMachine = new StateMachine(new Dictionary <string, State> { ["idle"] = new SnailIdleState(TileMap, Player, snail), ["moving"] = new SnailMovingState(TileMap, Player, snail), ["chasing"] = new SnailChasingState(TileMap, Player, snail) }); await snail.ChangeState("idle", new Dictionary <string, object> { ["wait"] = TimeSpan.FromSeconds(Super50Bros.Instance.Random.Next(5) + 1) }); Level.Entities.Add(snail); } } } } } }
public override async Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { IEnumerable <string> authValues; if (!actionContext.Request.Headers.TryGetValues("AuthToken", out authValues)) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } Snail snail = await _snailRepository.GetSnailByAuthToken(authValues.First()); if (snail == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } ((SnailsController)actionContext.ControllerContext.Controller).SetCurrentSnail(snail); await base.OnActionExecutingAsync(actionContext, cancellationToken); }
public override async Task Update(TimeSpan dt) { if (WaitTimer < WaitPeriod) { WaitTimer += dt; } else { await Snail.ChangeState("moving"); } // calculate difference between snail and player on X axis // and only chase if <= 5 tiles var diffX = Math.Abs(Player.X - Snail.X); if (diffX < 5 * Super50Bros.Instance.TileSize) { await Snail.ChangeState("chasing"); } }
public override async Task Update(TimeSpan dt) { Snail.CurrentAnimation.Update(dt); // calculate difference between snail and player on X axis // and only chase if <= 5 tiles var diffX = Math.Abs(Player.X - Snail.X); if (diffX > 5 * Super50Bros.Instance.TileSize) { await Snail.ChangeState("moving"); } else if (Player.X < Snail.X) { Snail.Direction = Direction.Left; Snail.X -= Super50Bros.Instance.SnailMoveSpeed * dt.TotalSeconds; // stop the snail if there's a missing tile on the floor to the left or a solid tile directly left var tileLeft = TileMap.PointToTile(Snail.X, Snail.Y); var tileBottomLeft = TileMap.PointToTile(Snail.X, Snail.Y + Snail.Height); if ((tileLeft != null & tileBottomLeft != null) && (tileLeft.Collidable() || !tileBottomLeft.Collidable())) { Snail.X += Super50Bros.Instance.SnailMoveSpeed * dt.TotalSeconds; } } else { Snail.Direction = Direction.Right; Snail.X += Super50Bros.Instance.SnailMoveSpeed * dt.TotalSeconds; // stop the snail if there's a missing tile on the floor to the right or a solid tile directly right var tileRight = TileMap.PointToTile(Snail.X + Snail.Width, Snail.Y); var tileBottomRight = TileMap.PointToTile(Snail.X + Snail.Width, Snail.Y + Snail.Height); if ((tileRight != null & tileBottomRight != null) && (tileRight.Collidable() || !tileBottomRight.Collidable())) { Snail.X -= Super50Bros.Instance.SnailMoveSpeed * dt.TotalSeconds; } } }
public void SetCurrentSnail(Snail currentSnail) { _currentSnail = currentSnail; }
public override async Task Update(TimeSpan dt) { MovingTimer += dt; Snail.CurrentAnimation.Update(dt); // reset movement direction and timer if timer is above duration if (MovingTimer > MovingDuration) { // chance to go into idle state randomly if (Super50Bros.Instance.Random.Next(4) == 0) { await Snail.ChangeState("idle", new System.Collections.Generic.Dictionary <string, object> { // random ammount of time for snail to be idle ["wait"] = TimeSpan.FromSeconds(Super50Bros.Instance.Random.Next(5) + 1) }); } else { MovingDirection = Super50Bros.Instance.Random.Next(2) == 0 ? Direction.Left : Direction.Right; Snail.Direction = MovingDirection; MovingDuration = TimeSpan.FromSeconds(Super50Bros.Instance.Random.Next(5)); MovingTimer = TimeSpan.Zero; } } else if (Snail.Direction == Direction.Left) { Snail.X -= Super50Bros.Instance.SnailMoveSpeed * dt.TotalSeconds; // stop the snail if there's a missing tile on the floor to the left or a solid tile directly left var tileLeft = Tilemap.PointToTile(Snail.X, Snail.Y); var tileBottomLeft = Tilemap.PointToTile(Snail.X, Snail.Y + Snail.Height); if ((tileLeft != null && tileBottomLeft != null) && (tileLeft.Collidable() || !tileBottomLeft.Collidable())) { Snail.X += Super50Bros.Instance.SnailMoveSpeed * dt.TotalSeconds; // reset direction if we hit a wall MovingDirection = Direction.Right; Snail.Direction = MovingDirection; MovingDuration = TimeSpan.FromSeconds(Super50Bros.Instance.Random.Next(5)); MovingTimer = TimeSpan.Zero; } } else { Snail.Direction = Direction.Right; Snail.X += Super50Bros.Instance.SnailMoveSpeed * dt.TotalSeconds; // stop the snail if there's a missing tile on the floor to the left or a solid tile directly left var tileRight = Tilemap.PointToTile(Snail.X + Snail.Width, Snail.Y); var tileBottomRight = Tilemap.PointToTile(Snail.X + Snail.Width, Snail.Y + Snail.Height); if ((tileRight != null && tileBottomRight != null) && (tileRight.Collidable() || !tileBottomRight.Collidable())) { Snail.X -= Super50Bros.Instance.SnailMoveSpeed * dt.TotalSeconds; // reset direction if we hit a wall MovingDirection = Direction.Left; Snail.Direction = MovingDirection; MovingDuration = TimeSpan.FromSeconds(Super50Bros.Instance.Random.Next(5)); MovingTimer = TimeSpan.Zero; } } // calculate difference between snail and player on X axis // and only chase if <= 5 tiles var diffX = Math.Abs(Player.X - Snail.X); if (diffX < 5 * Super50Bros.Instance.TileSize) { await Snail.ChangeState("chasing"); } }
public void AddSnail(Snail snail) { snails.Add(snail); }
public void SetUp() { snail = new Snail { Array = new[] { new[] { 1, 2, 3 }, new[] { 4, 5, 6 }, new[] { 7, 8, 9 } } }; }
public Task <HttpResponseMessage> Update([FromBody] Snail snail) { _repository.Update(snail); return(Task.FromResult(Request.CreateResponse(HttpStatusCode.OK))); }
public override void Realize() { if (realizedCreature != null) { return; } switch (creatureTemplate.TopAncestor().type) { case CreatureTemplate.Type.Slugcat: realizedCreature = new Player(this, world); break; case CreatureTemplate.Type.LizardTemplate: realizedCreature = new Lizard(this, world); break; case CreatureTemplate.Type.Fly: realizedCreature = new Fly(this, world); break; case CreatureTemplate.Type.Leech: realizedCreature = new Leech(this, world); break; case CreatureTemplate.Type.Snail: realizedCreature = new Snail(this, world); break; case CreatureTemplate.Type.Vulture: realizedCreature = new Vulture(this, world); break; case CreatureTemplate.Type.GarbageWorm: GarbageWormAI.MoveAbstractCreatureToGarbage(this, Room); realizedCreature = new GarbageWorm(this, world); break; case CreatureTemplate.Type.LanternMouse: realizedCreature = new LanternMouse(this, world); break; case CreatureTemplate.Type.CicadaA: realizedCreature = new Cicada(this, world, creatureTemplate.type == CreatureTemplate.Type.CicadaA); break; case CreatureTemplate.Type.Spider: realizedCreature = new Spider(this, world); break; case CreatureTemplate.Type.JetFish: realizedCreature = new JetFish(this, world); break; case (CreatureTemplate.Type)patch_CreatureTemplate.Type.SeaDrake: realizedCreature = new SeaDrake(this, world); break; case CreatureTemplate.Type.BigEel: realizedCreature = new BigEel(this, world); break; case CreatureTemplate.Type.Deer: realizedCreature = new Deer(this, world); break; case (CreatureTemplate.Type)patch_CreatureTemplate.Type.WalkerBeast: realizedCreature = new WalkerBeast(this, world); break; case CreatureTemplate.Type.TubeWorm: realizedCreature = new TubeWorm(this, world); break; case CreatureTemplate.Type.DaddyLongLegs: realizedCreature = new DaddyLongLegs(this, world); break; case CreatureTemplate.Type.TentaclePlant: if (creatureTemplate.type == CreatureTemplate.Type.TentaclePlant) { realizedCreature = new TentaclePlant(this, world); } else { realizedCreature = new PoleMimic(this, world); } break; case CreatureTemplate.Type.MirosBird: realizedCreature = new MirosBird(this, world); break; case CreatureTemplate.Type.TempleGuard: realizedCreature = new TempleGuard(this, world); break; case CreatureTemplate.Type.Centipede: case CreatureTemplate.Type.RedCentipede: case CreatureTemplate.Type.Centiwing: case CreatureTemplate.Type.SmallCentipede: realizedCreature = new Centipede(this, world); break; case CreatureTemplate.Type.Scavenger: realizedCreature = new Scavenger(this, world); break; case CreatureTemplate.Type.Overseer: realizedCreature = new Overseer(this, world); break; case CreatureTemplate.Type.VultureGrub: if (creatureTemplate.type == CreatureTemplate.Type.VultureGrub) { realizedCreature = new VultureGrub(this, world); } else if (creatureTemplate.type == CreatureTemplate.Type.Hazer) { realizedCreature = new Hazer(this, world); } break; case CreatureTemplate.Type.EggBug: realizedCreature = new EggBug(this, world); break; case CreatureTemplate.Type.BigSpider: case CreatureTemplate.Type.SpitterSpider: realizedCreature = new BigSpider(this, world); break; case CreatureTemplate.Type.BigNeedleWorm: if (creatureTemplate.type == CreatureTemplate.Type.SmallNeedleWorm) { realizedCreature = new SmallNeedleWorm(this, world); } else { realizedCreature = new BigNeedleWorm(this, world); } break; case CreatureTemplate.Type.DropBug: realizedCreature = new DropBug(this, world); break; } InitiateAI(); for (int i = 0; i < stuckObjects.Count; i++) { if (stuckObjects[i].A.realizedObject == null) { stuckObjects[i].A.Realize(); } if (stuckObjects[i].B.realizedObject == null) { stuckObjects[i].B.Realize(); } } }
public Task Insert(Snail entity) { throw new NotImplementedException(); }
static void Main(string[] args) { Start: Player P1 = new Player { }; Console.WriteLine("Hello brave adventurer, are you prepared to embark on a journey of epic proportions?"); Console.WriteLine("countless perils await you, but so does endless fame and fortune!"); Console.WriteLine(""); Console.WriteLine("(Press any key to continue)"); Console.ReadLine(); Console.WriteLine("Now before you go on your quest, tell me, what is your name?"); P1.Name = Console.ReadLine(); Console.WriteLine("Go now, " + P1.Name + " and seek your fortune"); Console.ReadLine(); Console.WriteLine("As you leave the saftey of your village, you can't help but to feel" + " a little nervous."); Console.ReadLine(); Console.WriteLine("You are attacked by a vicious snail!"); Console.ReadLine(); Console.Clear(); Snail S1 = new Snail { }; Console.WriteLine("Battle Start!"); Console.WriteLine(""); Console.WriteLine("Snail Health : " + S1.Health); Console.WriteLine(""); Console.WriteLine("Player Health : " + P1.Health); Console.ReadLine(); while (P1.Health > 0 && S1.Health > 0) { S1.Health = S1.Health - P1.Attack; P1.Health = P1.Health - S1.Attack; Console.WriteLine("Snail Health : " + S1.Health); Console.WriteLine(""); Console.WriteLine("Player Health : " + P1.Health); if (P1.Health <= 0) { Console.WriteLine("You died!"); Console.WriteLine("Would you like to start again?"); string Answer = Console.ReadLine(); if (Answer == "yes") { goto Start; } else { break; } } else if (S1.Health <= 0) { Console.WriteLine("You won!"); } Console.ReadLine(); } }
public Task Update(Snail entity) { throw new NotImplementedException(); }
public void Start() { snail = GetComponentInParent(typeof(Snail)) as Snail; }