public bool HasAttacked(Human human) { if(this.bounds.Intersects(human.getBounds())){ if (ms.LeftButton == ButtonState.Pressed && !human.checkIfSafe()) { return true; } } return false; }
private void Init() { light = new List<Lights>(); light.Add(new Lights(new Vector2(0.2f, 0.2f),new Vector2(0.7f, 0.7f))); light.Add(new Lights(new Vector2(0.8f, 0.2f),new Vector2(0.2f,0.8f))); light.Add(new Lights(new Vector2(0.2f, 0.8f), new Vector2(0.8f, 0.2f))); for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { byte ident = levelDesc[i,j]; switch(ident){ case 1: ground[i, j] = new Ground(game, "Tiles\\Stone", new Vector2(j * 32, i * 32), true); break; case 0: ground[i, j] = new Ground(game, "Tiles\\Grass", new Vector2(j * 32, i * 32),true); break; case RTR: ground[i, j] = new Ground(game, "Tiles\\Roof_top_right", new Vector2(j * 32, i * 32), false); break; case RTL: ground[i, j] = new Ground(game, "Tiles\\Roof_top_left", new Vector2(j * 32, i * 32), false); break; case RBL: ground[i, j] = new Ground(game, "Tiles\\Roof_bottom_left", new Vector2(j * 32, i * 32), false); break; case RBR: ground[i, j] = new Ground(game, "Tiles\\Roof_bottom_right", new Vector2(j * 32, i * 32), false); break; case BR: ground[i, j] = new Ground(game, "Tiles\\Bench-right", new Vector2(j * 32, i * 32), false); break; case BL: ground[i, j] = new Ground(game, "Tiles\\Bench-left", new Vector2(j * 32, i * 32), false); break; } } } int seed = unchecked(Environment.TickCount); Random rand = new Random(1000); int ind = NUMBER_OF_HUMANS; while (ind != 0) { Human tmp = new Human(game, new Vector2(rand.Next(50, 600), rand.Next(50, 450)), "Actors\\human_male_sheet"); if(CheckValidPos(tmp.getPos())){ humans.Add(tmp); ind--; } } humansLeft = humans.Count; }