コード例 #1
0
ファイル: Scent.cs プロジェクト: carpentre1/AIP_FinalProject
    public GameObject StrongestNeighbor()//find a nearby tile with a stronger scent than this one
    {
        float      strongestScent       = scentStrength;
        GameObject strongestScentObject = null;

        foreach (GameObject g in neighbors)
        {
            if (!g)
            {
                continue;
            }
            if (!g.GetComponent <Scent>())
            {
                continue;
            }
            Scent neighborScent = g.GetComponent <Scent>();
            if (neighborScent.scent == scent)//we're looking for the same type of scent only
            {
                if (neighborScent.scentStrength > strongestScent)
                {
                    strongestScent       = neighborScent.scentStrength;
                    strongestScentObject = g;
                }
            }
        }
        return(strongestScentObject);
    }
コード例 #2
0
ファイル: ScentMapper.cs プロジェクト: ds5678/ModComponent
        internal static float GetScentIntensity(GameObject prefab)
        {
            Scent scent = ComponentUtils.GetComponent <Scent>(prefab);

            if (scent is null)
            {
                return(0f);
            }

            switch (scent.m_ScentCategory)
            {
            case ScentRangeCategory.COOKED_MEAT:
                return(5f);

            case ScentRangeCategory.COOKED_FISH:
                return(5f);

            case ScentRangeCategory.GUTS:
                return(20f);

            case ScentRangeCategory.QUARTER:
                return(50f);

            case ScentRangeCategory.RAW_MEAT:
                return(15f);

            case ScentRangeCategory.RAW_FISH:
                return(15f);

            default:
                return(0f);
            }
        }
コード例 #3
0
 public ActionResult AddScent(ProductViewModel collection)
 {
     try
     {
         DBEntities db       = new DBEntities();
         string     filename = Path.GetFileNameWithoutExtension(collection.Image.FileName);
         string     ext      = Path.GetExtension(collection.Image.FileName);
         filename = filename + DateTime.Now.Millisecond.ToString();
         filename = filename + ext;
         string filetodb = filename;
         filename = Path.Combine(Server.MapPath("~/image/product/"), filename);
         collection.Image.SaveAs(filename);
         collection.Photo = filetodb;
         Scent per = new Scent()
         {
             Name  = collection.Name,
             Price = collection.Price,
             Type  = collection.TypeId,
             Image = collection.Photo
         };
         db.Scents.Add(per);
         db.SaveChanges();
         Alert.ScentAdd = true;
         return(RedirectToAction("ViewScents", "Admin"));
     }
     catch (Exception exp)
     {
         return(Content(exp.Message));
     }
 }
コード例 #4
0
        internal static float GetScentIntensity(ModComponent modComponent)
        {
            Scent scent = ModUtils.GetComponent <Scent>(modComponent);

            if (scent == null)
            {
                return(0f);
            }

            switch (scent.m_ScentCategory)
            {
            case ScentRangeCategory.COOKED_MEAT:
                return(5f);

            case ScentRangeCategory.COOKED_FISH:
                return(5f);

            case ScentRangeCategory.GUTS:
                return(20f);

            case ScentRangeCategory.QUARTER:
                return(50f);

            case ScentRangeCategory.RAW_MEAT:
                return(15f);

            case ScentRangeCategory.RAW_FISH:
                return(15f);

            default:
                return(0f);
            }
        }
コード例 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Scent scent = db.Scents.Find(id);

            db.Scents.Remove(scent);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "ScentID,ScentName,AddDateTime,AddUserName,LastUpdateTime,LastUpdateUserName,Season,IsSeasonal,IsDeleted")] Scent scent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(scent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(scent));
 }
コード例 #7
0
ファイル: ScentsController.cs プロジェクト: zpalms91/BelleLLC
 public ActionResult Edit([Bind(Include = "ScentId,ScentName,ScentDesc")] Scent scent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(scent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(scent));
 }
コード例 #8
0
        public ActionResult Create([Bind(Include = "ScentID,ScentName,AddDateTime,AddUserName,LastUpdateTime,LastUpdateUserName,Season,IsSeasonal,IsDeleted")] Scent scent)
        {
            if (ModelState.IsValid)
            {
                db.Scents.Add(scent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(scent));
        }
コード例 #9
0
ファイル: ScentsController.cs プロジェクト: zpalms91/BelleLLC
        public ActionResult Create([Bind(Include = "ScentId,ScentName,ScentDesc")] Scent scent)
        {
            if (ModelState.IsValid)
            {
                db.Scents.Add(scent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(scent));
        }
コード例 #10
0
 public void ReceiveScent(Scent scent)
 {
     if (scent.scentStrength < smellPower)
     {
         return;//couldn't smell it!
     }
     else
     {
         DetermineScentResponse(scent);
     }
 }
コード例 #11
0
    void LookForFood()
    {
        if (busyThinking)
        {
            return;
        }

        if (hunger > .5f)
        {
            return;
        }

        foreach (GameObject g in detectedObjects)
        {
            if (g.tag == "bush" && isPrey && !GameManager.Instance.occupiedObjects.Contains(g))
            {
                //go to bush and eat
                UpdateObjective(Objective.Eating, g);
                objective = g;
                return;
            }
            else if ((g.tag == "bunny" || g.tag == "chicken") && isPredator)
            {
                if (g.GetComponent <Behavior>().alive)
                {
                    //chase/stalk the prey
                    UpdateObjective(Objective.Stalking, g);
                }
                else
                {
                    UpdateObjective(Objective.Eating, g);
                }
                return;
            }
        }
        foreach (GameObject g in smelledObjects)
        {
            Scent scent = g.GetComponent <Scent>();
            if (!scent.scentProvider)
            {
                continue;
            }
            if (scent.scentStrength < 1)
            {
                continue;
            }
            if ((scent.scentProvider.tag == "chicken" || scent.scentProvider.tag == "bunny") && isPredator)
            {
                UpdateObjective(Objective.Tracking, g);
            }
        }
    }
コード例 #12
0
 void DetermineScentResponse(Scent scent)
 {
     if (scent.gameObject.GetComponent <Behavior>())
     {
         Behavior behavior = scent.gameObject.GetComponent <Behavior>();
     }
     if (scent.scent == Scent.ScentType.Fox && myBehavior.isPrey)
     {
         myBehavior.UpdateObjective(Behavior.Objective.Escaping, scent.gameObject);
         Debug.Log("fleeing due to smell");
     }
     GetComponent <Behavior>().smelledObjects.Add(scent.gameObject);
 }
コード例 #13
0
        internal static void Configure(ModComponent modComponent)
        {
            ModScentComponent modScentComponent = ModUtils.GetComponent <ModScentComponent>(modComponent);

            if (modScentComponent == null)
            {
                return;
            }

            Scent scent = ModUtils.GetOrCreateComponent <Scent>(modScentComponent);

            scent.m_ScentCategory = ModUtils.TranslateEnumValue <ScentRangeCategory, ScentCategory>(modScentComponent.scentCategory);
        }
コード例 #14
0
ファイル: ScentMapper.cs プロジェクト: ds5678/ModComponent
        internal static void Configure(GameObject prefab)
        {
            ModScentComponent modScentComponent = ComponentUtils.GetComponent <ModScentComponent>(prefab);

            if (modScentComponent is null)
            {
                return;
            }

            Scent scent = ComponentUtils.GetOrCreateComponent <Scent>(modScentComponent);

            scent.m_ScentCategory = EnumUtils.TranslateEnumValue <ScentRangeCategory, ScentCategory>(modScentComponent.scentCategory);
        }
コード例 #15
0
        // GET: Scents/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Scent scent = db.Scents.Find(id);

            if (scent == null)
            {
                return(HttpNotFound());
            }
            return(View(scent));
        }
コード例 #16
0
ファイル: Scent.cs プロジェクト: carpentre1/AIP_FinalProject
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.GetComponent <Scent>())
     {
         Scent animalScent = other.GetComponent <Scent>();
         if (animalScent.scentStrength > scentStrength)
         {
             AddScent(animalScent);
         }
     }
     if (other.GetComponent <SenseSmell>() && isTurf)
     {
         SenseSmell smell = other.GetComponent <SenseSmell>();
         smell.ReceiveScent(this);
     }
 }
コード例 #17
0
    public void AddScent(Coordinate coord, float ratio, Vector3 foodPos)
    {
        map[coord] = new Scent(coord, (int)(ratio * MAX_SCENT), foodPos);

        /*if ((map.ContainsKey(coord) && map[coord] == null) || !map.ContainsKey(coord))
         * {
         *  Scent scent = new Scent(coord, (int) (ratio * MAX_SCENT), foodPos);
         *  map[coord] = scent;
         * }
         * if (map.ContainsKey(coord) && map[coord] != null)
         * {
         *  map[coord].amount += (int) (ratio * MAX_SCENT);
         *  if (map[coord].amount > MAX_SCENT)
         *  {
         *      map[coord].amount = MAX_SCENT;
         *  }
         * }*/
    }
コード例 #18
0
        public void AnyScentFailedTest()
        {
            //Arrange
            Scent scent = new Scent();

            scent.pos1.Add(5);
            scent.pos2.Add(3);
            scent.orientation.Add('S');

            Robot robot = new Robot();

            robot.position[1] = 3;
            robot.position[0] = 5;
            robot.orientation = 'N';

            bool expected = false;
            //Act
            var result = scent.AnyScent(robot);

            //Assert
            Assert.AreEqual(expected, result);
        }
コード例 #19
0
ファイル: Scent.cs プロジェクト: carpentre1/AIP_FinalProject
 /// <summary>
 /// Adds a scent to the object or increases that scent's potency
 /// Occurs each time an animal moves onto or performs an action on that object
 /// </summary>
 public void AddScent(Scent animalScent)
 {
     if (GetComponent <Behavior>())
     {
         return;
     }
     if (scent != animalScent.scent)
     {
         scent         = animalScent.scent;
         scentProvider = animalScent.gameObject;
         scentStrength = animalScent.scentStrength;
         float dist = Vector2.Distance(this.gameObject.transform.position, animalScent.gameObject.transform.position);
         scentStrength -= dist;
         //Debug.Log(this.gameObject + " scent changed to " + animalScent.scent);
     }
     else
     {
         if (scentStrength < animalScent.scentStrength)
         {
             scentStrength = animalScent.scentStrength;
         }
     }
 }
コード例 #20
0
        public void AddScentPositionTest()
        {
            //Arrange
            Scent scent            = new Scent();
            int   pos1             = 3;
            int   pos2             = 4;
            char  orientation      = 'E';
            var   firstPos1        = scent.pos1.Count();
            var   firstPos2        = scent.pos1.Count();
            var   firstOrientation = scent.orientation.Count();

            //Act
            scent.AddScentPosition(pos1, pos2, orientation);
            var actualPos1        = scent.pos1.Count();
            var actualPos2        = scent.pos1.Count();
            var actualOrientation = scent.orientation.Count();

            //Assert
            Assert.IsTrue(
                actualPos1 > firstPos1 &&
                actualPos2 > firstPos2 &&
                actualOrientation > firstOrientation);
        }
コード例 #21
0
ファイル: Scent.cs プロジェクト: kylesmile/Foxtrail
 static void DrawScentLocation(Scent scent, GizmoType _gizmoType)
 {
     Gizmos.DrawWireSphere(scent.transform.position, 0.5f);
 }
コード例 #22
0
        public ActionResult ContinueScent(ContinueScentsViewModel collection)
        {
            try
            {
                DBEntities db       = new DBEntities();
                var        perfumes = db.Perfumes.Where(x => x.Type == 2).ToList <Perfume>();
                if (Request.IsAuthenticated)
                {
                    string userId = User.Identity.GetUserId();
                    var    result = (from a in db.Carts
                                     join b in db.Perfumes on a.ProductId equals b.Id
                                     where a.UserId == userId
                                     select new CartViewModel
                    {
                        Id = a.Id,
                        ProductId = a.ProductId,
                        ProductName = b.Name,
                        Price = b.Price,
                        Quantity = a.Quantity,
                        Image = b.Image
                    }).ToList <CartViewModel>();

                    ViewData["cart"] = result;

                    var customCart = (from a in db.CustomOrders
                                      join b in db.CustomOrderScents on a.Id equals b.CustomOrderId
                                      where a.UserId == userId
                                      select new CustomCartViewModel
                    {
                        Id = a.Id,
                        Name = a.Name,
                        Quantity = a.Quantity,
                        Size = a.BottleSize,
                        ScentId = b.ScentId
                    }).ToList <CustomCartViewModel>();

                    List <CustomCartViewModel> noDuplicate = new List <CustomCartViewModel>();
                    List <int?> noDup = new List <int?>();
                    foreach (var i in customCart)
                    {
                        if (noDup.Contains(i.Id))
                        {
                            foreach (CustomCartViewModel k in noDuplicate)
                            {
                                if (i.Id == k.Id)
                                {
                                    var scnt = db.Scents.Where(x => x.Id == i.ScentId).FirstOrDefault();
                                    k.ScentList.Add(scnt);
                                }
                            }
                        }
                        else
                        {
                            var scnt = db.Scents.Where(x => x.Id == i.ScentId).FirstOrDefault();
                            i.ScentList.Add(scnt);
                            noDuplicate.Add(i);
                            noDup.Add(i.Id);
                        }
                    }
                    ViewData["customCart"] = noDuplicate;
                }
                List <Scent> scents = new List <Scent>();
                foreach (string i in collection.Scents)
                {
                    int   id   = Convert.ToInt32(i);
                    Scent scnt = db.Scents.Where(x => x.Id == id).FirstOrDefault();
                    scents.Add(scnt);
                }
                ViewData["selectedscents"] = scents;
                return(View());
            }catch (Exception exp)
            {
                return(Content(exp.Message));
            }
        }
コード例 #23
0
        public void Execute(string input)
        {
            if (!InputValidator.IsValid(input))
            {
                CustomConsoleWriter.WriteLine("Not able to continue. Input is not valid.");
            }

            var splitInput        = input.Split('\n');
            var PlanetCoordinates = splitInput[0].Split(' ');
            var planet            = new Planet(Int16.Parse(PlanetCoordinates[0]), Int16.Parse(PlanetCoordinates[1]));

            PlanetCoordinateX = planet.CoordenateX;
            PlanetCoordinateY = planet.CoordenateY;

            var tempRobots = splitInput.ToList();

            tempRobots.RemoveAt(0);
            var temp = ListToDictionary(tempRobots.ToList());

            var robots = new List <Robot>();

            foreach (KeyValuePair <string, string> result in temp)
            {
                var positionInput = result.Key.Split(' ');
                var position      = new Position(Int16.Parse(positionInput[0]), Int16.Parse(positionInput[1]), positionInput[2].ToString());
                var robot         = new Robot(position, result.Value);
                robots.Add(robot);
            }

            LoadData();
            scent = new Scent();

            int[] updatedLoc     = new int[2];
            var   newOrientation = new char();

            foreach (var robot in robots)
            {
                var orientation  = robot.RobotPosition.Orientation;
                var instructions = robot.Instruction.ToCharArray();

                for (int i = 0; i < instructions.Length; i++)
                {
                    newOrientation = getUpdateDirection(instructions[i], char.Parse(robot.RobotPosition.Orientation));
                    robot.RobotPosition.Orientation = newOrientation.ToString();

                    if (instructions[i] == 'F')
                    {
                        try
                        {
                            updatedLoc = getUpdateLocation(robot.RobotPosition.CoordenateX, robot.RobotPosition.CoordenateY, robot.RobotPosition.Orientation);
                            robot.RobotPosition.CoordenateX = updatedLoc[0];
                            robot.RobotPosition.CoordenateY = updatedLoc[1];
                        }
                        catch (ScentFoundException)
                        {
                            CustomConsoleWriter.WriteLine("Scent found");
                            continue;
                        }
                        catch (RobotLostException)
                        {
                            CustomConsoleWriter.WriteLine("Robot Lost");
                            i = instructions.Length;
                        }
                    }
                }

                CustomConsoleWriter.WriteLine("Updated location for Robot#" + robots.IndexOf(robot) + "(" + robot.RobotPosition.CoordenateX.ToString() + ", " + robot.RobotPosition.CoordenateY + ", " + newOrientation + ")");
            }
        }
コード例 #24
0
 public void ForgetSmell(Scent scent)
 {
     GetComponent <Behavior>().smelledObjects.Remove(scent.gameObject);
 }