예제 #1
0
        public static Item MapSeedToEntity(ItemSeed itemSeed)
        {
            var itemEntity = new Item();

            MapSeedToEntity(itemSeed, itemEntity);
            return(itemEntity);
        }
예제 #2
0
    public void SetID(int id)
    {
        SR = GetComponent <SpriteRenderer>();
        ID = id;

        CropManager.Instance.AddCrop(this);
        Seed        = InventoryManager.Instance.GetItemById(ID) as ItemSeed;
        SR.sprite   = Resources.Load <Sprite>(Seed.Sprite);
        DiffSprites = Seed.Sprites;
        MaxGrow     = Seed.Maxgrow;
        DayGrow     = Seed.Daygrow;
    }
    public virtual void PlantSeed(ItemSeed seed)
    {
        seedType = seed.seedType;
        GameObject plantObject = seed.GetGamePrefab();

        plant = Instantiate(plantObject, this.transform).GetComponent <Growable>();
        // Make sure we have a Growable being planted
        if (plant == null)
        {
            Debug.LogError("Error trying to plant seed.");
        }
    }
예제 #4
0
    public void SetSeed(int id, int count)
    {
        Icon          = UITool.FindChild <Image>(gameObject, "Icon");
        Name          = UITool.FindChild <Text>(gameObject, "Name");
        CountText     = UITool.FindChild <Text>(gameObject, "Count");
        mPlayerStatus = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStatus>();

        ID             = id;
        Seed           = InventoryManager.Instance.GetItemById(ID) as ItemSeed;
        Icon.sprite    = Resources.Load <Sprite>(Seed.Sprite);
        CountText.text = count.ToString();
        Name.text      = Seed.Name;
    }
예제 #5
0
 public static void MapSeedToEntity(ItemSeed itemSeed, Item itemEntity)
 {
     itemEntity.Aura            = itemSeed.aura;
     itemEntity.CasterLevel     = itemSeed.caster_level;
     itemEntity.Category        = itemSeed.category;
     itemEntity.Cost            = itemSeed.cost;
     itemEntity.FullText        = HttpUtility.HtmlDecode(itemSeed.full_text);
     itemEntity.Id              = itemSeed.Id;
     itemEntity.ManifesterLevel = itemSeed.manifester_level;
     itemEntity.Name            = itemSeed.name;
     itemEntity.Prerequisites   = itemSeed.prereq;
     itemEntity.Price           = itemSeed.price;
     itemEntity.Reference       = itemSeed.reference;
     itemEntity.SpecialAbility  = itemSeed.special_ability;
     itemEntity.Subcategory     = itemSeed.subcategory;
     itemEntity.Weight          = itemSeed.weight;
 }
예제 #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ItemSeed itemSeed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // app.UseHsts();
                app.ConfigureExceptionHandler();
            }

            // itemSeed.SeedItems();
            // app.UseHttpsRedirection();
            app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            app.UseAuthentication();
            app.UseMvc();
        }
예제 #7
0
    void ParseItemJson()
    {
        itemList = new List <Item>();
        TextAsset  itemText  = Resources.Load <TextAsset>("Json/ItemsInfo");
        string     itemsJson = itemText.text;
        JSONObject j         = new JSONObject(itemsJson);

        foreach (JSONObject temp in j.list)
        {
            Item          item      = null;
            int           id        = (int)temp["id"].n;
            string        name      = temp["name"].str;
            string        des       = temp["des"].str;
            string        sprite    = temp["sprite"].str;
            int           buyprice  = (int)temp["buyPrice"].n;
            int           sellprice = (int)temp["sellPrice"].n;
            int           capacity  = (int)temp["capacity"].n;
            string        strtype   = temp["type"].str;
            Item.ItemType type      = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), strtype);
            switch (type)
            {
            case Item.ItemType.Consumable:
                JSONObject             j3 = temp["applyAttr"];
                List <ApplyAttrEffect> applyAttrEffects2 = new List <ApplyAttrEffect>();
                if (j3.type == JSONObject.Type.ARRAY)
                {
                    foreach (JSONObject temp2 in j3.list)
                    {
                        ApplyAttrEffect applyAttrEffect = null;
                        AttrType        attrType        = (AttrType)System.Enum.Parse(typeof(AttrType), temp2["attrTpye"].str);
                        bool            positive        = temp2[1].b;
                        int             value           = (int)temp2[2].n;
                        applyAttrEffect = new ApplyAttrEffect(attrType, positive, value);
                        applyAttrEffects2.Add(applyAttrEffect);
                    }
                }
                else if (j3.type == JSONObject.Type.OBJECT)
                {
                    ApplyAttrEffect applyAttrEffect = null;
                    AttrType        attrType        = (AttrType)System.Enum.Parse(typeof(AttrType), j3["attrTpye"].str);
                    bool            positive        = j3[1].b;
                    int             value           = (int)j3[2].n;
                    applyAttrEffect = new ApplyAttrEffect(attrType, positive, value);
                    applyAttrEffects2.Add(applyAttrEffect);
                }
                item = new Consumable(id, name, des, sprite, buyprice, sellprice, capacity, type, applyAttrEffects2);
                break;

            case Item.ItemType.Equipment:
                string stret = temp["equipType"].str;
                Equipment.EquipType    equipType        = (Equipment.EquipType)System.Enum.Parse(typeof(Equipment.EquipType), stret);
                JSONObject             j2               = temp["applyAttr"];
                List <ApplyAttrEffect> applyAttrEffects = new List <ApplyAttrEffect>();
                if (j2.type == JSONObject.Type.ARRAY)
                {
                    foreach (JSONObject temp2 in j2.list)
                    {
                        ApplyAttrEffect applyAttrEffect = null;
                        AttrType        attrType        = (AttrType)System.Enum.Parse(typeof(AttrType), temp2["attrTpye"].str);
                        bool            positive        = temp2[1].b;
                        int             value           = (int)temp2[2].n;
                        applyAttrEffect = new ApplyAttrEffect(attrType, positive, value);
                        applyAttrEffects.Add(applyAttrEffect);
                    }
                }
                else if (j2.type == JSONObject.Type.OBJECT)
                {
                    ApplyAttrEffect applyAttrEffect = null;
                    AttrType        attrType        = (AttrType)System.Enum.Parse(typeof(AttrType), j2["attrTpye"].str);
                    bool            positive        = j2[1].b;
                    int             value           = (int)j2[2].n;
                    applyAttrEffect = new ApplyAttrEffect(attrType, positive, value);
                    applyAttrEffects.Add(applyAttrEffect);
                }
                item = new Equipment(id, name, des, sprite, buyprice, sellprice, capacity, type, equipType, applyAttrEffects);
                break;

            case Item.ItemType.Materials:
                item = new Materials(id, name, des, sprite, buyprice, sellprice, capacity, type);
                break;

            case Item.ItemType.OtherItem:
                OtherItem.OtherItemType otherItemType = (OtherItem.OtherItemType)System.Enum.Parse(typeof(OtherItem.OtherItemType), temp["othertype"].str);
                switch (otherItemType)
                {
                case OtherItem.OtherItemType.Seed:
                    int           maxgrow     = (int)temp["maxgrow"].n;
                    int           daygrow     = (int)temp["daygrow"].n;
                    int           productid   = (int)temp["productid"].n;
                    JSONObject    j4          = temp["diffsprites"];
                    List <string> diffsprites = new List <string>();
                    for (int i = 0; i < j4.list.Count; i++)
                    {
                        string diffsprite = j4[i].str;
                        diffsprites.Add(diffsprite);
                    }
                    item = new ItemSeed(id, name, des, sprite, buyprice, sellprice, capacity, type, otherItemType, maxgrow, daygrow, productid, diffsprites);
                    break;

                case OtherItem.OtherItemType.Pet:
                    int petid = (int)temp["petid"].n;
                    item = new ItemPet(id, name, des, sprite, buyprice, sellprice, capacity, type, otherItemType, petid);
                    break;
                }
                break;
            }
            itemList.Add(item);
        }
    }
예제 #8
0
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            builder.Entity <PokemonType>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();
            });

            builder.Entity <PokemonMatchup>(x =>
            {
                x.HasOne(y => y.AttackingType)
                .WithMany(y => y.Attacking)
                .HasForeignKey(y => y.AttackingTypeId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_PokemonType_PokemonMatchup_Attacking");

                x.HasOne(y => y.DefendingType)
                .WithMany(y => y.Defending)
                .HasForeignKey(y => y.DefendingTypeId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_PokemonType_PokemonMatchup_Defending");

                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();
            });

            builder.Entity <PokemonMoveType>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();
            });

            builder.Entity <PokemonAbility>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();
            });

            builder.Entity <PokemonItem>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();
            });

            builder.Entity <PokemonNature>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();
            });

            builder.Entity <PokemonStat>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();
            });

            builder.Entity <Pokemon>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();

                x.HasOne(y => y.Type1)
                .WithMany(y => y.PokemonType1)
                .HasForeignKey(y => y.Type1Id)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_Type1_Pokemon");

                x.HasOne(y => y.Type2)
                .WithMany(y => y.PokemonType2)
                .HasForeignKey(y => y.Type2Id)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_Type2_Pokemon");
            });

            builder.Entity <PokemonMoveset>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();

                x.HasOne(y => y.Move)
                .WithMany(y => y.Moveset)
                .HasForeignKey(y => y.MoveId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_Move_Moveset");

                x.HasOne(y => y.MoveType)
                .WithMany(y => y.Moveset)
                .HasForeignKey(y => y.MoveTypeId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_MoveType_Moveset");

                x.HasOne(y => y.Pokemon)
                .WithMany(y => y.Moveset)
                .HasForeignKey(y => y.PokemonId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_Pokemon_Moveset");
            });

            builder.Entity <PokemonAbilityset>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();

                x.HasOne(y => y.Ability)
                .WithMany(y => y.Abilityset)
                .HasForeignKey(y => y.AbilityId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_Ability_Abilityset");

                x.HasOne(y => y.Pokemon)
                .WithMany(y => y.Abilities)
                .HasForeignKey(y => y.PokemonId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_Pokemon_Abilityset");
            });

            builder.Entity <TeamMember>(x =>
            {
                x.HasKey(y => y.Id);
                x.Property(y => y.Id).ValueGeneratedOnAdd();

                x.HasOne(y => y.Pokemon)
                .WithMany(y => y.TeamMembers)
                .HasForeignKey(y => y.PokemonId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_Pokemon");

                x.HasOne(y => y.Ability)
                .WithMany(y => y.TeamMembers)
                .HasForeignKey(y => y.AbilityId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_PokemonAbility");

                x.HasOne(y => y.Nature)
                .WithMany(y => y.TeamMembers)
                .HasForeignKey(y => y.NatureId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_Nature");

                x.HasOne(y => y.Item)
                .WithMany(y => y.TeamMembers)
                .HasForeignKey(y => y.ItemId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_Item");

                x.HasOne(y => y.Move1)
                .WithMany(y => y.TeamMembers1)
                .HasForeignKey(y => y.Move1Id)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_Move1");

                x.HasOne(y => y.Move2)
                .WithMany(y => y.TeamMembers2)
                .HasForeignKey(y => y.Move2Id)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_Move2");

                x.HasOne(y => y.Move3)
                .WithMany(y => y.TeamMembers3)
                .HasForeignKey(y => y.Move3Id)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_Move3");

                x.HasOne(y => y.Move4)
                .WithMany(y => y.TeamMembers4)
                .HasForeignKey(y => y.Move4Id)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_Move4");

                x.HasOne(y => y.User)
                .WithMany(y => y.TeamMembers)
                .HasForeignKey(y => y.UserId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMember_User");
            });

            builder.Entity <Team>(x =>
            {
                x.HasKey(a => a.Id);
                x.Property(a => a.Id).ValueGeneratedOnAdd();

                x.HasOne(y => y.User)
                .WithMany(y => y.Teams)
                .HasForeignKey(y => y.UserId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_Team_User");
            });

            builder.Entity <TeamLike>(x =>
            {
                x.HasKey(a => a.Id);
                x.Property(a => a.Id).ValueGeneratedOnAdd();

                x.HasOne(a => a.Team)
                .WithMany(a => a.Likes)
                .HasForeignKey(a => a.TeamId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamLikes_Team");

                x.HasOne(a => a.User)
                .WithMany(a => a.TeamLikes)
                .HasForeignKey(a => a.UserId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_User_TeamMember");
            });

            builder.Entity <TeamMembers>(x =>
            {
                x.HasKey(a => a.Id);
                x.Property(a => a.Id).ValueGeneratedOnAdd();

                x.HasOne(a => a.Team)
                .WithMany(a => a.Members)
                .HasForeignKey(a => a.TeamId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMembers_Team");

                x.HasOne(a => a.TeamMember)
                .WithMany(a => a.Members)
                .HasForeignKey(a => a.TeamMemberId)
                .OnDelete(DeleteBehavior.Restrict)
                .HasConstraintName("FK_TeamMembers_TeamMember");
            });

            builder.Entity <NewsItem>(x =>
            {
                x.HasKey(a => a.Id);
                x.Property(a => a.Id).ValueGeneratedOnAdd();
            });

            var categories = CategorySeed.Seed(builder);
            var types      = TypeSeed.Seed(builder);
            var moveTypes  = MoveTypeSeed.Seed(builder);

            MatchupSeed.Seed(builder, types);
            var abilities = AbilitySeed.Seed(builder);

            ItemSeed.Seed(builder);
            NatureSeed.Seed(builder);
            StatSeed.Seed(builder);
            var moves = MoveSeed.Seed(builder, types, categories);

            PokemonSeed.Seed(builder, types, moveTypes, moves, abilities);
        }
    private void Update()
    {
        if (toolUsageCooldownTimer > 0f)
        {
            toolUsageCooldownTimer -= Time.deltaTime;
        }

        bool useItemPressed        = Input.GetButton("Fire1");
        bool useItemSpecialPressed = Input.GetButton("SpecialAttack");
        bool waterButtonPressed    = Input.GetButton("Fire2");

        int indexChange = 0;

        indexChange  = Mathf.RoundToInt(10f * Input.GetAxis("Mouse ScrollWheel"));
        indexChange += Input.GetButtonDown("NavLeft")? -1 : 0;
        indexChange += Input.GetButtonDown("NavRight") ? 1 : 0;

        if (indexChange != 0)
        {
            SetSelectedItemIndex(selectedItemIndex += indexChange);
        }

        if (useItemPressed)
        {
            InventorySlot currentItem = inventorySlots[selectedItemIndex];

            // Right now all we can do is use items, so nothing left to do.
            if (currentItem.IsEmpty())
            {
                return;
            }

            // Check to see if we have a variety of things and if we can use them
            Growable  plantableSeed = currentItem.GetGamePrefab().GetComponent <Growable>();
            DirtPatch dirtPatch     = currentItem.GetGamePrefab().GetComponent <DirtPatch>();

            PlantableZone plantableZone = player.GetAvailablePlantableZone();

            // Planting a seed
            if (plantableSeed != null)
            {
                ItemSeed seed = (ItemSeed)currentItem.GetItem();
                if (plantableZone != null && !plantableZone.IsPlanted())
                {
                    plantableZone.PlantSeed(seed);
                    currentItem.Use();
                }
            }
            // Placing dirt on the ground
            else if (dirtPatch != null)
            {
                if (plantableZone == null && player.OnPlantableGround())
                {
                    GameObject dirt = Instantiate(dirtPatch.gameObject);

                    // Assign the dirt patch to be parented to whatever the player is standing on
                    // This allows us to recursively destroy plants after we plant on top of them
                    // (e.g. dirt pile on a leaf platform. Destroy bottom plant, it destroys the rest)
                    Transform parent = player.GetObjectBelow().transform;
                    dirt.transform.parent = parent;

                    // Place this dirt roughly on the ground
                    dirt.transform.position = player.transform.position + Vector3.down * 0.5f;
                    currentItem.Use();
                }
            }
            else
            {
                currentItem.Use();
            }
        }

        if (useItemSpecialPressed)
        {
            InventorySlot currentItem = inventorySlots[selectedItemIndex];

            // Make sure we have something equipped.
            if (currentItem.IsEmpty())
            {
                return;
            }

            currentItem.UseSpecial();
        }

        if (waterButtonPressed)
        {
            PlantableZone plantableZone = player.GetAvailablePlantableZone();
            if (plantableZone != null && plantableZone.CanBeWatered())
            {
                GameObject target = (plantableZone as MonoBehaviour).gameObject;
                if (waterLevel > 0)
                {
                    if (!waterSprite.PlanningToVisit(target))
                    {
                        // Everything that we have that implements interfaces is also a MonoBehavior, so we can
                        // use this as a """safe""" cast in order to find the game object
                        // The water sprite reaching the PlantableZone will handle the watering itself.
                        waterSprite.AddImmediateToTargetList((plantableZone as MonoBehaviour).gameObject);

                        // TODO: Consider implications of this call. It means we can't possibly overwater, but it
                        // also changes the watersprite visual before it actually reaches the PlantableZone
                        ChangeWaterLevel(-1);
                    }
                    else
                    {
                        Debug.LogError("D:");
                    }
                }
                else
                {
                    // lol you've got no water, nerd
                }
            }
        }


        // Quick and dirty keypress check for inventory slots
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            SetSelectedItemIndex(0);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            SetSelectedItemIndex(1);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            SetSelectedItemIndex(2);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            SetSelectedItemIndex(3);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            SetSelectedItemIndex(4);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            SetSelectedItemIndex(5);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            SetSelectedItemIndex(6);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            SetSelectedItemIndex(7);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha9))
        {
            SetSelectedItemIndex(8);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            SetSelectedItemIndex(9);
        }
        else if (Input.GetKeyDown(KeyCode.Minus))
        {
            SetSelectedItemIndex(10);
        }
        else if (Input.GetKeyDown(KeyCode.Equals))
        {
            SetSelectedItemIndex(11);
        }
    }