Ejemplo n.º 1
0
    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");
        }
    }
Ejemplo n.º 2
0
    private void CreateFocusPanel(GameLogPanel.TargetClass targetCard, GameObject focusPanelObject, bool pawnOnly, bool friendly)
    {
        Transform pawnTransform = null;

        GameObject card = gameplayComponent.CardsComp.SpawnCardByName(targetCard.targetName);

        if (card != null)
        {
            pawnTransform = card.transform.Find("Pawn");
            card.GetComponent <CardInteraction> ().SetCardOrder(210);
            pawnTransform.GetComponent <SpriteRenderer> ().color = new Color(1, 1, 1, 1);
        }
        else            //no in card base? it should be Hero
        {
            GameObject hero = gameplayComponent.HeroesComp.GetHeroByName(targetCard.targetName);
            if (hero != null)
            {
                pawnTransform = hero.transform;
                pawnOnly      = true;
            }
        }

        if (pawnTransform != null)
        {
            Pawn pawnComp = pawnTransform.GetComponent <Pawn> ();
            pawnComp.SetAttack(targetCard.targetAttack);
            pawnComp.SetHealth(targetCard.targetHealth);
            if (pawnOnly)
            {
                pawnComp.DetachPawn();
                pawnTransform.gameObject.GetComponent <SpriteRenderer> ().sortingOrder = 2100;
                pawnTransform.SetParent(focusPanelObject.transform, false);
                pawnTransform.transform.localScale    = new Vector3(InLogFocusScale - 10, InLogFocusScale - 10, 1);
                pawnTransform.transform.localPosition = new Vector3(0, 0, 0);
                pawnTransform.transform.localRotation = new Quaternion(0, 0, 0, 0);
                Destroy(card);
            }
            else
            {
                card.transform.SetParent(focusPanelObject.transform, false);
                card.transform.localScale    = new Vector3(InLogFocusScale, InLogFocusScale, 1);
                card.transform.localPosition = new Vector3(0, -50, 0);
                card.transform.localRotation = new Quaternion(0, 0, 0, 0);
            }

            if (friendly == false)
            {
                if (pawnComp.CardType == CardsBase.CardTypesEnum.Pawn)
                {
                    pawnTransform.gameObject.GetComponent <SpriteRenderer> ().color = gameplayComponent.enemyColor;
                }
                pawnComp.Friendly = false;
                pawnComp.SetBorder(gameplayComponent.enemyColor);
            }

            SpawnedCardsInFocusPanel.Add(focusPanelObject);
        }
        else
        {
            Destroy(focusPanelObject);
        }
    }
Ejemplo n.º 3
0
    /// <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);
    }