public static int[] GetMineNeighbourIds(int i) { i = SanitizeCellIndex(i); bool cond_v, cond_h; int[] output = new int[8]; AdjacentCells edges = GetAdjacentCells(i); MineInfo mine = Data.MineField[i]; cond_h = edges.HasFlag(AdjacentCells.Right); output[0] = cond_h ? i + 1 : -1; cond_v = edges.HasFlag(AdjacentCells.Bottom); output[1] = cond_v && cond_h ? i + Data.MineFieldWidth + 1 : -1; output[2] = cond_v ? i + Data.MineFieldWidth : -1; cond_h = edges.HasFlag(AdjacentCells.Left); output[3] = cond_v && cond_h ? i + Data.MineFieldWidth - 1 : -1; output[4] = cond_h ? i - 1 : -1; cond_v = edges.HasFlag(AdjacentCells.Top); output[5] = cond_v && cond_h ? i - Data.MineFieldWidth - 1 : -1; output[6] = cond_v ? i - Data.MineFieldWidth : -1; cond_h = edges.HasFlag(AdjacentCells.Right); output[7] = cond_v && cond_h ? i - Data.MineFieldWidth + 1 : -1; return(output); }
public void SetUI(MineInfo mineInfo, int index) { MinePetInfo mpi = ElementInstanceManager.Instance.m_elementCopyLoginPush.minePetInfos.get_Item(index); this.m_blockID = mpi.blockId; BlockInfo blockInfo = ElementInstanceManager.Instance.m_elementCopyLoginPush.activateBlocks.Find((BlockInfo a) => a.blockId == mpi.blockId); YKuangJingKu yKuangJingKu = DataReader <YKuangJingKu> .Get(blockInfo.incidentTypeId); this.TextMineName.set_text(yKuangJingKu.holdName); ResourceManager.SetSprite(this.ImageProduceIcon, GameDataUtils.GetIcon(DataReader <Items> .Get(yKuangJingKu.item.get_Item(0)).icon)); PetInfo petInfo = PetManager.Instance.GetPetInfo(mpi.petId); int num = 0; this.TextMineTime.set_text(TimeConverter.ChangeSecsToString(ElementInstanceManager.Instance.GetTimeCal(mineInfo.blockId))); if (DataReader <Pet> .Get(petInfo.petId).element == yKuangJingKu.petType) { num = yKuangJingKu.petStar.get_Item(petInfo.star - 1); } this.TextProduceValue.set_text((mineInfo.debrisInfos == null || mineInfo.debrisInfos.get_Count() <= 0) ? "0" : mineInfo.debrisInfos.get_Item(0).debrisNum.ToString()); this.TextProduceNum.set_text((yKuangJingKu.itemAddTime.get_Item(0) + num).ToString() + "/小时"); ResourceManager.SetSprite(this.ImagePetIcon, PetManager.Instance.GetSelfPetIcon(petInfo.petId)); ResourceManager.SetSprite(this.ImageMine, GameDataUtils.GetIcon(yKuangJingKu.icon)); if (mineInfo.debrisInfos.get_Count() == 0) { ImageColorMgr.SetImageColor(this.BtnGet.get_transform().FindChild("Image").GetComponent <Image>(), true); this.BtnGet.set_enabled(false); } else { ImageColorMgr.SetImageColor(this.BtnGet.get_transform().FindChild("Image").GetComponent <Image>(), false); this.BtnGet.set_enabled(true); } }
private void OnGetMineInfoRes(short state, MineInfoRes down) { if (state != 0) { StateManager.Instance.StateShow(state, 0); return; } if (down != null) { EventDispatcher.Broadcast(EventNames.OnGetMineInfoRes); this.m_mineInfoRes = down; for (int i = 0; i < this.m_mineInfoRes.mineInfos.get_Count(); i++) { MineInfo mineInfo = this.m_mineInfoRes.mineInfos.get_Item(i); if (this.m_mapTimeCal.ContainsKey(mineInfo.blockId)) { this.m_mapTimeCal.get_Item(mineInfo.blockId).time = mineInfo.lastModifyTime; } else { this.m_mapTimeCal.Add(mineInfo.blockId, new TimeEnty(mineInfo.lastModifyTime)); } } } if (this.actionOnGetMineInfoRes != null) { this.actionOnGetMineInfoRes.Invoke(); this.actionOnGetMineInfoRes = null; } }
public void DisplayOutpostInfo() { MineInfo.SetActive(false); BuildingInfo.SetActive(false); UnitInfo.SetActive(false); OutpostInfo.SetActive(true); }
public static void SetMineLabel(int i) { i = SanitizeCellIndex(i); int o = 0; MineInfo compare = MineInfo.MineAtMidRight | MineInfo.MineAtBotRight | MineInfo.MineAtBotCenter | MineInfo.MineAtBotLeft | MineInfo.MineAtMidLeft | MineInfo.MineAtTopLeft | MineInfo.MineAtTopCenter | MineInfo.MineAtTopRight; compare &= Data.MineField[i]; foreach (MineInfo m in Enum.GetValues(typeof(MineInfo))) { o += compare.HasFlag(m) ? 1 : 0; } Data.MineFieldNeighbours[i] = o; }
public Cell CellForRow(ListView listView, int row) { Cell cell = listView.CellForReuseIndentify("cell"); if (cell == null) { cell = new Cell(listView); cell.identify = "cell"; GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab("ElementInstanceMineObj"); cell.content = instantiate2Prefab; ElementInstanceMineObj component = instantiate2Prefab.GetComponent <ElementInstanceMineObj>(); component.BtnGet.onClickCustom = new ButtonCustom.VoidDelegateObj(this.OnClickBtnGet); } MineInfo mineInfo = ElementInstanceManager.Instance.m_mineInfoRes.mineInfos.get_Item(row); ElementInstanceMineObj component2 = cell.content.GetComponent <ElementInstanceMineObj>(); component2.SetUI(mineInfo, row); return(cell); }
void ReceivePlayed(MineInfo tMineInfo) { if (tMineInfo.bomb) { field_group.Controls["Mine_" + tMineInfo.x + "_" + tMineInfo.y].Text = "B"; }else{ field_group.Controls["Mine_" + tMineInfo.x + "_" + tMineInfo.y].Text = tMineInfo.count.ToString(); } if (tMineInfo.player != Players.None) { field_group.Controls["Mine_" + tMineInfo.x + "_" + tMineInfo.y].ForeColor = General.PlayerColors[(int)tMineInfo.player - 1]; } ((Mine)field_group.Controls["Mine_" + tMineInfo.x + "_" + tMineInfo.y]).open = true; }
void Played(MineInfo tMineInfo) { Command cmd; if (appType == Minefield_Online.appType.Server) { tMineInfo.bomb = minefield.Mines[tMineInfo.x, tMineInfo.y].bomb; tMineInfo.count = minefield.Mines[tMineInfo.x, tMineInfo.y].count; if (tMineInfo.bomb) { if (tMineInfo.player == Players.Player1) { informations.Player1Points += 1; } else if (tMineInfo.player == Players.Player2) { informations.Player2Points += 1; } else if (tMineInfo.player == Players.Player3) { informations.Player3Points += 1; } else if (tMineInfo.player == Players.Player4) { informations.Player4Points += 1; } field_group.Controls["Mine_" + tMineInfo.x +"_" + tMineInfo.y].Text = "B"; } else { field_group.Controls["Mine_" + tMineInfo.x +"_" + tMineInfo.y].Text = tMineInfo.count.ToString(); } if (tMineInfo.player != Players.None) { field_group.Controls["Mine_" + tMineInfo.x + "_" + tMineInfo.y].ForeColor = General.PlayerColors[(int)tMineInfo.player - 1]; } if (tMineInfo.count == 0) { minefield.checkForEmpty(minefield.Mines[tMineInfo.x, tMineInfo.y]); } ((Mine)field_group.Controls["Mine_" + tMineInfo.x + "_" + tMineInfo.y]).open = true; minefield.Mines[tMineInfo.x, tMineInfo.y].open = true; cmd.command = Commands.played; cmd.extraDataLength = Network.MineInfoSize; for (ushort i = 0; i < settings.Players - 1; i++) { SendCommandToClient(i, cmd, Network.SerializeStruct<MineInfo>(tMineInfo)); } if (minefield.GameOver()) { ServerGameOver(); } else { NextPlayer(); } } else { tMineInfo.bomb = false; tMineInfo.count =0; cmd.command = Commands.played; cmd.extraDataLength = Network.MineInfoSize; SendCommandToServer(cmd, Network.SerializeStruct<MineInfo>(tMineInfo)); } }
public MineEventArgs(MineInfo _tMineInfo) { tMineInfo = _tMineInfo; }
private void UpdateSelectedUnitUI() { if (gc.SelectedObject != null) { if (ObjectType.text != gc.SelectedObject.GetComponent <ObjectInfo>().ut.ToString()) { ObjectType.text = gc.SelectedObject.GetComponent <ObjectInfo>().ut.ToString(); } if (gc.SelectedObject.GetComponent <ObjectInfo>().ut == UnitTypes.Base) { MineInfo.SetActive(false); BuildingInfo.SetActive(true); UnitInfo.SetActive(false); OutpostInfo.SetActive(false); if (ActionsRemaining.text != gc.SelectedObject.GetComponent <BaseController>().NumberOfActionsRemaining.ToString()) { ActionsRemaining.text = gc.SelectedObject.GetComponent <BaseController>().NumberOfActionsRemaining.ToString(); } } else if (gc.SelectedObject.GetComponent <ObjectInfo>().ut == UnitTypes.Mine) { MineInfo.SetActive(true); BuildingInfo.SetActive(false); UnitInfo.SetActive(false); OutpostInfo.SetActive(false); if (ActionsRemaining.text != "") { ActionsRemaining.text = ""; } DisplayMineInfo(gc.SelectedObject.GetComponent <MineHandler>().NumberOfResourcesToAdd, gc.SelectedObject.GetComponent <MineHandler>().UpgradeCost); } else if (gc.SelectedObject.GetComponent <ObjectInfo>().ut == UnitTypes.Outpost) { MineInfo.SetActive(false); BuildingInfo.SetActive(false); UnitInfo.SetActive(false); OutpostInfo.SetActive(true); if (ActionsRemaining.text != gc.SelectedObject.GetComponent <OutpostHandler>().NumberOfActionsRemaining.ToString()) { ActionsRemaining.text = gc.SelectedObject.GetComponent <OutpostHandler>().NumberOfActionsRemaining.ToString(); } CostOfMiner.text = gc.SelectedObject.GetComponent <OutpostHandler>().CostOfMiner.ToString(); } else if (gc.SelectedObject.GetComponent <ObjectInfo>().ut == UnitTypes.Soldier || gc.SelectedObject.GetComponent <ObjectInfo>().ut == UnitTypes.Settler || gc.SelectedObject.GetComponent <ObjectInfo>().ut == UnitTypes.Miner) { MineInfo.SetActive(false); BuildingInfo.SetActive(false); UnitInfo.SetActive(true); OutpostInfo.SetActive(false); if (ActionsRemaining.text != gc.SelectedObject.GetComponent <UnitBehaviour>().NumberOfActions.ToString()) { ActionsRemaining.text = gc.SelectedObject.GetComponent <UnitBehaviour>().NumberOfActions.ToString(); } CostToUpgrade.text = gc.SelectedObject.GetComponent <UnitBehaviour>().CostToUpgrade.ToString(); if (CostForAction.text != gc.SelectedObject.GetComponent <UnitBehaviour>().CostForAction.ToString()) { CostForAction.text = gc.SelectedObject.GetComponent <UnitBehaviour>().CostForAction.ToString(); } } } }