public void ShowLogFocus(GameObject panel) { GameObject foundedPanel = null; //HideLogFocus ();//hide if was showed already foreach (GameObject founded in PanelsInList) { if (founded == panel) { foundedPanel = founded; break; } } if (foundedPanel != null) { bool pOnly = false; FocusPanelCanvas.enabled = true; GameObject panelOb = Instantiate(LogFocusPanelPrefab); GameLogPanel Panel = foundedPanel.GetComponent <GameLogPanel> (); panelOb.transform.SetParent(LogFocusMainTransform, false); if (Panel.pawnOnPanelPawnComponent.CardType == CardsBase.CardTypesEnum.Effect) { pOnly = false; } else { pOnly = Panel.pawnOnly; } GameLogPanel.TargetClass target = new GameLogPanel.TargetClass(); target.targetName = Panel.pawnOnPanelPawnComponent.Name; target.targetAttack = Panel.pawnOnPanelPawnComponent.Attack; target.targetHealth = Panel.pawnOnPanelPawnComponent.Health; CreateFocusPanel(target, panelOb, pOnly, Panel.pawnOnPanelPawnComponent.Friendly); CreateInfoPicture(Panel.PawnAction, !Panel.pawnOnly); //w-a Destroy(CurrentInfoPictureObject); CreateInfoPicture(Panel.PawnAction, !Panel.pawnOnly); //w-a end if (Panel.PawnAction != GamePlayActionStack.ActionTypeEnum.play) { foreach (GameLogPanel.TargetClass targetCard in Panel.Targets) { GameObject panelTargetOb = Instantiate(LogFocusPanelPrefab); panelTargetOb.transform.SetParent(LogFocusListTransform, false); CreateFocusPanel(targetCard, panelTargetOb, true, targetCard.friendly); } } } else { Debug.LogError("Cannot find panel in internal list"); } }
public GameLogPanel AddLogAction(GamePlayActionStack.ActionTypeEnum action, Pawn pawnToLog) { Debug.Log("Add new action to log: " + action + " for pawn:" + pawnToLog.Name); if (action == GamePlayActionStack.ActionTypeEnum.newTurn) { LogListTransform.GetChild(0).GetComponent <GameLogPanel> ().PawnID = -1; return(null); } GameObject panelOb = Instantiate(LogPanelPrefab); GameLogPanel Panel = panelOb.GetComponent <GameLogPanel> (); panelOb.transform.SetParent(LogListTransform, false); panelOb.transform.SetAsFirstSibling(); GameObject card = gameplayComponent.CardsComp.SpawnCardByName(pawnToLog.Name); Transform pawnTransform; if (!card) { GameObject hero = gameplayComponent.HeroesComp.GetHeroByName(pawnToLog.Name); pawnTransform = hero.transform; } else { pawnTransform = card.transform.Find("Pawn"); } Pawn pawnComp = pawnTransform.GetComponent <Pawn> (); if (pawnComp != null) { pawnTransform.SetParent(panelOb.transform, false); pawnTransform.GetComponent <SpriteRenderer> ().color = new Color(1, 1, 1, 1); //spawn card creates invisible cards now pawnTransform.localScale = new Vector3(InLogScale, InLogScale, 0.1f); pawnTransform.localPosition = new Vector3(-200, 0, 0); pawnTransform.localRotation = new Quaternion(0, 0, 0, 0); pawnTransform.gameObject.GetComponent <KeepParentRenderLayer> ().KeepingActive = false; pawnTransform.GetComponent <KeepParentRenderLayer> ().KeepingActive = false; pawnTransform.gameObject.GetComponent <SmothTransform> ().SmothTransformTo(new Vector3(0, 0, 0), 10); if (pawnToLog.Friendly == false) { pawnTransform.gameObject.GetComponent <SpriteRenderer> ().color = gameplayComponent.enemyColor; pawnComp.Friendly = false; pawnComp.SetBorder(gameplayComponent.enemyColor); } if (action == GamePlayActionStack.ActionTypeEnum.play) { Panel.pawnOnly = false; } else { Panel.pawnOnly = true; } Panel.PawnOnPanel = pawnTransform.gameObject; Panel.PawnAction = action; Panel.pawnOnPanelPawnComponent = pawnComp; Panel.pawnOnPanelPawnComponent.SetAttack(pawnToLog.Attack); Panel.pawnOnPanelPawnComponent.SetHealth(pawnToLog.Health); Panel.PawnID = pawnToLog.pawnBoardID; Panel.gameLogComp = GetComponent <GameLog> (); if (card) { Destroy(card); } PanelsInList.Add(panelOb); if (PanelsInList.Count > LogPanelsCountMax) { Destroy(PanelsInList [0]); PanelsInList.RemoveAt(0); } } else { Debug.LogError("cannot find pawn in gameplay"); Destroy(panelOb); } return(Panel); }
/// <summary> /// Add new event to short game actions history. /// </summary> /// <returns>Added log panel.</returns> /// <param name="action">Action to add.</param> /// <param name="pawnToLog">Pawn to add to log, you will see it as thumbnail.</param> /// <param name="TargetBoardID">Pawn board id that is target of this action.</param> /// <param name="LogValue">Some action can have some additional value (ex, buff or heal value).</param> /// <param name="LogValue2">Some action can have some additional value (ex, buff or heal value).</param> public GameLogPanel AddLogAction(GamePlayActionStack.ActionTypeEnum action, Pawn pawnToLog, int TargetBoardID, int LogValue, int LogValue2) { GameLogPanel Panel = null; if (pawnToLog == null) { Debug.LogError("You need to set Pawn to log object component"); return(null); } if (LogListTransform.GetChild(0) != null) { Debug.Log("Add new action to log: " + action + " for pawn:" + pawnToLog.Name + " id: " + pawnToLog.pawnBoardID + " last id:" + LogListTransform.GetChild(0).GetComponent <GameLogPanel> ().PawnID); GameLogPanel LastPanel = LogListTransform.GetChild(0).GetComponent <GameLogPanel> (); if ((LastPanel.PawnID == pawnToLog.pawnBoardID) && ((LastPanel.PawnAction == action) || (LastPanel.PawnAction == GamePlayActionStack.ActionTypeEnum.play))) { Debug.Log("Add new target to last action"); Panel = LogListTransform.GetChild(0).GetComponent <GameLogPanel> (); } else { Debug.Log("Add new action"); Panel = AddLogAction(action, pawnToLog); } } else { Debug.Log("Add new action"); Panel = AddLogAction(action, pawnToLog); } if (Panel != null) { Pawn pawnToTarget = gameplayComponent.GetBoardPawnByID(TargetBoardID); Panel.PawnAction = action; if (pawnToTarget != null) { bool found = false; foreach (GameLogPanel.TargetClass targetCard in Panel.Targets) { if (targetCard.targetID == pawnToTarget.pawnBoardID) { found = true; targetCard.targetAttack = pawnToTarget.Attack; targetCard.targetHealth = pawnToTarget.Health; break; } } if (!found) { GameLogPanel.TargetClass newtarget = new GameLogPanel.TargetClass(); newtarget.targetName = pawnToTarget.Name; newtarget.targetAttack = pawnToTarget.Attack; newtarget.targetHealth = pawnToTarget.Health; newtarget.targetID = pawnToTarget.pawnBoardID; newtarget.friendly = pawnToTarget.Friendly; if (action == GamePlayActionStack.ActionTypeEnum.buff) { newtarget.targetAttack += LogValue2; newtarget.targetHealth += LogValue; } //if (action == GamePlayActionStack.ActionTypeEnum.attack) { //newtarget.targetHealth -= pawnToLog.Attack; //} else if (action == GamePlayActionStack.ActionTypeEnum.attackAndCounter) { //newtarget.targetHealth -= pawnToLog.Attack; //Panel.pawnOnPanelPawnComponent.SetHealth (Panel.pawnOnPanelPawnComponent.Health - pawnToTarget.Attack); //} Debug.Log("Add new action target: " + newtarget); Panel.Targets.Add(newtarget); } } else { Debug.LogError("cannot find target on board - board ID:" + TargetBoardID); } } return(Panel); }