Example #1
0
 /// <summary>
 /// Inicjowanie popup-u typu Icon
 /// </summary>
 /// <param name="iconType">Typ ikony, jaka jest wyświetlana przez IconBox/param>
 /// <param name="lifeSpan">Czas wyświetlania IconBox-u</param>
 /// <param name="onOpen">Akcje wywoływane po wyświetleniu IconBox-u</param>
 /// <param name="onClick">Akcje wywoływane po naciśnięciu na IconBox</param>
 /// <param name="onClose">Akcje wywoływane po zniszczeniu IconBox-u</param>
 public IconPopup(IconPopupType iconType, PopupAction onClose = null, AutoCloseMode closeMode = AutoCloseMode.NewAppears)
     : base(closeMode)
 {
     this.iconType = iconType;
     this.onClose  = onClose;
     onClick       = Functionality.Destroy(); //Icon popup po kliknięciu jest zamykany
 }
Example #2
0
    /// <summary>
    /// Inicjowanie popup-u typu Icon
    /// </summary>
    /// <param name="iconType">Typ ikony do wyświetlania</param>
    /// <param name="closeMode">Tryb automatycznego zamknięcia popupu</param>
    /// <param name="message">Wiadomość do wyświetlenia w QuestionPopupie po kliknięciu IconPopup-u</param>
    public IconPopup(IconPopupType iconType, string message, AutoCloseMode closeMode = AutoCloseMode.NewAppears)
        : base(closeMode)
    {
        this.iconType = iconType;
        onClick       = Functionality.Destroy();

        QuestionPopup toShow = QuestionPopup.CreateOkDialog(message);

        onClose += Functionality.Show(toShow);
    }
Example #3
0
 /// <summary>
 /// Określa jaki Sprite odpowiada podanemu typowi
 /// </summary>
 /// <param name="iconType">Typ ikony</param>
 /// <returns>Sprite odpowiadający podanemu typowi</returns>
 private Sprite MatchSprite(IconPopupType iconType)
 {
     if ((int)iconType < sprites.Count)
     {
         return(sprites[(int)iconType]);
     }
     else
     {
         return(sprites[0]);
     }
 }
Example #4
0
    /// <summary>
    /// Inicjowanie popup-u typu Icon
    /// </summary>
    /// <param name="iconType">Typ ikony do wyświetlania</param>
    /// <param name="closeMode">Tryb automatycznego zamknięcia popupu</param>
    /// <param name="toShow">Popup, który ma zostać wyświetlony po kliknięciu ikon boxu</param>
    public IconPopup(IconPopupType iconType, Popup toShow = null, AutoCloseMode closeMode = AutoCloseMode.NewAppears)
        : base(closeMode)
    {
        this.iconType = iconType;
        onClick       = Functionality.Destroy();

        if (toShow != null)
        {
            onClose += Functionality.Show(toShow);
        }
    }
Example #5
0
    public void SendPopupMessage(string[] message, IconPopupType iconType, Player target)
    {
        object[]          data         = { message, (int)iconType };
        int               targetActor  = target.NetworkPlayer.ActorNumber;
        RaiseEventOptions raiseOptions = new RaiseEventOptions {
            TargetActors = new int[] { targetActor }
        };
        SendOptions sendOptions = new SendOptions {
            Reliability = true
        };

        PhotonNetwork.RaiseEvent((byte)EventsId.Message, data, raiseOptions, sendOptions);
    }
Example #6
0
    private void OnMessageArrival(string[] message, IconPopupType iconType)
    {
        string             unpackedMessage = "";
        LanguageController lang            = SettingsController.instance.languageController;

        foreach (string word in message)
        {
            if (lang.IsPacked(word))
            {
                unpackedMessage += lang.GetWord(lang.UnpackKey(word));
            }
            else
            {
                unpackedMessage += word;
            }
        }

        IconPopup messagePopup = new IconPopup(iconType, unpackedMessage);

        PopupSystem.instance.AddPopup(messagePopup);
    }
Example #7
0
    /// <summary>
    /// Zamiana event sieciowego na event lokalny
    /// </summary>
    /// <param name="photonEvent">Dane eventu</param>
    public void OnEvent(EventData photonEvent)
    {
        byte eventCode = photonEvent.Code;

        switch (eventCode)
        {
        case (byte)EventsId.GameStateChange:
        {
            object[]  data          = (object[])photonEvent.CustomData;
            GameState previousState = (GameState)data[0];
            GameState newState      = (GameState)data[1];
            onGameStateChanged?.Invoke(previousState, newState);
        }
        break;

        case (byte)EventsId.PlayerQuit:
        {
            object[] data       = (object[])photonEvent.CustomData;
            string   playerName = (string)data[0];
            onPlayerQuited?.Invoke(playerName);
        }
        break;

        case (byte)EventsId.PlayerMove:
        {
            object[] data           = (object[])photonEvent.CustomData;
            string   playerName     = (string)data[0];
            int      fromFieldIndex = (int)data[1];
            int      toFieldIndex   = (int)data[2];
            onPlayerMoved?.Invoke(playerName, fromFieldIndex, toFieldIndex);
        }
        break;

        case (byte)EventsId.TurnChange:
        {
            object[] data = (object[])photonEvent.CustomData;
            string   previousPlayerName = (string)data[0];
            string   currentPlayerName  = (string)data[1];
            onTurnChanged?.Invoke(previousPlayerName, currentPlayerName);
        }
        break;

        case (byte)EventsId.PlayerAquiredBuiding:
        {
            object[] data       = (object[])photonEvent.CustomData;
            string   playerName = (string)data[0];
            int      fieldId    = (int)data[1];
            onAquiredBuilding?.Invoke(playerName, fieldId);
        }
        break;

        case (byte)EventsId.Auction:
        {
            object[] data           = (object[])photonEvent.CustomData;
            string   playerName     = (string)data[0];
            int      placeId        = (int)data[1];
            string   bidder         = (string)data[2];
            float    bid            = (float)data[3];
            string   passPlayerName = (string)data[4];
            onAuction?.Invoke(playerName, placeId, bidder, bid, passPlayerName);
        }
        break;

        case (byte)EventsId.Sync:
        {
            object[] data        = (object[])photonEvent.CustomData;
            int      syncNumber  = (int)data[0];
            string   source      = (string)data[1];
            string   target      = (string)data[2];
            int      syncCommand = (int)data[3];
            onSync?.Invoke(syncNumber, source, target, syncCommand);
        }
        break;

        case (byte)EventsId.PlayerUpgradeBuilding:
        {
            object[] data       = (object[])photonEvent.CustomData;
            string   playerName = (string)data[0];
            int      placeId    = (int)data[1];
            onUpgradedBuilding?.Invoke(playerName, placeId);
        }
        break;

        case (byte)EventsId.Pay:
        {
            object[] data         = (object[])photonEvent.CustomData;
            string   payerName    = (string)data[0];
            string   receiverName = (string)data[1];
            float    amount       = (float)data[2];
            onPay?.Invoke(payerName, receiverName, amount);
        }
        break;

        case (byte)EventsId.PlayerLostGame:
        {
            object[] data       = (object[])photonEvent.CustomData;
            string   playerName = (string)data[0];
            onPlayerLostGame?.Invoke(playerName);
        }
        break;

        case (byte)EventsId.PlayerReady:
        {
            object[] data       = (object[])photonEvent.CustomData;
            string   playerName = (string)data[0];
            bool     ready      = (bool)data[1];
            onPlayerReady?.Invoke(playerName, ready);
        }
        break;

        case (byte)EventsId.PlayerTeleport:
        {
            object[] data           = (object[])photonEvent.CustomData;
            string   playerName     = (string)data[0];
            int      fromFieldIndex = (int)data[1];
            int      toFieldIndex   = (int)data[2];
            onPlayerTeleported?.Invoke(playerName, fromFieldIndex, toFieldIndex);
        }
        break;

        case (byte)EventsId.PlayerImprison:
        {
            object[] data       = (object[])photonEvent.CustomData;
            string   playerName = (string)data[0];

            onPlayerImprisoned?.Invoke(playerName);
        }
        break;

        case (byte)EventsId.TradeOffer:
        {
            object[] data                  = (object[])photonEvent.CustomData;
            string   senderNickName        = (string)data[0];
            string[] senderBuildingNames   = (string[])data[1];
            float    senderMoney           = (float)data[2];
            string   receiverNickName      = (string)data[3];
            string[] receiverBuildingNames = (string[])data[4];
            float    receiverMoney         = (float)data[5];

            onTradeOffer?.Invoke(senderNickName, senderBuildingNames, senderMoney, receiverNickName, receiverBuildingNames, receiverMoney);
        }
        break;

        case (byte)EventsId.TradeResponse:
        {
            object[] data             = (object[])photonEvent.CustomData;
            bool     accepted         = (bool)data[0];
            string   senderNickName   = (string)data[1];
            string   receiverNickName = (string)data[2];

            onTradeOfferResponse?.Invoke(accepted, senderNickName, receiverNickName);
        }
        break;

        case (byte)EventsId.Message:
        {
            object[]      data     = (object[])photonEvent.CustomData;
            string[]      message  = (string[])data[0];
            IconPopupType iconType = (IconPopupType)data[1];

            onMessageArrival?.Invoke(message, iconType);
        }
        break;

        case (byte)EventsId.MasterStartedGame:
        {
            object[] data = (object[])photonEvent.CustomData;

            onMasterStartedGame?.Invoke();
        }
        break;

        case (byte)EventsId.PlayerMoneyChanged:
        {
            object[] data       = (object[])photonEvent.CustomData;
            string   playerName = (string)data[0];

            onPlayerMoneyChanged?.Invoke(playerName);
        }
        break;
        }
    }