public Actor.Actor checkKick(Max aux, GameTime gameTime, InputHandler inputHandler) { Point kick = aux.Kick(inputHandler); Actor.Actor returnable = null; if (kick != Point.Zero) { foreach (Actor.Actor ac in actors) { if (ac.GetType() == typeof(Block)) { Block auxBlock = (Block)ac; //Console.WriteLine(auxBlock.collisionRect.ToString()); //Console.WriteLine(auxBlock.collisionRect.Intersects(new Rectangle(kick, new Point(10, 10)))); if (auxBlock.collisionRect.Contains(kick.X, kick.Y)) { aux.state.ChangeState(new KickState(aux.state, aux)); auxBlock.setDir(CalculateVector(kick - aux.position.ToPoint())); auxBlock.Update(gameTime, inputHandler); returnable = ac; } } } } return(returnable); }
private double calculateDistance(Actor.Actor actor, Max max) { Vector2 actOrigin = actor.position + new Vector2(40, 47); Vector2 maxOrigin = max.position + new Vector2(33, 41); return(Math.Sqrt(Math.Pow((maxOrigin.X - actOrigin.X), 2) + Math.Pow((maxOrigin.Y - actOrigin.Y), 2))); }
public void collideBlocks(GameTime gameTime, InputHandler inputHandler) { Block aux = (Block)movingBlock; bool collide = false; foreach (RectangleObjects ro in rectangles) { if (aux.nextRectangle.Intersects(ro.collisionRegion)) { aux.hasCollide(); collide = true; movingBlock = null; //Console.WriteLine("F*****G collided"); } } foreach (Actor.Actor ac in actors) { if (ac.GetType() != typeof(Max) && ac != movingBlock) { Block auxBlock = (Block)ac; if (aux.nextRectangle.Intersects(auxBlock.collisionRect)) { aux.hasCollide(); collide = true; movingBlock = null; } } } if (!collide) { aux.Update(gameTime, inputHandler); aux.move(); } }
private void switchState(Actor.Actor actor, Max max) { double distance = calculateDistance(actor, max); Enemy enemy = (Enemy)actor; PatrolState patrol = (PatrolState)enemy.state.state; if (distance <= 200 && patrol.atitude != PatrolState.Atitude.pursue) { patrol.changeState(PatrolState.Atitude.pursue); } }
private void checkCollideActors(Actor.Actor actor) { Enemy enemy = (Enemy)actor; bool hasCollide = false; foreach (Actor.Actor ac in actors) { if (ac.GetType() == typeof(Enemy) && enemy != (Enemy)ac) { Enemy aux = (Enemy)ac; if (enemy.collideRectangle.Intersects(aux.collideRectangle)) { hasCollide = true; } } if (ac.GetType() == typeof(Rock)) { Rock aux = (Rock)ac; if (enemy.collideRectangle.Intersects(aux.collisionRect)) { hasCollide = true; } } } foreach (RectangleObjects ro in rectangles) { if (enemy.collideRectangle.Intersects(ro.collisionRegion)) { hasCollide = true; } } if (enemy.collideRectangle.Intersects(resetRectangle)) { hasCollide = true; } if (!hasCollide) { enemy.move(); } else { changeDirection(enemy); } }
public TargettingState( Actor.Actor source, TargetZone zone, int spellnum, Func <IEnumerable <Loc>, Option <ICommand> > callback) { _source = source; _targetZone = zone; CurrentSpell = spellnum; _callback = callback; _targettableActors = new List <Actor.Actor>(); _targetted = new List <Loc>(); _path = new List <Loc>(); _inRange = zone.GetAllValidTargets(_source.Pos); // Pick out the interesting targets. // TODO: select items for item targetting spells foreach (Loc point in _inRange) { Game.MapHandler.GetActor(point) .MatchSome(actor => _targettableActors.Add(actor)); } // Initialize the targetting to an interesting target. var firstActor = Option.None <Actor.Actor>(); foreach (Actor.Actor target in _targettableActors) { if (!(target is Actor.Player) && Game.MapHandler.Field[target.Pos].IsVisible) { firstActor = Option.Some(target); break; } } firstActor.Match( some: first => _cursor = first.Pos, none: () => _cursor = source.Pos); DrawTargettedTiles(); }
public void update(GameTime gameTime, InputHandler inputHandler, Rectangle resetRectangle) { for (int i = 0; i < actors.Count; i++) { if (actors[i].GetType() == typeof(Max)) { actors[i].Update(gameTime, inputHandler); Max aux = (Max)actors[i]; collideMax(aux); if (movingBlock == null) { movingBlock = checkKick(aux, gameTime, inputHandler); } if (aux.maxRectangleY.Intersects(resetRectangle)) { state.ChangeState(new MainMenuState(state)); } } if (actors[i] == movingBlock) { Block auxBlock = (Block)movingBlock; auxBlock.Update(gameTime, inputHandler); collideBlocks(gameTime, inputHandler); } if (actors[i].GetType() == typeof(Rock)) { Rock rock = (Rock)actors[i]; if (rock.throwed) { collideRock(rock, gameTime, inputHandler); } } } }
public Actor.Actor checkGrab(Max aux, GameTime gameTime, InputHandler inputHandler) { Point grab = aux.Grab(inputHandler); Actor.Actor returnable = null; if (grab != Point.Zero) { foreach (Actor.Actor ac in actors) { if (ac.GetType() == typeof(Rock)) { //Console.WriteLine("grabbed"); Rock auxRock = (Rock)ac; if (auxRock.collisionRect.Contains(grab)) { aux.state.ChangeState(new GrabState(aux, aux.state)); returnable = ac; } } } } return(returnable); }
public PickupCommand(Actor.Actor source, in Item item)
private void checkCollidePursue(Actor.Actor actor, IList <RectangleObjects> rectangles, IList <Actor.Actor> actors, Rectangle resetRectangle) { Enemy enemy = (Enemy)actor; bool hasCollideX = false; bool hasCollideY = false; foreach (Actor.Actor ac in actors) { if (ac.GetType() == typeof(Enemy) && enemy != (Enemy)ac) { Enemy aux = (Enemy)ac; if (enemy.collideX.Intersects(aux.collideRectangle)) { hasCollideX = true; } if (enemy.collideY.Intersects(aux.collideRectangle)) { hasCollideY = true; } } if (ac.GetType() == typeof(Rock)) { Rock aux = (Rock)ac; if (enemy.collideX.Intersects(aux.collisionRect)) { hasCollideX = true; } if (enemy.collideY.Intersects(aux.collisionRect)) { hasCollideY = true; } } } foreach (RectangleObjects ro in rectangles) { if (enemy.collideX.Intersects(ro.collisionRegion)) { hasCollideX = true; } if (enemy.collideY.Intersects(ro.collisionRegion)) { hasCollideY = true; } } if (enemy.collideX.Intersects(resetRectangle)) { hasCollideX = true; } if (enemy.collideY.Intersects(resetRectangle)) { hasCollideY = true; } if (!hasCollideX && hasCollideY) { enemy.moveX( ); } else if (hasCollideX && !hasCollideY) { enemy.moveY(); } else if (!hasCollideX && !hasCollideY) { enemy.moveX(); enemy.moveY(); } }
void IActorDeathEventListener.OnEventRaised(Actor.Actor actor) { this.GameOver(); }
public MoveCommand(Actor.Actor source, in Loc pos)
public MoveAnimation(Actor.Actor source, in Loc prev, bool multmove = false)
public PushCommand(Actor.Actor source, Actor.Actor target) { _source = source; _target = target; }