public override void Setup(object objdata = null)
        {
            base.Setup(objdata);
            this.data = objdata as CollectableData;
            if (data == null)
            {
                throw new ArgumentException("objdata");
            }

            collectionData = resourceService.GetCollection(data.collectionId);

            int index = 0;

            foreach (CollectableData collectableData in collectionData.collectableIds.Select(id => resourceService.GetCollectable(id)))
            {
                if (index < collectableViews.Length)
                {
                    collectableViews[index].Setup(collectableData);
                    index++;
                }
            }

            collectionView.Setup(collectionData);

            collectionNameText.text = resourceService.GetString(collectionData.nameId);

            StartCoroutine(CorEffect());
        }
Example #2
0
 public void Init(CollectableData data)
 {
     this.data = data;
     GetComponent <SpriteRenderer>().sprite         = data.sprite;
     outline.GetComponent <SpriteRenderer>().sprite = data.sprite;
     outline.SetActive(false);
 }
Example #3
0
 //FOR COLLECTABLES
 public CollectableData CollectablesJoin()
 {
     if (charactersCollectables.Count > 0)
     {
         string charactersCollectable = charactersCollectables.Pop();
         // if there is a registered player
         if (CollectableDisplayed.Count > 0)
         {
             CollectableData newPlayer = CollectableDisplayed.Dequeue();
             newPlayer.CollectableImageName = charactersCollectable;
             newPlayer.CollectablePosition  = new Position
             {
                 X = new Random().Next(500),
                 Y = new Random().Next(400)
             };
             // Tell all the other clients that this player has Joined
             Clients.Others.collectableJoined(newPlayer);
             // Tell this client about all the other current
             Clients.Caller.CurrentCollectables(Collectables);
             // Finaly add the new player on teh server
             Collectables.Add(newPlayer);
             return(newPlayer);
         }
     }
     return(null);
 }
Example #4
0
 public void OnChange(CollectableData collectableData, int newAmount)
 {
     if (collectableData == sugarCubesCollectableData)
     {
         sugarCubesAmount.text = newAmount.ToString();
     }
 }
        public bool IsCollectionReadyToCharge(CollectionData collection)
        {
            bool collectablesReady = true;

            RavenhillResourceService resourceService = engine.GetService <IResourceService>().Cast <RavenhillResourceService>();
            PlayerService            playerService   = engine.GetService <IPlayerService>().Cast <PlayerService>();

            foreach (string collectableId in collection.collectableIds)
            {
                CollectableData data        = resourceService.GetCollectable(collectableId);
                int             playerCount = playerService.GetItemCount(data);
                if (playerCount <= 0)
                {
                    collectablesReady = false;
                    break;
                }
            }

            bool chargersReady = true;

            foreach (var info in collection.chargers)
            {
                ChargerData data        = resourceService.GetCharger(info.id);
                int         playerCount = playerService.GetItemCount(data);
                if (playerCount < info.count)
                {
                    chargersReady = false;
                    break;
                }
            }

            return(collectablesReady && chargersReady);
        }
Example #6
0
        // Get score data for player Tag


        private void process(CollectableData cd)
        {
            switch (cd.ACTION)
            {
            // if a collectable is delivered and it is not in the collection
            // Then add it
            case COLLECTABLE_ACTION.DELIVERED:
                if (Collectables.FirstOrDefault(c => c.collectableData.CollectableName == cd.CollectableName) != null)
                {
                    return;
                }
                Collectables.Add(new Collectable(
                                     Content.Load <Texture2D>(@"Collectables\" + cd.CollectableName),
                                     new Vector2(cd.X, cd.Y), 1)
                {
                    collectableData = cd
                });
                collectablesAliveCount = Collectables.Count();
                break;

            case COLLECTABLE_ACTION.DELETED:
                Collectable found;
                if ((found = Collectables.FirstOrDefault(c => c.collectableData.collectableId == cd.collectableId)) != null)
                {
                    Collectables.Remove(found);
                }
                collectablesAliveCount = Collectables.Count();
                break;
            }
        }
Example #7
0
 private static object process(CollectableData collectableData)
 {
     if (collectableData == null)
     {
         return(null);
     }
     return(collectableData);
 }
Example #8
0
 private void process(CollectableData collectableData)
 {
     if (collectableData == null)
     {
         return;
     }
     new Collectable(Game, collectableData, Game.Content.Load <Texture2D>(@"Collectables\" + collectableData.AssetName), new Vector2(collectableData.X, collectableData.Y));
 }
Example #9
0
    public void Add(CollectableData col)
    {
        GameObject item = Instantiate(inventoryItem, Vector3.zero, Quaternion.identity);

        item.transform.SetParent(inventoryPanel, false);

        item.GetComponent <InventoryItem>().Init(col, this);
    }
Example #10
0
 public Collectable(Game game, CollectableData cData, Texture2D Texture, Position userPosition) : base(game)
 {
     game.Components.Add(this);
     position        = userPosition;
     texture         = Texture;
     collectableData = cData;
     bounds          = new Rectangle((int)this.position.X, (int)this.position.Y, this.texture.Width, this.texture.Height);
 }
Example #11
0
        //COLLECTABLE CREATE when a player joins
        private void CreateCollectables(CollectableData collectable)
        {
            new Collectables(this, collectable, Content.Load <Texture2D>(collectable.CollectableImageName),
                             new Point(collectable.CollectablePosition.X, collectable.CollectablePosition.Y));


            connectionMessage = collectable.CollectableID + " created ";
        }
Example #12
0
 private void process(CollectableData collectableData)
 {
     //create new collectable game item
     if (collectableData != null)
     {
         new Collectable(Game, collectableData, Game.Content.Load <Texture2D>(@"Collectables\" + collectableData.AssetName), new Vector2(collectableData.X, collectableData.Y));
     }
 }
Example #13
0
        private void catchMessage(object obj)
        {
            if (obj == null)
            {
                return;
            }
            Type type = obj.GetType();

            switch (type.Name.ToString())
            {
            case "CollectableData":
                CollectableData cd = (CollectableData)Convert.ChangeType(obj, type);
                process(cd);
                break;

            case "ScoreData":
                ScoreData sd = (ScoreData)Convert.ChangeType(obj, type);
                process(sd);
                break;

            case "PlayerData":
                PlayerData pd = (PlayerData)Convert.ChangeType(obj, type);
                process(pd);
                break;

            //case "LeavingData":
            //    process(ld);
            //    LeavingData ld = (LeavingData)Convert.ChangeType(obj, type);
            //    break;
            case "ErrorMess":
                ErrorMess err = (ErrorMess)Convert.ChangeType(obj, type);
                process(err);
                break;

            case "GameMessage":
                GameMessage msg = (GameMessage)Convert.ChangeType(obj, type);
                process(msg);
                break;

            case "MoveMessage":
                MoveMessage moveMsg = (MoveMessage)Convert.ChangeType(obj, type);
                process(moveMsg);
                break;

            case "SetWorldSize":
                SetWorldSize wsize = (SetWorldSize)Convert.ChangeType(obj, type);
                process(wsize);
                break;

            case "TimerData":
                TimerData tmess = (TimerData)Convert.ChangeType(obj, type);
                process(tmess);
                break;

            default:
                break;
            }
        }
Example #14
0
        public void Collected(string playerID, CollectableData c)
        {
            PlayerData found = Players.FirstOrDefault(p => p.playerID == playerID);

            if (found != null)
            {
                Clients.Others.CollectableCollected(playerID, c);
            }
        }
Example #15
0
        public void process(CollectableData collectableData)
        {
            if (collectableData == null)
                return;

            new Collectable(Game, collectableData,
                Game.Content.Load<Texture2D>)(@"Collectables\" + collectableData.assetName),
                new Vector2(collectableData.X, collectableData.Y)}; 
        }
        public void Setup(CollectableData data)
        {
            this.data = data;

            iconImage.overrideSprite = resourceService.GetSprite(data);
            int playerCount = playerService.GetItemCount(data);

            iconImage.color = (playerCount > 0) ? Color.white : new Color(1, 1, 1, 0.5f);
        }
Example #17
0
    private void ChangeFocusedCollectable(CollectableData data)
    {
        string description = "";

        description += "Value: " + data.value.ToString() + "\n";
        description += "Weight: " + (data.weight * 10).ToString() + "\n";
        description += data.text;

        descriptionText.text = description;
    }
Example #18
0
    public void RemoveCollectable(CollectableData col)
    {
        currentGold   -= col.value;
        currentWeight -= col.weight;

        weightBar.ChangeWeight(currentWeight);
        goldScript.UpdateGold(currentGold);

        SpawnCollectable(col);
    }
Example #19
0
    public void SpawnTerrainModifierObjects(ProceduralTerrainModifierObjects data, ref float[,] terrainData, Transform parent, LevelData level)
    {
        noise    = new Noise();
        objNoise = new float[data.width, data.height];
        objNoise = noise.GenerateNoise(data.width, data.height, data.scale, data.xOffset, data.yOffset, 1, level.seed);
        for (int j = 0; j < data.height; j++)
        {
            for (int i = 0; i < data.width; i++)
            {
                bool canPlace = false;
                foreach (Vector2 v in data.placementLocations)
                {
                    if (terrainData[i, j] > v.x && terrainData[i, j] < v.y)
                    {
                        canPlace = true;
                    }
                }
                if (canPlace)
                {
                    float max = 0;
                    for (int k = Mathf.Clamp(j - data.peakScanArea, 0, data.height - 1); k < Mathf.Clamp(j + data.peakScanArea, 0, data.height - 1); k++)
                    {
                        for (int l = Mathf.Clamp(i - data.peakScanArea, 0, data.width - 1); l < Mathf.Clamp(i + data.peakScanArea - 1, 0, data.width); l++)
                        {
                            float value = objNoise[l, k];
                            if (value > max)
                            {
                                max = value;
                            }
                        }
                    }
                    if (objNoise[i, j] == max)
                    {
                        objNoise[i, j] = 1;
                        GameObject go = (GameObject)GameObject.Instantiate(data.obj);
                        go.transform.position = new Vector3(j, 0, i);

                        CollectableData cData = new CollectableData();
                        cData.position      = go.transform.position;
                        go.transform.parent = parent;

                        float heightArea = terrainData[i, j];

                        for (int y = Mathf.Clamp(i - data.area, 0, data.height - 1); y < Mathf.Clamp(i + data.area, 0, data.height - 1); y++)
                        {
                            for (int x = Mathf.Clamp(j - data.area, 0, data.width - 1); x < Mathf.Clamp(j + data.area, 0, data.width - 1); x++)
                            {
                                terrainData[y, x] = Mathf.SmoothStep(terrainData[y, x], data.areaheight, 0.5f);
                            }
                        }
                    }
                }
            }
        }
    }
 // Constructor epects to see a loaded Texture
 // and a start position
 public Collectables(Game game, CollectableData data, Texture2D spriteImage,
                     Point startPosition) : base(game)
 {
     cData = data;
     game.Components.Add(this);
     // Take a copy of the texture passed down
     CollectablesImage = spriteImage;
     // Take a copy of the start position
     CollectablesPosition = CollectablesPosition = startPosition;
     // Calculate the bounding rectangle
     CollectablesBoundingRect = new Rectangle(CollectablesPosition.X, CollectablesPosition.Y, CollectablesImage.Width, CollectablesImage.Height);
     CollectablesTarget       = startPosition;
 }
        private System.Collections.IEnumerator CorShowReceivedCollectables(CollectableData data)
        {
            RavenhillViewService viewService = engine.GetService <IViewService>().Cast <RavenhillViewService>();

            yield return(new WaitUntil(() => (!viewService.ExistView(RavenhillViewType.collectable_added_note_view))));

            viewService.ShowView(RavenhillViewType.collectable_added_note_view, data);
            yield return(new WaitUntil(() => (!viewService.ExistView(RavenhillViewType.collectable_added_note_view))));

            yield return(new WaitForSeconds(0.3f));

            collectableViewStarted = false;
        }
 private void OnInventoryItemAdded(InventoryItemType type, string itemId, int count)
 {
     if (type == InventoryItemType.Collectable)
     {
         RavenhillResourceService resourceService = engine.GetService <IResourceService>().Cast <RavenhillResourceService>();
         CollectableData          data            = resourceService.GetCollectable(itemId);
         if (data != null)
         {
             receivedCollectables.Enqueue(data);
             //StopCoroutine("CorShowReceivedCollectables");
             //StartCoroutine(CorShowReceivedCollectables(data));
         }
     }
 }
Example #23
0
 public void OnCollect(CollectableData collectableData, int amount)
 {
     if (!CollectableStorage.ContainsKey(collectableData))
     {
         CollectableStorage.Add(collectableData, amount);
     }
     else
     {
         CollectableStorage[collectableData] += amount;
     }
     foreach (IInventoryChange listener in InventoryChangeListeners)
     {
         listener.OnChange(collectableData, CollectableStorage[collectableData]);
     }
 }
Example #24
0
    public void SpawnCollectableObjects(ProceduralCollectablesPlacementData data, float[,] terrainData, Transform parent, LevelData level)
    {
        noise    = new Noise();
        objNoise = new float[data.width, data.height];
        objNoise = noise.GenerateNoise(data.width, data.height, data.scale, data.xOffset, data.yOffset, 1, level.seed);
        for (int j = 0; j < data.height; j++)
        {
            for (int i = 0; i < data.width; i++)
            {
                bool canPlace = false;
                foreach (Vector2 v in data.placementLocations)
                {
                    if (terrainData[i, j] > v.x && terrainData[i, j] < v.y)
                    {
                        canPlace = true;
                    }
                }
                if (canPlace)
                {
                    float max = 0;
                    for (int k = Mathf.Clamp(j - data.peakScanArea, 0, data.height - 1); k < Mathf.Clamp(j + data.peakScanArea, 0, data.height - 1); k++)
                    {
                        for (int l = Mathf.Clamp(i - data.peakScanArea, 0, data.width - 1); l < Mathf.Clamp(i + data.peakScanArea - 1, 0, data.width); l++)
                        {
                            float value = objNoise[l, k];
                            if (value > max)
                            {
                                max = value;
                            }
                        }
                    }
                    if (objNoise[i, j] == max)
                    {
                        objNoise[i, j] = 1;
                        GameObject go = (GameObject)GameObject.Instantiate(data.obj, new Vector3(j, 0, i), Quaternion.identity);

                        CollectableData cData = new CollectableData();
                        cData.position      = go.transform.position;
                        go.transform.parent = parent;

                        go.GetComponent <Collectable>().SetData(data.collectables, cData);

                        data.collectables.Add(cData);
                    }
                }
            }
        }
    }
        public void Setup(CollectableData data)
        {
            this.data                = data;
            nameText.text            = resourceService.GetString(data.nameId);
            iconImage.overrideSprite = resourceService.GetSprite(data);

            int playerCount = playerService.GetItemCount(data);

            if (playerCount > 0)
            {
                iconImage.color = nonEmptyCellColor;
                countPanObj.ActivateSelf();
                countText.text = playerCount.ToString();
            }
            else
            {
                iconImage.color = emptyCellColor;
                countText.text  = string.Empty;
                countPanObj.DeactivateSelf();
            }

            if (playerService.IsWishlistContains(data) || playerService.IsWishlistFull)
            {
                addWishButton.interactable = false;
            }
            else
            {
                addWishButton.interactable = true;
            }

            addWishButton.SetListener(() => {
                playerService.AddToWishlist(data);
            }, engine.GetService <IAudioService>());

            if (playerCount > 0)
            {
                sendGiftButton.interactable = true;
            }
            else
            {
                sendGiftButton.interactable = false;
            }

            sendGiftButton.SetListener(() => {
                Debug.Log("Show Friend Selection View");
            }, engine.GetService <IAudioService>());
        }
Example #26
0
        private void collectableCollected(string playerID, CollectableData c)
        {
            foreach (Collectable collectable in collectables)
            {
                if (collectable.collectableData.ID == c.ID)
                {
                    foreach (PlayerData p in score.players)
                    {
                        if (p.playerID == playerID)
                        {
                            p.Score += c.worth;
                        }
                    }
                    collectable.Visible = false;

                    break;
                }
            }
        }
Example #27
0
        public override void Setup(CollectionData data)
        {
            base.Setup(data);

            for (int i = 0; i < collectableViews.Length; i++)
            {
                if (i < data.collectableIds.Count)
                {
                    CollectableData collectableData = resourceService.GetCollectable(data.collectableIds[i]);
                    if (collectableData != null)
                    {
                        collectableViews[i].Setup(collectableData);
                    }
                }
            }

            chargersView.Setup(data);

            collectionItemView.Setup(data);
        }
Example #28
0
    // All
    public Collectable(string newName, int newColour, int newShape, int newValue, string newLongName)
    {
        CollectableData d = new CollectableData();

        name  = newName;
        count = 1; colour = newColour; shape = newShape; value = newValue;
        if (colour >= 0 &&
            shape >= 0 &&
            colour < d.colours.Length &&
            shape < d.shapes.Length)
        {
            longName = d.shapes[shape] + " " +
                       d.colours[colour] + " " +
                       name;
        }
        else
        {
            longName = newLongName;
        }
        detail = d.getDetail(newName);
    }
Example #29
0
        private static object process(CollectableData cd)
        {
            if (cd == null)
            {
                return(null);
            }
            // only process messages where the Header is collected
            if (cd.ACTION != COLLECTABLE_ACTION.COLLECTED)
            {
                return(null);
            }
            CollectableData found = Collectables.FirstOrDefault(c => c.collectableId == cd.collectableId);

            if (found == null)
            {
                return(null);
            }
            // remove from server collection
            Collectables.Remove(found);
            // remove from all clients
            cd.ACTION = COLLECTABLE_ACTION.DELETED;
            DataHandler.sendNetMess <CollectableData>(server, cd, SENT.TOALL);
            return(cd);
        }
Example #30
0
 public static void Collected(CollectableData collectableData)
 {
     collectableData.ACTION = COLLECTABLE_ACTION.COLLECTED;
     DataHandler.sendNetMess <CollectableData>(client, collectableData, SENT.FROMCLIENT);
 }