Ejemplo n.º 1
0
    private void viewTreasureUI(GameItemType itemType)
    {
        string str;

        switch (itemType)
        {
        case GameItemType.coin:
            return;

        case GameItemType.empty:
            str = "ハズレ";
            break;

        case GameItemType.jewel:
            str = "宝石獲得!";
            break;

        case GameItemType.bread:
            str = "ミルク獲得!";
            break;

        case GameItemType.securityCamera:
            str = "防犯センサー獲得!";
            break;

        case GameItemType.treasureCoin:
            str = "コイン獲得!";
            break;

        default:
            str = "空っぽだ...(ハズレ)";
            break;
        }
        popupMessage.SetMessage(str, 2, GamePopUpColor.white);
    }
Ejemplo n.º 2
0
 public Recipe(GameItemType outputItem, KeyValuePair <GameItemType, int> firstItem, KeyValuePair <GameItemType, int> secondItem, KeyValuePair <GameItemType, int> thirdItem)
 {
     this.outputItem = outputItem;
     this.firstItem  = firstItem;
     this.secondItem = secondItem;
     this.thirdItem  = thirdItem;
 }
Ejemplo n.º 3
0
        public void Initialize(long worldId, GameItemType itemType)
        {
            WorldId  = worldId;
            ItemType = itemType;

            gameObject.SetActive(true);
        }
Ejemplo n.º 4
0
    private void itemsEffectApplying(GameItemType itemType)
    {
        switch (itemType)
        {
        case GameItemType.jewel:
            if (PhotonManager.Instance.IsConnect)
            {
                m_photonView.RPC("syncJewel", PhotonTargets.All);
            }
            else
            {
                syncJewel();
            }

            if (catJewelCount >= 3 && PhotonManager.Instance.NowPlayerType == PlayerType.Cat)
            {
                IsCatWin = true;
            }
            break;

        case GameItemType.bread:
            sweetController.addSweet();
            break;

        case GameItemType.securityCamera:
            sensorController.addSensor();
            break;
        }
    }
Ejemplo n.º 5
0
 public override void Deserialize(NetworkReader reader)
 {
     base.Deserialize(reader);
     ActionType = (ItemActionType)reader.ReadInt32();
     WorldId    = reader.ReadInt64();
     ItemType   = (GameItemType)reader.ReadInt32();
 }
Ejemplo n.º 6
0
        private void OnItemBuyMsg(AppChangingItemsMessage message)
        {
            PlayerInfo     playerInfo = GetPlayer(message.ConnectionId);
            PlayerItemInfo itemInfo   = playerInfo.Inventory.GetItem(message.WorldId);
            GameItemType   itemType   = itemInfo.ItemType;;

            int price = GetPrice(itemType);

            ItemsChangingResponse response;

            if (playerInfo.Inventory.Coins >= price)
            {
                PlayerItemInfo newItemInfo = new PlayerItemInfo(itemType, Storage.GetUniqueWorldId());
                playerInfo.Inventory.AddItem(newItemInfo);
                playerInfo.Inventory.Coins -= price;

                Storage.Change(playerInfo);

                response = new ItemsChangingResponse(true);
            }
            else
            {
                response = new ItemsChangingResponse(false, "Not enough coins");
            }

            AppChangingItemsAnswerMessage answer = new AppChangingItemsAnswerMessage();

            SendAnswer(answer, message);
        }
Ejemplo n.º 7
0
        private void OnItemBuyMsg(AppChangingItemsMessage message)
        {
            PlayerInfo playerInfo = GetPlayer(message.ConnectionId);
            var        response   = new ItemsChangingResponse();

            for (var i = 0; i < message.ItemsCount; i++)
            {
                var            worldId  = message.GetWorldId(i);
                PlayerItemInfo itemInfo = playerInfo.Inventory.GetItem(worldId);
                GameItemType   itemType = itemInfo.ItemType;
                int            price    = GetPrice(itemType);

                if (playerInfo.Inventory.Coins >= price)
                {
                    PlayerItemInfo newItemInfo = new PlayerItemInfo(itemType, Storage.GetUniqueWorldId());
                    playerInfo.Inventory.AddItem(newItemInfo);
                    playerInfo.Inventory.Coins -= price;
                }
                else
                {
                    response.ErrorText = "Not enough coins";
                    break;
                }
            }
            Storage.Change(playerInfo);
            AppChangingItemsAnswerMessage answer = new AppChangingItemsAnswerMessage(response);

            SendMessageToClient(answer, message.ConnectionId);
        }
Ejemplo n.º 8
0
        public static GameItemCategory GetItemCategory(GameItemType itemType)
        {
            GameItemCategory itemCategory;

            BindedItems.TryGetValue(itemType, out itemCategory);

            return(itemCategory);
        }
Ejemplo n.º 9
0
 private void SelectNewCurrentInfo(GameItemType itemType)
 {
     SelectedInfo = Items.Find(item => item.ItemType == itemType);
     if (SelectedInfo == null)
     {
         SelectedInfo = new DecoratorInfo();
     }
 }
Ejemplo n.º 10
0
 public static GameItemType getInstance()
 {
     if (gameItemType == null)
     {
         gameItemType = new GameItemType();
     }
     return(gameItemType);
 }
Ejemplo n.º 11
0
        public void DropItem(GameItemType itemType, long worldId, Vector3 pos)
        {
            var item = CreateItemInstance(pos);

            item.Initialize(worldId, itemType);
            item.Interacted += OnInteracted;

            _droppedItems.Add(worldId, item);
        }
Ejemplo n.º 12
0
        Sprite IInventoryImageCatalog.GetInventoryItemSprite(GameItemType itemId)
        {
            var info = ItemId.Find(item => item.ItemType == itemId);

            if (info != null)
            {
                return(info.Sprite);
            }
            return(null);
        }
Ejemplo n.º 13
0
        Sprite IShopImageCatalog.GetShopItemSprite(GameItemType shopItemId)
        {
            var info = ItemId.Find(item => item.ItemType == shopItemId);

            if (info != null)
            {
                return(info.Sprite);
            }
            return(null);
        }
Ejemplo n.º 14
0
        public GameObject GetHelmet(GameItemType itemType)
        {
            HelmetInfo info = _helmetItemsList.Find(c => c.ItemType == itemType);

            if (info == null)
            {
                throw new ArgumentException(string.Format("Helmet of type {0} not found in catalog.", itemType));
            }

            return(info.HelmetPrefab);
        }
Ejemplo n.º 15
0
    public void SetPackageItemSprite(IFetched fetchedItem)
    {
        ItemStatus item = fetchedItem.GetFetchedItemStatus();

        _PackageItemState        = item.ItemState;
        _PackageItemType         = item.ItemType;
        _ImagePackageItem.sprite = _itemSpritesArray[(int)_PackageItemType].ItemSprites[(int)_PackageItemState];
        _ImagePackageItem.DOFade(1, 1)
        .OnComplete(() => CharacterAbilities.instance._HoldInHand = false);
        _IsEmpty = false;
    }
Ejemplo n.º 16
0
 public void SetItemState(string id, string itemPath, GameItemType itemType, BiomeType[] biomeTypes, Vector3 minSize, Vector3 maxSize, bool uniformXZ, bool needsCollider)
 {
     _id                = id;
     _itemPath          = itemPath;
     this.itemType      = itemType;
     this.biomeTypes    = biomeTypes;
     this.minSize       = minSize;
     this.maxSize       = maxSize;
     this.uniformXZ     = uniformXZ;
     this.needsCollider = needsCollider;
 }
Ejemplo n.º 17
0
 internal GameItemDynamic(ref Coords coords, GameItemType type, bool allowBounce, Vector3? velocity = null, int id = -1)
     : base(ref coords, id)
 {
     Type = type;
     AllowBounce = allowBounce;
     if (velocity.HasValue) Velocity = velocity.Value;
     IsMoving = true;
     if (!WorldData.GameItems.ContainsKey(Id)) WorldData.GameItems.TryAdd(Id, this);
     var chunk = WorldData.Chunks[coords];
     if (!chunk.GameItems.ContainsKey(Id)) chunk.GameItems.TryAdd(Id, this);
 }
Ejemplo n.º 18
0
        void IUnitSkinDecorator.ApplySkinItem(GameItemType item)
        {
            if(!IsValid(item))
            {
                return;
            }

            var material = _decorator.GetTankMaterial(item);
            if (material != null)
            {
                _tankView.BodуRenders.ForEach(render =>
                render.sharedMaterial = material);
            }
        }
Ejemplo n.º 19
0
    public string GetGameItemId(GameItemType outputItem)
    {
        string id = ((int)outputItem).ToString();

        if (id.Length > 1)
        {
            string itNumber = id.Remove(3);
            string idNumer  = id.Substring(3, id.Length - 3);
            id = idNumer + ":" + itNumber;
            return(id);
        }

        return("No id for recipe item");
    }
Ejemplo n.º 20
0
 public static String GetStandartTextureIDByType(GameItemType type)
 {
     switch (type)
     {
         case GameItemType._1:
             return "_0";
         case GameItemType._2:
             return "_1";
         case GameItemType._3:
             return "_2";
         case GameItemType._4:
             return "_3";
         case GameItemType._5:
             return "_4";
         case GameItemType._6:
             return "_5";
         case GameItemType._7:
             return "_6";
         case GameItemType._8:
             return "_7";
         case GameItemType._9:
             return "_8";
         case GameItemType._10:
             return "_9";
         case GameItemType._11:
             return "_10";
         case GameItemType._12:
             return "_11";
         case GameItemType._13:
             return "_12";
         case GameItemType._14:
             return "_13";
         case GameItemType._15:
             return "_14";
         case GameItemType._16:
             return "_15";
         case GameItemType._2x:
             return "_16";
         case GameItemType._ToMoveItem:
             if(Game.isExtreme)
             return "_7";
             else
             return "_17";
         case GameItemType._XItem:
             return "_18";
         default:
             return String.Empty;
     }
 }
Ejemplo n.º 21
0
    public Dictionary <Recipe, bool> CheckInventoryForRecipes(BasePickableItem[] craftItems)      // Dictionary<Transform, InventoryItem> inventory
    {
        itemTypes.Clear();
        itemTypes.Add(GameItemType.EmptyItem_0, 0);

        for (int i = 0; i < craftItems.Length; i++)
        {
            if (craftItems[i] != null)
            {
                GameItemType type = craftItems[i].itemType;

                if (itemTypes.ContainsKey(type))
                {
                    itemTypes[type] += 1;
                }
                else
                {
                    itemTypes.Add(type, 1);
                }
            }
        }

        foreach (Recipe r in recipes)
        {
            bool hasPrereq = false;

            if (itemTypes.ContainsKey(r.firstItem.Key) && itemTypes[r.firstItem.Key] >= r.firstItem.Value)
            {
                if (itemTypes.ContainsKey(r.secondItem.Key) && itemTypes[r.secondItem.Key] >= r.secondItem.Value)
                {
                    if (itemTypes.ContainsKey(r.thirdItem.Key) && itemTypes[r.thirdItem.Key] >= r.thirdItem.Value)
                    {
                        hasPrereq = true;
                    }
                }
            }

            if (!creatableRecipes.ContainsKey(r))
            {
                creatableRecipes.Add(r, hasPrereq);
            }
            else
            {
                creatableRecipes[r] = hasPrereq;
            }
        }

        return(creatableRecipes);
    }
Ejemplo n.º 22
0
        GameItemInfo IGameItemsInfoCatalog.GetInfo(GameItemType itemId)
        {
            var targetItem = Items.Find(item => item.Id == itemId);

            if (targetItem != null)
            {
                return(targetItem.Info);
            }
            else
            {
                DevLogger.Warning(string.Format("Item with id {0} not" +
                                                " exist at catolg. Return dafault", itemId));
                return(new GameItemInfo());
            }
        }
Ejemplo n.º 23
0
    public void ApplySkinItem(GameItemType itemType)
    {
        if (!IsValid(itemType))
        {
            return;
        }

        if (_tankView.Helmet != null)
        {
            Object.Destroy(_tankView.Helmet);
        }

        GameObject helmetPrefab   = _helmetCatalog.GetHelmet(itemType);
        GameObject helmetInstance = Object.Instantiate(helmetPrefab, _tankView.HelmetPoint);

        _tankView.Helmet = helmetInstance;
    }
    public BaseItem CreateItem(GameItemType itemType, Vector3 position, Quaternion rotation, Transform parent = null)
    {
        BaseItem item    = GetItem(itemType);
        BaseItem newItem = null;

        if (item != null)
        {
            newItem = Instantiate(item, position, rotation) as BaseItem;
            if (parent != null)
            {
                newItem.transform.SetParent(parent);
            }
            newItem.Initialize();
        }

        return(newItem);
    }
Ejemplo n.º 25
0
    public void SetObtainedObject(GameItemType itemType)
    {
        // 宝箱コインはランダム
        int itemCount = 1;

        if (itemType == GameItemType.treasureCoin)
        {
            itemCount = UnityEngine.Random.Range(0, 5);
        }
        // 獲得リストに追加
        int newCount = obtainedObjectCounts[itemType.ToString()] + itemCount;

        obtainedObjectCounts[itemType.ToString()] = newCount;
        itemsEffectApplying(itemType);
        viewTreasureUI(itemType);
        Debug.Log(itemType.ToString() + "を獲得");
    }
Ejemplo n.º 26
0
        private void OnLoadDMarketDataMsg(AppLoadDMarketDataMessage message)
        {
            int connectionId = message.ConnectionId;

            if (!IsCanMakeDMarketOperation(connectionId))
            {
                return;
            }

            DMarketApi.GetInMarketInventory(Model.GetPlayerMarketAccessToken(connectionId),
                                            (response, request) =>
            {
                PlayerInfo playerInfo = GetPlayer(connectionId);

                PlayerInventoryInfo inventory = GetInventory(connectionId);
                playerInfo.Inventory          = inventory;
                inventory.RemoveAllDMarketItems();

                foreach (var item in response.Items)
                {
                    GameItemType itemType = DMarketConverter.GetItemType(item.classId);
                    long worldId          = DMarketConverter.GetWorldId(item.assetId);

                    PlayerItemInfo dmarketItem = new PlayerItemInfo(itemType, worldId, true);
                    inventory.AddItem(dmarketItem);
                }

                Storage.Change(playerInfo);

                SendDmarketDataUpdateAnswer(connectionId);
            },
                                            error =>
            {
                if (error.ErrorCode == ErrorCode.DMarketTokenExpired)
                {
                    RefreshMarketToken(connectionId, () => OnLoadDMarketDataMsg(message),
                                       errorParam => SendLoadDMarketLoadDataError(connectionId, errorParam));
                    return;
                }

                SendLoadDMarketLoadDataError(connectionId, error.ErrorCode);
            });
        }
Ejemplo n.º 27
0
        private void OnLoadInventoryBasicIntegration(InventoryBasicIntegrationMessage message)
        {
            int connectionId = message.ConnectionId;

            if (!IsCanMakeDMarketOperation(connectionId))
            {
                return;
            }

            DMarketApi.GetInMarketInventory(Model.GetPlayerMarketAccessToken(connectionId),
                                            (response, request) =>
            {
                List <ItemInfo> itemsList = new List <ItemInfo>();
                foreach (var item in response.Items)
                {
                    GameItemType itemType = DMarketConverter.GetItemType(item.classId);
                    long worldId          = DMarketConverter.GetWorldId(item.assetId);

                    ItemInfo dmarketItem = new ItemInfo(worldId, itemType);
                    itemsList.Add(dmarketItem);
                }

                if (itemsList.Count == 0)
                {
                    SendLoadInventoryData(connectionId);
                    return;
                }

                ApplyCommand(new ServerBulkTransferInventoryBasicIntegrationCommand(itemsList, ItemActionType.FromMarket, connectionId));
            },
                                            error =>
            {
                if (error.ErrorCode == ErrorCode.DMarketTokenExpired)
                {
                    RefreshMarketToken(connectionId, () => OnLoadInventoryBasicIntegration(message),
                                       errorCode => SendLoadInventoryData(connectionId, errorCode));
                    return;
                }

                SendLoadInventoryData(connectionId, error.ErrorCode);
            });
        }
Ejemplo n.º 28
0
        internal GameItemDynamic(ref Coords coords, GameItemType type, bool allowBounce, Vector3?velocity = null, int id = -1) : base(ref coords, id)
        {
            Type        = type;
            AllowBounce = allowBounce;
            if (velocity.HasValue)
            {
                Velocity = velocity.Value;
            }
            IsMoving = true;
            if (!WorldData.GameItems.ContainsKey(Id))
            {
                WorldData.GameItems.TryAdd(Id, this);
            }
            var chunk = WorldData.Chunks[coords];

            if (!chunk.GameItems.ContainsKey(Id))
            {
                chunk.GameItems.TryAdd(Id, this);
            }
        }
    public BaseItem GetItem(GameItemType itemType)
    {
        if (gameItems == null || gameItems.Count <= 0)
        {
            Debug.LogError("No items in database");
            return(null);
        }

        foreach (BaseItem i in gameItems)
        {
            if (i.itemType == itemType)
            {
                return(i);
            }
        }

        Debug.LogWarning("The object: " + itemType.ToString() + " could not be found. Please check if the object has an item script with the correct settings and that it is a valid item in the items enum!");

        return(null);
    }
Ejemplo n.º 30
0
        /// <summary>
        /// Returns the counter configuration for the specified GameItemType.
        /// </summary>
        /// <param name="gameItemType"></param>
        /// <returns></returns>
        public List <CounterConfiguration> GetCounterConfiguration(GameItemType gameItemType)
        {
            switch (gameItemType)
            {
            case GameItemType.Character:
                return(CharacterCounterConfiguration);

            case GameItemType.Level:
                return(LevelCounterConfiguration);

            case GameItemType.Player:
                return(PlayerCounterConfiguration);

            case GameItemType.World:
                return(WorldCounterConfiguration);

            default:
                return(null);
            }
        }
Ejemplo n.º 31
0
 public static void ShowScalingLabel(GameObject initGameObject,bool onTop, bool leftSide, String text, Color textColor, Color shadowColor, int animateFromSize,
      int animateToSize, int step = 1, Font font = null,
     bool destroyAfterAnimation = false, LabelAnimationFinishedDelegate callback = null, int rotateAngle = 0, GameItemType? type = null)
 {
     //var wp = initGameObject.transform.position;
     var newPos = Game.Middleground.transform.InverseTransformPoint(initGameObject.transform.position);// calling it with foreground causes MaxInitialElement z index decreasing(shows under pause menu)...
     var showOn = new Vector3(newPos.x + (onTop ? 0 : ((leftSide ? -25 : 25) * initGameObject.GetComponent<SpriteRenderer>().bounds.size.x)),
         newPos.y + (onTop ? 25 * initGameObject.GetComponent<SpriteRenderer>().bounds.size.y : 0), newPos.z - 6);// 25 is default pixels per unit 100 / 2 (half of object size(which is size.y / 2, cause 1 in size = 2 units)
     if(type.HasValue)
     {
         for(int i = 0;i < PointLabels.Count;i++)
             if(PointLabels[i]._type.Value == type && PointLabels[i]._scaleState == ScaleState._none)
             {
                 PointLabels[i]._labelText.text = text;
                 PointLabels[i].transform.localPosition = showOn;
                 PointLabels[i].transform.localScale = PointLabels[i]._localScale;
                 if (PointLabels[i].Shadow != null)
                 {
                     PointLabels[i].Shadow._labelText.text = text;
                     PointLabels[i].Shadow.transform.localPosition = new Vector3(showOn.x - 3,showOn.y,showOn.z);
                     PointLabels[i].Shadow.transform.localScale = PointLabels[i]._localScale;
                 }
                 PointLabels[i]._scaleState = ScaleState._increase;
                 return;
             }
     }
     GameObject obj;
     if (type.HasValue)
         obj = Instantiate(ShortLabelPrefab) as GameObject;
     else
         obj = Instantiate(LabelPrefab) as GameObject;
     var label = obj.GetComponent<LabelShowing>();
     label._type = type;
     label.transform.SetParent(Game.Foreground.transform);
     label.ShowScalingLabel(showOn, text, textColor, shadowColor, animateFromSize, animateToSize, step, font, destroyAfterAnimation, callback, false, rotateAngle);
     if (label._type.HasValue)
         PointLabels.Add(label);
 }
Ejemplo n.º 32
0
    public static List <HouseItem> GenerateItems(FloorType[,] layout, int[,] distanceToWall)
    {
        int w = layout.GetLength(0);
        int h = layout.GetLength(1);
        List <HouseItem> rlt = new List <HouseItem>();

        for (int i = 0; i < w; i++)
        {
            for (int j = 0; j < h; j++)
            {
                if (itemsConfig.ContainsKey(layout[i, j]) && distanceToWall[i, j] == 1)
                {
                    if (FakeRandom.Range01() < 0.3f)
                    {
                        List <GameItemType> items      = itemsConfig[layout[i, j]];
                        GameItemType        randomItem = items[FakeRandom.Range(0, items.Count)];
                        rlt.Add(new HouseItem(new VecInt3(i, 1, j), randomItem));
                    }
                }
            }
        }
        return(rlt);
    }
Ejemplo n.º 33
0
 public virtual void ResetPlayground()
 {
     for (var i = 0; i < FieldSize; i++)
         for (var j = 0; j < FieldSize; j++)
         {
             /*var item = Items[i][j] as GameObject;
             if (item != null)
             {
                 var gims = item.GetComponent<GameItemMovingScript>();
                 if (gims != null) gims.CancelMoving(true);
             }
             Items[i][j] = null;
             Destroy(item);*/
             RemoveGameItem(i, j);
         }
     Items = null;
     MaxType = GameItemType._3;
     CurrentScore = 0;
 }
Ejemplo n.º 34
0
 protected virtual GameItemMovingType GetMovingTypeByItemType(GameItemType type)
 {
     switch (type)
     {
         case GameItemType._XItem:
             return GameItemMovingType.Static;
         case GameItemType._ToMoveItem:
             if (Game.isExtreme)
                 return GameItemMovingType.StandartExchangable;
             else
                 return GameItemMovingType.Standart;
         default:
             return GameItemMovingType.Standart;
     }
 }
 private void VeryHardLevelActionDeactivate(object sender, EventArgs e)
 {
     for (int col = 0; col < FieldSize; col++)
         for (int row = 0; row < FieldSize; row++)
             if (Items[col][row] != null)
             {
                 var gi = (Items[col][row] as GameObject).GetComponent<GameItem>();
                 if (gi.Type == toBlock)
                     gi.MovingType = GameItemMovingType.Standart;
             }
     toBlock = (GameItemType)RandomObject.Next(1, FieldSize);
     ProgressBar.SetSmallXsColor(GameColors.Match3Colors[toBlock]);
     MoveTimerMultiple = MoveTimerMultiple + 16;
 }
 protected override String ItemsTextureName(GameItemType type)
 {
     switch(type)
     {
         case GameItemType._XItem:
             return base.ItemPrefabName;
         default:
             return ItemPrefabName;
     }
 }
Ejemplo n.º 37
0
        /// <summary>
        /// Initializes a product data entry for use in XML.
        /// </summary>
        /// <param name="currencyType">Type of currency the item is sold for</param>
        /// <param name="description">NFS: World Beta feature, still gonna keep it for MAYBE future-use</param>
        /// <param name="rentalDurationInMinutes">0 if not a rental, rental duration in minutes if else</param>
        /// <param name="hash">Item hash value that is recognized by NFS: World</param>
        /// <param name="iconString">Item icon that is displayed somewhere around its title</param>
        /// <param name="levelLimit">0 if not level limited, minimum level value if else</param>
        /// <param name="tooltipDescription">NFS: World Beta feature, still gonna keep it for MAYBE future-use</param>
        /// <param name="price">How much the item is sold for</param>
        /// <param name="priorityNumber">Priority in the shopping list in-game, commonly used for new items or discounts</param>
        /// <param name="id">Server product id</param>
        /// <param name="title">Item title that is displayed in-game</param>
        /// <param name="itemType">Item type that NFS: World can recognize</param>
        /// <param name="extraDetail">If there is one, a special condition for the item that is displayed in-game</param>
        /// <returns>An XElement wrapped around in ProductTrans tags.</returns>
        public static XElement getProductTransactionEntry(Currency currencyType, String description, Int32 rentalDurationInMinutes, Int64 hash, String iconString, Int16 levelLimit, String tooltipDescription, Int32 price, Int16 priorityNumber, String id, String title, GameItemType itemType, Special extraDetail = Special.None)
        {
            XElement ProductNode =
                new XElement("ProductTrans",
                             new XElement("Currency", currencyType.GetString()),
                             new XElement("Description", description),
                             new XElement("DurationMinute", rentalDurationInMinutes.ToString()),
                             new XElement("Hash", hash.ToString()),
                             new XElement("Icon", iconString),
                             new XElement("Level", levelLimit.ToString()),
                             new XElement("LongDescription", tooltipDescription),
                             new XElement("Price", price.ToString()),
                             new XElement("Priority", priorityNumber.ToString()),
                             new XElement("ProductId", id),
                             new XElement("ProductTitle", title),
                             new XElement("ProductType", itemType.GetString()),
                             new XElement("SecondaryIcon", extraDetail.GetString()),
                             new XElement("UseCount", "1")
                             );

            return(ProductNode);
        }
Ejemplo n.º 38
0
        private void GenerateDropsModeItem(int col, int row, GameItemType type = GameItemType.NullItem)
        {
            var callback = (MovingFinishedDelegate)((sender, result) =>
            {
                CurrentDroppingItem = null;
                while (ClearChains() > 0)
                {
                    RemoveAdditionalItems();
                }
            })
                ;
            var gameItem = (type != GameItemType.NullItem) ?
                GenerateGameItem(type, col, row, new Vector2(0, 1),null, true, 2, callback)
                : GenerateGameItem(col, row, null, new Vector2(0, 1), true, 2, callback);

            if (gameItem != null)
                gameItem.GetComponent<GameItem>().IsDraggableWhileMoving = true;
            Items[col][row] = gameItem;

            CurrentDroppingItem = new Point{X = col, Y = row};
        }
Ejemplo n.º 39
0
        public virtual bool MatchPattern(GameItemType itemType, Point firstItem, Point secondItem, IEnumerable<Point> pointForCheck)
        {
            var mainType = MatchType(firstItem.X + secondItem.X, firstItem.Y + secondItem.Y, itemType);
            if (!mainType) return false;

            var lineGenerationPoints = pointForCheck.Where(point => MatchType(firstItem.X + point.X, firstItem.Y + point.Y, itemType)).ToList();
            if (!lineGenerationPoints.Any()) return false;

            foreach (var lineGenerationPoint in lineGenerationPoints)
            {
                if (secondItem.X == 0)
                {
                    LogFile.Message("secondItem.X == 0 and firstItem.X: " + firstItem.X + " firstItem.Y: " + firstItem.Y +
                                    " secondItem.Y: " + secondItem.Y + "lineGenerationPoint.Y: " + lineGenerationPoint.Y, true);
                    if (Math.Abs(secondItem.Y) > 1)
                        SelectedPoint1 = new Point
                        {
                            X = firstItem.X,
                            Y = firstItem.Y + (secondItem.Y > 0 ? 1 : -1)
                        };
                    else
                    {
                        SelectedPoint1 = new Point
                        {
                            X = firstItem.X,
                            Y = firstItem.Y + (lineGenerationPoint.Y > 0 ? 2 : -1)
                        };
                    }
                }
                else if (secondItem.Y == 0)
                {
                    LogFile.Message("secondItem.Y == 0 and firstItem.X: " + firstItem.X + " firstItem.Y: " + firstItem.Y +
                                    " secondItem.Y: " + secondItem.Y + "lineGenerationPoint.Y: " + lineGenerationPoint.Y, true);
                    if (Math.Abs(secondItem.X) > 1)
                        SelectedPoint1 = new Point
                        {
                            X = firstItem.X + (secondItem.X > 0 ? 1 : -1),
                            Y = firstItem.Y
                        };
                    else
                    {
                        SelectedPoint1 = new Point
                        {
                            X = firstItem.X + (lineGenerationPoint.X > 0 ? 2 : -1),
                            Y = firstItem.Y
                        };
                    }
                }
                var diffX = Math.Abs(SelectedPoint1Coordinate.X - (firstItem.X + lineGenerationPoint.X));
                var diffY = Math.Abs(SelectedPoint1Coordinate.Y - (firstItem.Y + lineGenerationPoint.Y));
                if (!((diffX == 0 && diffY == 1) || (diffX == 1 && diffY == 0)))
                    continue;
                if (Items[SelectedPoint1Coordinate.X][SelectedPoint1Coordinate.Y] != null && Items[SelectedPoint1Coordinate.X][SelectedPoint1Coordinate.Y] != DisabledItem)
                {
                    var selectedObject = Items[SelectedPoint1Coordinate.X][SelectedPoint1Coordinate.Y] as GameObject;
                    if (selectedObject != null)
                    {
                        var gi = selectedObject.GetComponent<GameItem>();
                        if (gi.MovingType == GameItemMovingType.Static || gi.Type == GameItemType.NullItem)
                            continue;
                    }
                }
                else continue;
                SelectedPoint2 = new Point { X = firstItem.X + lineGenerationPoint.X, Y = firstItem.Y + lineGenerationPoint.Y };
                return true;
            }
            return false;
        }
Ejemplo n.º 40
0
 protected void SpawnItemOnRandomPlace(GameItemType type, MoveDirections? area = null, Vector3? scaleTo = null)
 {
     int col;
     int row;
     int fromCol = 1;
     int toCol = FieldSize - 1;
     int fromRow = fromCol;
     int toRow = toCol;
     if(area != null)
     switch (area.Value)
     {
         case MoveDirections.Left:
             fromCol = 1;
             toCol = FieldSize/2;
             fromRow = 1;
             toRow = FieldSize - 1;
             break;
         case MoveDirections.Right:
             fromCol = FieldSize / 2 + FieldSize%2;
             toCol = FieldSize - 1;
             fromRow = 1;
             toRow = FieldSize - 1;
             break;
     }
     while (true)
     {
         col = RandomObject.Next(fromCol, toCol);
         row = RandomObject.Next(fromRow, toRow);
         if (Items[col][row] == null || Items[col][row] == DisabledItem) continue;
         var o = Items[col][row] as GameObject;
         if (o == null) continue;
         var gi = o.GetComponent<GameItem>();
         if (Items[col][row] != null && Items[col][row] != DisabledItem &&
             gi.Type < GameItemType._2x && gi.Type != (MaxType + 1) &&
             !o.GetComponent<GameItemScalingScript>().isScaling)
             break;
     }
     RemoveGameItem(col, row, (item, r) =>
     {
         Items[col][row] = GenerateGameItem(type, col, row, Vector2.zero, scaleTo == null ? GameItemScale : scaleTo, false, null, null);
     });
 }
Ejemplo n.º 41
0
        public virtual int ClearChains()
        {
            if (IsGameOver) return -1;

            SelectedPoint1 = null;
            SelectedPoint2 = null;

            var lines = GetAllLines();
            if (lines.Count == 0)
            {
                if (RaiseMaxInitialElement && CallbacksCount == 0)
                {
                    RaiseMaxInitialElement = false;
                    MaxInitialElementTypeRaisedActions();
                }
                ChainCounter = 0;
                if (HintTimeCounter < 0) HintTimeCounter = 0;

                if (!RemoveAdditionalItems() && CallbacksCount == 0 && !CheckForPossibleMoves())
                {
                    LogFile.Message("No moves", true);
                    if (Game.isExtreme)
                    {
                        if (lastMoved != GameItemType._ToMoveItem)
                        {
                            GenerateField(false, true, Game.Difficulty != DifficultyLevel._easy, () => CreateInGameHelpModule("Match3NoMoves"));
                            if (Game.Difficulty > DifficultyLevel._easy)
                            {
                                lastMoved = GameItemType._ToMoveItem;
                                _selectedPoint1Coordinate = null;
                                _selectedPoint2Coordinate = null;
                            }
                        }
                    }
                    else
                    {
                        GenerateField(false, true);
                    }
                }
                UpdateTime();
                return 0;
            }
            if (Game.isExtreme && lastMoved == GameItemType._ToMoveItem)
                lastMoved = GameItemType.NullItem;
            HintTimeCounter = -1;
            _isDropDone = false;
            LogFile.Message("Start clear chaines. Lines: " + lines.Count, true);
            var linesCount = lines.Count;
            var pointsBank = 0;
            var l = lines.FirstOrDefault();
            int repeatForLine = -1;
            bool raiseMaxIEtype = true;
            int toObjX = 0, toObjY = 0;
            Vector3 toCell = Vector3.zero;
            while (l != null && !IsGameOver)
            {
                var pointsMultiple = 1;
                if (l.Orientation == LineOrientation.Vertical)
                {
                    pointsMultiple += l.Y2 - l.Y1 - 2;
                    if (repeatForLine == -1)
                    {
                        toObjX = l.X2;
                        toObjY = l.Y2 - (l.Y2 - l.Y1)/2;
                        for (var j = l.Y2; j >= l.Y1; j--)
                        {
                            var lwi = LinesWithItem(lines, l.X1, j);
                            var enumerable = lwi as IList<Line> ?? lwi.ToList();
                            if (enumerable.Count() <= 1) continue;

                            toObjX = l.X1;
                            toObjY = j;
                            repeatForLine = lines.IndexOf(enumerable.FirstOrDefault(line => line != l));
                        }
                        toCell = GetCellCoordinates(toObjX, toObjY);
                    }
                    else
                    {
                        raiseMaxIEtype = false;
                        repeatForLine = -1;
                    }
                    for (var j = l.Y2; j >= l.Y1; j--)
                    {
                        if (Items[l.X1][j] == null || Items[l.X1][j] == DisabledItem || j == toObjY)
                            continue;

                        var gobj = Items[l.X1][j] as GameObject;
                        if (gobj == null) continue;

                        gobj.transform.localPosition = new Vector3(gobj.transform.localPosition.x, gobj.transform.localPosition.y, -0.5f);
                        var c = gobj.GetComponent<GameItemMovingScript>();

                        var cX = l.X1;
                        var cY = j;
                        if (c.GetComponent<GameItem>().IsTouched)
                        {
                            var cell = toCell;
                            GetComponent<DragItemScript>().CancelDragging((s, e) =>
                            {
                                CallbacksCount++;
                                Items[cX][cY] = null;
                                c.MoveTo(null, cell.y, Game.StandartItemSpeed, (item, result) =>
                                {
                                    LogFile.Message(cX + " " + cY, true);
                                    CallbacksCount--;
                                    if (!result) return;
                                    DestroyGameItem((GameObject)item);
                                });
                            });
                        }
                        else
                        {
                            CallbacksCount++;
                            Items[cX][cY] = null;
                            c.MoveTo(null, toCell.y, Game.StandartItemSpeed, (item, result) =>
                            {
                                LogFile.Message(cX + " " + cY, true);
                                CallbacksCount--;
                                if (!result) return;
                                DestroyGameItem((GameObject)item);
                            });
                        }

                    }
                }
                else
                {
                    pointsMultiple += l.X2 - l.X1 - 2;
                    if (repeatForLine == -1)
                    {
                        toObjX = l.X2 - (l.X2 - l.X1) / 2;
                        toObjY = l.Y2;
                        for (var i = l.X2; i >= l.X1; i--)
                        {
                            var lwi = LinesWithItem(lines, i, l.Y1);
                            var enumerable = lwi as IList<Line> ?? lwi.ToList();
                            if (enumerable.Count() <= 1) continue;
                            toObjX = i;
                            toObjY = l.Y1;
                            repeatForLine = lines.IndexOf(enumerable.FirstOrDefault(line => line != l));
                        }
                        toCell = GetCellCoordinates(toObjX, toObjY);
                    }
                    else
                    {
                        raiseMaxIEtype = false;
                        repeatForLine = -1;
                    }
                    for (var i = l.X2; i >= l.X1; i--)
                    {
                        if (Items[i][l.Y1] == null || Items[i][l.Y1] == DisabledItem || i == toObjX)
                        {
                            continue;
                        }

                        var gobj = Items[i][l.Y1] as GameObject;
                        if (gobj == null) continue;

                        gobj.transform.localPosition = new Vector3(gobj.transform.localPosition.x, gobj.transform.localPosition.y, -0.5f);
                        var c = gobj.GetComponent<GameItemMovingScript>();

                        var cX = i;
                        var cY = l.Y1;

                        if (c.GetComponent<GameItem>().IsTouched)
                        {
                            var cell = toCell;
                            GetComponent<DragItemScript>().CancelDragging((s, e) =>
                            {
                                CallbacksCount++;
                                Items[cX][cY] = null;
                                c.MoveTo(cell.x, null, Game.StandartItemSpeed, (item, result) =>
                                {
                                    LogFile.Message(cX + " " + cY, true);
                                    CallbacksCount--;
                                    if (!result) return;
                                    DestroyGameItem((GameObject)item);
                                });
                            });
                        }
                        else
                        {
                            CallbacksCount++;
                            Items[cX][cY] = null;
                            c.MoveTo(toCell.x, null, Game.StandartItemSpeed, (item, result) =>
                            {
                                LogFile.Message(cX + " " + cY, true);
                                CallbacksCount--;
                                if (!result) return;
                                DestroyGameItem((GameObject)item);
                            });
                        }
                    }
                }
                var toGobj = Items[toObjX][toObjY] as GameObject;
                if (toGobj != null)
                {
                    var toGi = toGobj.GetComponent<GameItem>();
                    if (raiseMaxIEtype && toGi.Type > MaxInitialElementType)
                        MaxInitialElementType = toGi.Type;
                    var newgobjtype = toGi.Type != GameItemType._2x ? toGi.Type + 1 : GameItemType._2x;
                    var newgobj = InstantiateGameItem(newgobjtype, toCell, GameItemScale);
                                //new Vector3(GameItemSize / ScaleMultiplyer, GameItemSize / ScaleMultiplyer, 0f));
                    if (toGobj.GetComponent<GameItemMovingScript>().IsMoving)
                        CallbacksCount--;
                    DestroyGameItem(toGobj);
                    Items[toObjX][toObjY] = newgobj;
                    var points = pointsMultiple * (int)Math.Pow(2, (double)newgobjtype);
                    if (newgobjtype <= MaxInitialElementType)
                    {
                        pointsBank += points;
                        LabelShowing.ShowScalingLabel(newgobj, (l.Orientation == LineOrientation.Horizontal), (toObjX >= FieldSize/2),
                            "+" + points, GameColors.ItemsColors[newgobjtype], GameColors.DefaultDark, LabelShowing.minLabelFontSize, LabelShowing.maxLabelFontSize, 2, Game.numbersFont, true, null, 0, newgobjtype);
                    }
                    else
                    {
                        pointsBank += 2 * points;
                        LabelShowing.ShowScalingLabel(newgobj, (l.Orientation == LineOrientation.Horizontal), (toObjX >= FieldSize / 2),
                            "+" + points + "x2", GameColors.ItemsColors[newgobjtype], GameColors.DefaultDark, LabelShowing.minLabelFontSize, LabelShowing.maxLabelFontSize, 2, Game.numbersFont, true, null, 0, newgobjtype);
                    }
                }
                lines.Remove(l);
                if (linesCount == 1)
                    DeviceButtonsHelpers.OnSoundAction(Power2Sounds.Line, false);

                LogFile.Message("line collected", true);
                if (repeatForLine == -1)
                    l = lines.FirstOrDefault();
                else
                    l = lines[repeatForLine - 1];

                if (ProgressBar != null)
                    ProgressBar.AddTime(pointsMultiple * 2);

                if (l != null) continue;

                if (linesCount > 1)
                    ShowComboLabel(linesCount);

                pointsBank *= linesCount;
                ChainCounter++;
                RaisePoints(pointsBank * ChainCounter);

                pointsBank = 0;
                lines = GetAllLines();
                linesCount = lines.Count;
                l = lines.FirstOrDefault();
            }
            LogFile.Message("All lines collected", true);
            //RemoveAdditionalItems();

            return linesCount;
        }
Ejemplo n.º 42
0
        public virtual bool GameItemsExchange(int x1, int y1, int x2, int y2, float speed, bool isReverse, MovingFinishedDelegate exchangeCallback = null)
        {
            var item1 = Items[x1][y1] as GameObject;
            var item2 = Items[x2][y2] as GameObject;

            if (Game.isExtreme)
            {
                if (item1 != null && Items[x1][y1] != DisabledItem)
                {
                    lastMoved = item1.GetComponent<GameItem>().Type;
                }
            }

            GameMovesCount++;

            if (item2 == null)
            {
                RevertMovedItem(x1, y1);
                if (exchangeCallback != null)
                    exchangeCallback(gameObject, false);
                return false;
            }
            if (!isReverse)
            {
                Items[x1][y1] = item2;
                Items[x2][y2] = item1;
            }
            var position1 = GetCellCoordinates(x1, y1);
            var position2 = GetCellCoordinates(x2, y2);
            LogFile.Message("Exchange items: " + position1.x + position1.y + " " + position2.x + " " + position2.y, true);

            if (item1 == null || item2 == null) return false;
            isExchanging = true;
                CallbacksCount++;
                CurrentExchangeItemsCount++;
                item1.GetComponent<GameItemMovingScript>()
                    .MoveTo(position2.x,
                       position2.y,
                        Game.StandartItemSpeed, (item, result) =>
                        {
                            CallbacksCount--;
                            //if (!result) return;
                            var currentItem = item as GameObject;
                            if (currentItem != null && isReverse)
                            {
                                CallbacksCount++;
                                currentItem.GetComponent<GameItemMovingScript>()
                                    .MoveTo(position1.x,
                                        position1.y,
                                        Game.StandartItemSpeed, (reverseItem, reverseResult) =>
                                        {
                                            CallbacksCount--;
                                            CurrentExchangeItemsCount--;
                                            if (CurrentExchangeItemsCount == 0)
                                                isExchanging = false;
                                            if (exchangeCallback != null)
                                                exchangeCallback(gameObject, true);
                                            if (CallbacksCount == 0 && CallClearChainsAfterExchange)
                                            {
                                                CallClearChainsAfterExchange = false;
                                                ClearChains();
                                            }
                                        });
                                return;
                            }
                            CurrentExchangeItemsCount--;
                            if (CurrentExchangeItemsCount == 0)
                                isExchanging = false;
                            if (exchangeCallback != null)
                                exchangeCallback(gameObject, true);
                            if (CallbacksCount == 0)
                            {
                                CallClearChainsAfterExchange = false;
                                ClearChains();
                            }

                        });

            CallbacksCount++;
            CurrentExchangeItemsCount++;
            item2.GetComponent<GameItemMovingScript>()
                    .MoveTo(position1.x,
                        position1.y,
                        Game.StandartItemSpeed, (item, result) =>
                        {
                            CallbacksCount--;
                            //if (!result) return;
                            var currentItem = item as GameObject;
                            if (currentItem != null && isReverse)
                            {
                                CallbacksCount++;
                                currentItem.GetComponent<GameItemMovingScript>()
                                    .MoveTo(position2.x,
                                        position2.y,
                                        Game.StandartItemSpeed, (reverseItem, reverseResult) =>
                                        {
                                            CallbacksCount--;
                                            CurrentExchangeItemsCount--;
                                            if (CurrentExchangeItemsCount == 0)
                                                isExchanging = false;
                                            if (exchangeCallback != null)
                                                exchangeCallback(gameObject, true);
                                            if (CallbacksCount == 0 && CallClearChainsAfterExchange)
                                            {
                                                CallClearChainsAfterExchange = false;
                                                ClearChains();
                                            }
                                        });
                                return;
                            }
                            CurrentExchangeItemsCount--;
                            if (CurrentExchangeItemsCount == 0)
                                isExchanging = false;
                            if (exchangeCallback != null)
                                exchangeCallback(gameObject, true);
                            if (CallbacksCount == 0)
                            {
                                CallClearChainsAfterExchange = false;
                                ClearChains();
                            }
                        });

            return true;
        }
 public override GameObject GenerateGameItem(GameItemType itemType, int i, int j, Vector2? generateOn = null, Vector3? scaleTo = null, bool isItemDirectionChangable = false, float? dropSpeed = null, MovingFinishedDelegate movingCallback = null, GameItemMovingType? movingType = null)
 {
     return base.GenerateGameItem(itemType, i, j, generateOn, Game.isExtreme && itemType == GameItemType._ToMoveItem ? _match3ItemsScale : scaleTo, isItemDirectionChangable, dropSpeed, movingCallback, movingType);
 }
 protected override GameItemMovingType GetMovingTypeByItemType(GameItemType type)
 {
     switch (type)
     {
         case GameItemType._ToMoveItem:
             return GameItemMovingType.StandartExchangable;
         default:
             return base.GetMovingTypeByItemType(type);
     }
 }
Ejemplo n.º 45
0
 public bool MatchType(int x, int y, GameItemType itemType)
 {
     // убедимся, что фишка не выходит за пределы поля
     if ((x < 0) || (x >= FieldSize) || (y < 0) || (y >= FieldSize) || Items[x][y] == null || Items[x][y] == DisabledItem || itemType > GameItemType._2x) return false;
     var gobj = Items[x][y] as GameObject;
     if (gobj == null) return false;
     var gi = gobj.GetComponent<GameItem>();
     return gi != null && gi.Type == itemType && gi.MovingType != GameItemMovingType.Static;
 }
Ejemplo n.º 46
0
 protected virtual void MaxInitialElementTypeRaisedActions()
 {
     switch (MaxType)
     {
         case GameItemType._3:
         case GameItemType._4:
         case GameItemType._5:
         case GameItemType._6:
             DifficultyRaisedGUI(false, MaxInitialElementTypeRaisedActionsAdditional);
             _nextUpperLevelGameItemType = GameItemType._7;
             break;
         case GameItemType._7:
             Game.Difficulty = DifficultyLevel._medium;
             _minTypePlus = 1;
             MoveTimerMultiple = InitialMoveTimerMultiple + 2;
             DifficultyRaisedGUI(_nextUpperLevelGameItemType != GameItemType.NullItem, MaxInitialElementTypeRaisedActionsAdditional);
             DeviceButtonsHelpers.OnSoundAction(Power2Sounds.NextLevel, false);
             _nextUpperLevelGameItemType = GameItemType._10;
             break;
         case GameItemType._8:
         case GameItemType._9:
             _minTypePlus = 0;
             _nextUpperLevelGameItemType = GameItemType._10;
             MoveTimerMultiple = InitialMoveTimerMultiple + 2;
             DifficultyRaisedGUI(false, MaxInitialElementTypeRaisedActionsAdditional);
             break;
         case GameItemType._10:
             Game.Difficulty = DifficultyLevel._hard;
             _minTypePlus = 1;
             MoveTimerMultiple = InitialMoveTimerMultiple + 4;
             DifficultyRaisedGUI(_nextUpperLevelGameItemType != GameItemType.NullItem, MaxInitialElementTypeRaisedActionsAdditional);
             if (Items2XCount < 1)
                 SpawnItemOnRandomPlace(GameItemType._2x);
             DeviceButtonsHelpers.OnSoundAction(Power2Sounds.NextLevel, false);
             SpawnXItems();
             _nextUpperLevelGameItemType = GameItemType._13;
             break;
         case GameItemType._11:
         case GameItemType._12:
             _minTypePlus = 0;
             _nextUpperLevelGameItemType = GameItemType._13;
             MoveTimerMultiple = InitialMoveTimerMultiple + 4;
             DifficultyRaisedGUI(false, MaxInitialElementTypeRaisedActionsAdditional);
             break;
         case GameItemType._13:
             Game.Difficulty = DifficultyLevel._veryhard;
             _minTypePlus = 1;
             MoveTimerMultiple = InitialMoveTimerMultiple + 2;
             DifficultyRaisedGUI(_nextUpperLevelGameItemType != GameItemType.NullItem, MaxInitialElementTypeRaisedActionsAdditional);
             if (Items2XCount < 2)
                 SpawnItemOnRandomPlace(GameItemType._2x);
             DeviceButtonsHelpers.OnSoundAction(Power2Sounds.NextLevel, false);
             _nextUpperLevelGameItemType = GameItemType._2x;
             break;
         case GameItemType._14:
         case GameItemType._15:
         case GameItemType._16:
             _minTypePlus = 0;
             _nextUpperLevelGameItemType = GameItemType._2x;
             MoveTimerMultiple = InitialMoveTimerMultiple + 2;
             DifficultyRaisedGUI(false, MaxInitialElementTypeRaisedActionsAdditional);
             break;
         case GameItemType._2x:
             IsGameOver = true;
             GenerateGameOverMenu(true);
             return;
     }
     if (MaxType - _spawnItemTypesInterval > GameItemType._1)
     {
         DestroyElements(new List<GameItemType> { MinType - 1, MinType - 1 + _minTypePlus });
     }
 }
Ejemplo n.º 47
0
 /// <summary>
 /// Initializes a product data entry for use in XML.
 /// </summary>
 /// <param name="currencyType">Type of currency the item is sold for</param>
 /// <param name="description">NFS: World Beta feature, still gonna keep it for MAYBE future-use</param>
 /// <param name="rentalDurationInMinutes">0 if not a rental, rental duration in minutes if else</param>
 /// <param name="hash">Item hash value that is recognized by NFS: World</param>
 /// <param name="iconString">Item icon that is displayed somewhere around its title</param>
 /// <param name="levelLimit">0 if not level limited, minimum level value if else</param>
 /// <param name="tooltipDescription">NFS: World Beta feature, still gonna keep it for MAYBE future-use</param>
 /// <param name="price">How much the item is sold for</param>
 /// <param name="priorityNumber">Priority in the shopping list in-game, commonly used for new items or discounts</param>
 /// <param name="id">Server product id</param>
 /// <param name="title">Item title that is displayed in-game</param>
 /// <param name="itemType">Item type that NFS: World can recognize</param>
 /// <param name="extraDetail">If there is one, a special condition for the item that is displayed in-game</param>
 /// <returns>An XElement wrapped around in ProductTrans tags.</returns>
 public static XElement getProductTransactionEntry(Currency currencyType, String description, Int32 rentalDurationInMinutes, Int64 hash, String iconString, Int16 levelLimit, String tooltipDescription, Int32 price, Int16 priorityNumber, String id, String title, GameItemType itemType, Special extraDetail = Special.None)
 {
     XElement ProductNode =
         new XElement("ProductTrans",
             new XElement("Currency", currencyType.GetString()),
             new XElement("Description", description),
             new XElement("DurationMinute", rentalDurationInMinutes.ToString()),
             new XElement("Hash", hash.ToString()),
             new XElement("Icon", iconString),
             new XElement("Level", levelLimit.ToString()),
             new XElement("LongDescription", tooltipDescription),
             new XElement("Price", price.ToString()),
             new XElement("Priority", priorityNumber.ToString()),
             new XElement("ProductId", id),
             new XElement("ProductTitle", title),
             new XElement("ProductType", itemType.GetString()),
             new XElement("SecondaryIcon", extraDetail.GetString()),
             new XElement("UseCount", "1")
         );
     return ProductNode;
 }
Ejemplo n.º 48
0
 protected virtual String ItemsTextureName(GameItemType type)
 {
     switch(type)
     {
         case GameItemType._ToMoveItem:
             if (Game.isExtreme)
                 return ItemsNameHelper.GetPrefabPath<ModeMatch3SquarePlayground>();
             else
                 return ItemPrefabName;
         default:
             return ItemPrefabName;
     }
 }
Ejemplo n.º 49
0
 public GameObject InstantiateGameItem(GameItemType itemType, Vector3 localPosition, Vector3 localScale, GameItemMovingType? movingType = null)
 {
     GameItem newgi = TempGameItems.Where(ti=>ti.Type == GameItemType.NullItem).FirstOrDefault();
     if (newgi == null)
     {
         var newgobj = Instantiate(Resources.Load(ItemPrefabName)) as GameObject;
         if (newgobj == null) return null;
         var rectTransform = newgobj.transform as RectTransform;
         if (rectTransform != null)
             rectTransform.sizeDelta = new Vector2(GameItemSize * 0.9375f, GameItemSize * 0.9375f);
         newgobj.transform.SetParent(transform);
         newgi = newgobj.GetComponent<GameItem>();
         /*newgobj.transform.localPosition = localPosition;
         newgobj.transform.localScale = localScale;
         newgi = newgobj.GetComponent<GameItem>();
         newgi.Type = itemType;
         if (movingType.HasValue)
             newgi.MovingType = movingType.Value;*/
         TempGameItems.Add(newgi);
     }
     newgi.transform.localPosition = localPosition;
     newgi.transform.localScale = localScale;
     if(!GameItemsSprites.Keys.Contains(itemType))
     GameItemsSprites.Add(itemType,Resources.LoadAll<Sprite>(ItemsTextureName(itemType).Split('/')[1] + "Tiles").FirstOrDefault(t => t.name.Contains(GetTextureIDByType(itemType))));
     newgi.GetComponent<SpriteRenderer>().sprite = GameItemsSprites[itemType];
     newgi.Type = itemType;
     newgi.MovingType = movingType != null? movingType.Value  : GetMovingTypeByItemType(itemType);
     return newgi.gameObject;
 }
Ejemplo n.º 50
0
 protected override GameItemMovingType GetMovingTypeByItemType(GameItemType type)
 {
     switch (type)
     {
         case GameItemType._XItem:
             return GameItemMovingType.Static;
         default:
             return GameItemMovingType.Standart;
     }
 }
Ejemplo n.º 51
0
        public virtual GameObject GenerateGameItem(GameItemType itemType, int i, int j, Vector2? generateOn = null, Vector3? scaleTo = null, bool isItemDirectionChangable = false, float? dropSpeed = null, MovingFinishedDelegate movingCallback = null, GameItemMovingType? movingType = null)
        {
            if (!generateOn.HasValue)
                generateOn = new Vector2(0, FieldSize - j);
            if (InitialGameItem == null)
                InitialGameItem = InitialGameItemPosition;
            var cell = GetCellCoordinates(i, j);
            var gobj = InstantiateGameItem(itemType, new Vector3(
                (float)Math.Round(cell.x + generateOn.Value.x * GameItemSize, 2),
                    InitialGameItem.Y + generateOn.Value.y * GameItemSize,
                InitialGameItem.Z), Vector3.zero, movingType);

            var c = gobj.GetComponent<GameItemMovingScript>();
            LogFile.Message("GameItem generated to X:" + gobj.transform.localPosition.x + " Y:" + (gobj.transform.localPosition.y - 6 * GameItemSize), true);
            CallbacksCount++;
            //var toS = GameItemSize / ScaleMultiplyer;
            c.MoveTo(cell.x, cell.y, dropSpeed.HasValue ? dropSpeed.Value : 10 - i % 2 + j * 1.5f, (item, result) =>
            {
                CallbacksCount--;
                if (movingCallback != null)
                    movingCallback(item, result);
                else
                {
                    //if (!result) return;
                    if (CallbacksCount == 0)
                        ClearChains();
                    else
                        if (isExchanging && CallbacksCount == CurrentExchangeItemsCount)
                            CallClearChainsAfterExchange = true;
                }
            }, new Vector2(InitialGameItem.X, InitialGameItem.Y + GameItemSize / 2), scaleTo != null ? scaleTo : Vector3.one/*new Vector3(toS, toS, 1f)*/, isItemDirectionChangable,
            null, Power2Sounds.Drop);

            return gobj;
        }
Ejemplo n.º 52
0
 protected override String ItemsTextureName(GameItemType type)
 {
     return ItemPrefabName;
 }
Ejemplo n.º 53
0
        public override bool MatchPattern(GameItemType itemType, Point firstItem, Point secondItem, IEnumerable<Point> pointForCheck)
        {
            var mainType = MatchType(firstItem.X + secondItem.X, firstItem.Y + secondItem.Y, itemType);
            if (!mainType) return false;

            var lineGenerationPoints = pointForCheck.Where(point => MatchType(firstItem.X + point.X, firstItem.Y + point.Y, itemType)).ToList();
            if (!lineGenerationPoints.Any()) return false;

            foreach (var lineGenerationPoint in lineGenerationPoints)
            {
                int sp1X;
                int sp1Y;
                if (secondItem.Y < 0)
                {
                    LogFile.Message("secondItem.Y < 0 and firstItem: " + firstItem.X + " " + firstItem.Y + " secondItem "
                        + secondItem.X + " " + secondItem.Y + "lineGenerationPoint: " + lineGenerationPoint.X + " " + lineGenerationPoint.Y, true);
                    if (secondItem.Y < -1)
                        {
                            sp1X = firstItem.X + (secondItem.X > 0 ? 1 : -1);
                            sp1Y = firstItem.Y - 1;
                        }
                    else
                        {
                            sp1X = firstItem.X + (lineGenerationPoint.Y > -2 ? -1 : 2);
                            sp1Y = firstItem.Y + (lineGenerationPoint.Y > -2 ? 1 : -2);
                        }
                }
                else if (secondItem.Y > 0)
                {
                    LogFile.Message("secondItem.Y > 0 and firstItem: " + firstItem.X + " " + firstItem.Y + " secondItem " + secondItem.X + " " + secondItem.Y + "lineGenerationPoint: "
                        + lineGenerationPoint.X + " " + lineGenerationPoint.Y, true);
                    if (secondItem.Y > 1)
                        {
                            sp1X = firstItem.X + (secondItem.X > 0 ? 1 : -1);
                            sp1Y = firstItem.Y + 1;
                        }
                    else
                        {
                            sp1X = firstItem.X + (lineGenerationPoint.Y < 2 ? -1 : 2);
                            sp1Y = firstItem.Y + (lineGenerationPoint.Y < 2 ? -1 : 2);
                        }
                }
                else
                    continue;
                if ((sp1X < 0) || (sp1X >= FieldSize) || (sp1Y < 0) || (sp1Y >= FieldSize) || Items[sp1X][sp1Y] == null || Items[sp1X][sp1Y] == DisabledItem)
                    continue;
                SelectedPoint1 = new Point
                {
                    X = sp1X,
                    Y = sp1Y
                };

                var diffX = Math.Abs(SelectedPoint1Coordinate.X - (firstItem.X + lineGenerationPoint.X));
                var diffY = Math.Abs(SelectedPoint1Coordinate.Y - (firstItem.Y + lineGenerationPoint.Y));
                if(!((diffX == 0 && diffY == 2) || (diffX == 2 && diffY == 0)))
                    continue;
                if (Items[SelectedPoint1Coordinate.X][SelectedPoint1Coordinate.Y] != null && Items[SelectedPoint1Coordinate.X][SelectedPoint1Coordinate.Y] != DisabledItem)
                {
                    var selectedObject = Items[SelectedPoint1Coordinate.X][SelectedPoint1Coordinate.Y] as GameObject;
                    if (selectedObject != null)
                    {
                        var gi = selectedObject.GetComponent<GameItem>();
                        if (gi.MovingType == GameItemMovingType.Static || gi.Type == GameItemType.NullItem)
                            continue;
                    }
                }
                else continue;
                SelectedPoint2 = new Point { X = firstItem.X + lineGenerationPoint.X, Y = firstItem.Y + lineGenerationPoint.Y };
                return true;
            }

            return false;
        }
 protected override void MaxInitialElementTypeRaisedActions()
 {
     switch (Game.Difficulty)
     {
         case DifficultyLevel._hard:
             SpawnXItems();
             break;
         case DifficultyLevel._veryhard:
             toBlock = (GameItemType)RandomObject.Next(1, (int)MaxType + 1);
             ProgressBar.TimeBorderActivated += VeryHardLevelAction;
             ProgressBar.TimeBorderDeActivated += VeryHardLevelActionDeactivate;
             ProgressBar.SetSmallXsColor(GameColors.Match3Colors[toBlock]);
             break;
     }
 }
Ejemplo n.º 55
0
 protected override String GetTextureIDByType(GameItemType type)
 {
     switch(type)
     {
         case GameItemType._ToMoveItem:
             return "_17";
         default:
             return GameItem.GetStandartTextureIDByType(type);
     }
 }
Ejemplo n.º 56
0
 /// <summary>
 /// Initializes a product data entry for use in XML.
 /// </summary>
 /// <param name="CurrencyType">Type of currency the item is sold for</param>
 /// <param name="Description">NFS: World Beta feature, still gonna keep it for MAYBE future-use</param>
 /// <param name="RentalDurationInMinutes">0 if not a rental, rental duration in minutes if else</param>
 /// <param name="Hash">Item hash value that is recognized by NFS: World</param>
 /// <param name="IconString">Item icon that is displayed somewhere around it's title</param>
 /// <param name="LevelLimit">0 if not level limited, minimum level value if else</param>
 /// <param name="TooltipDescription">NFS: World Beta feature, still gonna keep it for MAYBE future-use</param>
 /// <param name="Price">How much the item is sold for</param>
 /// <param name="PriorityNumber">Priority in the shopping list in-game, commonly used for new items or discounts</param>
 /// <param name="SType">Item type that the server can recognize, not the game</param>
 /// <param name="Id">Item index for the server</param>
 /// <param name="Title">Item title that is displayed in-game</param>
 /// <param name="GType">Item type that NFS: World can recognize, not the server</param>
 /// <param name="ExtraDetail">If there is one, a special condition for the item that is displayed in-game</param>
 /// <returns>An XElement wrapped around in ProductTrans tags.</returns>
 public static XElement GetProductTransactionEntry(Currency CurrencyType, String Description, Int32 RentalDurationInMinutes, Int64 Hash, String IconString, Int16 LevelLimit, String TooltipDescription, Int32 Price, Int16 PriorityNumber, ServerItemType SType, Int32 Id, String Title, GameItemType GType, Special ExtraDetail)
 {
     XElement ProductNode = 
         new XElement("ProductTrans",
             new XElement("BundleItems",
                 new XAttribute(ServerAttributes.nilNS + "nil", "true")
             ),
             new XElement("CategoryId",
                 new XAttribute(ServerAttributes.nilNS + "nil", "true")
             ),
             new XElement("Currency", CurrencyType.GetString()),
             new XElement("Description", Description),
             new XElement("DurationMinute", RentalDurationInMinutes.ToString()),
             new XElement("Hash", Hash.ToString()),
             new XElement("Icon", IconString),
             new XElement("Level", LevelLimit.ToString()),
             new XElement("LongDescription", TooltipDescription),
             new XElement("Price", Price.ToString()),                   
             new XElement("Priority", PriorityNumber.ToString()),
             new XElement("ProductId", String.Format("ItemEntry{0}-{1}", SType.GetString(), Id.ToString())),
             new XElement("ProductTitle", Title),
             new XElement("ProductType", GType.GetString()),
             new XElement("SecondaryIcon", ExtraDetail.GetString()),
             new XElement("UseCount", "1")
         );
     return ProductNode;
 }
Ejemplo n.º 57
0
 protected virtual String GetTextureIDByType(GameItemType type)
 {
     return GameItem.GetStandartTextureIDByType(type);
 }
Ejemplo n.º 58
0
 public void Reset()
 {
     IsTouched = false;
     //CurrentPosition = transform.localPosition;
     Type = GameItemType.NullItem;
 }