Ejemplo n.º 1
0
    /// <summary>
    /// Send move by Photon event (Photon turn extention).
    /// </summary>
    /// <param name="Action">Move action type.</param>
    /// <param name="PawnID">Moving pawnID</param>
    /// <param name="EffectName">Card effect class name</param>
    /// <param name="TargetPawnID">Move target pawn ID</param>
    /// <param name="TargetPosition">Target position</param>
    /// <param name="TargetRotation">Target rotation index (0-5)</param>
    /// <param name="HandIndex">Card hand index</param>
    /// <param name="SendBackEvent">Process this move locally (false by default)</param>
    public void GameplaySendMove(
        GamePlayActionStack.ActionTypeEnum Action,
        int PawnID,
        string EffectName,
        int TargetPawnID,
        int TargetPosition,
        int TargetRotation,
        int HandIndex,
        bool SendBackEvent = false)
    {
        GameplayPlayerMove move = new GameplayPlayerMove();

        move.Action         = Action;
        move.PawnID         = PawnID;
        move.EffectName     = EffectName;
        move.TargetPawnID   = TargetPawnID;
        move.TargetPosition = TargetPosition;
        move.TargetRotation = TargetRotation;
        move.HandIndex      = HandIndex;

        Debug.Log("[SEND EVENT]:" + JsonUtility.ToJson(move).ToString());
        this.turnManager.SendMove(JsonUtility.ToJson(move), false, SendBackEvent);
    }
Ejemplo n.º 2
0
    private void CreateInfoPicture(GamePlayActionStack.ActionTypeEnum action, bool withCard)
    {
        if (action == GamePlayActionStack.ActionTypeEnum.attack)
        {
            CurrentInfoPictureObject = Instantiate(AttackPicturePrefab);
        }
        else if (action == GamePlayActionStack.ActionTypeEnum.attackAndCounter)
        {
            CurrentInfoPictureObject = Instantiate(AttackAndCounterPicturePrefab);
        }
        else if (action == GamePlayActionStack.ActionTypeEnum.buff)
        {
            CurrentInfoPictureObject = Instantiate(BuffPicturePrefab);
        }
        else if (action == GamePlayActionStack.ActionTypeEnum.heal)
        {
            CurrentInfoPictureObject = Instantiate(HealPicturePrefab);
        }
        if (CurrentInfoPictureObject != null)
        {
            CurrentInfoPictureObject.transform.SetParent(LogFocusMainTransform);
            if (withCard)
            {
                CurrentInfoPictureObject.transform.localPosition = InfoWithCardPicureLocalPosition;
            }
            else
            {
                CurrentInfoPictureObject.transform.localPosition = InfoPicureLocalPosition;
            }

            /*CurrentInfoPictureObject.transform.localScale =
             *      new Vector3 (InfoPicureLocalScale/CurrentInfoPictureObject.transform.lossyScale.x,
             *                              InfoPicureLocalScale/CurrentInfoPictureObject.transform.lossyScale.y,
             *                              InfoPicureLocalScale/CurrentInfoPictureObject.transform.lossyScale.z);*/
            CurrentInfoPictureObject.GetComponent <SpriteRenderer>().sortingOrder = InfoPictureRenderLayer;
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Send move by Photon event (Photon turn extention).
 /// Some action does not require lot of params.
 /// </summary>
 /// <param name="Action">Move action type.</param>
 /// <param name="StringParam">Addition param for move action</param>
 /// <param name="SendBackEvent">Process this move locally (false by default)</param>
 public void GameplaySendMove(GamePlayActionStack.ActionTypeEnum Action, string StringParam, bool SendBackEvent = false)
 {
     GameplaySendMove(Action, 0, StringParam, 0, 0, 0, 0, SendBackEvent);
 }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
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);
    }
Ejemplo n.º 6
0
 public GameLogPanel AddLogAction(GamePlayActionStack.ActionTypeEnum action, Pawn pawnToLog, int TargetBoardID)
 {
     return(AddLogAction(action, pawnToLog, TargetBoardID, 0, 0));
 }