private void OnZonesList(OperationResponse response) { //Debug.Log("OnZonesList "); object zoneList; if (response.Parameters.TryGetValue((byte)ParameterCode.ZoneList, out zoneList)) { //Debug.Log("zoneList"); GameManager.GameZones.Clear(); foreach (var item in zoneList as Dictionary <string, string> ) { GameZone gameZone = new GameZone() { ServerId = new Guid(item.Key) }; gameZone.InitData(item.Value); GameManager.GameZones.Add(gameZone); // Debug.Log(string.Format("{0} - {1}", item.Key, item.Value)); } _uiLoginManager.OnResponseZoneList(); } //GameManager.Status = GameStatus.ZoneSelect; }
public void Enters() { m_Zone = GameZone.InPlay; m_Used = true; GameState.theGame.m_PlayingField.Add (this); GameState.theGame.m_Hand.Remove (this); }
//add channel zone to GUI public void AddZone(GameZone gameZone, int index) { GameObject go = NGUITools.AddChild(zoneRoot, zonePrefabs); go.transform.localPosition = new Vector3(0, -(_zoneCount * 60 + _zoneCount * 3), 0); go.name = gameZone.ZoneName; UIZoneButtonManager uiZoneButtonManager = go.GetComponent <UIZoneButtonManager>(); uiZoneButtonManager.gameZone = gameZone; float percent = ((float)gameZone.ZoneCurCCU) / (float)gameZone.ZoneMaxCCU; Color c = Color.green; if (percent >= 0.5f) { c = Color.yellow; } if (percent >= 0.8f) { c = Color.red; } uiZoneButtonManager.lblName.text = string.Format("[{0}]{1}[-]", Helper.ColorToHex(c), GameManager.serverName + " " + index); uiZoneButtonManager.uiZoneManager = this; _zones.Add(go); _zoneCount++; }
public static GameZone GenerateZone(int level) { var tilesCount = startTilesCount + level; var gameZone = new GameZone(); gameZone.CorrectColor = chooseRandomColor(); for (int i = 0; i < tilesCount; i++) { var generatedTile = generateGameTile(i); gameZone.GameTiles.Add(generatedTile); if (generatedTile.Color == gameZone.CorrectColor) { gameZone.CountCorrectTiles++; } } if (!gameZone.GameTiles.Any(x => x.Color == gameZone.CorrectColor)) { gameZone = GenerateZone(level); } return(gameZone); }
void Start() { for (int i = 0; i < HumanCaches.Length; i++) { HumanCaches[i].Init(); } for (int ii = 0; ii < DeadCaches.Length; ii++) { DeadCaches[ii].Init(); } for (int iii = 0; iii < GameZones.Length; iii++) { if (iii == GameZoneIndex) { GameZones[iii].Enable(); CurrentGameZone = GameZones[iii]; } else { GameZones[iii].Disable(); } } }
/// <summary> /// 在游戏区中话棋盘 /// </summary> private void DrawChess() { Graphics g = GameZone.CreateGraphics(); GameZone.BackColor = m_clsBackColor; // 背景颜色 if (m_bFirstDraw) { g.Clear(GameZone.BackColor);//用背景色清空 } Pen pen = new Pen(Color.BlanchedAlmond); int nHeight = GameZone.Height; int nWide = GameZone.Width; int nPerHeight = nHeight / m_nRowCount; int nPerWidth = nWide / m_nRowCount; for (int i = 0; i < m_nRowCount; i++) { Point p1 = new Point(0, i * nPerHeight); Point p2 = new Point(nWide, i * nPerHeight); g.DrawLine(pen, p1, p2); Point p3 = new Point(i * nPerWidth, 0); Point p4 = new Point(i * nPerWidth, nHeight); g.DrawLine(pen, p3, p4); } g.Dispose(); }
public void Print(Player playerNumber, GameZone typeOfAction, int index) { Console.Clear(); if (playerNumber == Player.UpperPlayer) { if (typeOfAction == GameZone.CardsOnTable) { PrintUpperPlayer(index); PrintActiveArea(_upperPlayerCardsInHand, -1); } else { PrintUpperPlayer(-1); PrintActiveArea(_upperPlayerCardsInHand, index); } PrintLowerPlayer(-1); } else { PrintUpperPlayer(-1); if (typeOfAction == GameZone.CardsOnTable) { PrintActiveArea(_lowerPlayerCardsInHand, -1); PrintLowerPlayer(index); } else { PrintActiveArea(_lowerPlayerCardsInHand, index); PrintLowerPlayer(-1); } } }
private Cell[,] BuildCells(GameZone gameZone) { var XCount = CellCount(_gameZoneSizeX); var ZCount = CellCount(_gameZoneSizeZ); var cells = new Cell[XCount, ZCount]; var createPosition = new Vector3(_gameZoneSizeX / 2 - _cellSize / 2, gameZone.transform.position.y + 0.01f, _gameZoneSizeZ / 2 - _cellSize / 2); for (int i = 0; i < XCount; i++) { for (int j = 0; j < ZCount; j++) { var newCell = _cellFactory.Create(); newCell.transform.position = createPosition; createPosition.z -= _cellSize; cells[i, j] = newCell; newCell.transform.SetParent(gameZone.transform); } createPosition.x -= _cellSize; createPosition.z = _gameZoneSizeZ / 2 - _cellSize / 2; } return(cells); }
public void UpdateStraightPath(Vector2 fromPos, Vector2 toPos) { _pathEndReached = false; _currentT = 0f; var result = GetViewport().GetWorld2d().DirectSpaceState.Raycast(fromPos, toPos, null, 1 << 0); Curve = GameZone.GetPathCurve(fromPos, result?.Position ?? toPos, 0f); }
public void Construct(Camera camera, LevelSettings levelSettings, GameZone gameZone) { _camera = camera; _cameraSpeed = levelSettings.CameraSpeed; _zoomSensitivity = levelSettings.ZoomSensitivity; _gameZone = gameZone; _targetPosX = transform.position.x; _targetPosZ = transform.position.z; }
private void Listener_ZoneChanged(GameZone gameZone) { _stateManager.SetState(State.Running); if (gameZone == GameZone.InGame) { _rules.ForEach(x => x.Initialize(_controller)); } }
private void ClearRectangle(int x, int y) { int width = GameZone.Width / m_nRowCount; int height = GameZone.Height / m_nRowCount; Graphics graphics = GameZone.CreateGraphics(); graphics.FillRectangle(new SolidBrush(GameZone.BackColor), x * width + 1, y * height + 1, width - 2, height - 2); graphics.Dispose(); }
private void ZoneListener_ZoneChanged(GameZone gameZone) { foreach (var entity in InterfaceHelper.FindObjects <IGameEntity>()) { if (!entity.Initialized) { entity.Initialize(_game); } } }
public void UpdatePathToPlayer() { _pathEndReached = false; var player = GetTree().GetFirstNodeInGroup <Player>(Player.GROUP); if (player != null) { Curve = GameZone.GetPathCurve(_owner.GlobalPosition, player.GlobalPosition, 10f); _currentT = 0f; } }
public string checkAreaClick(Zone z) { string rString = ""; GameZone zone = getGameZone(z); if (zone != null) { rString = zone.getAreaT().name; } return(rString); }
public void HandleHit(DamageDealerComponent damageDealer) { Camera.Shake(_cameraShakeMagnitude); if (_flashScreen) { Camera.Flash(); } if (_showDamageNumber) { GameZone.CreateDamageNumber(this, damageDealer.Damage); } EmitSignal(nameof(DamageReceived), damageDealer.Damage); }
/// <summary> /// 游戏初始化:画棋盘、背景填充、初始化分数、标记球背景 /// </summary> public void GameInit() { m_nCurScore = 0; m_bFirstDraw = true; m_nMaxScore = ScoreManager.GetMaxHistoryScore(); GameZone.BackColor = m_clsBackColor; // 背景初始化为灰色 MaxScoreLable.Text = "最高分:" + m_nMaxScore; // 历史最大分数 ScoreLable.Text = "分数:" + m_nCurScore; // 当前分数 ZoomTimer.Enabled = false; Graphics g = GameZone.CreateGraphics(); g.Clear(GameZone.BackColor); }
public Interface() { _currentPlayer = Player.UpperPlayer; _currentZone = GameZone.CardsOnTable; _currentIndex = 0; _upperPlayerCardsOnBoard = new List<string> {"card 1", "card 2", "card 3"}; _upperPlayerCardsInHand = new List<string> {"card 1", "card 2", "card 3"}; _lowerPlayerCardsInHand = new List<string> {"card 4", "card 5", "card 6"}; _lowerPlayerCardsOnBoard = new List<string> {"card 1", "card 2", "card 3"}; Print(_currentPlayer, _currentZone, _currentIndex); }
public StageSystem(StagePrefabs stagePrefabs, KeysSystem keysSystem) { getStagePrefabs = stagePrefabs.GetGroup; getStageIndex = () => PersistentData.GetIntDecoded(GetType(), 0); incrementStageIndex = () => PersistentData.SetIntEncoded(GetType(), 0, getStageIndex() + 1); checkIfKeyIsTaken = (stage, substage) => { bool isKeyTaken; keysSystem.SetAndTestCurrentStageAndSubstage(stage, substage, out isKeyTaken); return(isKeyTaken); }; gameZone = Object.FindObjectOfType <GameZone>(); }
private void GameZone_MouseMove(object sender, MouseEventArgs e) { Graphics graphics = GameZone.CreateGraphics(); int x = e.X / (GameZone.Width / m_nRowCount); int y = e.Y / (GameZone.Height / m_nRowCount); if (m_nLastX != -1 && m_nLastY != -1) { graphics.DrawRectangle(new Pen(Color.BlanchedAlmond), m_nLastX * (GameZone.Width / m_nRowCount), m_nLastY * (GameZone.Width / m_nRowCount), GameZone.Width / m_nRowCount, GameZone.Height / m_nRowCount); } graphics.DrawRectangle(new Pen(Color.Red), x * (GameZone.Width / m_nRowCount), y * (GameZone.Width / m_nRowCount), GameZone.Width / m_nRowCount, GameZone.Height / m_nRowCount); m_nLastX = x; m_nLastY = y; graphics.Dispose(); }
private void setGameZone(GameZone gameZone) { countCorrectAnswers = 0; currentGameZone = gameZone; GameZonePanel.Children.Clear(); correctColor = gameZone.CorrectColor; correctColorControl.Fill = getColorByName(correctColor.ToString()); foreach (var tile in gameZone.GameTiles) { GameZonePanel.Children.Add(createTile(tile.Color)); } GameTimer.ExecuteWithDelay(new Action(flipTiles), TimeSpan.FromSeconds(PREVIEW_TIME)); }
public BallSystem(BallPrefabs ballPrefabs, StageSystem stageSystem) { stageSystem.AddNoMoreBallsTrigger(this); getBallPrefab = ballPrefabs.GetPrefab; ballCategoriesTotal = ballPrefabs.GetGroupsCount(); getSelectedBallCategory = () => PersistentData.GetIntDecoded(GetType(), 0); getSelectedBallIndex = () => PersistentData.GetIntDecoded(GetType(), 1); setSelectedBallCategory = x => PersistentData.SetIntEncoded(GetType(), 0, x); setSelectedBallIndex = x => PersistentData.SetIntEncoded(GetType(), 1, x); UnlockBall(0, 0); gameZone = Object.FindObjectOfType <GameZone>(); ballCollector = Object.FindObjectOfType <BallCollector>(); }
private void DrawBall(int x, int y, Color color, int nDrx = 0) { Graphics graphics = GameZone.CreateGraphics(); graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; Bitmap bitmap = (Bitmap)manager.GetObject(color.ToString().Substring(7).Replace("]", "")); if (bitmap != null) { graphics.DrawImage(bitmap, GameZone.Width * x / m_nRowCount + nDrx + 1, GameZone.Height * y / m_nRowCount + nDrx + 1, GameZone.Width / m_nRowCount - nDrx * 2 - 2, GameZone.Height / m_nRowCount - nDrx * 2 - 2); } graphics.Dispose(); }
private void OnZonesList(OperationResponse response) { object zoneList; if (response.Parameters.TryGetValue((byte)ParameterCode.ZoneList, out zoneList)) { GameManager.GameZones.Clear(); foreach (var item in zoneList as Dictionary <string, string> ) { GameZone gameZone = new GameZone() { ServerId = new Guid(item.Key) }; gameZone.InitData(item.Value); GameManager.GameZones.Add(gameZone); } _manager.OnResponseZoneList(); } }
public Die[] getDiceInZone(string z) { Die[] rDice = null; Zone zone = getZone(z); if (zone != null) { GameZone gZ = getGameZone(zone); if (gZ != null) { // NOTE: Find better spot for this? // Only update when KNOW there was a CHANGE // This updates EVERY TIME just get list [not saving anything] // DieLogic.moveDie() gZ.gatherDice(); rDice = gZ.dice; } } return(rDice); }
public GameObject getZoneDiceParent(string a, string z) { GameArea gA = getArea(a); if (gA != null) { GameZone gZ = gA.getZone(z); if (gZ != null) { return(gZ.getDiceT().gameObject); } } return(null); /* * string obj = a + "/"; * if (obj == "/") obj = ""; * obj = z + "/Dice"; * return GameObject.Find(obj); */ }
// createArea via code (instead of Unity drag-drop) #if false void createArea() { string[] zones = { }; switch (areaType) { case eAreaType.PLAYER: areaZones = new GameZone[6]; zones = "zoneSupport,zoneServicable,zoneSummoned,zoneSpent,zoneStored,zoneSupply".Split(','); break; case eAreaType.MARKET: areaZones = new GameZone[3]; zones = "zoneCard1,zoneCard2,zoneCard3".Split(','); break; } for (int i = 0; i < areaZones.Length; i++) { areaZones[i] = new GameZone(zones[i]); } }
public GameZone getGameZone(Zone z) { if (z == null) { return(null); } GameZone rZone = null; foreach (GameArea area in gameAreas) { foreach (GameZone zone in area.areaZones) { if (zone.zone == z) { rZone = zone; } } } return(rZone); }
public Interface() { _currentPlayer = Player.UpperPlayer; _currentZone = GameZone.CardsOnTable; _currentIndex = 0; _upperPlayerCardsOnBoard = new List <string> { "card 1", "card 2", "card 3" }; _upperPlayerCardsInHand = new List <string> { "card 1", "card 2", "card 3" }; _lowerPlayerCardsInHand = new List <string> { "card 4", "card 5", "card 6" }; _lowerPlayerCardsOnBoard = new List <string> { "card 1", "card 2", "card 3" }; Print(_currentPlayer, _currentZone, _currentIndex); }
/// <summary> /// Get the game title for a specified position /// </summary> /// <returns>The game title.</returns> /// <param name="i">The index.</param> /// <param name="zone"></param> /// <param name="transformation"> </param> public string GetGameTitle(int answerIndex, GameZone zone, TextTransformations transformation) { GameEntry game = Answers [answerIndex]; string title = ""; if (zone == GameZone.PAL) { title = Answers [answerIndex].TitlePAL; } else if (zone == GameZone.NTSC) { title = Answers [answerIndex].TitleUS; } if (transformation != TextTransformations.NONE) { string[] words = title.Split (' '); string maskedTitle = ""; foreach (string w in words) { for (int i=0; i<w.Length; i++) { if (i == 0 && transformation == TextTransformations.FIRST_LETTER_ONLY) { maskedTitle += w [i]; } else { maskedTitle += "_"; } } maskedTitle += " "; } title = maskedTitle.Substring(0, maskedTitle.Length-1); } if (game == CorrectAnswer && Constants.DEBUG_MODE) { title += "*"; } return title/*.ToUpper ()*/; }
public Interface() { _currentPlayer = Player.UpperPlayer; _currentZone = GameZone.CardsOnTable; _currentIndex = 0; var Engine = new GameLogic.Engine(); Engine.StartGame(); _upperPlayerCardsOnBoard = new List<string> {"card 1", "card 2", "card 3"}; _upperPlayerCardsInHand = new List<string>(); foreach (var setOfCard in Engine.UpperPlayer.Cards) { _upperPlayerCardsInHand.Add(setOfCard.ToString()); } _lowerPlayerCardsInHand = new List<string>(); foreach (var setOfCard in Engine.LowerPlayer.Cards) { _lowerPlayerCardsInHand.Add(setOfCard.ToString()); } _lowerPlayerCardsOnBoard = new List<string> { "card 1", "card 2", "card 3" }; Print(_currentPlayer, _currentZone, _currentIndex); }
public void KeyHandler() { while (true) { ConsoleKeyInfo pressedKey = Console.ReadKey(); if (pressedKey.Key == ConsoleKey.UpArrow) { if (_currentPlayer == Player.UpperPlayer && _currentZone == GameZone.CardsOnTable) { if (_currentIndex == 0) { _currentZone = GameZone.CardsInHands; _currentIndex = _upperPlayerCardsInHand.Count - 1; } else { _currentIndex--; } } else if (_currentPlayer == Player.UpperPlayer && _currentZone == GameZone.CardsInHands) { if (_currentIndex == 0) { _currentZone = GameZone.CardsOnTable; _currentIndex = _upperPlayerCardsOnBoard.Count - 1; } else { _currentIndex--; } } else if (_currentPlayer == Player.LowerPlayer && _currentZone == GameZone.CardsOnTable) { if (_currentIndex == 0) { _currentZone = GameZone.CardsInHands; _currentIndex = _lowerPlayerCardsInHand.Count - 1; } else { _currentIndex--; } } else if (_currentPlayer == Player.LowerPlayer && _currentZone == GameZone.CardsInHands) { if (_currentIndex == 0) { _currentZone = GameZone.CardsOnTable; _currentIndex = _lowerPlayerCardsOnBoard.Count - 1; } else { _currentIndex--; } } Print(_currentPlayer, _currentZone, _currentIndex); } if (pressedKey.Key == ConsoleKey.DownArrow) { if (_currentPlayer == Player.UpperPlayer && _currentZone == GameZone.CardsOnTable) { if (_currentIndex == _upperPlayerCardsInHand.Count - 1) { _currentZone = GameZone.CardsInHands; _currentIndex = 0; } else { _currentIndex++; } } else if (_currentPlayer == Player.UpperPlayer && _currentZone == GameZone.CardsInHands) { if (_currentIndex == _upperPlayerCardsOnBoard.Count - 1) { _currentZone = GameZone.CardsOnTable; _currentIndex = 0; } else { _currentIndex++; } } else if (_currentPlayer == Player.LowerPlayer && _currentZone == GameZone.CardsOnTable) { if (_currentIndex == _lowerPlayerCardsInHand.Count - 1) { _currentZone = GameZone.CardsInHands; _currentIndex = 0; } else { _currentIndex++; } } else if (_currentPlayer == Player.LowerPlayer && _currentZone == GameZone.CardsInHands) { if (_currentIndex == _lowerPlayerCardsOnBoard.Count - 1) { _currentZone = GameZone.CardsOnTable; _currentIndex = 0; } else { _currentIndex++; } } Print(_currentPlayer, _currentZone, _currentIndex); } if (pressedKey.Key == ConsoleKey.Enter) { if (_currentPlayer == Player.UpperPlayer) { _currentPlayer = Player.LowerPlayer; _currentZone = GameZone.CardsOnTable; _currentIndex = 0; } else if (_currentPlayer == Player.LowerPlayer) { _currentPlayer = Player.UpperPlayer; _currentZone = GameZone.CardsOnTable; _currentIndex = 0; } Print(_currentPlayer, _currentZone, _currentIndex); } } }
protected override void OnServiceStop() { GameZone.Stop(); }
/// <summary> /// 播放选中音乐并对球进行缩放或移动 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GameZone_MouseClick(object sender, MouseEventArgs e) { int width = GameZone.Width / m_nRowCount; int height = GameZone.Height / m_nRowCount; int x = e.X / width; int y = e.Y / height; // 如果选择的是空的,则移动到目标地点 if (balls[x, y] == GameZone.BackColor) { ZoomTimer.Enabled = false; List <Point> path = new List <Point>(); if (m_nMoveX != -1 && m_nMoveY != -1 && SearchPath(ref path, new Point(x, y), new Point(m_nMoveX, m_nMoveY))) // 有待移动的球 { balls[x, y] = balls[m_nMoveX, m_nMoveY]; balls[m_nMoveX, m_nMoveY] = GameZone.BackColor; ClearRectangle(m_nMoveX, m_nMoveY); m_nMoveX = -1; m_nMoveY = -1; UpdateNextBallColor(); // 先更新next RandomNextColors(false); DrawBalls(); if (CheckSucces(x, y)) { Forms.SaveScoreForm saveScoreForm = new Forms.SaveScoreForm(m_nCurScore, this); saveScoreForm.Show(); ZoomTimer.Enabled = false; } } return; } else { //// 已经选中了一个,则交换 //if (m_nMoveX != -1 && m_nMoveY != -1) //{ // Color tmp = balls[m_nMoveX, m_nMoveY]; // balls[m_nMoveX, m_nMoveY] = balls[x, y]; // balls[x, y] = tmp; // DrawBalls(); //} // 对选中的进行缩放 ClearRectangle(x, y); Bitmap bitmap = (Bitmap)manager.GetObject(balls[x, y].ToString().Substring(7).Replace("]", "")); Graphics graphics = GameZone.CreateGraphics(); graphics.DrawImage(bitmap, x * width + 5, y * height + 5, width - 10, height - 10); graphics.Dispose(); m_nMoveX = x; m_nMoveY = y; if (CheckSucces(m_nMoveX, m_nMoveY)) { ZoomTimer.Enabled = false; } ZoomTimer.Enabled = true; } playAudio("MoveStart.wav"); if (IsGameOver()) { m_bIsGameOver = true; } }
// createArea via code (instead of Unity drag-drop) void createArea() { string[] zones = { }; switch (areaType) { case eAreaType.PLAYER: areaZones = new GameZone[6]; zones = "zoneSupport,zoneServicable,zoneSummoned,zoneSpent,zoneStored,zoneSupply".Split(','); break; case eAreaType.MARKET: areaZones = new GameZone[3]; zones = "zoneCard1,zoneCard2,zoneCard3".Split(','); break; } for (int i = 0; i < areaZones.Length; i++) { areaZones[i] = new GameZone(zones[i]); } }
void Awake() { HideLabels(); active = this; Invoke("StartClocks",gameStartDelay); }