public bool PathBlocked(int aX, int aY) { bool lIsBlocked = false; //check base grid if ((this.BaseGrid.GetItem(aX, aY) == LevelTiles.Wall)) { lIsBlocked = true; } //check object grid ObjectInterface lObj = ObjectGrid.GetItem(aX, aY); if (lObj != null) { if (!lObj.CanWalk()) { lIsBlocked = true; } } //check Actorgrid if (ActorGrid.GetItem(aX, aY) != null) { lIsBlocked = true; } return(lIsBlocked); }
public override ActionResult Perform() { ActionResult lResult = new ActionResult(false); Coordinate lNewPos = this.Actor.GetPos() + this.Dir; // check if there is anyone in the space Actor lTarget = this.Level.ActorGrid.GetItem(lNewPos); if (lTarget != null) { lResult.Alternate(new MeleeAttackAction(this.Actor, lTarget)); return(lResult); } //is it a door or something that can be opened ObjectInterface lObject = this.Level.ObjectGrid.GetItem(lNewPos); if (lObject != null) { if (!lObject.CanWalk()) { lResult.Alternate(lObject.DefaultAction(this.Actor)); return(lResult); } } //set new position this.Actor.SetPos(lNewPos); lResult.Success(); debug.Print("MoveAction: ", "Name:" + this.Actor.Stats.Name.ToString() + " pos:" + lNewPos.ToString() + " dir:" + this.Dir.ToString(), 20); Item lItem = this.Level.ItemGrid.GetItem(lNewPos); if (lItem != null) { lResult.Success("There is a " + lItem.GetName() + " on the floor here."); } else { lResult.Success(); } return(lResult); }