public void InitData() { AnalysisRate(); areaCount = areaTran.childCount; for (int i = 0; i < areaCount; i++) { Area area = areaTran.GetChild(i).GetComponent <Area>(); area.Id = i + 1; } currentBetChipType = ChipType.Ten; currentChip = chipsArray [0]; isOpenHistory = false; chipsArray [0].transform.localScale = Vector3.one * 1.2f; chipsArray [1].transform.localScale = Vector3.one * 0.8f; chipsArray [2].transform.localScale = Vector3.one * 0.8f; chipsArray [3].transform.localScale = Vector3.one * 0.8f; continueCountTex.gameObject.SetActive(false); InitLotteryRecord(GameData.Instance.LotteryRecordList); GameData.Instance.LottryRecordChangeEvent += InitLotteryRecord; ContinueCount = 0; curMoreFunctionState = MoreFunctionState.Close; moreFunctionContent.SetActive(false); }
public RSoundChip SearchOPNA() { if (nScci != null) { int iCount = nScci.NSoundInterfaceManager_.getInterfaceCount(); for (int i = 0; i < iCount; i++) { NSoundInterface iIntfc = nScci.NSoundInterfaceManager_.getInterface(i); NSCCI_INTERFACE_INFO iInfo = nScci.NSoundInterfaceManager_.getInterfaceInfo(i); int sCount = iIntfc.getSoundChipCount(); for (int s = 0; s < sCount; s++) { NSoundChip sc = iIntfc.getSoundChip(s); int t = sc.getSoundChipType(); if (t != 1) { continue; } string ChipName = sc.getSoundChipInfo().cSoundChipName; string InterfaceName = iInfo.cInterfaceName; RScciSoundChip rsc = new RScciSoundChip(0, i, s); rsc.scci = nScci; return(rsc); } } } if (nc86ctl != null) { int iCount = nc86ctl.getNumberOfChip(); for (int i = 0; i < iCount; i++) { NIRealChip rc = nc86ctl.getChipInterface(i); NIGimic2 gm = rc.QueryInterface(); ChipType cct = gm.getModuleType(); if (cct != ChipType.CHIP_YM2608 && cct != ChipType.CHIP_YMF288) { continue; } int o = -1; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } string ChipName = gm.getModuleInfo().Devname; string InterfaceName = gm.getMBInfo().Devname; RC86ctlSoundChip rsc = new RC86ctlSoundChip(-1, i, o); rsc.c86ctl = nc86ctl; return(rsc); } } return(null); }
private ChipType[,] CreateEmptyBlock(int door, int height, int width) { var block = new ChipType[height, width]; // 外周を全て埋める for (int w = 0; w < width; ++w) { block[0, w] = ChipType.Wall; block[height - 1, w] = ChipType.Wall; } for (int h = 1; h < height - 1; ++h) { block[h, 0] = ChipType.Wall; block[h, width - 1] = ChipType.Wall; } // 奇数行列だけ埋める for (int h = 2; h < height - 1; h += 2) { for (int w = 2; w < width; w += 2) { block[h, w] = ChipType.Wall; } } return(block); }
public Chip(ChipName name, ChipType _type) { type = _type; Name = name; NumConnectLimit = LimitConnect.Get(name); }
public void SureBet() { int count = selectedChipObjList.Count; if (count > 0) { for (int i = 0; i < count; i++) { Destroy(selectedChipObjList[i]); } } betedChipCount += chipCount; if (betedChipCount > 0) { betedChipCountText.gameObject.SetActive(true); betedChipCountText.text = betedChipCount.ToString(); } else { betedChipCountText.gameObject.SetActive(false); } chipCount = 0; selectedChipObjList.Clear(); curType = ChipType.None; chipCountText.gameObject.SetActive(false); }
private ChipType[,] CreateEmptyBlock(int door, int height, int width) { var block = new ChipType[height, width]; // 바깥 둘레를 모두 메운다. for (int w = 0; w < width; ++w) { block[0, w] = ChipType.Wall; block[height - 1, w] = ChipType.Wall; } for (int h = 1; h < height - 1; ++h) { block[h, 0] = ChipType.Wall; block[h, width - 1] = ChipType.Wall; } // 홀수 행렬만 메운다. // (4타일의 중심. 기둥이 놓인 곳). for (int h = 2; h < height - 1; h += 2) { for (int w = 2; w < width; w += 2) { block[h, w] = ChipType.Wall; } } return(block); }
public void PlaySound(int wavId, ChipType chipType, bool muteOther, MuteGroupType muteGroup, float volume = 1.0f, float delayTime = 0.0f) { if (!mWavInfoList.ContainsKey(wavId)) { // fallback to drum clip sound. var prop = UserManager.Instance.LoggedOnUser.DrumChipProperty[chipType]; MainScript.Instance.DrumSound.PlaySound( chipType, prop.MuteBeforeUtter, prop.MuteGroupType, volume); return; } if (muteOther && muteGroup != MuteGroupType.Unknown) { foreach (var soundInfo in mWavInfoList.Values) { if (soundInfo.MuteGroup == muteGroup) { soundInfo.Stop(); } } } var waveInfo = mWavInfoList[wavId]; waveInfo.PlaySound(muteGroup, volume); }
private static extern FT_STATUS FT_GetDeviceInfoDetail( uint index, ref DeviceState flags, ref ChipType chiptype, ref uint id, ref uint locid, [In, Out] byte[] serialnumber, [In, Out] byte[] description, ref IntPtr ftHandle);
public List <Setting.ChipType> GetRealChipList() { List <Setting.ChipType> ret = new List <Setting.ChipType>(); if (nScci != null) { int iCount = nScci.NSoundInterfaceManager_.getInterfaceCount(); for (int i = 0; i < iCount; i++) { NSoundInterface iIntfc = nScci.NSoundInterfaceManager_.getInterface(i); NSCCI_INTERFACE_INFO iInfo = nScci.NSoundInterfaceManager_.getInterfaceInfo(i); int sCount = iIntfc.getSoundChipCount(); for (int s = 0; s < sCount; s++) { NSoundChip sc = iIntfc.getSoundChip(s); int t = sc.getSoundChipType(); Setting.ChipType ct = new Setting.ChipType(); ct.SoundLocation = 0; ct.BusID = i; ct.SoundChip = s; ct.ChipName = sc.getSoundChipInfo().cSoundChipName; ct.Type = t; ct.InterfaceName = iInfo.cInterfaceName; ret.Add(ct); } } } if (nc86ctl != null) { int iCount = nc86ctl.getNumberOfChip(); for (int i = 0; i < iCount; i++) { NIRealChip rc = nc86ctl.getChipInterface(i); NIGimic2 gm = rc.QueryInterface(); ChipType cct = gm.getModuleType(); Setting.ChipType ct = null; int o = -1; ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; ret.Add(ct); } } return(ret); }
public FtdiDeviceInfo(DeviceState flags, ChipType type, uint id, uint locationId, IntPtr handle, string serialNumber, string description) { Flags = flags; Type = type; Id = id; LocationId = locationId; Handle = handle; SerialNumber = serialNumber; Description = description; }
public MMC1(Emulator emulator, ChipType chipType) : base(emulator) { _type = chipType; if (chipType == ChipType.MMC1B) { _prgRAMEnabled = true; } UpdateControl(0x0F); _emulator.Cartridge.MirroringMode = Horizontal; }
public void CancleBet() { for (int i = 0; i < selectedChipObjList.Count; i++) { Destroy(selectedChipObjList[i]); } chipCount = 0; selectedChipObjList.Clear(); curType = ChipType.None; chipCountText.gameObject.SetActive(false); }
public ChipTypeConversion(string pn, string an, ChipType scType, FITOMDeviceType ftType, bool bfm, bool rhy, bool pcm, bool psg) { ProductName = pn; AliasName = an; SCCIType = scType; FITOMType = ftType; FM = bfm; Rhythm = rhy; PCM = pcm; PSG = psg; }
public void Init(int id) { Id = id; chipCount = 0; betedChipCount = 0; selectedChipObjList.Clear(); betedChipCountText.gameObject.SetActive(false); curType = ChipType.None; rateText = transform.FindChild("OddsText").GetComponent <EasyFontTextMesh>(); name = GameData.Instance.areaNameDic[Id]; InitRate(); }
/// <summary> /// The GetChipValue method is called to return the dollar value for a provided chip type. /// </summary> /// <param name="chipType"></param> /// <returns></returns> public static int GetChipValue(ChipType chipType) { int value = 0; switch (chipType) { case ChipType.One: value = Constants.OneDollar; break; case ChipType.Five: value = Constants.FiveDollar; break; case ChipType.TwentyFive: value = Constants.TwentyFiveDollar; break; case ChipType.OneHundred: value = Constants.OneHundredDollar; break; case ChipType.FiveHundred: value = Constants.FiveHundredDollar; break; case ChipType.OneThousand: value = Constants.OneThousandDollar; break; case ChipType.FiveThousand: value = Constants.FiveThousandDollar; break; case ChipType.TwentyFiveThousand: value = Constants.TwentyFiveThousandDollar; break; case ChipType.OneHundredThousand: value = Constants.OneHundredThousandDollar; break; case ChipType.FiveHundredThousand: value = Constants.FiveHundredThousandDollar; break; } return(value); }
public void Chip5O0nClick() { if (isOpenHistory) { return; } AudioManager.Instance.PlaySound(SoundName.ButtonClick); if (currentBetChipType != ChipType.FiveHundred) { currentBetChipType = ChipType.FiveHundred; currentChip.localScale = Vector3.one * 0.8f; currentChip = chipsArray[3]; chipsArray [3].transform.localScale = Vector3.one * 1.2f; } }
public void StopBet() { int count = selectedChipObjList.Count; if (count > 0) { for (int i = 0; i < count; i++) { Destroy(selectedChipObjList[i]); } } chipCount = 0; selectedChipObjList.Clear(); curType = ChipType.None; chipCountText.gameObject.SetActive(false); }
public FT_STATUS GetDeviceInfoDetail( uint index, ref DeviceState flags, ref ChipType chiptype, ref uint id, ref uint locid, byte[] serialnumber, byte[] description, ref IntPtr ftHandle) => FT_GetDeviceInfoDetail( index, ref flags, ref chiptype, ref id, ref locid, serialnumber, description, ref ftHandle);
public void OnClick() { if (BetPanel.Instance.isOpenHistory) { return; } if (GameData.Instance.currentGameState == GameState.StopBet) { TipsManager.Instance.ShowTips("本期已封盘,请等待下期"); return; } else if (GameData.Instance.currentGameState == GameState.Resulting) { TipsManager.Instance.ShowTips("开奖同步中……"); return; } if (curType == ChipType.None) { curType = BetPanel.Instance.currentBetChipType; } else if (curType != BetPanel.Instance.currentBetChipType) { TipsManager.Instance.ShowTips("确认下注后在下注"); return; } AudioManager.Instance.PlaySound(SoundName.AddChip); Debug.Log("Id:" + Id); BetPanel.Instance.CurrentSelectArea = this; chipCount += (int)BetPanel.Instance.currentBetChipType; GameObject obj = ResoureManager.Instance.LoadUIPrefab("Chip"); obj.GetComponent <tk2dSprite> ().SetSprite(GetChipName()); obj.transform.position = currentChip.transform.position; obj.transform.DOScale(0.5f, 0.5f); obj.transform.DOLocalMove(this.transform.position, 0.5f).OnComplete(AnimCallBack); selectedChipObjList.Add(obj); BetPanel.Instance.AddToSelectedAreaList(this); }
/// <summary> /// Default constructor. /// </summary> public RoulettePlayer() : base() { // Cash/bets. _totalCash = Constants.InitialCashDollars; // Chips. _selectedChip = ChipType.Undefined; OneChip = new One(); FiveChip = new Five(); TwentyFiveChip = new TwentyFive(); OneHundredChip = new OneHundred(); FiveHundredChip = new FiveHundred(); OneThousandChip = new OneThousand(); FiveThousandChip = new FiveThousand(); TwentyFiveThousandChip = new TwentyFiveThousand(); OneHundredThousandChip = new OneHundredThousand(); FiveHundredThousandChip = new FiveHundredThousand(); // Commands. ClearBetsCommand = new DelegateCommand(ClearBets).ObservesCanExecute(() => PlaceBets); }
public void NextMovement(int row, int col, ChipType chipType) { _board[row, col] = (int)chipType; Clients.AllExcept(this.Context.ConnectionId).showNewMovement(row,col,chipType); var gameOver = CheckGameOver(row, col); switch (gameOver) { case 1: _board = new int[Total, Total]; Clients.All.gameOver(_users[this.Context.ConnectionId]); _users.Clear(); break; case -1: _board = new int[Total, Total]; Clients.All.gameOver(""); _users.Clear(); break; } }
public void PlaySound(ChipType chipType, bool muteOther = false, MuteGroupType muteGroup = MuteGroupType.Unknown, float volume = 1f) { if (!mChipTypeToDrumSound.ContainsKey(chipType)) { return; } if (muteOther && muteGroup != MuteGroupType.Unknown) { foreach (var soundInfo in mChipTypeToDrumSound.Values) { if (soundInfo.MuteGroup == muteGroup) { soundInfo.Stop(); } } } var drumSoundInfo = mChipTypeToDrumSound[chipType]; drumSoundInfo.PlaySound(muteGroup, volume); }
private void changeColorByType() { string type = this.gameObject.name.Split('_')[1]; switch (type) { case "Turret": Type = ChipType.TURRET; this.gameObject.GetComponent <SpriteRenderer>().color = Color.red; break; case "Const": Type = ChipType.CONST; this.gameObject.GetComponent <SpriteRenderer>().color = Color.white; break; case "State": Type = ChipType.STATE; this.gameObject.GetComponent <SpriteRenderer>().color = Color.green; break; case "Consumable": Type = ChipType.CONSUMABLE; this.gameObject.GetComponent <SpriteRenderer>().color = Color.yellow; break; case "Skill": Type = ChipType.SKILL; this.gameObject.GetComponent <SpriteRenderer>().color = Color.cyan; break; default: Type = ChipType.NONE; break; } }
public RSoundChip GetRealChip(Setting.ChipType chipType, int ind = 0) { if (nScci != null) { int iCount = nScci.NSoundInterfaceManager_.getInterfaceCount(); for (int i = 0; i < iCount; i++) { NSoundInterface iIntfc = nScci.NSoundInterfaceManager_.getInterface(i); NSCCI_INTERFACE_INFO iInfo = nScci.NSoundInterfaceManager_.getInterfaceInfo(i); int sCount = iIntfc.getSoundChipCount(); for (int s = 0; s < sCount; s++) { NSoundChip sc = iIntfc.getSoundChip(s); switch (ind) { case 0: if (0 == chipType.SoundLocation && i == chipType.BusID && s == chipType.SoundChip) { RScciSoundChip rsc = new RScciSoundChip(0, i, s, chipType.Type); rsc.scci = nScci; return(rsc); } break; case 1: if (0 == chipType.SoundLocation2A && i == chipType.BusID2A && s == chipType.SoundChip2A) { RScciSoundChip rsc = new RScciSoundChip(0, i, s, chipType.Type2A); rsc.scci = nScci; return(rsc); } break; case 2: if (0 == chipType.SoundLocation2B && i == chipType.BusID2B && s == chipType.SoundChip2B) { RScciSoundChip rsc = new RScciSoundChip(0, i, s, chipType.Type2B); rsc.scci = nScci; return(rsc); } break; } } } } if (nc86ctl != null) { int iCount = nc86ctl.getNumberOfChip(); for (int i = 0; i < iCount; i++) { NIRealChip rc = nc86ctl.getChipInterface(i); NIGimic2 gm = rc.QueryInterface(); ChipType cct = gm.getModuleType(); int o = -1; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } switch (ind) { case 0: if (-1 == chipType.SoundLocation && i == chipType.BusID && o == chipType.SoundChip) { RC86ctlSoundChip rsc = new RC86ctlSoundChip(-1, i, o, chipType.Type); rsc.c86ctl = nc86ctl; return(rsc); } break; case 1: if (-1 == chipType.SoundLocation2A && i == chipType.BusID2A && o == chipType.SoundChip2A) { RC86ctlSoundChip rsc = new RC86ctlSoundChip(-1, i, o, chipType.Type2A); rsc.c86ctl = nc86ctl; return(rsc); } break; case 2: if (-1 == chipType.SoundLocation2B && i == chipType.BusID2B && o == chipType.SoundChip2B) { RC86ctlSoundChip rsc = new RC86ctlSoundChip(-1, i, o, chipType.Type2B); rsc.c86ctl = nc86ctl; return(rsc); } break; } } } return(null); }
public void DebugPrint(ChipType[,] block) { for (int h = 0; h < block.GetLength(0); ++h) { for (int w = 0; w < block.GetLength(1); ++w) { switch (block[h, w]) { case ChipType.Wall: Console.Write("@"); break; case ChipType.Floor: Console.Write(" "); break; case ChipType.BottomKey: Console.Write("b"); break; case ChipType.TopKey: Console.Write("t"); break; case ChipType.RightKey: Console.Write("r"); break; case ChipType.LeftKey: Console.Write("l"); break; case ChipType.Door: Console.Write("d"); break; case ChipType.BossKey: Console.Write("B"); break; default: throw new Exception("그런 블록은 없어요"); } } Console.WriteLine(string.Empty); } }
public ChipType[, ][,] CreateField() { if (this.blockHeight == 0) { throw new Exception("サイズをセットしてください"); } // スタートとゴールをランダム選択 int start = -1; int goal = -1; while (start == goal || goal < -1 || start < -1) { start = random.Next(4); goal = random.Next(4); } int door = 0; if (start == 0) { door |= Direction.Top; } else if (start == 1) { door |= Direction.Bottom; } else if (start == 2) { door |= Direction.Left; } else if (start == 3) { door |= Direction.Right; } if (goal == 0) { door |= Direction.Top; } else if (goal == 1) { door |= Direction.Bottom; } else if (goal == 2) { door |= Direction.Left; } else if (goal == 3) { door |= Direction.Right; } ChipType[, ][,] field = new ChipType[this.fieldHeight, this.fieldWidth][, ]; var block = CreateEmptyBlock(door, fieldHeight * 2 + 1, fieldWidth * 2 + 1); CreateWall(ref block); CreateDoor(ref block, door); // fieldサイズに圧縮 for (int h = 0; h < this.fieldHeight; ++h) { int blockH = 2 * h + 1; for (int w = 0; w < this.fieldWidth; ++w) { int blockW = 2 * w + 1; int blockDoor = 0; if (block[blockH + 1, blockW] != ChipType.Wall) { blockDoor |= Direction.Bottom; } if (block[blockH - 1, blockW] != ChipType.Wall) { blockDoor |= Direction.Top; } if (block[blockH, blockW + 1] != ChipType.Wall) { blockDoor |= Direction.Right; } if (block[blockH, blockW - 1] != ChipType.Wall) { blockDoor |= Direction.Left; } var curBlock = CreateEmptyBlock(blockDoor, this.blockHeight, this.blockWidth); CreateDoor(ref curBlock, blockDoor); CreateKey(ref curBlock, blockDoor); field[h, w] = curBlock; } } return(field); }
private void CreateDoor(ref ChipType[,] block, int door) { int hd = 0; int wd = 0; if (((block.GetLength(0)-2) / 2) % 2 == 1) hd = 1; if (((block.GetLength(1)-2) / 2) % 2 == 1) wd = 1; if ((door & Direction.Left) != 0) { block[block.GetLength(0)/2-hd, 0] = ChipType.Door; block[block.GetLength(0)/2-hd, 1] = ChipType.Floor; } if ((door & Direction.Right) != 0) { block[block.GetLength(0)/2-hd, block.GetLength(1)-1] = ChipType.Door; block[block.GetLength(0)/2-hd, block.GetLength(1)-2] = ChipType.Floor; } if ((door & Direction.Top) != 0) { block[0, block.GetLength(1)/2+wd] = ChipType.Door; block[1, block.GetLength(1)/2+wd] = ChipType.Floor; } if ((door & Direction.Bottom) != 0) { block[block.GetLength(0)-1, block.GetLength(1)/2+wd] = ChipType.Door; block[block.GetLength(0)-2, block.GetLength(1)/2+wd] = ChipType.Floor; } }
public MMC3(Emulator emulator, ChipType chipType) : base(emulator) { _type = chipType; _prgBankOffsets = new uint[] { 0, 0x2000, _lastBankOffset, _lastBankOffset + 0x2000 }; }
private void CreateKey(ref ChipType[,] block, int door) { // 플로어 수 카운트 int nofFloor = 0; for (int h = 1; h < block.GetLength(0)-1; ++h) { for (int w = 1; w < block.GetLength(1)-1; ++w) { if (block[h, w] == ChipType.Floor) ++nofFloor; } } // 열쇠 설치 for (int i = 0; i < 4; ++i) { ChipType key; if (i == 0) { key = ChipType.RightKey; if ((door & Direction.Right) == 0) continue; } else if (i == 1) { key = ChipType.LeftKey; if ((door & Direction.Left) == 0) continue; } else if (i == 2) { key = ChipType.BottomKey; if ((door & Direction.Bottom) == 0) continue; } else { key = ChipType.TopKey; if ((door & Direction.Top) == 0) continue; } double total = 0.0; double p = random.NextDouble(); for (int h = 1; h < block.GetLength(0)-1; ++h) { for (int w = 1; w < block.GetLength(1)-1; ++w) { total += 1.0 / nofFloor; if (block[h,w] != ChipType.Floor || p > total) continue; block[h, w] = key; --nofFloor; h = block.GetLength(0); break; } } } }
private void CreateDoor(ref ChipType[,] block, int door, bool is_room) { int hd = 0; int wd = 0; if (((block.GetLength(0)-2) / 2) % 2 == 1) hd = 1; if (((block.GetLength(1)-2) / 2) % 2 == 1) wd = 1; ChipType doorChip = ChipType.Door; if ((door & Direction.Left) != 0) { if(is_room) { block[block.GetLength(0)/2-hd, 0] = ChipType.Wall; block[block.GetLength(0)/2-hd, 1] = doorChip; } else { block[block.GetLength(0)/2-hd, 0] = doorChip; block[block.GetLength(0)/2-hd, 1] = ChipType.Floor; } } if ((door & Direction.Right) != 0) { if(is_room) { block[block.GetLength(0)/2-hd, block.GetLength(1)-1] = ChipType.Wall; block[block.GetLength(0)/2-hd, block.GetLength(1)-2] = doorChip; } else { block[block.GetLength(0)/2-hd, block.GetLength(1)-1] = doorChip; block[block.GetLength(0)/2-hd, block.GetLength(1)-2] = ChipType.Floor; } } if ((door & Direction.Top) != 0) { if(is_room) { block[0, block.GetLength(1)/2+wd] = ChipType.Wall; block[1, block.GetLength(1)/2+wd] = doorChip; } else { block[0, block.GetLength(1)/2+wd] = doorChip; block[1, block.GetLength(1)/2+wd] = ChipType.Floor; } } if ((door & Direction.Bottom) != 0) { if(is_room) { block[block.GetLength(0)-1, block.GetLength(1)/2+wd] = ChipType.Wall; block[block.GetLength(0)-2, block.GetLength(1)/2+wd] = doorChip; } else { block[block.GetLength(0)-1, block.GetLength(1)/2+wd] = doorChip; block[block.GetLength(0)-2, block.GetLength(1)/2+wd] = ChipType.Floor; } } }
/// <summary> /// 지정한 블록 간의 거리( )를 구한다. /// </summary> /// <param name="from_fh">블록 위치</param> /// <param name="from_fw">블록 위치</param> /// <param name="to_fh">블록 위치</param> /// <param name="to_fw">블록 위치</param> /// <returns>거리</returns> public int GetDistanceBetweenTwoBlock(ChipType[,][,] field, int from_fh, int from_fw, int to_fh, int to_fw) { // 일단 미로를 무시한 거리를 반환. // return Math.Abs(from_fh - to_fh) + Math.Abs(from_fw - to_fw); var h = field.GetLength(0); var w = field.GetLength(1); int[,] doorInfo = new int[h, w]; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { var d = 0; var b = field[i, j]; var bh = b.GetLength(0); var bw = b.GetLength(1); var bhc = (bh / 2) % 2 == 0 ? bh/2-1 : bh/2; var bwc = (bw / 2) % 2 == 0 ? bw/2+1 : bw/2; if (b[bhc, 0] == ChipType.Door) d |= Direction.Left; if (b[bhc, bw-1] == ChipType.Door) d |= Direction.Right; if (b[0, bwc] == ChipType.Door) d |= Direction.Top; if (b[bh-1, bwc] == ChipType.Door) d |= Direction.Bottom; doorInfo[i, j] = d; } } // DFS var distance = int.MaxValue; var closed = new bool[h, w]; var open = new Queue<KeyValuePair<int, int>>(); var d_buffer = new Queue<int>(); open.Enqueue(new KeyValuePair<int,int>(from_fh, from_fw)); d_buffer.Enqueue(0); Func<int, int, bool> RangeTest = (i, j) => { if (i < 0 || j < 0 || i >= h || j >= w) return false; return true; }; while (open.Count != 0) { var pos = open.Dequeue(); var i = pos.Key; var j = pos.Value; var d = d_buffer.Dequeue(); if (closed[i, j]) continue; if ((i == to_fh && j == to_fw) && distance > d) { distance = d; continue; } if (HasTargetDoor(doorInfo[i, j], Direction.Top) && RangeTest(i-1, j)) { open.Enqueue(new KeyValuePair<int, int>(i-1, j)); d_buffer.Enqueue(d+1); } if (HasTargetDoor(doorInfo[i, j], Direction.Bottom) && RangeTest(i+1, j)) { open.Enqueue(new KeyValuePair<int, int>(i+1, j)); d_buffer.Enqueue(d+1); } if (HasTargetDoor(doorInfo[i, j], Direction.Left) && RangeTest(i, j-1)) { open.Enqueue(new KeyValuePair<int, int>(i, j-1)); d_buffer.Enqueue(d+1); } if (HasTargetDoor(doorInfo[i, j], Direction.Right) && RangeTest(i, j+1)) { open.Enqueue(new KeyValuePair<int, int>(i, j+1)); d_buffer.Enqueue(d+1); } closed[i, j] = true; } return distance; }
public void DebugPrint(ChipType[,][,] field) { for (int fh = 0; fh < this.fieldHeight; ++fh) { for (int bh = 0; bh < this.blockHeight; ++bh) { for (int fw = 0; fw < this.fieldWidth; ++fw) { for (int bw = 0; bw < this.blockWidth; ++bw) { var temp = field[fh, fw][bh, bw]; switch (temp) { case ChipType.Wall: Console.Write("@"); break; case ChipType.Floor: Console.Write(" "); break; case ChipType.BottomKey: Console.Write("b"); break; case ChipType.TopKey: Console.Write("t"); break; case ChipType.RightKey: Console.Write("r"); break; case ChipType.LeftKey: Console.Write("l"); break; case ChipType.Door: Console.Write("d"); break; case ChipType.Spawn: Console.Write("s"); break; case ChipType.BossKey: Console.Write("B"); break; default: throw new Exception("그런 블록은 없어요"); } } } Console.WriteLine(string.Empty); } } }
/// <summary> /// 블록 내의 모퉁이에 적의 발생 위치를 랜덤하게 생성한다. /// </summary> /// <param name="block">대상 블록</param> public void CreateSpawnPointAtCornnerAtRandom(ChipType[,] block) { // 플로어 수를 카운트. int candidate = 0; // 스폰 포인트가 될 수 있는 플로어 수. for (int bh = 1; bh < block.GetLength(0); ++bh) { for (int bw = 1; bw < block.GetLength(1); ++bw) { if (block[bh, bw] != ChipType.Floor || !IsCornner(block, bh, bw)) continue; ++candidate; } } if (candidate == 0) return; // 플로어를 랜덤 선택. double r = random.NextDouble(); double total = 0.0; for (int bh = 1; bh < block.GetLength(0); ++bh) { for (int bw = 1; bw < block.GetLength(1); ++bw) { if (block[bh, bw] != ChipType.Floor || !IsCornner(block, bh, bw)) continue; total += 1.0/candidate; if (r < total) { block[bh, bw] = ChipType.Spawn; return; } } } }
/// <summary> /// 지정 위치가 모퉁인지 조사한다. /// </summary> private bool IsCornner(ChipType[,] block, int h, int w) { // 모퉁이인지 조사한다. if (block[h-1, w] == ChipType.Wall) if (block[h, w-1] == ChipType.Wall || block[h, w+1] == ChipType.Wall) return true; if (block[h+1, w] == ChipType.Wall) if (block[h, w-1] == ChipType.Wall || block[h, w+1] == ChipType.Wall) return true; return false; }
public ChipType[,][,] CreateField() { if (this.blockHeight == 0) throw new Exception("크기를 설정해 주세요"); // start과 goal을 랜덤하게 선택 int start = -1; int goal = -1; while (start == goal || goal < -1 || start < -1) { start = random.Next(4); goal = random.Next(4); } int door = 0; if (start == 0) door |= Direction.Top; else if (start == 1) door |= Direction.Bottom; else if (start == 2) door |= Direction.Left; else if (start == 3) door |= Direction.Right; if (goal == 0) door |= Direction.Top; else if (goal == 1) door |= Direction.Bottom; else if (goal == 2) door |= Direction.Left; else if (goal == 3) door |= Direction.Right; ChipType[,][,] field = new ChipType[this.fieldHeight, this.fieldWidth][,]; var block = CreateEmptyBlock(door, fieldHeight * 2 + 1, fieldWidth * 2 + 1); // 필드 문 설치. CreateDoor(ref block, door, false); // 필드를 구분하는 벽 배치. CreateWall(ref block); //var doorInfo = new int[this.fieldHeight, this.fieldWidth]; // 필드 구축. for (int h = 0; h < this.fieldHeight; ++h) { int blockH = 2 * h + 1; for (int w = 0; w < this.fieldWidth; ++w) { int blockW = 2 * w + 1; int blockDoor = 0; if (block[blockH+1, blockW] != ChipType.Wall) blockDoor |= Direction.Bottom; if (block[blockH-1, blockW] != ChipType.Wall) blockDoor |= Direction.Top; if (block[blockH, blockW+1] != ChipType.Wall) blockDoor |= Direction.Right; if (block[blockH, blockW-1] != ChipType.Wall) blockDoor |= Direction.Left; var curBlock = CreateEmptyBlock(blockDoor, this.blockHeight, this.blockWidth); field[h, w] = curBlock; CreateWall(ref curBlock); CreateDoor(ref curBlock, blockDoor, false); //CreateKey(ref curBlock, blockDoor); } } // 보스 열쇠 배치. //SetBossKey(field); return field; }
public List <Setting.ChipType> GetRealChipList(EnmRealChipType realChipType) { List <Setting.ChipType> ret = new List <Setting.ChipType>(); if (nScci != null) { int iCount = nScci.NSoundInterfaceManager_.getInterfaceCount(); for (int i = 0; i < iCount; i++) { NSoundInterface iIntfc = nScci.NSoundInterfaceManager_.getInterface(i); NSCCI_INTERFACE_INFO iInfo = nScci.NSoundInterfaceManager_.getInterfaceInfo(i); int sCount = iIntfc.getSoundChipCount(); for (int s = 0; s < sCount; s++) { NSoundChip sc = iIntfc.getSoundChip(s); int t = sc.getSoundChipType(); if (t == (int)realChipType) { Setting.ChipType ct = new Setting.ChipType(); ct.SoundLocation = 0; ct.BusID = i; ct.SoundChip = s; ct.ChipName = sc.getSoundChipInfo().cSoundChipName; ct.InterfaceName = iInfo.cInterfaceName; ret.Add(ct); } else { //互換指定をチェック NSCCI_SOUND_CHIP_INFO chipInfo = sc.getSoundChipInfo(); for (int n = 0; n < chipInfo.iCompatibleSoundChip.Length; n++) { if ((int)realChipType != chipInfo.iCompatibleSoundChip[n]) { continue; } Setting.ChipType ct = new Setting.ChipType(); ct.SoundLocation = 0; ct.BusID = i; ct.SoundChip = s; ct.ChipName = sc.getSoundChipInfo().cSoundChipName; ct.InterfaceName = iInfo.cInterfaceName; ret.Add(ct); break; } } } } } if (nc86ctl != null) { int iCount = nc86ctl.getNumberOfChip(); for (int i = 0; i < iCount; i++) { NIRealChip rc = nc86ctl.getChipInterface(i); NIGimic2 gm = rc.QueryInterface(); ChipType cct = gm.getModuleType(); Setting.ChipType ct = null; int o = -1; switch (realChipType) { case EnmRealChipType.AY8910: if (cct == ChipType.CHIP_UNKNOWN || cct == ChipType.CHIP_YM2608 || cct == ChipType.CHIP_YMF288 || cct == ChipType.CHIP_YM2203) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; case EnmRealChipType.YM2203: case EnmRealChipType.YM2608: if (cct == ChipType.CHIP_YM2608 || cct == ChipType.CHIP_YMF288 || cct == ChipType.CHIP_YM2203) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; case EnmRealChipType.YM2413: if (cct == ChipType.CHIP_YM2413 || cct == ChipType.CHIP_UNKNOWN) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; } break; case EnmRealChipType.YM2610: if (cct == ChipType.CHIP_YM2608 || cct == ChipType.CHIP_YMF288) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; case EnmRealChipType.YM2151: if (cct == ChipType.CHIP_YM2151) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; case EnmRealChipType.YM3526: case EnmRealChipType.YM3812: case EnmRealChipType.YMF262: if (cct == ChipType.CHIP_OPL3) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; } if (ct != null) { ret.Add(ct); } } } return(ret); }
/// <summary> /// Block을 만든다. /// </summary> /// <param name="emptyBlock"></param> /// <returns></returns> private void CreateWall(ref ChipType[,] emptyBlock) { int height = emptyBlock.GetLength(0); int width = emptyBlock.GetLength(1); for (int h = 2; h < height-1; h+=2) { for (int w = 2; w < width-1; w+=2) { int randMax = 3; var next = random.Next(randMax); if (next == 0) // 오른쪽 방향 emptyBlock[h,w+1] = ChipType.Wall; else if (next == 1) // 왼쪽 방향 emptyBlock[h,w-1] = ChipType.Wall; else if (next == 2) // 아래 방향 emptyBlock[h+1,w] = ChipType.Wall; } } }
public ChipType[,][,] CreateField() { if (this.blockHeight == 0) throw new Exception("サイズをセットしてください"); // スタートとゴールをランダム選択 int start = -1; int goal = -1; while (start == goal || goal < -1 || start < -1) { start = random.Next(4); goal = random.Next(4); } int door = 0; if (start == 0) door |= Direction.Top; else if (start == 1) door |= Direction.Bottom; else if (start == 2) door |= Direction.Left; else if (start == 3) door |= Direction.Right; if (goal == 0) door |= Direction.Top; else if (goal == 1) door |= Direction.Bottom; else if (goal == 2) door |= Direction.Left; else if (goal == 3) door |= Direction.Right; ChipType[,][,] field = new ChipType[this.fieldHeight, this.fieldWidth][,]; var block = CreateEmptyBlock(door, fieldHeight * 2 + 1, fieldWidth * 2 + 1); CreateWall(ref block); CreateDoor(ref block, door); // fieldサイズに圧縮 for (int h = 0; h < this.fieldHeight; ++h) { int blockH = 2 * h + 1; for (int w = 0; w < this.fieldWidth; ++w) { int blockW = 2 * w + 1; int blockDoor = 0; if (block[blockH+1, blockW] != ChipType.Wall) blockDoor |= Direction.Bottom; if (block[blockH-1, blockW] != ChipType.Wall) blockDoor |= Direction.Top; if (block[blockH, blockW+1] != ChipType.Wall) blockDoor |= Direction.Right; if (block[blockH, blockW-1] != ChipType.Wall) blockDoor |= Direction.Left; var curBlock = CreateEmptyBlock(blockDoor, this.blockHeight, this.blockWidth); CreateDoor(ref curBlock, blockDoor); CreateKey(ref curBlock, blockDoor); field[h, w] = curBlock; } } return field; }
private ChipType[,] CreateEmptyBlock(int door, int height, int width) { var block = new ChipType[height, width]; // 바깥 둘레를 모두 메운다. for (int w = 0; w < width; ++w) { block[0, w] = ChipType.Wall; block[height-1,w] = ChipType.Wall; } for (int h = 1; h < height-1; ++h) { block[h, 0] = ChipType.Wall; block[h, width-1] = ChipType.Wall; } // 홀수 행렬만 메운다. // (4타일의 중심. 기둥이 놓인 곳). for (int h = 2; h < height-1; h+=2) { for (int w = 2; w < width; w+=2) { block[h, w] = ChipType.Wall; } } return block; }
public LevelDescription(int width, int height, int colorCount, ChipColor defaultColor, ChipType defaultType) { Width = width; Height = height; ColorCount = colorCount; for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { var newSlotChipDescription = new SlotChipDescription() { Position = new int2(i, j), Color = defaultColor, ChipType = defaultType }; SlotChipDescriptions.Add(newSlotChipDescription); } } for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { var newSlotDescription = new SlotDescription() { Position = new int2(i, j), Generator = j == Height - 1 }; SlotDescriptions.Add(newSlotDescription); } } }
public YM2413(ChipType type) { MaxVolume = short.MaxValue; opll = OPLL_new(3579545, 44100, (int)type); }
private static RSoundChip CheckDevice() { SChipType ct = null; int iCount = 0; switch (device) { case 1: //GIMIC存在チェック nc86ctl = new Nc86ctl.Nc86ctl(); nc86ctl.initialize(); iCount = nc86ctl.getNumberOfChip(); if (iCount == 0) { nc86ctl.deinitialize(); nc86ctl = null; Log.WriteLine(LogLevel.ERROR, "Not found G.I.M.I.C."); device = 0; break; } for (int i = 0; i < iCount; i++) { NIRealChip rc = nc86ctl.getChipInterface(i); NIGimic2 gm = rc.QueryInterface(); ChipType cct = gm.getModuleType(); int o = -1; if (cct == ChipType.CHIP_YM2608 || cct == ChipType.CHIP_YMF288 || cct == ChipType.CHIP_YM2203) { ct = new SChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; ct = null; continue; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; break; } } RC86ctlSoundChip rsc = null; if (ct == null) { nc86ctl.deinitialize(); nc86ctl = null; Log.WriteLine(LogLevel.ERROR, "Not found G.I.M.I.C.(OPNA module)"); device = 0; } else { rsc = new RC86ctlSoundChip(-1, ct.BusID, ct.SoundChip); rsc.c86ctl = nc86ctl; rsc.init(); rsc.SetMasterClock(7987200); //SoundBoardII rsc.setSSGVolume(63); //PC-8801 } return(rsc); case 2: //SCCI存在チェック nScci = new NScci.NScci(); iCount = nScci.NSoundInterfaceManager_.getInterfaceCount(); if (iCount == 0) { nScci.Dispose(); nScci = null; Log.WriteLine(LogLevel.ERROR, "Not found SCCI."); device = 0; break; } for (int i = 0; i < iCount; i++) { NSoundInterface iIntfc = nScci.NSoundInterfaceManager_.getInterface(i); NSCCI_INTERFACE_INFO iInfo = nScci.NSoundInterfaceManager_.getInterfaceInfo(i); int sCount = iIntfc.getSoundChipCount(); for (int s = 0; s < sCount; s++) { NSoundChip sc = iIntfc.getSoundChip(s); int t = sc.getSoundChipType(); if (t == 1) { ct = new SChipType(); ct.SoundLocation = 0; ct.BusID = i; ct.SoundChip = s; ct.ChipName = sc.getSoundChipInfo().cSoundChipName; ct.InterfaceName = iInfo.cInterfaceName; goto scciExit; } } } scciExit :; RScciSoundChip rssc = null; if (ct == null) { nScci.Dispose(); nScci = null; Log.WriteLine(LogLevel.ERROR, "Not found SCCI(OPNA module)."); device = 0; } else { rssc = new RScciSoundChip(0, ct.BusID, ct.SoundChip); rssc.scci = nScci; rssc.init(); } return(rssc); } return(null); }
public List <Setting.ChipType> GetRealChipList(EnmRealChipType realChipType) { List <Setting.ChipType> ret = new List <Setting.ChipType>(); if (nScci != null) { int iCount = nScci.NSoundInterfaceManager_.getInterfaceCount(); for (int i = 0; i < iCount; i++) { NSoundInterface iIntfc = nScci.NSoundInterfaceManager_.getInterface(i); NSCCI_INTERFACE_INFO iInfo = nScci.NSoundInterfaceManager_.getInterfaceInfo(i); int sCount = iIntfc.getSoundChipCount(); for (int s = 0; s < sCount; s++) { NSoundChip sc = iIntfc.getSoundChip(s); int t = sc.getSoundChipType(); if (t == (int)realChipType || (realChipType == EnmRealChipType.YM2203 && t == (int)EnmRealChipType.YM2608) || (realChipType == EnmRealChipType.YM2610 && t == (int)EnmRealChipType.YM2608) || (realChipType == EnmRealChipType.AY8910 && t == (int)EnmRealChipType.YM2203) || (realChipType == EnmRealChipType.AY8910 && t == (int)EnmRealChipType.YM2608) || (realChipType == EnmRealChipType.AY8910 && t == (int)EnmRealChipType.YM2610) ) { Setting.ChipType ct = new Setting.ChipType(); ct.SoundLocation = 0; ct.BusID = i; ct.SoundChip = s; ct.ChipName = sc.getSoundChipInfo().cSoundChipName; ct.Type = t; ct.InterfaceName = iInfo.cInterfaceName; ret.Add(ct); } } } } if (nc86ctl != null) { int iCount = nc86ctl.getNumberOfChip(); for (int i = 0; i < iCount; i++) { NIRealChip rc = nc86ctl.getChipInterface(i); NIGimic2 gm = rc.QueryInterface(); ChipType cct = gm.getModuleType(); Setting.ChipType ct = null; int o = -1; switch (realChipType) { case EnmRealChipType.AY8910: if (cct == ChipType.CHIP_YM2608 || cct == ChipType.CHIP_YMF288 || cct == ChipType.CHIP_YM2203) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; case EnmRealChipType.YM2203: case EnmRealChipType.YM2608: if (cct == ChipType.CHIP_YM2608 || cct == ChipType.CHIP_YMF288 || cct == ChipType.CHIP_YM2203) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; case EnmRealChipType.YM2610: if (cct == ChipType.CHIP_YM2608 || cct == ChipType.CHIP_YMF288) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; case EnmRealChipType.YM2151: if (cct == ChipType.CHIP_YM2151) { ct = new Setting.ChipType(); ct.SoundLocation = -1; ct.BusID = i; string seri = gm.getModuleInfo().Serial; if (!int.TryParse(seri, out o)) { o = -1; } ct.SoundChip = o; ct.ChipName = gm.getModuleInfo().Devname; ct.InterfaceName = gm.getMBInfo().Devname; ct.Type = (int)cct; } break; } if (ct != null) { ret.Add(ct); } } } return(ret); }
private ChipType[,] CreateEmptyBlock(int door, int height, int width) { var block = new ChipType[height, width]; // 外周を全て埋める for (int w = 0; w < width; ++w) { block[0, w] = ChipType.Wall; block[height-1,w] = ChipType.Wall; } for (int h = 1; h < height-1; ++h) { block[h, 0] = ChipType.Wall; block[h, width-1] = ChipType.Wall; } // 奇数行列だけ埋める for (int h = 2; h < height-1; h+=2) { for (int w = 2; w < width; w+=2) { block[h, w] = ChipType.Wall; } } return block; }
public void SetChip(ChipType newChip, int x, int y) { chipInstances[x, y] = newChip; }
/// <summary> /// 출구와 입구를 획득한다 /// </summary> /// <remarks>출구와 입구에 차이는 없으니 편리한대로 사용하세요</remarks> /// <returns>출구와 입구의 장소</returns> public Position[] GetEndPoints(ChipType[,][,] field) { Position[] endpoints = new Position[2]; endpoints[0].fieldHeight = -1; // 왼쪽 벽을 조사한다 for (int fh = 0; fh < this.fieldHeight; ++fh) { for (int bh = 0; bh < this.blockHeight; ++bh) { if (field[fh, 0][bh, 0] == ChipType.Door) { endpoints[0].fieldHeight = fh; endpoints[0].fieldWidth = 0; endpoints[0].blockHeight = bh; endpoints[0].blockWidth = 0; fh = int.MaxValue-1; break; } } } // 위쪽 벽을 조사한다. for (int fw = 0; fw < this.fieldWidth; ++fw) { for (int bw = 0; bw < this.blockWidth; ++bw) { if (field[0, fw][0, bw] == ChipType.Door) { int target = endpoints[0].fieldHeight == -1 ? 0 : 1; endpoints[target].fieldHeight = 0; endpoints[target].fieldWidth = fw; endpoints[target].blockHeight = 0; endpoints[target].blockWidth = bw; if (target == 1) { return endpoints; } fw = int.MaxValue-1; break; } } } // 오른쪽 벽을 조사한다. for (int fh = 0; fh < this.fieldHeight; ++fh) { for (int bh = 0; bh < this.blockHeight; ++bh) { if (field[fh, this.fieldWidth-1][bh, this.blockWidth-1] == ChipType.Door) { int target = endpoints[0].fieldHeight == -1 ? 0 : 1; endpoints[target].fieldHeight = fh; endpoints[target].fieldWidth = this.fieldWidth-1; endpoints[target].blockHeight = bh; endpoints[target].blockWidth = this.blockWidth-1; if (target == 1) { return endpoints; } fh = int.MaxValue-1; break; } } } // 아래쪽 벽을 조사한다. for (int fw = 0; fw < this.fieldWidth; ++fw) { for (int bw = 0; bw < this.blockWidth; ++bw) { if (field[this.fieldHeight-1, fw][this.blockHeight-1, bw] == ChipType.Door) { int target = endpoints[0].fieldHeight == -1 ? 0 : 1; endpoints[target].fieldHeight = this.fieldHeight-1; endpoints[target].fieldWidth = fw; endpoints[target].blockHeight = this.blockHeight-1; endpoints[target].blockWidth = bw; if (target == 1) { return endpoints; } fw = int.MaxValue-1; break; } } } return endpoints; }
private void SetBossKey(ChipType[,][,] field) { var ep = GetEndPoints(field); for (int i = 0; i < ep.Length; ++i) { var block = field[ep[i].fieldHeight, ep[i].fieldWidth]; // Endpoint가 있는 블록. // endpoint를 여는 열쇠 삭제. for (int bh = 0; bh < block.GetLength(0); ++bh) { for (int bw = 0; bw < block.GetLength(1); ++bw) { if ((ep[i].blockHeight == 0 && block[bh, bw] == ChipType.TopKey) || (ep[i].blockHeight == block.GetLength(0)-1 && block[bh, bw] == ChipType.BottomKey) || (ep[i].blockWidth == 0 && block[bh, bw] == ChipType.LeftKey) || (ep[i].blockWidth == block.GetLength(1)-1 && block[bh, bw] == ChipType.RightKey)) { block[bh, bw] = ChipType.Floor; } } } } var numFloor = 0; for (int fh = 0; fh < this.fieldHeight; ++fh) { for (int fw = 0; fw < this.fieldWidth; ++fw) { // 출입구에는 배치하지 않으므로 플로어 카운트를 하지 않는다. if ((ep[0].fieldHeight == fh && ep[0].fieldWidth == fw) || (ep[1].fieldHeight == fh && ep[1].fieldWidth == fw)) continue; for (int bh = 0; bh < this.blockHeight; ++bh) for (int bw = 0; bw < this.blockWidth; ++bw) if (field[fh, fw][bh, bw] == ChipType.Floor) ++numFloor; } } double r = random.NextDouble(); double total = 0.0; for (int fh = 0; fh < this.fieldHeight; ++fh) { for (int fw = 0; fw < this.fieldWidth; ++fw) { // 출입구에는 배치하지 않으므로 지나감. if ((ep[0].fieldHeight == fh && ep[0].fieldWidth == fw) || (ep[1].fieldHeight == fh && ep[1].fieldWidth == fw)) continue; for (int bh = 0; bh < this.blockHeight; ++bh) { for (int bw = 0; bw < this.blockWidth; ++bw) { if (field[fh, fw][bh, bw] == ChipType.Floor) { total += 1.0/numFloor; if (r < total) { field[fh, fw][bh, bw] = ChipType.BossKey; fh = fw = bh = bw = int.MaxValue-1; } } } } } } }