public void RemakeData(DoorWindow data) { _properties = data; transform.localScale = new Vector3(_properties.Width, _properties.Height, _properties.Large); transform.localPosition = new Vector3(_properties._coordX, _properties._coordY, _properties._coordZ); }
public void SetData(DoorWindow data) { _properties = data; transform.localScale = new Vector3(_properties.Width, _properties.Height, _properties.Large); transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z); }
/// <summary> /// Check if actor can move in this tile. /// As per map.IsWalkable() check only tile and mapobject, ignore actors. /// "Move in" = walk in or handle the blocking mapobject to make way using one of the allowed actions /// Eg: open a door, jump on obj, push obj, break obj. /// </summary> /// <param name="game"></param> /// <param name="a"></param> /// <param name="map"></param> /// <param name="pos"></param> /// <returns></returns> /// <see cref="Map.IsWalkable(Point)"/> /// <see cref="AllowedActions"/> bool CanMoveIn(RogueGame game, Actor a, Map map, Point pos) { // check tile & mapobj if (map.IsWalkable(pos)) { return(true); } MapObject mobj = map.GetMapObjectAt(pos); if (mobj == null) { // blocked by a wall tile return(false); } // blocked by a mapobj, can we operate it? //... a door? if ((AllowedActions & SpecialActions.DOORS) != 0) { DoorWindow door = mobj as DoorWindow; if (door != null) { // open? if (game.Rules.IsOpenableFor(a, door)) { return(true); } // break? if (((AllowedActions & SpecialActions.BREAK) != 0) && game.Rules.IsBreakableFor(a, door)) { return(true); } // nope, blocked by door return(false); } } //... a jumpable? if (((AllowedActions & SpecialActions.JUMP) != 0) && mobj.IsJumpable && game.Rules.HasActorJumpAbility(a)) { return(true); } //... a pushable? if (((AllowedActions & SpecialActions.PUSH) != 0) && game.Rules.CanActorPush(a, mobj)) { return(true); } //... a breakable? if (((AllowedActions & SpecialActions.BREAK) != 0) && game.Rules.IsBreakableFor(a, mobj)) { return(true); } // blocked by a mapobject we can't handle. return(false); }
public ActionBashDoor(Actor actor, DoorWindow door) : base(actor) { m_Door = door #if DEBUG ?? throw new ArgumentNullException(nameof(door)) #endif ; }
ActorAction ExecuteBarricading(RogueGame game, Location location, bool toTheMax) { ///////////////////// // 1. Check validity. // 2. Perform. ///////////////////// // 1. Check validity. if (m_Actor.Location.Map != location.Map) { return(null); } DoorWindow door = location.Map.GetMapObjectAt(location.Position) as DoorWindow; if (door == null) { return(null); } if (!game.Rules.CanActorBarricadeDoor(m_Actor, door)) { return(null); } // 2. Perform. // 2.1 If adjacent, barricade. // 2.2 Move closer. // 2.1 If adjacent, barricade. if (game.Rules.IsAdjacent(m_Actor.Location.Position, location.Position)) { ActorAction barricadeAction = new ActionBarricadeDoor(m_Actor, game, door); if (barricadeAction.IsLegal()) { if (!toTheMax) { SetOrder(null); } return(barricadeAction); } else { return(null); } } // 2.2 Move closer. ActorAction moveAction = BehaviorIntelligentBumpToward(game, location.Position, false, false); if (moveAction != null) { RunIfPossible(game.Rules); return(moveAction); } else { return(null); } }
public void AddDoorWindow(DoorWindow doorWindow) { if (!_doorWindows.Exists(x => x._itemId == doorWindow._itemId)) { return; } _doorWindows.Add(doorWindow); }
public ActionOpenDoor(Actor actor, RogueGame game, DoorWindow door) : base(actor, game) { if (door == null) { throw new ArgumentNullException("door"); } m_Door = door; }
public ActionBashDoor(Actor actor, DoorWindow door) : base(actor) { #if DEBUG if (null == door) { throw new ArgumentNullException(nameof(door)); } #endif m_Door = door; }
public void UpdateDoorWindow(DoorWindow doorWindow) { if (!_doorWindows.Exists(x => x._itemId == doorWindow._itemId)) { return; } var newProperties = _doorWindows.Find(x => x._itemId == doorWindow._itemId); newProperties = doorWindow; }
protected void BarricadeDoors(Map map, Rectangle rect, int barricadeLevel) { barricadeLevel = Math.Min(Rules.BARRICADING_MAX, barricadeLevel); for (int x = rect.Left; x < rect.Right; x++) { for (int y = rect.Top; y < rect.Bottom; y++) { DoorWindow door = map.GetMapObjectAt(x, y) as DoorWindow; if (door == null) { continue; } door.BarricadePoints = barricadeLevel; } } }
private void InstanceStructureGO() { var doorWindow = new DoorWindow(); if (!string.IsNullOrEmpty(_width.text)) { doorWindow.Width = int.Parse(_width.text); } if (!string.IsNullOrEmpty(_height.text)) { doorWindow.Height = int.Parse(_height.text); } doorWindow._itemType = _type.value; var wall = Instantiate(_prefab, _world); wall.GetComponent <DoorWindowProperties>().SetData(doorWindow); }
protected static bool PlaceDoorIfAccessible(Map map, Point pt, TileModel floor, int minAccessibility, DoorWindow door) { int num = Direction.COMPASS.Select(d => pt + d).Count(pt2 => map.IsWalkable(pt2)); // includes IsInBounds check if (num < minAccessibility) { return(false); } PlaceDoorIfNoObject(map, pt, floor, door); return(true); }
protected static bool PlaceDoorIfAccessibleAndNotAdjacent(Map map, Point pt, TileModel floor, int minAccessibility, DoorWindow door) { int num = 0; foreach (var point2 in pt.Adjacent()) // micro-optimized: loop combines a reject-any check with a counting operation { if (map.IsWalkable(point2)) { ++num; } if (map.GetMapObjectAt(point2) is DoorWindow) { return(false); } } if (num < minAccessibility) { return(false); } PlaceDoorIfNoObject(map, pt, floor, door); return(true); }
protected static void PlaceDoorIfNoObject(Map map, Point pt, TileModel floor, DoorWindow door) { if (!map.HasMapObjectAt(pt)) { PlaceDoor(map, pt, floor, door); } }
protected static void PlaceDoor(Map map, Point pt, TileModel floor, DoorWindow door) { map.SetTileModelAt(pt, floor); MapObjectPlace(map, pt, door); }
public ActionOpenDoor(Actor actor, DoorWindow door) : base(actor) { m_Door = door; }
public ActionCloseDoor(Actor actor, DoorWindow door, bool free = false) : base(actor) { m_Door = door; m_IsFreeAction = free; }