public ActionResult EatTypes(EatType eat, int id = 0)
 {
     if (ModelState.IsValid)
     {
         if (id == 0)
         {
             try
             {
                 db.EatTypes.Add(eat);
                 db.SaveChanges();
                 return(RedirectToAction("ViewAndEditEatTypes"));
             }
             catch (Exception ex)
             {
                 logger.Info(ex.Message);
             }
         }
         else
         {
             EatType temp = db.EatTypes.FirstOrDefault(f => f.eatTypeId == id);
             eat.eatTypeId = id;
             db.Entry(temp).CurrentValues.SetValues(eat);
             db.SaveChanges();
             return(RedirectToAction("ViewAndEditEatTypes"));
         }
     }
     if (id != 0)
     {
         EatType temp = db.EatTypes.FirstOrDefault(f => f.eatTypeId == id);
         return(View(temp));
     }
     return(View());
 }
Ejemplo n.º 2
0
        public Carrot(Pos Envpos, Vector2f GlCoordinate) : base(Envpos, GlCoordinate)
        {
            FoodRec = 2;
            EType   = EatType.SmallGround;
            ID      = ActorID.Carrot;
            ASprite = WorldMap.SpriteCollection.SCarrot;

            highdr    = 0;
            Anim.with = 64; Anim.top = 41; Anim.heigh = 41; Anim.AnimTime = 0;
        }
        public ActionResult EditEatType(int eatTypeId)
        {
            EatType findedElement = _db.EatTypes.Find(eatTypeId);

            if (findedElement != null)
            {
                return(View("EatTypes", findedElement));
            }
            else
            {
                return(RedirectToAction("EatTypeList", "Home", new { message = "Данные пришли пустыми" }));
            }
        }
        public ActionResult DeleteEatType(int eatTypeId = 0)
        {
            EatType elementToDelete = _db.EatTypes.Find(eatTypeId);

            if (elementToDelete != null)
            {
                try
                {
                    _db.EatTypes.Remove(elementToDelete);
                    _db.SaveChanges();
                    return(RedirectToAction("EatTypeList", "Home", new { message = "Удалено успешено." }));
                }
                catch (Exception e)
                {
                    return(RedirectToAction("EatTypeList", "Home", new { message = e.ToString() }));
                }
            }

            return(RedirectToAction("EatTypeList", "Home", new { message = "Данные пришли пустыми." }));
        }
        public ActionResult AddEatType(EatType eatType)
        {
            if (string.IsNullOrEmpty(eatType.EatTypeName))
            {
                return(RedirectToAction("EatTypeList", "Home",
                                        new { message = "Вы не заполнили имя." }));
            }
            try
            {
                if (eatType.TypeId == 0)
                {
                    _db.EatTypes.Add(eatType);
                    _db.SaveChanges();
                    return(RedirectToAction("EatTypeList", "Home",
                                            new { message = "Данные были добавлены успешно." }));
                }
                EatType findedElement = _db.EatTypes.Find(eatType.TypeId);

                if (findedElement == null)
                {
                    return(RedirectToAction("EatTypeList", "Home",
                                            new { message = "Данные пришли пустыми." }));
                }

                findedElement.EatTypeName      = eatType.EatTypeName;
                _db.Entry(findedElement).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("EatTypeList", "Home",
                                        new { message = "Данные были изменены успешно." }));
            }
            catch (Exception e)
            {
                _logger.Error(e.ToString);
                return(RedirectToAction("EatTypeList", "Home", new { message = e.ToString() }));
            }
        }
Ejemplo n.º 6
0
    public Bass Instanciate(Vector3 pos, float size, BassRange range, int kassei, int sure, EatType type, Baits[] baits)
    {
        //Instantiate(ObjectToSpawn, areas[0].GetRandomPointInArea(), transform.rotation);

        BassParameters paramsb = new BassParameters();

        paramsb.size           = size;
        paramsb.spawnedPosiion = pos;
        if (paramsb.spawnedPosiion.y > depth)
        {
            paramsb.spawnedPosiion.y = depth;
        }
        paramsb.range       = range;
        paramsb.KASSEILEVEL = kassei;
        paramsb.SURELEVEL   = sure;
        paramsb.eatType     = type;
        paramsb.bate        = baits;
        return(LureSpawner.Instance.SpawnBassOnPoint(paramsb));
    }
Ejemplo n.º 7
0
    //kasseiLevel 0.0-1.0 cautiouslevel=0.0f -1.0f
    public void Init(float size, Vector3 pos, BassRange bassRange, int kasseiLevel, int cautiousLevel, EatType eatType, Baits[] bate)
    {
        this.parameters.bate = bate;
        isVisible            = false;

        if (pos.y < Constants.Params.bassVisibleInDepth)
        {
            isVisible = true;
        }
        VisibleBass(isVisible);
        bassState = BassState.Back;
        this.parameters.eatType = eatType;

        moveFrequency_still    = Equations.EaseInQuad(kasseiLevel, 0.07f, 0.4f, 1.0f);
        parameters.KASSEILEVEL = kasseiLevel;
        parameters.SURELEVEL   = cautiousLevel;
        transform.localScale   = new Vector3(size * Constants.BassBihaviour.sizeScallingFactor, size * Constants.BassBihaviour.sizeScallingFactor, size * Constants.BassBihaviour.sizeScallingFactor);
        parameters.range       = bassRange;
        transform.position     = pos;

        sizeNanido = Equations.EaseInQuad(transform.localScale.x, 0.0f, 2.0f, 1.0f);
        if (bassRange == BassRange.Top)
        {
            transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f));
        }
        else
        {
            transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, Random.Range(-25.0f, 25.0f)));
        }

        ChangeState(BassState.Stay);
    }
Ejemplo n.º 8
0
 public Animal(EatType eatType, Size size)
 {
     this.EatType = eatType;
     this.Size    = size;
 }
Ejemplo n.º 9
0
    public void EatBlocks(EatType type = EatType.NormalEat)
    {
        if (path.Count < 0)
        {
            return;
        }

        if (path.Count < 3 && type == EatType.NormalEat)
        {
            UnSelectBlockOnPath();
            if (SoundManager.instance != null)
            {
                SoundManager.instance.PlaySFX(SFX.EAT_BLOCK_FAIL);
            }
            return;
        }

        suggetionMove.Disable();

        if (path.Count > 4 && type == EatType.NormalEat)
        {
            Block block;

            switch (path.Count)
            {
            case 5:
                block = BlockMaker.instance.InstanceBlock(BlockType.Sun);
                break;

            case 6:
                block = BlockMaker.instance.InstanceBlock(BlockType.Bunny);
                break;

            case 7:
                block = BlockMaker.instance.InstanceBlock(BlockType.Puppy);
                break;

            default:
                block = BlockMaker.instance.InstanceBlock(BlockType.Bird);
                int timeCombos = 2 * (path.Count - 8);
                if (timeCombos != 0)
                {
                    LoadTime.instance.AddTime(timeCombos);
                    string timeConbosText = "+" + timeCombos + "s";
                    ComboManager.instance.ActiveCombos(timeConbosText);
                }
                break;
            }


            if (block == null)
            {
                Debug.Log("Chua tao duoc quan dac biet");
                return;
            }
            block.SetState(BlockState.Normal);
            block.transform.SetParent(transform);


            int row = (int)path[path.Count - 1].y;
            int col = (int)path[path.Count - 1].x;

            block.transform.position = path[path.Count - 1].transform.position;
            block.x = path[path.Count - 1].x;
            block.y = path[path.Count - 1].y;
            listBlocks[row, col] = block;
            path[path.Count - 1].SetState(BlockState.Destroy);
            path.RemoveAt(path.Count - 1);
        }

        GameManager.instance.SetGameState(GameState.EFFECT);

        ComboManager.instance.Count();
        ComboManager.instance.ResetStartTime();
        ComboManager.instance.CheckCombo();
        ScoreCalculator.instance.CalculateScore(path, ComboManager.instance.GetCombo());

        Dictionary <int, int> offsets = new Dictionary <int, int>();

        for (int i = 0; i < width; ++i)
        {
            offsets.Add(i, height);
        }

        CreatBlockAfterEat(offsets);
        DestroyBlockOnPath(offsets);
        //----------------------Kiem tra duong di tren boardgame
        if (!suggetionMove.CheckPath())
        {
            //Tao moi boardgame khi het duong di
            Debug.Log("HET DUONG DI");
            RecreateBoardGame();
        }

        LineRenderPooling.current.UnUsedAllPooledObject();
        suggetionMove.ResetTime();
        return;
    }