public void Undo(Snek snek) { if (prevSnek != null) { snek.Body = prevSnek.Body; } }
public SnekBody(Color color, Snek cellOwner, LinkedListNode <Point> bodyNode) { _cellOwner = cellOwner; _bodyNode = bodyNode; Color = color; }
//private IEnumerable<(int, int, ICell)> Cells(Arena arena, int x, int y) //{ // for (int i = x - Radius; i < x + Radius; i++) // { // for (int j = y - Radius; j < y + Radius; j++) // { // if (i == x || j == y) // continue; // var obj = arena.GetCell((arena.Width + i) % arena.Width, (arena.Height + j) % arena.Height); // if (obj == null || obj is ISnekBody || obj is BlackHoleBuff) // continue; // yield return ((arena.Width + i) % arena.Width, (arena.Height + j) % arena.Height, obj); // } // } //} public void Interact(Snek snek) { var coords = snek.Body.Last.Value; foreach (var(item, x, y) in new ArenaEnumerable(snek.Arena, coords.X, coords.Y, Radius)) { item.Interact(snek); snek.Arena.UpdateCell(x, y, null); } }
// Use this for initialization void Start() { snekCtrl = snek.GetComponent <Snek> (); snekSpeed = snekCtrl.defaultSpeed; difficulty = Difficulties.easy; level = 0; score = 0; newLevel(); }
public void Interact(Snek snek) { if (snek.Body.Last == _bodyNode) { snek.ChangeDirection(Direction.None); } else { _cellOwner.TrimTail(_bodyNode); } // HUGE unecessary memory leak. For demonstration purposes only. //prevSnek = snek.Clone() as Snek; }
public void Undo(Snek snek) { snek.Growth -= 1; }
public void Interact(Snek snek) { snek.Growth += 1; }
public void Setup(Snek snek) { this.snek = snek; Spawnvoid(); }
public override void Paint(Level level) { base.Paint(level); Snek.Place(GetTileCenter() * 16 + new Vector2(8, 0), level.Area); }
public void Undo(Snek snek) { _baseFoodItem.Undo(snek); }
public void Interact(Snek snek) { _baseFoodItem.Interact(snek); }
public void Undo(Snek snek) { }
public Snake() { rand = new Random(0); N = 30; M = 20; size = 16; w = size * N; h = size * M; num = 4; s = new Snek[100]; for (var a = 0; a < s.Length; a++) { s[a] = new Snek(); } f = new Fruct(); window = new RenderWindow(new VideoMode((uint)w, (uint)h), "Snake Game!"); t1 = new Texture("images/04/white.png"); t2 = new Texture("images/04/red.png"); sprite1 = new Sprite(t1); sprite2 = new Sprite(t2); clock = new Clock(); timer = 0; delay = 0.1f; f.x = 10; f.y = 10; window.Closed += window_Closed; while (window.IsOpen) { float time = clock.ElapsedTime.AsSeconds(); clock.Restart(); timer += time; window.DispatchEvents(); if (Keyboard.IsKeyPressed(Keyboard.Key.Left)) { dir = 1; } if (Keyboard.IsKeyPressed(Keyboard.Key.Right)) { dir = 2; } if (Keyboard.IsKeyPressed(Keyboard.Key.Up)) { dir = 3; } if (Keyboard.IsKeyPressed(Keyboard.Key.Down)) { dir = 0; } if (timer > delay) { timer = 0; Tick(); } //draw window.Clear(); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { sprite1.Position = new Vector2f(i * size, j * size); window.Draw(sprite1); } } for (int i = 0; i < num; i++) { sprite2.Position = new Vector2f(s[i].x * size, s[i].y * size); window.Draw(sprite2); } sprite2.Position = new Vector2f(f.x * size, f.y * size); window.Draw(sprite2); window.Display(); } }
public override void Paint(Level level) { if (LevelSave.BiomeGenerated is IceBiome) { var clip = Painter.Clip; Painter.Clip = null; Painter.Rect(level, this, 0, Tile.WallB); Painter.Clip = clip; } Painter.Rect(level, this, 1, Tile.WallA); var exit = new HiddenExit { id = "dm" }; level.Area.Add(exit); exit.BottomCenter = GetCenter() * 16 + new Vector2(8, 8); var points = new List <Vector2>(); var a = false; if (Rnd.Chance(60)) { a = true; points.Add(new Vector2(Left + 4.5f, Top + 4.5f) * 16); } if (Rnd.Chance(60)) { a = true; points.Add(new Vector2(Right - 3.5f, Bottom - 4f) * 16); } if (Rnd.Chance(60)) { a = true; points.Add(new Vector2(Right - 3.5f, Top + 4.5f) * 16); } if (!a || Rnd.Chance(60)) { points.Add(new Vector2(Left + 4.5f, Bottom - 4f) * 16); } var types = new List <byte> { /*0, 1, 2, 3,*/ 4 /*5, 6, 7, 8*/ }; if (GlobalSave.IsTrue(ShopNpc.Roger)) { types.Add(0); } if (GlobalSave.IsTrue(ShopNpc.Boxy)) { types.Add(1); } if (GlobalSave.IsTrue(ShopNpc.Snek)) { types.Add(2); } if (GlobalSave.IsTrue(ShopNpc.Vampire)) { types.Add(5); } if (GlobalSave.IsTrue(ShopNpc.Nurse)) { types.Add(6); } if (GlobalSave.IsTrue(ShopNpc.Elon)) { types.Add(7); } if (GlobalSave.IsTrue(ShopNpc.Duck)) { types.Add(8); } foreach (var p in points) { var i = Rnd.Int(types.Count); var tp = types[i]; types.RemoveAt(i); switch (tp) { case 0: { Roger.Place(p, level.Area); break; } case 1: { Boxy.Place(p, level.Area); break; } case 2: { Snek.Place(p, level.Area); break; } case 3: { Gobetta.Place(p, level.Area); break; } case 4: { TrashGoblin.Place(p, level.Area); break; } case 5: { Vampire.Place(p, level.Area); break; } case 6: { Nurse.Place(p, level.Area); break; } case 7: { DungeonElon.Place(p, level.Area); break; } case 8: { DungeonDuck.Place(p, level.Area); break; } } if (types.Count == 0) { break; } } }
public Enemy AddEnemyEntity(EnemyData data) { EnemyPrototype proto = EnemyDatabase.GetEnemyPrototype(data.type); if (proto == null) { return(null); } Enemy temp = null; switch (proto.enemyType) { case EnemyType.Slime: temp = new Slime(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Eye: temp = new Eye(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.WurmAlien: temp = new WurmAlien(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Snek: temp = new Snek(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Stag: temp = new Stag(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Snowball: temp = new Snowball(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Sporby: temp = new Sporby(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Voidling: temp = new Voidling(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Ghost: temp = new Ghost(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Snowdrift: temp = new Snowdrift(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Treedude: temp = new Treedude(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.FrogLegs: temp = new FrogLegs(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Hedgehog: temp = new Hedgehog(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Nest: temp = new Nest(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Crawler: temp = new Crawler(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.Nipper: temp = new Nipper(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case EnemyType.PhoenixEgg: temp = new PhoenixEgg(proto); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; } return(temp); }