コード例 #1
0
ファイル: Program.cs プロジェクト: ScavengerAsh/cs492
        static void Main(string[] args)
        {
            Toy doll = new Toy();
            doll.Make = "rubber";
            doll.Model = "barbie";
            doll.Name = "Elsa";

            Toy car = new Toy();
            car.Make = "plastic";
            car.Model = "BMW";
            car.Name = "SPUR";

            System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();
            myArrayList.Add(doll);
            myArrayList.Add(car);

            System.Collections.Specialized.ListDictionary myDictionary
                = new System.Collections.Specialized.ListDictionary();

            myDictionary.Add(doll.Name, doll);
            myDictionary.Add(car.Name, car);
            foreach (object o in myArrayList)
            {
                Console.WriteLine(((Toy)o).Name);
            }

            Console.WriteLine(((Toy)myDictionary["Elsa"]).Model);
            Console.ReadLine();
        }
コード例 #2
0
    public Toy getNextTarget(Toy pToy)
    {
        Toy pTarget = null;
        CAMP_TYPE eCamp = pToy.TOY_CAMP;
        Vector2 pCellPos = pToy.getCellPos();
        if (eCamp == CAMP_TYPE.eATTACKER)
        {
            // 进攻方从下到上查询敌人
            int i;
            for (i = (int)pCellPos.x + 1; i < MapManage.MAP_ROWS; ++i)
            {
                Vector2 pCellTemp = new Vector2(i, pCellPos.y);
                pTarget = ToyManager.Instance().findToy(pCellPos, CAMP_TYPE.eDEFENSE);
                break;
            }    
        }
        else if (eCamp == CAMP_TYPE.eDEFENSE)
        {
            // 防守方从上到下
            int i;
            for (i = (int)pCellPos.x -1; i >= 0; --i)
            {
                Vector2 pCellTemp = new Vector2(i, pCellPos.y);
                pTarget = ToyManager.Instance().findToy(pCellPos, CAMP_TYPE.eATTACKER);
                break;
            }
        }

        return pTarget;
    }
コード例 #3
0
        public override void Generate()
        {
            var ageRangeIds = this.Database.AgeRanges.Select(a => a.Id).ToList();
            var manufacturerIds = this.Database.Manufacturers.Select(m => m.Id).ToList();
            var categoryIds = this.Database.Categories.Select(c => c.Id).ToList();

            Console.WriteLine("Adding toys");
            for (int i = 0; i < this.Count; i++)
            {
                var toy = new Toy
                {
                    Name = this.Random.GetRandomStringWithRandomLength(5, 50),
                    Type = this.Random.GetRandomNumber(1, 3) == 3 ? null : this.Random.GetRandomStringWithRandomLength(5, 20),
                    Price = this.Random.GetRandomNumber(10, 500),
                    Color = this.Random.GetRandomNumber(1, 5) == 5 ? null : this.Random.GetRandomStringWithRandomLength(5, 20),
                    ManufacturerId = manufacturerIds[this.Random.GetRandomNumber(0, manufacturerIds.Count - 1)],
                    AgeRangeId = ageRangeIds[this.Random.GetRandomNumber(0, ageRangeIds.Count - 1)]
                };

                if (categoryIds.Count > 0)
                {
                    var uniqueCategoryIds = new HashSet<int>();
                    var categoriesInToy = this.Random.GetRandomNumber(1, Math.Min(10, categoryIds.Count));

                    while (uniqueCategoryIds.Count != categoriesInToy)
                    {
                        uniqueCategoryIds.Add(categoryIds[this.Random.GetRandomNumber(0, categoryIds.Count - 1)]);
                    }

                    foreach (var uniqueCategoryId in uniqueCategoryIds)
                    {
                        toy.Categories.Add(this.Database.Categories.Find(uniqueCategoryId));
                    }
                }

                if (i % 100 == 0)
                {
                    Console.Write(".");
                    this.Database.SaveChanges();
                }

                this.Database.Toys.Add(toy);
            }

            Console.WriteLine("\nToys added");
        }
コード例 #4
0
        public int BuyFromDistributor(string name, string description, decimal price, int brandId, int categoryId)
        {
            ValidateToy(name, brandId, categoryId, price);

            var toy = new Toy()
            {
                Name        = name,
                Description = description,
                Price       = price,
                BrandId     = brandId,
                CategoryId  = categoryId
            };

            this.data.Toys.Add(toy);
            this.data.SaveChanges();

            return(toy.Id);
        }
コード例 #5
0
        public int BuyFromDistributor(AddingToyServiceModel model)
        {
            ValidateToy(model.Name, model.BrandId, model.CategoryId, model.Price);

            var toy = new Toy()
            {
                Name        = model.Name,
                Description = model.Description,
                Price       = model.Price,
                BrandId     = model.BrandId,
                CategoryId  = model.CategoryId
            };

            this.data.Toys.Add(toy);
            this.data.SaveChanges();

            return(toy.Id);
        }
コード例 #6
0
        public async Task <bool> DeleteToy(int id)
        {
            bool isDeleted = false;

            Toy toy = await _context.Toys.FindAsync(id);

            if (toy != null)
            {
                toy.IsDeleted = true;
                var response = await _context.SaveChangesAsync();

                if (response == SystemStatusCode.SUCCESS)
                {
                    isDeleted = true;
                }
            }
            return(isDeleted);
        }
        public void BuyToyFromDistributor(AddingToyServiceModel model)
        {
            ValidateName(model.Name);
            ValidateProfit(model.Profit);

            var toy = new Toy()
            {
                Name             = model.Name,
                Description      = model.Description,
                DistributorPrice = model.Price,
                Price            = model.Price + (model.Price * model.Profit),
                BrandId          = model.BrandId,
                CategoryId       = model.CategoryId
            };

            this.data.Toys.Add(toy);
            this.data.SaveChanges();
        }
コード例 #8
0
        public void SetToy(Toy newToy, int index)
        {
            Toy[] temp = new Toy[_toysMass.Length + 1];
            for (int i = 0; i < _toysMass.Length; i++)
            {
                if (i < index)
                {
                    temp[i] = _toysMass[i];
                }
                else
                {
                    temp[i + 1] = _toysMass[i];
                }
            }

            temp[index] = newToy;
            _toysMass   = temp;
        }
コード例 #9
0
        public ActionResult Decline(int id) //ToyRentalViewModel model
        {
            if (id == 0)                    //ToyID??
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ToyRent toyRent = db.ToyRents.Find(id);

            toyRent.Status = ToyRent.StatusEnum.Rejected;

            Toy toyInDb = db.Toys.Find(toyRent.ToyID);

            toyInDb.Avaibility += 1;
            db.SaveChanges();


            return(RedirectToAction("Index"));
        }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: svevash/web-2
        public ActionResult Add(Toy toy)
        {
            if (db.Toys.Contains(toy))
            {
                return(BadRequest());
            }

            if (!db.ToyTypes.Contains(toy.Type))
            {
                db.ToyTypes.Add(toy.Type);
            }

            toy.CreationDate = DateTime.Now;
            db.Toys.Add(toy);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #11
0
    static int Main()
    {
        char[] delimiterChars = { ' ', '\n' };
        string line;

        using (StreamReader fileIn = new StreamReader("input1.txt"))
        {
            line = fileIn.ReadToEnd();;
        }
        string[] info = line.Split(delimiterChars);
        Toy[]    a    = new Toy[info.Length / 4];

        int k = 0;
        Toy b;

        for (int i = 0; i < info.Length - 3; i += 4)
        {
            b.name     = info[i];
            b.cost     = int.Parse(info[i + 1]);
            b.yeardown = int.Parse(info[i + 2]);
            b.yearup   = int.Parse(info[i + 3]);
            a[k]       = b;
            k++;
        }
        Console.WriteLine("Введи возрасnные границы для поиска игрушек");
        int n1 = int.Parse(Console.ReadLine());
        int m1 = int.Parse(Console.ReadLine());
        int n, m;

        if (n1 > m1)
        {
            n = m1;
            m = n1;
        }
        else
        {
            n = n1;
            m = m1;
        }
        Array.Sort(a);
        Show(a);
        Show(a, n, m);
        return(0);
    }
コード例 #12
0
    bool CheckToy(Toy t)
    {
        bool[]  check   = new bool[actualOrder.Length];
        Piece[] toyData = t.GetToyData();

        //Check the Toy with the Order
        for (int i = 0; i < check.Length; i++)
        {
            for (int j = 0; j < toyData.Length; j++)
            {
                if (actualOrder[i] == null)
                {
                    break;
                }

                if (i != 2)   //Check Sprites
                {
                    if (actualOrder[i].sprite == toyData[j].sprite)
                    {
                        check[i] = true;
                        break;
                    }
                }
                else
                {
                    if (actualOrder[i].color == toyData[j].color)
                    {
                        check[i] = true;
                        break;
                    }
                }
            }
        }

        for (int i = 0; i < check.Length; i++)
        {
            if (!check[i])
            {
                return(false);
            }
        }

        return(true);
    }
コード例 #13
0
        public void AddNewProduct(int input)
        {
            if (input == 1)
            {
                Electronics newElectronic = new Electronics();

                Console.WriteLine("Product name: ");
                newElectronic.ProductName = Console.ReadLine();
                Console.WriteLine("Product brand: ");
                newElectronic.Brand = Console.ReadLine();
                Console.WriteLine("Product price: ");
                newElectronic.Price = double.Parse(Console.ReadLine());

                storeList.Add(newElectronic);
            }

            if (input == 2)
            {
                Toy newToy = new Toy();

                Console.WriteLine("Product name: ");
                newToy.ProductName = Console.ReadLine();
                Console.WriteLine("Product brand: ");
                newToy.ToyType = Console.ReadLine();
                Console.WriteLine("Product price: ");
                newToy.Price = double.Parse(Console.ReadLine());

                storeList.Add(newToy);
            }

            if (input == 3)
            {
                Food newFood = new Food();

                Console.WriteLine("Product name: ");
                newFood.ProductName = Console.ReadLine();
                Console.WriteLine("Product brand: ");
                newFood.Manufacturer = Console.ReadLine();
                Console.WriteLine("Product price: ");
                newFood.Price = double.Parse(Console.ReadLine());

                storeList.Add(newFood);
            }
        }
コード例 #14
0
        static void Main(string[] args)
        {
            // array of objects
            Toy[] toys = new Toy[3]
            {
                new Toy("wasp", 345, "Gun Powder", Color.BlueViolet, 173, "Animal",
                        true, 0.33),
                new Toy("Dragon Ball", 222, "Gun Powder", Color.Salmon, 25, "Fantasy",
                        true, 0.33),
                new Toy("Glec", 623, "Gun Powder", Color.DodgerBlue, 73, "idk",
                        true, 0.33)
            };

            IEnumerable <Toy> s = toys.OrderBy(toy => toy.Cost);           // smallest --> largest
            IEnumerable <Toy> l = toys.OrderByDescending(toy => toy.Cost); // largest --> smallest

            foreach (Toy toy in l)
            {
                Console.WriteLine("{0}--{1}", toy.Name, toy.Cost);
            }


            foreach (Toy toy in s)
            {
                Console.WriteLine("{0}--{1}", toy.Name, toy.Cost);
            }



            List <Toy> arr = new List <Toy>(); // lab 11 --> List<T>

            Toy t1 = new Toy("Police Chibi", 345, "Gun Powder", Color.Aqua, 50, "small piece of coolity",
                             true, 0.33);
            Toy t2 = new Toy("Beebop", 774, "Jp bla-bla inc.",
                             Color.Beige, 164, "Original masterpiece chibi", false, 0.34);

            arr.Add(t1);
            arr.Add(t2);

            foreach (Toy value in arr)
            {
                Console.WriteLine(value);
            }
        }
コード例 #15
0
        public int Create(string name, string decsription, decimal distributorPrice, decimal price, int brand, int category, string imageUrl)
        {
            if (name == null)
            {
                throw new InvalidOperationException("Toy name cannot be empty!");
            }
            if (this.db.Toys.Any(x => x.Name == name))
            {
                throw new InvalidOperationException($"Toy name {name} already exists!");
            }
            if (decsription.Length < 10)
            {
                throw new InvalidOperationException($"Toy decsription cannot be less than 10 symbols!");
            }
            if (name.Length > DataValidation.NameMaxLength)
            {
                throw new InvalidOperationException($"Toy name cannot be more than {DataValidation.NameMaxLength} symbols!");
            }
            if (distributorPrice < 0)
            {
                throw new InvalidOperationException($"Distributor price should be more than 0$!");
            }
            if (price < 0)
            {
                throw new InvalidOperationException($"Price should be more than 0$!");
            }

            var brandId = this.db.Brands.Where(x => x.Id == brand).Select(x => x.Id).FirstOrDefault();
            var categoryId = this.db.Categories.Where(x => x.Id == category).Select(x => x.Id).FirstOrDefault();

            var toy = new Toy
            {
                Name = name,
                Price = price,
                DistributorPrice = distributorPrice,
                Description = decsription,
                ImageUrl = imageUrl,
                BrandId = brandId,
                CategoryId = categoryId
            };
            this.db.Toys.Add(toy);
            this.db.SaveChanges();
            return toy.Id;
        }
コード例 #16
0
    public static float GetDistanceBonus(string toy_name, Vector3 position, Toy _toy) // Toy t is only for setting parent toy, meh
    {
        float total_bonus = 0f;
        // float building_count = 0f;
        //   Toy closest_building = null;
        //  float closest_building_distance = 999999f;

        List <Toy> toy_parents = Peripheral.Instance.toy_parents;

        if (Peripheral.Instance.toy_parents.Count > 1)
        {
            Debug.LogError("Have more than 1 toy parent!!!\n");
        }

        for (int i = 0; i < toy_parents.Count; i++)
        {
            //Debug.Log(buildings[i].building_id.target_toy_name + " " + toy.name + "\n");
            if (toy_parents[i].isToyATarget(toy_name))
            {
                float max_range = toy_parents[i].rune.getRange();
                float bonus     = 0.5f;

                float eff_distance = Mathf.Max(0f, max_range - Vector2.Distance(toy_parents[i].gameObject.transform.position, position) + 0.5f);

//                if (closest_building_distance > eff_distance) { closest_building = toy_parents[i]; closest_building_distance = eff_distance; }

                float extra_slope = 1.2f;
                if (_toy != null)
                {
                    _toy.parent_toy = toy_parents[i];
                }
                float final = extra_slope * bonus * eff_distance / max_range;

                //   Debug.Log("Getting distance bonus for " + toy_name + " from " + buildings[i].name + " eff_dist " + eff_distance +
                //  " max range " + max_range + " final " + final + "\n");

                //if (_toy != null) Debug.Log("Distance: " + Vector3.Distance(buildings[i].gameObject.transform.position, _toy.gameObject.transform.position) + " max_range: " + max_range + " bonus " + final + "\n");
                total_bonus += final;
                //      building_count++;
            }
        }

        return(total_bonus);
    }
コード例 #17
0
    public void purchaseToy(int toy)
    {
        Toy newToy = new Toy();

        newToy.toyIndex = toy;
        if (toy == 1)
        {
            newToy.hornygrade = 1;
        }
        else if (toy == 2)
        {
            newToy.hornygrade = 1;
        }
        else if (toy == 3)
        {
            newToy.hornygrade = 2;
        }
        else if (toy == 4)
        {
            newToy.hornygrade = 2;
        }
        else if (toy == 5)
        {
            newToy.hornygrade = 3;
        }
        else if (toy == 6)
        {
            newToy.hornygrade = 3;
        }
        else if (toy == 7)
        {
            newToy.hornygrade = 4;
        }
        else if (toy == 8)
        {
            newToy.hornygrade = 4;
        }
        else
        {
            newToy.hornygrade = 5;
        }
        toys[toy - 1] = newToy;
    }
コード例 #18
0
        public void BuyToy(ToyInputViewModelService model)
        {
            var owner = ExistOwner(model.OwnerId);

            if (owner == null)
            {
                throw new ArgumentException();
            }

            var toy = new Toy
            {
                Name    = model.Name,
                Price   = model.Price,
                OwnerId = model.OwnerId
            };

            this.db.Toys.Add(toy);
            this.db.SaveChanges();
        }
コード例 #19
0
        public IActionResult Delete(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Toy toy = _context.Toy.Single(m => m.ToyId == id);

            if (toy == null)
            {
                return(NotFound());
            }

            _context.Toy.Remove(toy);
            _context.SaveChanges();

            return(Ok(toy));
        }
コード例 #20
0
        public ActionResult Details(int id)
        {
            ViewData["Tid"] = id;
            //functie krijgt toysid => zoekt alle orderdetails met die toysid => creert order lijst waar orderdetails gemaakt zijn => selecteert de top 5 toys van die orders
            //viewmodel voor toy en toysid
            var TL  = RT(id);
            Toy toy = db.Toy.Find(id);
            var t   = from T in db.Toy
                      where T.ToysId == id
                      select T;
            Toy TT = t.First();
            var rt = new Recommended
            {
                t  = TT,
                lt = TL
            };

            return(View(rt));
        }
コード例 #21
0
        static void Setup(string name)
        {
            context = new TestDbContext();

            parents            = new List <Parent>();
            sons               = new List <Son>();
            sonsWithAutoParent = new List <SonWithAutoParent>();
            toys               = new List <Toy>();

            for (int i = 0; i < 120; i++)
            {
                var parent = new Parent()
                {
                    Name = "P" + i + name
                };
                parents.Add(parent);

                for (int j = 0; j < 55; j++)
                {
                    var son = new Son()
                    {
                        Parent = parent, Name = "S" + j + name
                    };
                    var sonsToys = new List <Toy>();
                    for (int l = 0; l < 10; l++)
                    {
                        var toy = new Toy()
                        {
                            Name = "S" + j + "T" + l + name
                        };
                        sonsToys.Add(toy);
                    }
                    son.Toys = sonsToys;
                    sons.Add(son);

                    var sonWithAutoParent = new SonWithAutoParent()
                    {
                        Parent = parent, Name = "S" + j + name
                    };
                    sonsWithAutoParent.Add(sonWithAutoParent);
                }
            }
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: rutvika16/Assignments
        public void AddToyDetails()
        {
            using (var database = new CompanyEntities())
            {
                var toydetail = new Toy();
                Console.WriteLine("Enter name of toy:" + toydetail.ToyName);
                toydetail.ToyName = Console.ReadLine();

                Console.WriteLine("Enter price of toy:" + toydetail.Price);
                toydetail.Price = Convert.ToInt32(Console.ReadLine());

                var mplist = database.ManufacturingPlants;
                {
                    foreach (var mpl in mplist)
                    {
                        Console.WriteLine($"List of Maufacturing Plants - {mpl.ManufacturingPlantId} - {mpl.PlantName}");
                    }
                }
                Console.WriteLine($"Enter Plant Id from above list:" + toydetail.ManufacturingPlantId);
                toydetail.ManufacturingPlantId = Convert.ToInt32(Console.ReadLine());
                var manu = database.ManufacturingPlants.SingleOrDefault(t => t.ManufacturingPlantId == toydetail.ManufacturingPlantId);
                if (manu == null)
                {
                    Console.WriteLine("There is no such manufacturing plant");
                    Console.WriteLine("Please Enter valid details");
                }


                var toy = database.Toys.SingleOrDefault(t => t.ToyName == toydetail.ToyName);
                if (toy == null)
                {
                    database.Toys.Add(toydetail);
                    database.SaveChanges();
                    Console.WriteLine("Toy details added to the list");
                }

                else
                {
                    Console.WriteLine("There is already such toy in the list");
                    throw new DuplicateWaitObjectException("There is already such toy in the list");
                }
            }
        }
コード例 #23
0
ファイル: CartTest.cs プロジェクト: kpalkowska/Testowanie.NET
        public void AddNewItemsTest()
        {
            Toy t1 = new Toy {
                ToyID = 1, Name = "Misio"
            };
            Toy t2 = new Toy {
                ToyID = 2, Name = "Lalka"
            };

            Cart cart = new Cart();

            cart.AddItem(t1, 1);
            cart.AddItem(t2, 3);
            Cart.CartItem[] result = cart.Items.ToArray();

            Assert.AreEqual(result.Length, 2);
            Assert.AreEqual(result[0].Toy, t1);
            Assert.AreEqual(result[1].Toy, t2);
        }
コード例 #24
0
        public int Add(Toy toy)
        {
            using (var db = new LiteDatabase(this.toysConnection))
            {
                var dbObject = InverseMap(toy);

                var repository = db.GetCollection <ToyDB>("toys");
                if (repository.FindById(toy.Id) != null)
                {
                    repository.Update(dbObject);
                }
                else
                {
                    repository.Insert(dbObject);
                }

                return(dbObject.Id);
            }
        }
コード例 #25
0
 /// <summary>
 /// Get API/Toy
 /// </summary>
 /// <returns>List de tous les Toys</returns>
 public IHttpActionResult Get()
 {
     if ((new[] { "Admin", "User", "Anonyme" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <ToyModel> List = repo.GetAll().Select(Toy => Toy?.MapTo <ToyModel>());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Json(List));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
コード例 #26
0
 public void SaveToy(Toy toy)
 {
     if (toy.ToyID == 0)
     {
         context.Toys.Add(toy);
     }
     else
     {
         Toy dbEntry = context.Toys.Find(toy.ToyID);
         if (dbEntry != null)
         {
             dbEntry.Name        = toy.Name;
             dbEntry.Description = toy.Description;
             dbEntry.Price       = toy.Price;
             dbEntry.Category    = toy.Category;
         }
     }
     context.SaveChanges();
 }
コード例 #27
0
ファイル: Tree.cs プロジェクト: SaikoVlad/work
        public void Add(Toy newToy)
        {
            int index = toysMass.Length;

            Toy[] temp = new Toy[toysMass.Length + 1];
            for (int i = 0; i < toysMass.Length; i++)
            {
                if (i < index)
                {
                    temp[i] = toysMass[i];
                }
                else
                {
                    temp[i + 1] = toysMass[i];
                }
            }
            temp[index] = newToy;
            toysMass    = temp;
        }
コード例 #28
0
ファイル: Damage.cs プロジェクト: linxiubao/UniShader
    public virtual bool autoCreateSkillDamageParam(Toy pHost, Toy pTarget)
    {
        if (null == pHost || null == pTarget)
        {
            return false;
        }

        setDamageOwned(pHost);
        setDamageWound(pTarget);
        int nSpeed = this.getProjectileSpeed(pHost);
        Vector2 v2Target = pTarget.getPosition();
        Vector2 v2Host   = pHost.getPosition();

        float fDistance = Vector2.Distance(v2Host, v2Target);
        m_pDamageParam.fRemainTime = fDistance / nSpeed / 2000;
        m_pDamageParam.nDamage = pHost.getDamage();

        return true;
    }
コード例 #29
0
ファイル: Island_Button.cs プロジェクト: Valensta/otherside
    public void MakeDeadIsland(float timer)
    {
        if (dead_island.Equals(""))
        {
            dead_island = "Props/dead_island";
        }
        my_toy = null;
        block  = Peripheral.Instance.zoo.getObject(dead_island, true).GetComponent <dead_island>();
        Vector3 pos = this.transform.position;

        pos.z = 1.1f;
        float make_me = (timer > 0) ? timer : 10f;

        block.EnableMe(make_me, this);

        block.transform.position = pos;

        blocked = true;
    }
コード例 #30
0
ファイル: AIFactory.cs プロジェクト: linxiubao/UniShader
    // 根据战士类型和阵营来创建AI,根据阵营和战士类型来创建目标选择策略
    public AIBase createAI(Toy pToy, HERO_TYPE eHeroType, CAMP_TYPE eCampType)
    {
        AIBase pAI = null;
        switch (eHeroType)
        {
            case HERO_TYPE.AI_WARRIOR:            // 战士
            case HERO_TYPE.AI_MASTER:             // 法师
            case HERO_TYPE.AI_TANKING:            // 肉盾
            case HERO_TYPE.AI_SHOOTER:            // 射手
            case HERO_TYPE.AI_WIZARD:             // 巫师
            case HERO_TYPE.AI_PARADIN:            // 奶骑
                {
                    pAI = createHeroAI(eCampType);

                    IBehavior pBehavior = null;
                    // 设置IDLE行为
                    pBehavior = new IdleBehavior();
                    pAI.setIdleBehavior(pBehavior);

                    // 设置思考行为
                    pBehavior = new ThinkBehavior();
                    pAI.setThinkBehavior(pBehavior);

                    // 冷却行为
                    pBehavior = new CoolDownBehavior();
                    pAI.setCoolDownBehavior(pBehavior);

                    // 设置攻击行为
                    pBehavior = new AttackBehavior();
                    pAI.setAttackBehavior(pBehavior);

                    // 设置选择策略
                    IChoiceStrategy pChoiceStrategy = createChooseStrategy();
                    pAI.setChoiceStrategy(pChoiceStrategy);
                }
                break;
            default:
                break;
                
        }

        return pAI;
    }
コード例 #31
0
        public async Task <IActionResult> Edit(int id, IFormFile imageFile, [Bind("ToyId,ToyTypeId,Color,Description,ImagePath")] Toy toy)
        {
            if (id != toy.ToyId)
            {
                return(NotFound());
            }

            // Remove user from model validation as it is not submitted in the form.
            // Validation will fail is this is not in here
            ModelState.Remove("UserId");


            var user = await GetCurrentUserAsync();

            if (ModelState.IsValid)
            {
                try
                {
                    toy.User   = user;
                    toy.UserId = user.Id;
                    _context.Update(toy);
                    await UploadImage(imageFile);

                    toy.ImagePath = imageFile.FileName;
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ToyExists(toy.ToyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ToyTypeId"] = new SelectList(_context.ToyType, "ToyTypeId", "Description", toy.ToyTypeId);
            ViewData["UserId"]    = new SelectList(_context.ApplicationUsers, "Id", "Id", toy.UserId);
            return(View(toy));
        }
コード例 #32
0
        public IActionResult Post([FromBody] ChildToy childToy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Create the child and add to the context
            Child child = new Child()
            {
                Name = childToy.ChildName
            };

            _context.Child.Add(child);

            // Create the toy and add to the context
            Toy toy = new Toy()
            {
                Name    = childToy.ToyName,
                ChildId = child.ChildId
            };

            _context.Toy.Add(toy);

            try
            {
                // Commit both new records to the database at once
                _context.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (ChildExists(child.ChildId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("GetChild", new { id = child.ChildId }, child));
        }
コード例 #33
0
        static void Main(string[] args)
        {
            ElectricToy e = new ElectricToy();
            e.Run();
            e.MakeSound();

            Display(e);

            Toy tOld = new Toy();
            //            tOld.isAnimal = true;
            Display(tOld);
            //tOld.Run();
            //tOld.MakeSound();

            Toy t=new ElectricToy();
            Display(t);
            //t.Run();
            //t.MakeSound();
        }
コード例 #34
0
        // GET: Toys/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Toy toy = db.Toys.Find(id);

            if (toy == null)
            {
                return(HttpNotFound());
            }
            var model = new ToyViewModel
            {
                Toy        = toy,
                TypeOfToys = db.ToysType.ToList()
            };

            return(View(model));
        }
コード例 #35
0
    public void initStats(Toy toy)
    {
        if (toy.runetype != RuneType.Castle && toy.runetype != RuneType.SensibleCity)
        {
            Moon.onTimeBasedXpAssigned += onTimeBasedXpAssigned;
            //Debug.Log($"{gameObject.nam}e} wants xp\n");
        }

        this.toy           = toy;
        Active             = false;
        start_ammo_by_time = false;
        arrow_count        = 0;
        last_target        = 0;
        CheckForUpgrades();
        Rune.onUpgrade    += onUpgrade;
        nextFireTime       = 0f;
        monsters_transform = Peripheral.Instance.monsters_transform;
        enemy_list         = Peripheral.Instance.enemy_list;
        current_shot       = 0;
    }
コード例 #36
0
 public ActionResult Edit(string id)
 {
     if (Session["IsAdmin"] != null && Session["IsAdmin"].Equals(false))
     {
         MongoDB db     = new MongoDB();
         var     orders = db.GetOrder(id);
         //utile per estrarre tutti i giochi richiesti dal bambino
         Orders modelToy = new Orders();
         modelToy.ToyList = orders.ToyKids;
         Toy toy = new Toy();
         //utile per passare alla view lo stato dell ordine
         Order model = new Order();
         model.Status = orders.Status;
         return(View(model));
     }
     else
     {
         return(RedirectToAction("../Users/Login"));
     }
 }
コード例 #37
0
    private bool initToy(Toy pToy, int nTypeID, int nQuality, CAMP_TYPE eCampType, stHeroData pHeroData)
    {
        if (null == pToy)
        {
            return false;
        }

        // 这边是AI类型和英雄类型ID之间的转化关系
        HERO_TYPE eHeroType = (HERO_TYPE)(nTypeID % 10000);

        pToy.TOY_CAMP = eCampType;
        pToy.init(nTypeID, pHeroData);

        pToy.setToyManager(ToyManager.Instance());
        pToy.setMapManager(MapManage.Instance());

        // 建议toy信息都完整了再绑定AI
        pToy.bindMyAI(eHeroType, eCampType);

        return true;
    }
コード例 #38
0
ファイル: PersonTestApp.cs プロジェクト: iMitaka/HackBulgaria
        public static void Main()
        {
            List<Person> persons = new List<Person>();
            persons.Add(new Adult("Ivan",Gender.male));
            persons.Add(new Children("IvanJunior", Gender.male));

            foreach (var person in persons)
            {
                Console.WriteLine(person.ToString());
            }
            Console.WriteLine();
            var Pesho = new Adult("Pesho", Gender.male);
            var PeshoJunior = new Children("PeshoJunior", Gender.male);
            var PeshoToy = new Toy() { Color = "Green", Size = 10 };
            Console.WriteLine(PeshoToy.ToString());
            Console.WriteLine();
            Console.WriteLine(Pesho.ToString());
            Console.WriteLine();
            Console.WriteLine(PeshoJunior.ToString());
            Console.WriteLine();

            Pesho.Childrens.Add(PeshoJunior);
            PeshoJunior.Toys.Add(PeshoToy);
            Pesho.isBooring = true;

            Console.WriteLine(Pesho.ToString());
            foreach (var child in Pesho.Childrens)
            {
                Console.WriteLine(child.ToString());
                foreach (var toy in child.Toys)
                {
                    Console.WriteLine(toy.ToString());
                }
            }
            Console.WriteLine();
            if (Pesho.isBooring)
            {
                Console.WriteLine("Golqma skukaa brat..!");
            }
        }
コード例 #39
0
ファイル: AIHeroAttack.cs プロジェクト: linxiubao/UniShader
    public void setTarget(Toy pTarget)
    {
        // 要设置的和现在的是同一个toy
        if (null != m_pMyTarget && m_pMyTarget == pTarget)
        {
            return;
        }

        // 在设置新目标之前要让自己不再目标的enemy列表中,表示自己不再攻击旧目标
        if (null != m_pMyTarget)
        {
            m_pMyTarget.removeEnemy(m_pHost);
        }

        // 设置新目标
        m_pMyTarget = pTarget;

        if (null != m_pMyTarget)
        {
            // 自己成为新目标的enemy,表示自己在攻击目标
            m_pMyTarget.addEnemy(m_pHost);
        }
    }
コード例 #40
0
    /// <summary>
    /// Sets the next toys' information
    /// </summary>
    /// <param name='toy'>
    /// Toy.
    /// </param>
    public void SetToy(Toy toy)
    {
        if (currentToy < finalIndex && toy != null)
        {
            toys [currentToy].displayName = toy.displayName;
            toys [currentToy].filename = toy.filename;
            toys [currentToy].color = toy.color;

            activeList [currentToy].SetSprite(initialToyAtlas, toy.filename, Color.white);
            currentToy++;
        }
    }
コード例 #41
0
ファイル: Damage.cs プロジェクト: linxiubao/UniShader
 // 获取攻击速度
 public int getProjectileSpeed(Toy pToy)
 {
     int nSpeed = -1;
     nSpeed = pToy.getAttackProjSpeed();
     return nSpeed;
 }
コード例 #42
0
ファイル: ThinkBehavior.cs プロジェクト: linxiubao/UniShader
 public override void setHost(Toy pToy)
 {
     m_pHost = pToy;
 }
コード例 #43
0
ファイル: AIBase.cs プロジェクト: linxiubao/UniShader
    // 敌人加进来了--我们的AI只针对同一列的故其他的不考虑
    public virtual void onRevengecry(Toy pEnemy)
    {

    }
コード例 #44
0
ファイル: AIBase.cs プロジェクト: linxiubao/UniShader
    // 目标死亡
    public virtual void onTargetDead(Toy pTarget)
    {

    }
コード例 #45
0
ファイル: AIBase.cs プロジェクト: linxiubao/UniShader
    // 自己死亡
    public virtual void onDead(Toy pEnemy)
    {

    }
コード例 #46
0
ファイル: AIHeroAttack.cs プロジェクト: linxiubao/UniShader
    public override void onRevengecry(Toy pEnemy)
    {
        if (null == pEnemy || pEnemy.isDead())
        {
            return;
        }

        // 判断当前状态能否攻打其他英雄
        // 眩晕中,正在攻击中其他英雄,都不行
        if (!canRevenge())
        {
            return;
        }

        this.setTarget(pEnemy);

        // 当前处于idle状态就直接攻击
        if (this.checkCurrBehaviorType(eBehaviorState.eBS_IDLE))
        {
            attack();
        }
    }
コード例 #47
0
 static void Display(Toy e)
 {
     e.Run();
     e.MakeSound();
 }
コード例 #48
0
ファイル: IBehavior.cs プロジェクト: linxiubao/UniShader
    public virtual void setTarget(Toy pToy)
    {

    }
コード例 #49
0
 /// <summary>
 /// There are no comments for Toys in the schema.
 /// </summary>
 public void AddToToys(Toy toy)
 {
     base.AddObject("Toys", toy);
 }
コード例 #50
0
ファイル: IBehavior.cs プロジェクト: linxiubao/UniShader
 public abstract void setHost(Toy pToy);
コード例 #51
0
ファイル: IActionState.cs プロジェクト: linxiubao/UniShader
 public virtual void setHost(Toy pToy)
 {
     m_pHost = pToy;
 }
コード例 #52
0
ファイル: ButtThumpAbility.cs プロジェクト: smelch/BVB
 public ButtThumpAbility(Toy toy)
     : base(toy)
 {
 }
コード例 #53
0
ファイル: AIHeroAttack.cs プロジェクト: linxiubao/UniShader
 // 通知AI目标死亡了,就是要换目标了
 public virtual void onTargetDead(Toy pTarget)
 {
     // 设置目标为空
     this.setTarget(null);
     // 重新思考
     doRethink();
 }
コード例 #54
0
ファイル: Damage.cs プロジェクト: linxiubao/UniShader
 public void setDamageOwned(Toy pToy)
 {
     m_pDamageParam.pOwner = pToy;
 }
コード例 #55
0
ファイル: AttackBehavior.cs プロジェクト: linxiubao/UniShader
 // 设置目标
 public override void setTarget(Toy pToy)
 {
     m_pTarget = pToy;
 }
コード例 #56
0
ファイル: MapManage.cs プロジェクト: linxiubao/UniShader
    public void leaveCell(Toy pToy, ref CellPos posCell)
    {
        if (!checkCellValid(ref posCell))
        {
            return;
        }

        Cell pCell = getCell(ref posCell);
        if (null != pCell)
        {
            pCell.leaveCell(pToy);
        }
    }
コード例 #57
0
 /// <summary>
 /// Create a new Toy object.
 /// </summary>
 /// <param name="id">Initial value of Id.</param>
 /// <param name="name">Initial value of Name.</param>
 /// <param name="minAge">Initial value of MinAge.</param>
 public static Toy CreateToy(int id, string name, int minAge)
 {
     Toy toy = new Toy();
     toy.Id = id;
     toy.Name = name;
     toy.MinAge = minAge;
     return toy;
 }
コード例 #58
0
ファイル: AIHeroDefend.cs プロジェクト: linxiubao/UniShader
    public override void setHost(Toy pToy)
    {
        m_pHost = pToy;
        if (null != m_pIdleBehavior)
        {
            m_pIdleBehavior.setHost(pToy);
        }

        if (null != m_pAttackBehavior)
        {
            m_pAttackBehavior.setHost(pToy);
        }

        if (null != m_pMoveBehavior)
        {
            m_pMoveBehavior.setHost(pToy);
        }

        if (null != m_pCoolDownBehavior)
        {
            m_pCoolDownBehavior.setHost(pToy);
        }

        if (null != m_pBeatBackBehavior)
        {
            m_pBeatBackBehavior.setHost(pToy);
        }

        if (null != m_pSkillBehavior)
        {
            m_pSkillBehavior.setHost(pToy);
        }

        if (null != m_pThinkBehavior)
        {
            m_pThinkBehavior.setHost(pToy);
        }
    }
コード例 #59
0
 public DITest(Animal animal, Toy toy)
 {
     this.animal = animal;
     this.toy = toy;
 }
コード例 #60
0
ファイル: Damage.cs プロジェクト: linxiubao/UniShader
 public void setDamageWound(Toy pToy)
 {
     m_pDamageParam.pWounded = pToy;
 }