public void ValidateNaughtyBadString()
        {
            Santa santa  = new Santa();
            bool  actual = santa.IsNiceString("haegwjzuvuyypxyu");

            Assert.AreEqual(false, actual);
        }
        public void ValidateNaughtyOneVowel()
        {
            Santa santa  = new Santa();
            bool  actual = santa.IsNiceString("dvszwmarrgswjxmb");

            Assert.AreEqual(false, actual);
        }
示例#3
0
 internal void NavigateSantaToDeliverPresents(Santa santa)
 {
     foreach (char direction in directions)
     {
         santa.VisitNextHouse(direction);
     }
 }
示例#4
0
        public static OptimizationInput Create()
        {
            // unavailable
            var unavailableDay1Before = (int.MinValue, StartDay1 - 1);
            var unavailableBetween    = (EndDay1 + 1, StartDay2 - 1);
            var unavailableDay2After  = (EndDay2 + 1, int.MaxValue);

            return(new OptimizationInput
            {
                Santas = new Santa[]
                {
                    new Santa
                    {
                        Id = SantaId1,
                    },
                    new Santa
                    {
                        Id = SantaId2,
                    },
                },
                Visits = new Visit[]
                {
                    new Visit
                    {
                        Id = 0,
                        Duration = Duration1,
                        IsBreak = false,
                        SantaId = -1,
                        WayCostFromHome = W01,
                        WayCostToHome = 0,
                        Desired = new(int, int)[]
示例#5
0
        public void Collision(Player player)
        {
            Rectangle bulletCollisionBox;

            Santa attacker = player as Santa;

            if (attacker == null)
            {
                return;
            }

            if (player.CollisionBox.TouchAnywhere(this.CollisionBox))
            {
                player.Health -= 1;
            }

            for (int i = 0; i < attacker.BulletFactory.GeneratedBullets.Count; i++)
            {
                bulletCollisionBox = new Rectangle(attacker.BulletFactory.GeneratedBullets[i].PositionX,
                                                   attacker.BulletFactory.GeneratedBullets[i].PositionY,
                                                   attacker.BulletFactory.GeneratedBullets[i].ProjectileTexture.Width,
                                                   attacker.BulletFactory.GeneratedBullets[i].ProjectileTexture.Height);

                if (bulletCollisionBox.TouchAnywhere(this.CollisionBox))
                {
                    this.Health -= (int)player.Damage;
                    attacker.BulletFactory.GeneratedBullets.Remove(attacker.BulletFactory.GeneratedBullets[i]);
                }
            }
        }
示例#6
0
        public void TestSantaMapping()
        {
            using (var trans = session.BeginTransaction())
            {
                var santa = new Santa()
                {
                    Name = "Santa 1"
                };
                var santaBreak = new Visit()
                {
                    City = "Rothrist", Duration = 60 * 60, VisitType = VisitType.Break
                };
                santa.Breaks.Add(santaBreak);

                Santa mgtSanta = session.Merge(santa);

                session.Clear();

                var loadedSanta = session.Get <Santa>(mgtSanta.Id);
                Assert.IsNotNull(loadedSanta);
                Assert.AreEqual(santa.Name, loadedSanta.Name);
                Assert.AreEqual(1, santa.Breaks.Count);
                Assert.AreEqual(santaBreak.City, santa.Breaks[0].City);

                session.Clear();

                var allBreaks = session.Query <Visit>().Where(v => v.VisitType == VisitType.Break).ToList();
                Assert.IsNotNull(allBreaks);
                var loadedSantaBreak = allBreaks[0];
                Assert.AreEqual("Rothrist", loadedSantaBreak.City);
                Assert.IsNotNull(loadedSantaBreak.Santa);
                Assert.AreEqual(santa.Name, loadedSantaBreak.Santa.Name);
                trans.Commit();
            }
        }
示例#7
0
        public void TestTwoRepeatingCharacterPattern()
        {
            Santa santa = new Santa();

            Assert.AreEqual(true, santa.MatchRepeatingCharacter("abcdefeghi"));
            Assert.AreEqual(true, santa.MatchRepeatingCharacter("aaa"));
        }
        public void ValidateNiceString()
        {
            Santa santa  = new Santa();
            bool  actual = santa.IsNiceString("ugknbfddgicrmopn");

            Assert.AreEqual(true, actual);
        }
示例#9
0
    // Start is called before the first frame update
    void Start()
    {
        gameOverPanel.SetActive(false);

        statBox = GetComponentInChildren <Text>();
        santa   = GameObject.FindGameObjectWithTag("Player").GetComponent <Santa>();
    }
示例#10
0
        private float GetNewSantaRating(Santa santa, float newRating, float oldRating = 0)
        {
            var numberOfOrders = santa.NumberOfOrders;
            var santaRating    = santa.Rating ?? 0;

            return((numberOfOrders * santaRating - oldRating + newRating) / numberOfOrders);
        }
示例#11
0
        public void ValidateThreeVowels()
        {
            Santa santa  = new Santa();
            bool  actual = santa.IsNiceString("aaa");

            Assert.AreEqual(true, actual);
        }
示例#12
0
        public void ValidateNaughtyNoDouble()
        {
            Santa santa  = new Santa();
            bool  actual = santa.IsNiceString("jchzalrnumimnmhp");

            Assert.AreEqual(false, actual);
        }
示例#13
0
    private void OnTriggerEnter(Collider other)
    {
        //check if the trigger is a santa and the house is selected by the same santa
        if (other.gameObject.tag == "Santa" && isSelected == true && santasId.Contains(other.gameObject.GetComponent <Santa>().id))
        {
            //check if the santa have the associated gift
            Santa touchedSanta = other.gameObject.GetComponent <Santa>();
            bool  isSantaHaveAssociatedGift = false;
            int   i = 0;
            while (i < associatedGifts.Count)
            {
                if (touchedSanta.collectedGifts.Contains(associatedGifts[i]))
                {
                    //deliver the gift
                    SantaGameManager.Instance.DeliveredGift(associatedGifts[i]);

                    //Remove the gift from the santa
                    touchedSanta.DeliverGift(associatedGifts[i]);

                    //Remove the gift from the santa gift UI list if the scroll view is enabled and if the active scroll view content is corresponding to the selected santa
                    if (SantaMainController.Instance.SantaScrollViewObject.activeInHierarchy && InputManager.Instance.selectedSanta.GetComponent <Santa>().id == touchedSanta.id)
                    {
                        //Refresh the scroll view
                        SantaMainController.Instance.ClearSantaScrollView();
                        SantaMainController.Instance.InitSantaScrollView(touchedSanta.collectedGifts);
                    }

                    //Remove the gift from house
                    associatedGifts.Remove(associatedGifts[i]);

                    //Set the boolean is have associated gift to true
                    isSantaHaveAssociatedGift = true;
                }
                else
                {
                    i++;
                }
            }

            //remove the santa id
            santasId.Remove(touchedSanta.id);

            //If the santa doesn't have the associated gift delete the destination
            if (!isSantaHaveAssociatedGift)
            {
                touchedSanta.touchWaypoint();
            }

            //Check if all gifts are delivred
            if (associatedGifts.Count == 0)
            {
                //Dishighlight the house
                GetComponent <Outline>().enabled = false;

                //Set the house non clickable
                gameObject.layer = 0;
            }
        }
    }
示例#14
0
        static void Main(string[] args)
        {
            Visitor santa = new Santa();

            santa.VisitorBoysHouse(new BoysHouse());

            santa.VisitorGirlsHousе(new GirlsHouse());
        }
示例#15
0
    //Create Santa GameObject
    void CreateSanta()
    {
        santa = GameObject.CreatePrimitive(PrimitiveType.Cube); //Create object
        santa.AddComponent <Santa>();                           //Add script to object
        Santa ss = santa.GetComponent <Santa>();                //Create instance of type Santa and assign it the class Santa from santa Gameobject

        ss.SetupSanta(0f, 4f, 1.0f, 1.0f, 0.2f, Color.red);     //Constructor variables
    }
示例#16
0
    void Start()
    {
        // Set santa to player.
        santa = GameObject.FindGameObjectWithTag("Player").GetComponent <Santa>();

        // Set the chimney spawner to spawner
        spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <ChimneySpawner>();
    }
示例#17
0
        public IncomingLetterProcessor(Santa santa, IPresentOrderProcessor presentOrderProcessor)
        {
            Contract.Requires(santa != null);
            Contract.Requires(presentOrderProcessor != null);

            _santa = santa;
            _presentOrderProcessor = presentOrderProcessor;
        }
示例#18
0
 // POST: api/Santa
 public void Post([FromBody] Santa value)
 {
     using (var dbSession = SessionFactory.Instance.OpenSession())
         using (var transaction = dbSession.BeginTransaction())
         {
             dbSession.Merge(value);
             transaction.Commit();
         }
 }
示例#19
0
        public async Task <IHttpActionResult> Register(RegisterSantaModel model)
        {
            //var model = new RegisterSantaModel();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            IdentityResult result;
            var            existingUser = await _userManager.FindByEmailAsync(model.Email);

            if (existingUser != null)
            {
                result = IdentityResult.Failed(new[] { "User with this email already exists" });
            }
            else
            {
                var santa = new Santa
                {
                    UserName  = model.Email,
                    Email     = model.Email,
                    Name      = model.Name,
                    PhotoPath = ""
                };

                result = await _santaManager.CreateAsync(santa, model.Password);

                if (result.Succeeded)
                {
                    var photoPath = HttpContext.Current.Server.MapPath("~/App_Data/Photos");
                    if (!Directory.Exists(photoPath))
                    {
                        Directory.CreateDirectory(photoPath);
                    }

                    var fileExtension = Path.GetExtension(model.Photo.Filename);
                    var filename      = $"{santa.Id}{fileExtension}";

                    photoPath = Path.Combine(photoPath, filename);
                    File.WriteAllBytes(photoPath, model.Photo.Content);
                    santa.PhotoPath = photoPath;
                    await _santaManager.UpdateAsync(santa);
                }
            }

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            return(Ok());
        }
示例#20
0
        public void TestTwoMatchingCharacters()
        {
            List <string> inputs = new List <string> {
                "xyxy", "aabcdefgaa"
            };
            Santa santa = new Santa();

            foreach (string input in inputs)
            {
                Assert.AreEqual(true, santa.MatchTwoLetters(input), input);
            }
            Assert.AreNotEqual(true, santa.MatchTwoLetters("aaa"), "aaa");
        }
示例#21
0
 internal void NavigateSantasToDeliverPresents(Santa santa, Santa roboSanta)
 {
     for (int i = 0; i < directions.Length; i++)
     {
         char direction = directions[i];
         if (IsSantasTurn(i))
         {
             santa.VisitNextHouse(direction);
         }
         else
         {
             roboSanta.VisitNextHouse(direction);
         }
     }
示例#22
0
        private void Initialize()
        {
            this.player = new Santa(100, 10, "Pesho");

            this.giftFactory  = new GiftFactory();
            this.enemyFactory = new EnemyFactory();

            this.giftFactory.Produce(this.levelManager.CurrentLevel.Tiles);
            this.enemyFactory.Produce(this.levelManager.CurrentLevel.Tiles);

            foreach (var generatedeEnemy in this.enemyFactory.GeneratedeEnemies)
            {
                generatedeEnemy.Killed += EnemyKilled;
            }

            this.player.Position = new Vector2(Constants.PlayerSpawnPoint, Constants.PlayerSpawnPoint);

            this.font     = this.Content.Load <SpriteFont>("Fonts/mainMenu");
            this.SideMenu = this.Content.Load <Texture2D>("Images/Backgrounds/SideMenu");

            this.MapViewport = new Viewport
            {
                X        = 420,
                Y        = 0,
                Width    = this.Graphics.PreferredBackBufferHeight,
                Height   = this.Graphics.PreferredBackBufferHeight,
                MinDepth = 0,
                MaxDepth = 1
            };

            this.MenuViewport = new Viewport
            {
                X        = this.Graphics.PreferredBackBufferHeight + 420,
                Y        = 0,
                Width    = this.Graphics.PreferredBackBufferWidth - this.Graphics.PreferredBackBufferHeight,
                Height   = this.Graphics.PreferredBackBufferHeight,
                MinDepth = 0,
                MaxDepth = 1
            };

            this.InventoryViewport = new Viewport
            {
                X        = 0,
                Y        = 0,
                Width    = 420,
                Height   = this.Graphics.PreferredBackBufferHeight,
                MinDepth = 0,
                MaxDepth = 1
            };
        }
示例#23
0
 private OptimizationInput GetInput()
 {
     return(new OptimizationInput()
     {
         Santas = new Santa[]
         {
             new Santa
             {
                 Id = 100,
             },
             new Santa
             {
                 Id = 200,
             },
         },
         Visits = new Visit[]
         {
             new Visit
             {
                 Id = 0,
                 IsBreak = false,
                 SantaId = -1,
             },
             new Visit
             {
                 Id = 1,
                 IsBreak = false,
                 SantaId = -1,
             },
             new Visit
             {
                 Id = 2,
                 IsBreak = false,
                 SantaId = -1,
             },
             new Visit
             {
                 Id = 3,
                 IsBreak = false,
                 SantaId = -1,
             },
             new Visit // will not be visited
             {
                 Id = 4,
                 IsBreak = true,
                 SantaId = 200,
             }
         },
         Days = new(int, int)[]
示例#24
0
    // Randomize height and position top
    // at start.
    void Start()
    {
        BoxCollider2D chimneyCollide = GetComponent <BoxCollider2D>();

        float newHeight = Random.Range(0.15f, 1f) * 4.5f;

        chimneyCollide.size   = new Vector2(1f, newHeight);
        chimneyCollide.offset = Vector2.up * newHeight / 2;

        ChimneyTop.GetComponent <Transform>().localPosition = Vector3.up * (newHeight + 0.25f);

        // Set santa to player
        santa = GameObject.FindGameObjectWithTag("Player").GetComponent <Santa>();

        spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <ChimneySpawner>();
    }
示例#25
0
        private static void Main(string[] args)
        {
            // Part 1
            Santa         santa       = new Santa();
            List <string> list        = File.ReadAllLines("input.txt").ToList();
            int           niceStrings = list.Count(x => santa.IsNiceString(x));

            Console.WriteLine(
                $"Part One: {list.Count} strings processed. {list.Count - niceStrings} strings marked as naughty. {niceStrings} strings are nice");

            // Part 2
            niceStrings = list.Count(x => santa.IsNiceString2(x));
            Console.WriteLine(
                $"Part Two: {list.Count} strings processed. {list.Count - niceStrings} strings marked as naughty. {niceStrings} strings are nice");
            Console.Write("Press any key...");
            Console.ReadKey();
        }
示例#26
0
    public void BefanaCatchSanta(Santa santa)
    {
        //remove the associated gifts
        if (santa.collectedGifts.Count > 0)
        {
            for (int i = 0; i < santa.collectedGifts.Count; i++)
            {
                gifts.Remove(santa.collectedGifts[i]);

                //remove gift from associated house
                House house = choosedHouses.Find(p => p.id == santa.collectedGifts[i].houseId);
                house.associatedGifts.Remove(santa.collectedGifts[i]);
            }
        }

        //Destroy the santa
        Destroy(santa.gameObject.transform.parent.gameObject);
    }
示例#27
0
        internal void Meet(Reindeer reindeer)
        {
            lock (ReindeerGroup)
            {
                ReindeerGroup.Add(reindeer);

                if (ReindeerGroup.Count == 9)
                {
                    var awakeMessage = new ReindeerAwakeMessage(ReindeerGroup.ToList());

                    foreach (var reindeerToRemove in awakeMessage.Group)
                    {
                        ReindeerGroup.Remove(reindeerToRemove);
                    }

                    Santa.Awake(awakeMessage);
                }
            }
        }
示例#28
0
        public void TestIsNiceString2()
        {
            Santa         santa     = new Santa();
            List <string> equalList = new List <string> {
                "qjhvhtzxzqqjkmpb", "xxyxx"
            };
            List <string> unequalList = new List <string> {
                "uurcxstgmygtbstg", "ieodomkazucvgmuy"
            };

            foreach (string s in equalList)
            {
                Assert.AreEqual(true, santa.IsNiceString2(s), s);
            }
            foreach (string s in unequalList)
            {
                Assert.AreNotEqual(true, santa.IsNiceString2(s), s);
            }
        }
示例#29
0
    private void Awake()
    {
        defs     = this.GetComponent <Defenses>();
        inter    = this.GetComponent <Interactables>();
        wave     = this.GetComponent <WaveController>();
        santa    = FindObjectOfType <Santa>();
        cam      = FindObjectOfType <Camera>();
        building = GameObject.FindGameObjectWithTag("Building").GetComponent <Building>();
        if (instance != null && instance != this)
        {
            // Destroy(this.gameObject);
            //temp TODO REPLACE to enable quick restart
            Destroy(instance.gameObject);
        }

        instance = this;
        DontDestroyOnLoad(this.gameObject);

        wave.LoadNextWave();
    }
示例#30
0
    private void OnTriggerEnter(Collider other)
    {
        //check if the trigger is a santa and the gift is selected by the same santa
        if (other.gameObject.tag == "Santa" && isSelected == true && other.gameObject.GetComponent <Santa>().id == santaId)
        {
            Santa touchedSanta = other.gameObject.GetComponent <Santa>();
            if (touchedSanta.collectedGifts.Count < 5)
            {
                touchedSanta.CollectGift(this);

                //Check if the scroll view is enabled
                if (SantaMainController.Instance.SantaScrollViewObject.activeInHierarchy && InputManager.Instance.selectedSanta.GetComponent <Santa>().id == other.gameObject.GetComponent <Santa>().id)
                {
                    SantaMainController.Instance.ClearSantaScrollView();
                    SantaMainController.Instance.InitSantaScrollView(touchedSanta.collectedGifts);
                }
                gameObject.SetActive(false);
            }
        }
    }