/// <summary>
 /// Initializes a new instance of the NotificationFormatException class.
 /// </summary>
 /// This is needed for ISerializable interface
 /// <param name="serializationInfo">SerializationInfo provides the class where the class is serialized.</param>
 /// <param name="streamingContext">Additional StreamingContext class.</param>
 protected NotificationFormatException(SerializationInfo serializationInfo, StreamingContext streamingContext) :
     base(serializationInfo, streamingContext)
 {
     if (serializationInfo != null)
     {
         PushMessageType messageType      = (PushMessageType)serializationInfo.GetInt16("MessageType");
         string          subscriptionName = serializationInfo.GetString("SubscriptionName");
         if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Raw)
         {
             string     rawMessageText = serializationInfo.GetString("rawMessageText");
             RawMessage rawMessage     = new RawMessage(subscriptionName, rawMessageText);
             this.NotificationMessage = rawMessage;
         }
         else if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Toast)
         {
             string       tileMessageText = serializationInfo.GetString("toastMessageText");
             ToastMessage toastMessage    = new ToastMessage(subscriptionName, tileMessageText);
             this.NotificationMessage = toastMessage;
         }
         else if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Tile)
         {
             string      tileMessageTitle = serializationInfo.GetString("tileMessageTitle");
             string      tileMessageCount = serializationInfo.GetString("tileMessageCount");
             string      tileMessageUrl   = serializationInfo.GetString("tileMessageUrl");
             TileMessage tileMessage      = new TileMessage(subscriptionName, tileMessageTitle, tileMessageCount, tileMessageUrl);
             this.NotificationMessage = tileMessage;
         }
         else if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Iphone)
         {
             string        messageAlert  = serializationInfo.GetString("iPhoneMessageAlert");
             string        messageBadge  = serializationInfo.GetString("iPhoneMessageBadge");
             string        messageSound  = serializationInfo.GetString("iPhoneMessageSound");
             iPhoneMessage iphoneMessage = new iPhoneMessage(subscriptionName, messageAlert, messageBadge, messageSound);
             this.NotificationMessage = iphoneMessage;
         }
         else if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Common)
         {
             string        messageTitle  = serializationInfo.GetString("commmonMessageTitle");
             int           messageCount  = serializationInfo.GetInt32("commonMessageCount");
             string        messageImage  = serializationInfo.GetString("commonMessageImage");
             string        messageSound  = serializationInfo.GetString("commonMessageSound");
             CommonMessage commonMessage = new CommonMessage(subscriptionName, messageTitle, messageCount, messageImage, messageSound);
             this.NotificationMessage = commonMessage;
         }
     }
 }
        /// <summary>
        /// Send a tile notification to all WP7 devices subscribed to a given subscription.
        /// </summary>
        /// <param name="subId">Id of the subscription to send the message to.</param>
        /// <param name="message">The message text.</param>
        /// <param name="count">Count to show on the tile or the badge.</param>
        /// <param name="image">The image to show on the tile.</param>
        /// <returns>Returns "success" if successful otherwise an error.</returns>
        public string SendTileNotification(string subId, string message, string count, string image)
        {
            // Make sure user is authenticated.
            if (!AuthManager.AuthenticateUser())
            {
                AuthManager.ConstructAuthResponse();
                return(null);
            }

            // Make sure subscription name is created.
            bool subExists = this.subscriptionInfoMgr.IsSubscriptionRegistered(subId);

            if (!subExists)
            {
                throw new WebFaultException <string>(Utils.GetErrorString(PushMessageError.ErrorSubscriptionNameNotFound), System.Net.HttpStatusCode.BadRequest);
            }

            // Make sure that the count is an int.
            int  countVal;
            bool success = int.TryParse(count, out countVal);

            if (!success)
            {
                throw new WebFaultException <string>(Utils.GetErrorString(PushMessageError.ErrorIllegalCount), System.Net.HttpStatusCode.BadRequest);
            }

            try
            {
                TileMessage tileMsg = new TileMessage(subId, message, count, image);
                this.msgQueue.Enque(tileMsg);
            }
            catch (Exception e)
            {
                Trace.TraceError(string.Format(CultureInfo.InvariantCulture, "Internal Error: SendTile subscription: {0} title: {1}, Error: {2}", subId, message, e.Message));
                throw new WebFaultException <string>(e.Message, System.Net.HttpStatusCode.InternalServerError);
            }

            return("success");
        }
Exemplo n.º 3
0
    public void EditTile(int num)
    {
        VRAR_Level lvl  = GameStateManager.instance.getCurrentLevel();
        VRAR_Tile  tile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y);

        currentBrush = num;
        if (brushTickDivider-- == 0) // || true)
        {
            brushTickDivider = 4;
            //VRAR_Level lvl = GameStateManager.instance.getCurrentLevel();//TileRenderer.getCurrLVL();

            //VRAR_Tile tile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y);
            if (tile != null)
            {
                //currentlySelected = tile;
                List <VRAR_Tile> effectedTiles = lvl.selectRadius(tile.tileIndex_X, tile.tileIndex_Y, brushSize);

                //resetPrevous.Clear();
                // resetPrevous.Add(lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position).x, lvlManager.getTilePosFromWorldPos(leftHandCursor.position).y));
                foreach (VRAR_Tile surroundTile in effectedTiles)
                {
                    if (surroundTile.hexObject != null)//phantom tiles shouldn't be changed
                    {
                        switch (num)
                        {
                        case 0:
                            if (surroundTile.height_ < maxTileHeight)
                            {
                                surroundTile.setHeight(surroundTile.height_ + 0.1f);
                                TileRenderer.instance.updateTile(surroundTile);    //todo only do this after the user stopped changing the height (for optimization)
                            }
                            //else { surroundTile.setHeight(minTileHeight); }
                            break;

                        case 1:
                            if (surroundTile.height_ > minTileHeight)
                            {
                                surroundTile.setHeight(surroundTile.height_ - 0.1f);
                                TileRenderer.instance.updateTile(surroundTile);    //todo only do this after the user stopped changing the height (for optimization)
                            }
                            //else { surroundTile.setHeight(maxTileHeight); }
                            break;

                        case 3:
                        {
                            //remove tile
                            VRAR_Tile remTile = lvl.removeTile(surroundTile.tileIndex_X, surroundTile.tileIndex_Y);

                            var tileMessage = new TileMessage(remTile, true);
                            NetworkServer.SendToAll(CustomNetMsg.Tile, tileMessage);

                            TileRenderer.instance.updateTile(surroundTile);
                        }
                        break;

                        case 4:
                            if (surroundTile.hexObject != null)
                            {
                                //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.defaultTileMaterial;
                                surroundTile.SetTerrain("Mountain");
                                TileRenderer.instance.updateTile(surroundTile);
                            }
                            break;

                        case 5:
                            if (surroundTile.hexObject != null)
                            {
                                //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.waterTileMaterial;
                                surroundTile.SetTerrain("Water");
                                TileRenderer.instance.updateTile(surroundTile);
                            }
                            break;

                        case 6:
                            if (surroundTile.hexObject != null)
                            {
                                //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.selectedTileMaterial;
                                surroundTile.SetTerrain("Grass");
                                TileRenderer.instance.updateTile(surroundTile);
                            }
                            break;
                        }
                    }
                    else
                    {//functions that run on both existing and phantom tiles but when the cursor is still on a existing tile!
                        switch (num)
                        {
                        case 2:
                            //if tile is phantom tile, create actual
                            if (surroundTile.isPhantom)
                            {
                                TileRenderer.instance.updateTile(lvl.addNewTile(surroundTile.tileIndex_X, surroundTile.tileIndex_Y));
                            }
                            break;
                        }
                    }
                }
                //lastSelectedTile = tile;
            }
            else
            {//cursor is not actually on a tile
                switch (num)
                {
                case 2:
                    //spawn middle tile first (and the rest gets spawned in the next tick), and select amount around it
                    TileRenderer.instance.updateTile(lvl.addNewTile(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y));
                    break;

                case 3:
                {
                    VRAR_Tile        middleTempTile = (lvl.addNewTile(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y));
                    List <VRAR_Tile> deletingTiles  = lvl.selectRadius(middleTempTile.tileIndex_X, middleTempTile.tileIndex_Y, brushSize);

                    foreach (VRAR_Tile surroundTile in deletingTiles)
                    {
                        TileRenderer.instance.updateTile(lvl.removeTile(surroundTile.tileIndex_X, surroundTile.tileIndex_Y));
                    }
                }
                break;
                }
            }
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        //cursorMove();
        switch (GameStateManager.instance.getGlobalStateIndex())
        {
        case GameStateManager.STATE_CAMPAIGN_EDITOR:
            cursorMarker.position = Vector3.Scale(leftHandCursor.position, (truncY)) + offY;
            lvl = lvlManager.getLevelObjectFromTilePos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position));
            if (lvl != null)
            {
                GameStateManager.instance.setCurrentLevel(lvl);

                //Reset the previous tile back to normal
                if (previousSelectedTile != null)
                {
                    previousSelectedTile.hexObject.gameObject.GetComponent <Renderer>().material = TileObjectManger.getMaterial(previousSelectedTile.GetTerrain());
                }

                //Set material of selected tile
                lvl.levelTile.hexObject.gameObject.GetComponent <Renderer>().material = TileObjectManger.getMaterial("Selection");

                //Add update list of selected tiles
                selectedTiles.Clear();
                selectedTiles.Add(lvl.levelTile);

                //update debug text of current selected tile
                selectedLevelText.text = "lvl :" + lvl.levelTile.tileIndex_X + "  " + lvl.levelTile.tileIndex_Y;

                previousSelectedTile = lvl.levelTile;
            }
            break;

        case GameStateManager.STATE_LEVEL_EDITOR:
            lvl = GameStateManager.instance.getCurrentLevel();
            cursorMarker.position = Vector3.Scale(rightHandCursor.position, (truncY)) + offY;
            selTile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(cursorMarker.position).x, lvlManager.getTilePosFromWorldPos(cursorMarker.position).y);
            if (selTile != null && selTile.hexObject != null && !Valve.VR.InteractionSystem.VRInputHandler.isInTileObjectEditMenu)
            {
                //if selectedHexPrefab is a prefab (so not in any scene)
                if (selectedHexPrefab.gameObject.scene.name == null)
                {
                    selectedHexPrefabItem = selectedHexPrefab;
                    //spawn prefab is scene
                    selectedHexPrefab = Instantiate(selectedHexPrefab);
                }


                //Reset the previous tile back to normal
                if (previousSelectedTile != null)
                {
                    //previousSelectedTile.hexObject.gameObject.GetComponent<Renderer>().material = TileObjectManger.getMaterial(previousSelectedTile.GetTerrain());
                }

                //Set material of selected tile

                //selTile.hexObject.gameObject.GetComponent<Renderer>().material = TileObjectManger.getMaterial("Selection");
                selectedHexPrefab.gameObject.transform.position = selTile.hexObject.position + (new Vector3(0, (float)(selTile.height_ + 0.1), 0));

                //Add update list of selected tiles
                selectedTiles.Clear();
                selectedTiles.Add(selTile);

                //update debug text of current selected tile
                selectedLevelText.text = "lvl :" + selTile.tileIndex_X + "  " + selTile.tileIndex_Y;

                previousSelectedTile = selTile;

                lvl.tileUpdate(0, 0);
            }
            break;

        case GameStateManager.STATE_PLAYING:
            lvl = GameStateManager.instance.getCurrentLevel();
            cursorMarker.position = Vector3.Scale(rightHandCursor.position, (truncY)) + offY;
            selTile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(cursorMarker.position).x, lvlManager.getTilePosFromWorldPos(cursorMarker.position).y);
            if (selTile != null && selTile.hexObject != null && !Valve.VR.InteractionSystem.VRInputHandler.isInTileObjectEditMenu)
            {
                if (prevSelTile != selTile)
                {
                    //var tileMessage = new TileMessage(selTile);
                    if (prevSelTile != null && prevSelTile.hexObject != null)
                    {
                        foreach (VRAR_Tile tile in GameStateManager.instance.getCurrentLevel().dirtyTiles)
                        {
                            var tileMessage = new TileMessage(tile, false);
                            NetworkServer.SendToAll(CustomNetMsg.Tile, tileMessage);
                        }
                        GameStateManager.instance.getCurrentLevel().dirtyTiles.Clear();
                    }
                }

                //if selectedHexPrefab is a prefab (so not in any scene)
                if (selectedHexPrefab.gameObject.scene.name == null)
                {
                    selectedHexPrefabItem = selectedHexPrefab;
                    //spawn prefab is scene
                    selectedHexPrefab = Instantiate(selectedHexPrefab);
                }

                //Set material of selected tile
                selectedHexPrefab.gameObject.transform.position = selTile.hexObject.position + (new Vector3(0, selTile.height_ - 1, 0));

                prevSelTile = selTile;
            }
            break;
        }
    }