private void DrawInEffectAreaOne(GameControl.UpdateInfo info, Sprite toDraw, bool currentPlayer = true) { EffectArea current; int currentPlID; if (currentPlayer) { current = effectAreas[info.PlayerID]; currentPlID = info.PlayerID; } else { current = effectAreas[info.PreviousPlayerID]; currentPlID = info.PreviousPlayerID; } ResetEffect(current); Rect area = current.GetArea(); current.spriteRendererHolder = new GameObject(); current._effectType = info.effect; current.lastChangeTime = Time.time; // set position and size current.spriteRendererHolder.transform.SetParent(this.transform); current.spriteRendererHolder.transform.position = new Vector3(area.x + OffsetX + (area.width / 2), area.y + OffsetY + (area.height / 2), 0f); current.spriteRendererHolder.transform.Rotate(new Vector3(0, 0, PlayersRotations.GetRotationOfPlayer(currentPlID))); current.spriteRendererHolder.transform.localScale = new Vector3(35, 35, 1f); current.spriteRendererHolder.AddComponent <SpriteRenderer>(); SpriteRenderer sr = current.spriteRendererHolder.GetComponent <SpriteRenderer>(); sr.sprite = toDraw; current.spriteRendererHolder.SetActive(true); }
private void BoderRectangleControl(GameControl.UpdateInfo updateConfig, Color32 val, bool marked = false, bool blinking = false) { if (updateConfig.CardId >= 0) { if (cards.ContainsKey(updateConfig.CardId)) { // destroy previous RemoveSpritesFromParent(cards[updateConfig.CardId]); cards.Remove(updateConfig.CardId); } // get card config ConfigFormats.Card cardConf = gamC.gameConfig.TblSettings.GetCardConfigByID(updateConfig.CardId); //Debug.Log("card id:" + cardConf.Id + " size:" + cardConf.X + "|" + cardConf.Y); if (cardConf == null) { Debug.Log("Card config not found id: " + updateConfig.CardId); return; } // get card size ConfigFormats.CardSize cardSizeConf = gamC.gameConfig.GetCardSizeByID(cardConf.SizeId); if (cardSizeConf == null) { Debug.Log("Card size config not found id: " + cardConf.SizeId); return; } // set card area CardArea crArea = new CardArea(); crArea.SetName("pl" + updateConfig.PlayerID + "_pos" + updateConfig.CardId); if (cardConf.turnNinety) { crArea.SetArea(RelativeToAbsolute(cardConf.X, cardConf.Y, mmToPixels(cardSizeConf.Height), mmToPixels(cardSizeConf.Width), false)); } else { crArea.SetArea(RelativeToAbsolute(cardConf.X, cardConf.Y, mmToPixels(cardSizeConf.Width), mmToPixels(cardSizeConf.Height), false)); } if (updateConfig.CardType == ARBangStateMachine.BangCard.NONE) { crArea.SetFilled(true); } else { crArea.SetFilled(false); } crArea.SetColor(val); crArea.SetBorderWidth(10); CreateRectangle(crArea, "Cards", true); crArea.SetReadyToDraw(true); crArea.AreaMarked = marked; crArea.AreaBlinking = blinking; crArea.LastChanged = Time.time; cards[updateConfig.CardId] = crArea; } else { //Debug.Log("Creating Border for player with color: " + val); // get info about player if (players.ContainsKey(updateConfig.PlayerID)) { // only update should be performed RemoveSpritesFromParent(players[updateConfig.PlayerID]); players.Remove(updateConfig.PlayerID); RemoveSpritesFromParent(effectAreas[updateConfig.PlayerID]); effectAreas.Remove(updateConfig.PlayerID); } // create active area for player PlayerArea plArea = new PlayerArea(); // get configuration params ConfigFormats.Player playerConf = gamC.gameConfig.TblSettings.PlayersArray.PlayerDataArray[updateConfig.PlayerID]; plArea.SetArea(RelativeToAbsolute(playerConf.ActiveArea.X, playerConf.ActiveArea.Y, playerConf.ActiveArea.Width, playerConf.ActiveArea.Height)); plArea.SetFilled(false); plArea.SetColor(PlayersColors.Universal); plArea.SetBorderWidth(10); CreateRectangle(plArea, "Players"); plArea.SetReadyToDraw(true); plArea.AreaMarked = marked; plArea.AreaBlinking = blinking; plArea.LastChanged = Time.time; players[updateConfig.PlayerID] = plArea; // create effects area for player EffectArea efArea = new EffectArea(); efArea.SetArea(RelativeToAbsolute(playerConf.EffectsArea.X, playerConf.EffectsArea.Y, playerConf.EffectsArea.Width, playerConf.EffectsArea.Height)); efArea.SetFilled(false); efArea.SetColor(val); efArea.SetBorderWidth(10); CreateRectangle(efArea, "Effects"); efArea.SetReadyToDraw(true); efArea.AreaMarked = marked; efArea.AreaBlinking = blinking; efArea.LastChanged = Time.time; effectAreas[updateConfig.PlayerID] = efArea; } }