public void AssignNeighbors() { for (int y = 0; y < m_height; y++) { for (int x = 0; x < m_width; x++) { RoomBase tScript = m_rooms[x + y * m_width]; tScript.m_neighbors = new RoomBase[4]; if (x != 0) { tScript.m_neighbors[(int)RoomBase.nbors.left] = m_rooms[(x + y * m_width) - 1]; } if (x < m_width - 1) { tScript.m_neighbors[(int)RoomBase.nbors.right] = m_rooms[(x + y * m_width) + 1]; } if (y != 0) { tScript.m_neighbors[(int)RoomBase.nbors.bottom] = m_rooms[(x + y * m_width) - m_width]; } if (y < m_height - 1) { tScript.m_neighbors[(int)RoomBase.nbors.top] = m_rooms[(x + y * m_width) + m_width]; } } } }
protected override void OnDivisibleStateChanged(RoomBase room, DivisibleStateChangeType changeType) { switch (changeType) { case DivisibleStateChangeType.Connected: foreach (var uiController in room.UIControllers) { uiController.Room = this; } foreach (var display in room.Displays) { display.Source = Source; } break; case DivisibleStateChangeType.Disconnected: foreach (var uiController in room.DefaultUIControllers) { uiController.ConnectToDefaultRoom(); } foreach (var display in room.Displays) { display.Source = room.Source; } break; } }
/// <summary> /// 普通攻击 /// </summary> /// <param name="room"></param> /// <param name="skillId"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="effect"></param> /// <returns></returns> public static DtoDamage[] NormalAttack(RoomBase <MobaPeer> room, int skillId, DtoMinion from, DtoMinion[] to, EffectModel effect) { DtoDamage[] damages = new DtoDamage[to.Length]; int attack = from.Attack; // 遍历被攻击者 for (int i = 0; i < to.Length; i++) { DtoMinion item = to[i]; if (item == null) { continue; } int defense = item.Defense; int damage = attack - defense; // 减少生命值 item.CurHp -= damage; // 死亡处理 if (item.CurHp <= 0) { ((BattleRoom)room).UnitLost(from, item); } damages[i] = new DtoDamage(from.Id, item.Id, damage, item.CurHp <= 0); } return(damages); }
public static void Main(string[] args) { // Create a random generator. Random random = new Random(); // Generate a map. MapGenerator generator = new MapGenerator(6, 3, random); RoomBase startRoom = generator.Generate(); // Prepare the game controller. Controller controller = new Controller(startRoom, 100, 3); StringBuilder builder = new StringBuilder(); controller.DescribeRoom(builder); Console.Write(builder.ToString()); // Main game loop. while (!controller.HasWon) { string command = Console.ReadLine(); command = command.Trim().ToLowerInvariant(); builder = new StringBuilder(); controller.ExecuteCommand(builder, command); Console.Write(builder.ToString()); } Console.ReadLine(); }
/// <summary>Creates service definition that can be registered with a server</summary> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static grpc::ServerServiceDefinition BindService(RoomBase serviceImpl) { return(grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_Join, serviceImpl.Join) .AddMethod(__Method_Sync, serviceImpl.Sync) .AddMethod(__Method_Leave, serviceImpl.Leave).Build()); }
public ADisplay(RoomBase room, DisplayDeviceBase displayDevice, DisplayConfig config) : base(room, displayDevice) { _config = config; Name = _config.Name; Position = config.Position; }
protected override void OnRoomDetailsChange(RoomBase room) { base.OnRoomDetailsChange(room); _roomNameLabel.Text = room.Name; _roomContactNumberLabel.Text = room.RoomContactNumber; }
private void CarveRooms() { for (int i = 0; i < MAX_ROOMS; i++) { var width = Random.Next(ROOM_MIN_SIZE, ROOM_MAX_SIZE); var height = Random.Next(ROOM_MIN_SIZE, ROOM_MAX_SIZE); var x = Random.Next(0, Width - width); var y = Random.Next(0, Height - height); var newRoom = new RoomBase(x, y, width, height); bool failed = false; foreach (var otherRoom in Rooms) { if (newRoom.Intersects(otherRoom)) { failed = true; continue; } } if (!failed) { // no intersections; the room is valid CreateRoom(newRoom); Rooms.Add(newRoom); } } }
private void AddItemsToRoom(RoomBase room) { // Keys. if (_random.Next(0, 3) == 0) { int keyLevel = 0; for (int i = 0; i < 2; i++) { if (_random.Next(0, 5) == 0) { keyLevel++; } } ItemBase item = new SmallKeyItem(keyLevel); room.Items.Add(item); _availableItems.Add(item); } // MEGABLOKS sets. if (_random.Next(0, 8) == 0) { ItemBase item = new MegaBloksSet(); room.Items.Add(item); _availableItems.Add(item); } }
public void CarveRoom() { var room = new RoomBase(1, 1, Width - 3, Height - 3); CreateRoom(room); Rooms.Add(room); }
protected virtual void OnRoomSourceChange(RoomBase room, RoomSourceChangeEventArgs args) { if (room != Room || !System.Booted) { return; } try { if (SourceChange != null) { SourceChange(room, args); } } catch (Exception e) { CloudLog.Exception(e); } if (args.NewSource != null) { UIShouldShowSource(args.NewSource); } else { UIShouldShowHomePage(ShowHomePageEventType.OnClearingSource); } }
public void OfferSelected(User user, ReceivedMessage message) { var splitted = message.Text.Split(' '); if (splitted.Length < 2) { goto SomethingWrong; } var action = splitted[0]; var itemName = string.Join(" ", splitted.Skip(1)); var itemManger = RoomBase.GetAllItems(); var item = itemManger.Keys() .Select(id => itemManger.Get(id)) .SingleOrDefault(i => i != null && i.Name == itemName); if (item == null) { goto SomethingWrong; } var offers = Offers.Load(); if (!offers.TryGetValue(item.Identifier, out var offer)) { goto SomethingWrong; } var state = new BuySellState { SelectedItemId = item.Identifier }; switch (action) { case "Продать": { state.Selling = true; break; } case "Купить": { state.Selling = false; break; } default: goto SomethingWrong; } Room.GetRoomVariables(user).Set("state", StateContainer.Serialize(state)); Room.SwitchAction <AuctionRoom.ItemOffersAction>(user); Room.GetAction <AuctionRoom.ItemOffersAction>().Enter(user); return; SomethingWrong: Enter(user); }
public MpcUIController(SystemBase system, RoomBase defaultRoom) : base(system, system.ControlSystem.MPC3x201TouchscreenSlot, defaultRoom) { var mpc = system.ControlSystem.MPC3x201TouchscreenSlot; mpc.Register(); _sourceButtons = new ButtonCollection { { 1, new UIButton(this, 5) }, { 2, new UIButton(this, 6) } }; _chanButtons = new ButtonCollection { { 1, new UIButton(this, 7) }, { 2, new UIButton(this, 10) } }; _audioButtons = new ButtonCollection { { 1, new UIButton(this, 8) }, { 2, new UIButton(this, 9) } }; _sourceButtons.ButtonEvent += SourceButtonsOnButtonEvent; _chanButtons.ButtonEvent += ChanButtonsOnButtonEvent; _audioButtons.ButtonEvent += AudioButtonsOnButtonEvent; _powerBtn = new UIButton(this, 10); _powerBtn.ButtonEvent += PowerBtnOnButtonEvent; _level = new MpcVolume(mpc); ((ASystem)system).Dsp.HasIntitialized += DspOnHasIntitialized; }
public DoorInstance(OrthogonalLine doorLine, Vector2Int facingDirection, RoomBase connectedRoom, RoomInstance connectedRoomInstance) { this.doorLine = doorLine; this.facingDirection = facingDirection; this.connectedRoom = connectedRoom; this.connectedRoomInstance = connectedRoomInstance; this.isHorizontal = FacingDirection == Vector2Int.up || FacingDirection == Vector2Int.down; }
public void RemoveRoomFromAllowedRooms(RoomBase room) { if (!_allowedRooms.Contains(room)) { throw new Exception("Room already not in allowed rooms"); } _allowedRooms.Remove(room); }
public void AddRoomToAllowedRooms(RoomBase room) { if (_allowedRooms.Contains(room)) { throw new Exception("Room already added"); } _allowedRooms.Add(room); }
/// <summary> /// Creates a room node from a given room. /// </summary> /// <param name="room"></param> /// <returns></returns> private RoomNode CreateRoomNode(RoomBase room) { var roomNode = new RoomNode(room); roomNodes.Add(roomNode); return(roomNode); }
public Controller(RoomBase currentRoom, int health, int money) { _currentRoom = currentRoom; _health = health; _money = money; _inventory = new List <ItemBase>(); _hasWon = false; }
protected override void OnRoomChange(UIController uiController, RoomBase previousRoom, RoomBase newRoom) { base.OnRoomChange(uiController, previousRoom, newRoom); if (_techPage.Visible || newRoom == null) { return; } SetHeaderTitle(newRoom.Name); }
// Start is called before the first frame update void Start() { Debug.Log("dab"); roomScript = GameObject.Find("room").GetComponent <RoomBase>(); player = GameObject.Find("player"); currentRoom = 0; currentTile = new Vector2(0, 0); currentPosition = roomScript.getActualPos(); }
// Start is called before the first frame update void Start() { roomScript = GameObject.Find("room").GetComponent <RoomBase>(); //Set the variables for the room roomScript.setActualPos(new Vector2(9, 9)); roomScript.setXMax(20); roomScript.setYMax(12); //roomScript.setIllegalRoom(new Vector2(5, 0)); }
public void CreateRoom(RoomBase created) { for (int x = created.Room.X + 1; x < created.Room.Right; x++) { for (int y = created.Room.Y + 1; y < created.Room.Bottom; y++) { Tiles[y * Width + x] = new Floor(x, y); } } }
public RoomInstance(RoomBase room, bool isCorridor, ConnectionBase connection, GameObject roomTemplatePrefab, GameObject roomTemplateInstance, Vector3Int position, Polygon2D outlinePolygon) { this.room = room; this.connection = connection; this.roomTemplatePrefab = roomTemplatePrefab; this.roomTemplateInstance = roomTemplateInstance; this.position = position; this.outlinePolygon = outlinePolygon; this.isCorridor = isCorridor; }
public void MoveToRoom(RoomBase room, Character objectToAdd) { if (objectToAdd.GetType().BaseType == typeof(Character) || objectToAdd.GetType() == typeof(Character)) { RoomBase originalRoom = objectToAdd.currentRoom; originalRoom.peoplePresent.Remove((Character)objectToAdd); objectToAdd.currentRoom = room; room.peoplePresent.Add((Character)objectToAdd); } }
/// <summary> /// Setups room shapes for a given room. /// </summary> /// <param name="room"></param> protected List <GameObject> GetRoomTemplates(RoomBase room) { var roomTemplates = room.GetRoomTemplates(); if (roomTemplates == null || roomTemplates.Count == 0) { return(GetRoomTemplates(config.LevelGraph.DefaultRoomTemplateSets, config.LevelGraph.DefaultIndividualRoomTemplates)); } return(roomTemplates); }
public Door findDoorFromDestination(Door door, RoomBase room, string exitString) { foreach (KeyValuePair <RoomExit, RoomBase> kvp in room.exits) { if (kvp.Value.ObjectName == exitString) { return(kvp.Key.door); } } return(door); }
public void AddToRoom(RoomBase room, GameObject objectToAdd) { if (objectToAdd.GetType().BaseType == typeof(Character) || objectToAdd.GetType() == typeof(Character)) { objectToAdd.currentRoom = room; room.peoplePresent.Add((Character)objectToAdd); } else { room.contents.Add(objectToAdd.ObjectName, objectToAdd); } }
private void CreateNewRoom() { Point roomPos = PickStartingPoint(); while (Tiles[roomPos.Y * Width + roomPos.X].IsBlockingMove) { roomPos = PickStartingPoint(); } RoomBase room = new RoomBase(new Rectangle(roomPos, new Point(1, 1))); Rooms.Add(room); }
public static void AttakSpeedDouble(RoomBase <MobaPeer> room, int skillId, DtoMinion from, DtoMinion[] to, EffectModel effect) { double original = from.AttackInterval; // 增加攻速 1/攻击间隔 转换为每秒攻击次数 再乘以倍数 from.AttackInterval = 1 / (1 / from.AttackInterval * (effect.EffectValue - 1)); // 恢复攻速 room.StartSchedule(DateTime.UtcNow.AddSeconds(effect.Duration), () => { from.AttackInterval = original; }); }
/// <summary> /// 使用技能 执行技能效果 不处理伤害 /// </summary> /// <param name="room">使用房间</param> /// <param name="from">使用者</param> /// <param name="to">目标</param> /// <returns></returns> public void RunSkill(RoomBase <MobaPeer> room, DtoMinion from, DtoMinion[] to) { if (Effect == null) { return; } for (int i = 0; i < Effect.GetInvocationList().Length; i++) { var action = (EffectHandler)Effect.GetInvocationList()[i]; action(room, SkillId, from, to, Data[i]); } }