示例#1
0
        public void InvalidSpotTest()
        {
            var spotBusiness = new SpotBusiness();
            IList<ValidationResult> validationErrorResults = new List<ValidationResult>();
            const bool NotValid = false;
            bool isValidActual;

            // Check validation of a seemly normal location.
            var noName = new Spot(new GeoPoint { Lat = 0.0, Lon = 0.0 }, null);

            // check validation
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(noName, validationErrorResults);
            Assert.AreEqual(NotValid, isValidActual, "no name generic location");

            // Check validation of a seemly normal location.
            var noLocation = new Spot(null, "Spot");

            // check validation
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(noLocation, validationErrorResults);
            Assert.AreEqual(NotValid, isValidActual, "no location generic location");

            spotBusiness.Dispose();
        }
示例#2
0
 protected static int getFishToAdd(Player p, Spot fishingSpot)
 {
     int fishingLevel = p.getSkills().getGreaterLevel(Skills.SKILL.FISHING);
     int[] canCatch = new int[fishingSpot.getFish().Length];
     int j = 0;
     for (int i = 0; i < fishingSpot.getFish().Length; i++) {
         if (fishingLevel >= fishingSpot.getLevel()[i]) {
             canCatch[j] = fishingSpot.getFish()[i];
             j++;
         }
     }
     int[] canCatch2 = new int[j];
     for (int i = 0; i < canCatch.Length; i++) {
         if (canCatch[i] > 0) {
             canCatch2[i] = canCatch[i];
         }
     }
     int fish = misc.random(canCatch2.Length-1);
     for (int i = 0; i < fishingSpot.getFish().Length; i++) {
         if (fish == fishingSpot.getFish()[i]) {
             return i;
         }
     }
     return misc.random(canCatch2.Length-1);
 }
 public static void CreateSpawnPattern()
 {
     _spawnPattern = new Spot[CarSpawn.All.Count];
     var cap = (int)Mathf.Floor(SpawnPct * CarSpawn.All.Count);
     for(int i = 0; i < CarSpawn.All.Count; i++) {
         var name = GetRandomName();
         if (i < cap) _spawnPattern[i] = new Spot { Name = name, Taken = true };
         else         _spawnPattern[i] = new Spot { Name = name, Taken = false };
     }
     _spawnPattern.Shuffle();
 }
示例#4
0
 public void Start()
 {
     spots = new Spot[9];
     Spot spot;
     int currentSpot = 0;
     foreach(Transform t in transform.Cast<Transform>().OrderBy(t=>t.name)) {
         spot = t.GetComponent<TinyBoard>();
         if(spot != null) {
             spots[currentSpot++] = spot;
         }
     }
 }
        /// <summary>
        /// MapModel 생성자
        /// </summary>
        /// <param name="x"> XSize</param>
        /// <param name="y">YSize</param>
        public MapModel(int x, int y)
        {
            MapSize = new Spot(x, y);

            MapData = new MapNode[y][];
            for (int i = 0; i < MapData.GetLength(0); i++)
            {
                MapData[i] = new MapNode[x];
                for (int j = 0; j < MapData.GetLength(1); j++)
                {
                    MapData[i][j] = new MapNode();
                }
            }
            OnMapModelCreate();
        }
示例#6
0
        public async Task <IActionResult> RemoveSpot([FromBody] Spot spot)
        {
            spot.ETag = "*";

            foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(spot))
            {
                string name  = descriptor.Name;
                object value = descriptor.GetValue(spot);
                _logger.LogInformation("{0}={1}", name, value);
            }
            TableOperation insertOperation = TableOperation.Delete(spot);
            TableResult    result          = await _table.ExecuteAsync(insertOperation).ConfigureAwait(false);

            _logger.LogInformation("OK");
            return(Ok(result));
        }
 public JsonResult AddSpot([FromBody] Spot spot)
 {
     try
     {
         spot.ID       = Guid.NewGuid();
         spot.IsDone   = false;
         spot.IsActive = true;
         _context.Spots.Add(spot);
         _context.SaveChanges();
         return(Json(Ok()));
     }
     catch (Exception e)
     {
         return(Json(BadRequest(e.Message)));
     }
 }
示例#8
0
        public async Task <Spot> UpdateSpotLocation(Spot spot, Location location)
        {
            if (spot.LocationId == null || spot.LocationId == 0)
            {
                await _locationService.Create(location);

                spot.Location = location;
            }
            else
            {
                location.LocationId = (int)spot.LocationId;
                _context.Update(location);
            }

            return(spot);
        }
示例#9
0
    public static Line InitLine(int index)
    {
        Line line = new Line
        {
            code  = new Spot[maxCols],
            clue  = new Spot[maxCols],
            index = index
        };

        for (int i = 0; i < maxCols; i++)
        {
            line.code[i] = Spot.CreateCodeSpot(index, i);
            line.clue[i] = Spot.CreateClueSpot(index, i);
        }
        return(line);
    }
 private void Update()
 {
     if (IsOwner)
     {
         if (Input.GetKeyDown(KeyCode.Mouse0))
         {
             Vector2      worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
             RaycastHit2D hit        = Physics2D.Raycast(worldPoint, Vector2.zero);
             slot = hit.transform.GetComponent <Spot>();
             if (hit.collider.CompareTag("PickingSlot"))
             {
                 MakePlayServerRpc(slot.Line, slot.Column);
             }
         }
     }
 }
示例#11
0
        override public bool Move(Direction direction)
        {
            var destinationField = Spot.NeighbourInDirection(direction);

            if (destinationField.IsEmpty())
            {
                destinationField.Place(this);
                Spot.Remove();
                Spot = destinationField;
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#12
0
    void Start()
    {
        audioS = gameObject.GetComponent <AudioSource> ();


        bestscoretxt.text = PlayerPrefs.GetInt("score").ToString();

        oldscore = PlayerPrefs.GetInt("score");

        spawnSpots = Spot.FindObjectsOfType <Spot>();

        foreach (Spot spawnSpot in spawnSpots)
        {
            a++;
        }
    }
示例#13
0
        public object Clone()
        {
            Spot spotClone = Spot is null
                ? null
                : (Spot)Spot.Clone();

            return(new SmoothSpot(spotClone, SmoothPassSequence, SmoothPassIterationSequence)
            {
                BestBreakFactorGroupName = BestBreakFactorGroupName,
                BreakSequence = BreakSequence,
                BreakPositionMovedFrom = BreakPositionMovedFrom,
                CanMoveToOtherBreak = CanMoveToOtherBreak,
                IsCurrent = IsCurrent,
                ExternalBreakRefAtStart = ExternalBreakRefAtStart
            });
        }
        private static Spot[][] PrepareInput(string[] inputData)
        {
            var result = new Spot[inputData.Length][];

            for (var row = 0; row < inputData.Length; row++)
            {
                var charRow   = inputData[row].ToCharArray();
                var rowResult = new Spot[charRow.Length];
                for (var col = 0; col < charRow.Length; col++)
                {
                    rowResult[col] = new Spot(row, col, charRow[col]);
                }
                result[row] = rowResult;
            }
            return(result);
        }
示例#15
0
    /// <summary>
    /// 맵의 진행도를 불러옵니다.
    /// </summary>
    /// <param name="spot">진행도를 불러올 맵의 첫spot</param>
    /// <param name="fileName">불러올 JSON파일의 이름</param>
    public static void LoadProgress(Spot spot, string fileName)
    {
#if UNITY_EDITOR
        UnityEditor.AssetDatabase.Refresh();
#endif

        string jsonData = File.ReadAllText(Application.persistentDataPath + "/TemporaryFiles/" + fileName + "_progress.json");
        JObject stage = (JObject)JObject.Parse(jsonData)[fileName];
        JArray spots = (JArray)stage["spots"];

        List<Spot> spotList = new List<Spot>();

        Debug.Log("진행도를 불러옴");

        LoadProgress(spot ,(JObject)spots[0]);
    }
示例#16
0
 private bool IsValidPath(Vector3Int[,] grid, Spot start, Spot end)
 {
     if (end == null)
     {
         return(false);
     }
     if (start == null)
     {
         return(false);
     }
     if (end.Height >= 1)
     {
         return(false);
     }
     return(true);
 }
        public void IsSpotEligible_SpotAndBreakBreakTypesMismatchesAndIgnoreSpotStartTime_SpotIsRejected()
        {
            // Arrange
            Spot fakeSpot = SpotWithValidBreakTypeAndStartTimeFactory();

            Break fakeBreak = BreakWithValidBreakTypeFactory();

            fakeBreak.BreakType += "Different";

            var service = CanAddSpotService.Factory(new SmoothBreak(fakeBreak, 1));

            // Act
            var result = service.IsSpotEligibleWhenIgnoringSpotTime(fakeSpot);

            // Assert
            _ = result.Should().BeFalse(because: null);
        }
示例#18
0
        // Handles all RadioButton clicks for FromSpot and ToSpot.
        private void NodeRadioButton_Click(object sender, EventArgs e)
        {
            if (myDiagram.SelectedNode == null)
            {
                return;
            }
            RadioButton tempRB = sender as RadioButton;

            if (tempRB == null)
            {
                return;
            }
            MyNodeData mnd = myDiagram.SelectedNode.Data as MyNodeData;

            if (mnd != null)
            {
                myDiagram.StartTransaction("Modify Port Spots");
                // "From" Side CheckBoxes are all unchecked when a "From" RadioButton is selected.
                if (ToFromSpotTabControl.SelectedItem == FromPortTab)
                {
                    this.IgnoreCheckBoxChanges = true;
                    FromLeftCB.IsChecked       = false;
                    FromTopCB.IsChecked        = false;
                    FromRightCB.IsChecked      = false;
                    FromBottomCB.IsChecked     = false;
                    this.IgnoreCheckBoxChanges = false;
                    // The names of FromPort RadioButtons are formatted in the pattern ("From"+NameOfSpot).
                    // Spot.Parse() converts the button name to a Spot value.
                    mnd.FromSpot = Spot.Parse(tempRB.Name.Substring(4));
                }
                // "To" Side CheckBoxes are all unchecked when a "To" RadioButton is selected.
                if (ToFromSpotTabControl.SelectedItem == ToPortTab)
                {
                    this.IgnoreCheckBoxChanges = true;
                    ToLeftCB.IsChecked         = false;
                    ToTopCB.IsChecked          = false;
                    ToRightCB.IsChecked        = false;
                    ToBottomCB.IsChecked       = false;
                    this.IgnoreCheckBoxChanges = false;
                    // The names of ToPort RadioButtons are formatted in the pattern ("To"+NameOfSpot).
                    // Spot.Parse() converts the button name to a Spot value.
                    mnd.ToSpot = Spot.Parse(tempRB.Name.Substring(2));
                }
                myDiagram.CommitTransaction("Modify Port Spots");
            }
        }
示例#19
0
        static Spot[,] InitializeGrid(int dimensions)
        {
            Spot[,] grid = new Spot[dimensions, dimensions];

            for (int x = 0; x < dimensions; x++)
            {
                for (int y = 0; y < dimensions; y++)
                {
                    grid[x, y] = new Spot(0, 0, 0, "0", x, y);
                }
            }
            foreach (Spot element in grid)
            {
                grid[element.x, element.y].neighbors = Ft_getneighbours(grid, element.x, element.y);
            }
            return(grid);
        }
示例#20
0
        static void Main(string[] args)
        {
            GameTypeCommand gameType = ClientRobot.Connect(args);

            Spot[] spots = new Spot[gameType.ROBOTS_IN_ONE_TEAM];
            for (int i = 0; i < spots.Length; i++)
            {
                spots[i] = new Spot("spot_" + i);
            }
            while (true)
            {
                foreach (Spot spot in spots)
                {
                    process(spot, getWhatToDo(spot));
                }
            }
        }
示例#21
0
文件: Formation.cs 项目: Linkaan/LD41
    Spot GetClosestSpot(Vector3 position)
    {
        float minDistance = Mathf.Infinity;
        Spot  closestSpot = spots[0];

        foreach (Spot spot in spots)
        {
            float distance = Vector3.Distance(position, spot.transform.position);
            if (distance < minDistance)
            {
                minDistance = distance;
                closestSpot = spot;
            }
        }

        return(closestSpot);
    }
示例#22
0
    private void SpotClicked(Dictionary <Vector2, Spot> board, Vector2 pos, int whoClicked)
    {
        Spot cSpot = board[pos];

        //Spot is now marked
        cSpot.updateOwn(whoClicked);

        //FLIPS here
        cb.iterDirection(board, 0, -1, cSpot, true);  //Down
        cb.iterDirection(board, 0, 1, cSpot, true);   //Up
        cb.iterDirection(board, -1, 0, cSpot, true);  //Right
        cb.iterDirection(board, 1, 0, cSpot, true);   //Left
        cb.iterDirection(board, 1, 1, cSpot, true);   //Up Left
        cb.iterDirection(board, 1, -1, cSpot, true);  //Down Left
        cb.iterDirection(board, -1, 1, cSpot, true);  //Up Right
        cb.iterDirection(board, -1, -1, cSpot, true); //Down Right
    }
        public void IsSpotEligible_SpotBreakTypeIsNullAndSpotStartTimeInsideBreak_SpotIsAllowed()
        {
            // Arrange
            Spot fakeSpot = SpotWithValidBreakTypeAndStartTimeFactory();

            fakeSpot.BreakType = null;

            Break fakeBreak = BreakWithValidBreakTypeFactory();

            var service = CanAddSpotService.Factory(new SmoothBreak(fakeBreak, 1));

            // Act
            var result = service.IsSpotEligibleWhenRespectingSpotTime(fakeSpot);

            // Assert
            _ = result.Should().BeTrue(because: null);
        }
示例#24
0
    private Spot GetClosestUnusedSpot(Vector3 position, List <Spot> spotList)
    {
        float minDistance = float.MaxValue;
        Spot  unusedSpot  = null;

        foreach (Spot spot in spotList)
        {
            float distance = Vector3.Distance(spot.SpotTransform.position, position);
            if (distance < minDistance && !spot.IsUsed)
            {
                minDistance = distance;
                unusedSpot  = spot;
            }
        }

        return(unusedSpot);
    }
示例#25
0
         void Start()
        {
            chosenSpot = Field.Spots[0, 0];//startverdi [0,0] i muldteig

            muldTeig = Farm.muldTeig; //bare ett jordstykke i oppgaven. muldteig      

            GameObject graphGO = GameObject.Instantiate(emptyGraphPrefab);
            graphGO.transform.SetParent(this.transform, false);
            graph = graphGO.GetComponent<WMG_Axis_Graph>();

            notfirsttime = false;
            thisSpot = Initializer.SpotValgt;

            InitierGraf();


        }//start()
 public SpotButton(Spot spot)
 {
     this._spot     = spot;
     this.Width     = 50;
     this.Height    = 50;
     this.Margin    = new Thickness(2);
     this.Content   = spot.SpotNumber;
     this.Focusable = false;
     if (spot.IsAvailable == 0)
     {
         this.Background = Brushes.Gray;
     }
     else if (spot.IsAvailable == 1)
     {
         this.IsEnabled = false;
     }
 }
        public void IsSpotEligible_MatchingBreakTypeAndSpotStartTimeAfterBreak_SpotIsRejected()
        {
            // Arrange
            Spot fakeSpot = SpotWithValidBreakTypeAndStartTimeFactory();

            MoveSpotByMinutes(fakeSpot, 10);

            Break fakeBreak = BreakWithValidBreakTypeFactory();

            var service = CanAddSpotService.Factory(new SmoothBreak(fakeBreak, 1));

            // Act
            var result = service.IsSpotEligibleWhenRespectingSpotTime(fakeSpot);

            // Assert
            _ = result.Should().BeFalse(because: null);
        }
示例#28
0
    public void SelectSpot(Spot spot)
    {
        if (selectedSpot == spot)
        {
            DeselectSpot();
            return;
        }

        selectedSpot = spot;
        extendable   = selectedSpot.spot;

        DeselectRoot();

        DeselectYggdrasil();

        spotUI.SetTarget(spot);
    }
        private static void CheckProductClashRulesWhenClashLimitsAreAllowed(
            IReadOnlyDictionary <Guid, SpotInfo> spotInfos,
            IReadOnlyDictionary <string, Clash> clashesByExternalRef,
            SmoothResources smoothResources,
            IClashExposureCountService clashExposureCountService,
            SmoothFailureMessagesForSpotsCollection result,
            IReadOnlyDictionary <string, int> spotChildClashCodeCount,
            IReadOnlyDictionary <string, int> spotParentClashCodeCount,
            IReadOnlyCollection <Spot> spotsAlreadyInTheBreak,
            Spot spot,
            SpotInfo spotInfo,
            IReadOnlyCollection <Spot> childProductClashSpots)
        {
            if (childProductClashSpots.Count > 0 && !String.IsNullOrEmpty(spotInfo.ProductClashCode))
            {
                CheckProductClashExposureCount(
                    clashesByExternalRef,
                    clashExposureCountService,
                    result,
                    spotChildClashCodeCount,
                    spot,
                    spotInfo,
                    childProductClashSpots);
            }

            // Check parent clashes
            var parentProductClashSpots = smoothResources.ProductClashChecker
                                          .GetProductClashesForSingleSpot(
                spot,
                spotsAlreadyInTheBreak,
                spotInfos,
                ClashCodeLevel.Parent)
                                          .ToList();

            if (parentProductClashSpots.Count > 0 && !String.IsNullOrEmpty(spotInfo.ParentProductClashCode))
            {
                CheckProductParentClashExposure(
                    clashesByExternalRef,
                    clashExposureCountService,
                    result,
                    spotParentClashCodeCount,
                    spot,
                    spotInfo,
                    parentProductClashSpots);
            }
        }
示例#30
0
        public override void Entry(IModHelper helper)
        {
            instance = this;
            Monitor.Log("CreeperForage reporting in. " + (Debug ? "Debug" : "Release") + " build active.");

            Config.Load();
            if (Config.ready)
            {
                Item.Setup();
                Spot.Setup(helper);
            }

            if (Debug)
            {
                helper.Events.Input.ButtonPressed += Input_ButtonPressed;
            }
        }
示例#31
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (isClear)
        {
            return;
        }

        foreach (Spot spot in Spot.nowSpot.nextSpots)
        {
            if (spot == this)
            {
                isClear = true;
                nowSpot = this;

                GameManager.instance.SaveProgress();

                switch (spot.sceneOption.type)
                {
                case SceneOption.Type.Boss:
                case SceneOption.Type.Battle:
                    SceneLoader.LoadScene("BattleScene", sceneOption);
                    break;

                case SceneOption.Type.Rest:
                    // 여기에다가 대충 동작 추가
                    GameObject go = Instantiate(Resources.Load("Rest Object", typeof(GameObject)), Vector3.zero, Quaternion.identity) as GameObject;
                    StartCoroutine(CO_RestProcess(go, 3));
                    break;

                case SceneOption.Type.Event:
                    int randam = Random.Range(0, 10);
                    if (randam % 2 == 0)
                    {
                        SceneLoader.LoadScene("BattleScene", sceneOption);
                    }
                    else
                    {
                        // 여기에다가 대충 동작 추가
                        GameObject _go = Instantiate(Resources.Load("Rest Object", typeof(GameObject)), Vector3.zero, Quaternion.identity) as GameObject;
                        StartCoroutine(CO_RestProcess(_go, 3));
                    }
                    break;
                }
            }
        }
    }
示例#32
0
 public void ConsumeServiceItem(IServiceMessage item, string serviceName)
 {
     //Here we listen to all ros msg and update our robot state
     if (serviceName == "ConnectionStateService")
     {
         bool newRosConnectionState = ((ConnectionStateMessage)item).ConnectionState;
         if (newRosConnectionState)
         {
             spot = new Spot(rosConnector.RosSocket);
             Debug.Log("Did set spot");
         }
         else
         {
             spot = null;
         }
     }
 }
 private void OnRemoveSpot()
 {
     if (SelectedSpot != null)
     {
         Spot spot = SelectedSpot;
         SelectedSpots.Remove(spot);
         foreach (Spot s in Spots)
         {
             if (s.Id == spot.Id)
             {
                 s.IsSelected = false;
                 s.Width      = 20;
                 s.Height     = 20;
             }
         }
     }
 }
        // Take vehicle and return first empty / available spot
        public void ParkVehicle()
        {
            Console.WriteLine("Park a Car or Mc?");
            string VehicleChoise = Console.ReadLine();

            VehicleChoise.ToLower();
            Console.WriteLine("Enter registration plate: ");
            string input = Console.ReadLine();

            switch (VehicleChoise)
            {
            case "car":
                Car car = new Car();
                car.RegPlate   = input;
                car.ArriveTime = DateTime.Now;

                ParkingSpot spot;
                spot = FindAvailableSpot(car);
                if (spot != null)
                {
                    spot.AddVehicle(car);
                    WriteToFile();
                    Console.WriteLine("Your car is now parked.");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("No empty spots available.");
                }
                Console.ReadKey();
                break;

            case "mc":
                MC newMC = new MC();
                newMC.RegPlate   = input;
                newMC.ArriveTime = DateTime.Now;

                ParkingSpot Spot;
                Spot = FindAvailableSpot(newMC);
                Spot.AddVehicle(newMC);
                WriteToFile();
                Console.WriteLine("Done");
                Console.ReadKey();
                break;
            }
        }
        private void OnRemoveTicket()
        {
            Spot            spot = SelectedSpot;
            ConfirmationBox cb   = new ConfirmationBox
            {
                Message =
                    String.Format(
                        "Вы действительно желаете удалить билет № {0}, {1}, {2}, {3} ряд, {4} место из списка билетов заказа?",
                        spot.Id, spot.SideName, spot.SectorName, spot.RowNum, spot.SeatNum)
            };


            bool?result = cb.ShowDialog();

            if (result ?? false)
            {
                //First we cancel ticket in the order
                Customer.Order.Seats = new List <Seat> {
                    new Seat()
                    {
                        Id = spot.Id
                    }
                };
                Customer.Order = Data.Access.Cancel(Customer.Order);

                // Then we remove a seat from selected seats collection
                SelectedSpots.Remove(spot);
                // and mark spot as unselected on the map
                foreach (Spot s in Spots)
                {
                    if (s.Id == spot.Id)
                    {
                        s.IsSelected = false;
                        s.Width      = 20;
                        s.Height     = 20;
                    }
                }

                // At last we again lock seats
                if (SelectedSpots.Count > 0)
                {
                    LockSeats(SelectedSpots.ToArray());
                }
            }
        }
示例#36
0
 public static bool canFish(Player p, Spot fishingSpot, Spot fishingSpot2, int index)
 {
     if (p == null || fishingSpot == null) {
         return false;
     }
     if (!p.getLocation().withinDistance(fishingSpot.getSpotLocation(), 2)) {
         return false;
     }
     if (fishingSpot2 != null) {
         if (!fishingSpot.Equals(fishingSpot2)) {
             return false;
         }
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.FISHING)< fishingSpot.getLevel()[index]){
         p.getPackets ().sendMessage ("You need a fishing level of " +fishingSpot.getLevel()[index] + " to fish here.");
         return false;
     }
     if (fishingSpot.getPrimaryItem() != -1) {
         if (!p.getInventory().hasItem (fishingSpot.getPrimaryItem())){
             p.getPackets ().sendMessage ("You need " + fishingSpot.getPrimaryName() + " to fish here.");
             return false;
         }
     }
     if (fishingSpot.getSecondaryItem() != -1) {
         if (!p.getInventory().hasItem (fishingSpot.getSecondaryItem())){
             p.getPackets ().sendMessage ("You need " + fishingSpot.getSecondaryName() + " to fish here.");
             return false;
         }
     }
     if (p.getInventory().findFreeSlot() == -1) {
         p.getPackets().sendChatboxInterface(210);
         p.getPackets().modifyText("Your inventory is too full to catch any more fish.", 210, 1);
         return false;
     }
     return true;
 }
示例#37
0
        public void ValidateSpotTest()
        {
            var spotBusiness = new SpotBusiness();
            IList<ValidationResult> validationErrorResults = new List<ValidationResult>();
            const bool NotValid = false;
            const bool Valid = true;
            bool isValidActual;

            // Check validation of an invalid latitude location.
            Spot invalidLatLocation = new Spot(new GeoPoint { Lat = 90.1, Lon = 0.0 }, "Spot");

            // check validation invalid
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(invalidLatLocation, validationErrorResults);
            Assert.AreEqual(NotValid, isValidActual, " latitude greater than 90.0 is not valid");

            invalidLatLocation = new Spot(new GeoPoint { Lat = 90.0, Lon = 0.0 }, "Spot");

            // check validation valid
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(invalidLatLocation, validationErrorResults);
            Assert.AreEqual(Valid, isValidActual, "latitude less than or equal to 90.0 is valid");

            // Check validation of an invalid latitude location.
            invalidLatLocation = new Spot(new GeoPoint { Lat = -90.1, Lon = 0.0 }, "Spot");

            // check validation
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(invalidLatLocation, validationErrorResults);
            Assert.AreEqual(NotValid, isValidActual, "latitude less than -90.0 is not valid");

            // Check validation of an invalid latitude location.
            invalidLatLocation = new Spot(new GeoPoint { Lat = -90.0, Lon = 0.0 }, "Spot");

            // check validation
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(invalidLatLocation, validationErrorResults);
            Assert.AreEqual(Valid, isValidActual, "latitude greater than or equal to -90.0 is valid");

            // Check validation of an invalid latitude location.
            Spot invalidLonLocation = new Spot(new GeoPoint { Lat = 0.0, Lon = 180.1 }, "Spot");

            // check validation invalid
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(invalidLonLocation, validationErrorResults);
            Assert.AreEqual(NotValid, isValidActual, "longitude greater than 180.0 is not valid");

            // Check validation of an invalid latitude location.
            invalidLonLocation = new Spot(new GeoPoint { Lat = 0.0, Lon = 180.0 }, "Spot");

            // check validation valid
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(invalidLonLocation, validationErrorResults);
            Assert.AreEqual(Valid, isValidActual, "longitude less than or equal to 180.0 is valid");

            // Check validation of an invalid latitude location.
            invalidLonLocation = new Spot(new GeoPoint { Lat = 0.0, Lon = -180.1 }, "Spot");

            // check validation
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(invalidLonLocation, validationErrorResults);
            Assert.AreEqual(NotValid, isValidActual, "longitude less than -180.0 is not valid");

            // Check validation of an invalid latitude location.
            invalidLonLocation = new Spot(new GeoPoint { Lat = 0.0, Lon = -180.0 }, "Spot");

            // check validation
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(invalidLonLocation, validationErrorResults);
            Assert.AreEqual(Valid, isValidActual, "longitude great than or equal to -180.0 is valid");

            spotBusiness.Dispose();
        }
示例#38
0
    protected Vector3 spotMasCercano(ArrayList spotParaOcultarse)
    {
        Vector3 pos = transform.position;
        Vector3 posSpot = new Vector3(0,0,0);
        float distancia = int.MaxValue;

        foreach (Spot spot in spotParaOcultarse) {
            float dis = (spot.transform.position - pos).magnitude;
            //Debug.Log ("Spot dis: "+dis+" pos: "+ spot);
            if (dis < distancia) {
                posSpot = spot.transform.position;
                spotOculto = spot;
                distancia = dis;
            }
        }
        return posSpot;
    }
示例#39
0
    void CheckClick()
    {
        if(GM.uiManager.isMenu && GM.uiManager.lastTooltip != "VillagerInfo")
            return;
        if(!Input.GetMouseButtonUp(0) && !Input.GetMouseButtonDown(0))
            return;
        if(Input.GetMouseButtonDown(0)){
            wasClick = true;
            prevPos = Input.mousePosition;
            return;
        }
        if(wasClick && Input.GetMouseButtonUp(0)){
            wasClick = false; float leniency = 6f;
            if(Mathf.Clamp(prevPos.x, Input.mousePosition.x - leniency, Input.mousePosition.x + leniency) != prevPos.x){
                return;
            }else if(Mathf.Clamp(prevPos.y, Input.mousePosition.y - leniency, Input.mousePosition.y + leniency) != prevPos.y){
                return;
            }
        }

        if(!UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()){
            if(GM.uiManager.toolTip){
                GM.uiManager.KillTooltip(true);
                if(GM.aiManager.resetTarget){
                    GM.aiManager.ResetCameraTarget();
                }
                return;
            }
        }else{
            return;
        }
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        if(Physics.Raycast(ray, out hit)){
            if(hit.transform.GetComponent<Spot>()){
                lastSpot = hit.transform.GetComponent<Spot>();
                //Debug.Log(hit.collider.gameObject);
                if(!lastSpot.filled){
                    GM.uiManager.QuickBuildTooltip();
                }else{
                    GM.uiManager.StructInfo(lastSpot.GetComponentInChildren<PhysicalStructure>());
                }
            }
            if(hit.transform.parent == GM.aiManager.villagerParent.transform){
                //GM.aiManager.SetCameraTarget(hit.transform);
                VillagerAI tvai = hit.transform.GetComponent<VillagerAI>();
                GM.uiManager.VillagerInfo(tvai.villager);
            }
        }
    }
示例#40
0
        public void ValidateTest()
        {
            var spotBusiness = new SpotBusiness();

            const bool NotValid = false;
            const bool Valid = true;
            bool isValidActual;
            IList<ValidationResult> validationErrorResults = new List<ValidationResult>();

            // check validation of null location... not valid.
            Spot nullSpot = null;

            isValidActual = spotBusiness.Validate(nullSpot, null);
            Assert.AreEqual(NotValid, isValidActual, "null is not valid, null result parameter");

            // check  validation

            isValidActual = spotBusiness.Validate(nullSpot, validationErrorResults);
            Assert.AreEqual(NotValid, isValidActual, "null is not valid");
            Assert.AreNotEqual(0, validationErrorResults.Count);

            // check validation of default location constructor... not valid.
            Spot defaultLocation = new Spot();

            // check validation
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(defaultLocation, validationErrorResults);
            Assert.AreEqual(NotValid, isValidActual, "newly constructed empty class is not valid");
            Assert.AreNotEqual(0, validationErrorResults.Count);

            // Check validation of a seemly normal location.
            Spot validGenericLocation = new Spot(new GeoPoint { Lat = 0.0, Lon = 0.0 }, "Spot");

            // check validation
            validationErrorResults.Clear();
            isValidActual = spotBusiness.Validate(validGenericLocation, validationErrorResults);
            Assert.AreEqual(Valid, isValidActual, "Valid generic location");
            Assert.AreEqual(0, validationErrorResults.Count);

            spotBusiness.Dispose();
        }
示例#41
0
 IEnumerator BatchBuild(string toBuild, int buildCount, Vector3 buildCenter)
 {
     RefreshEmptySpots();
     List<Spot> batchSpots = new List<Spot>();
     for(int i = 0; i < buildCount; i++){
         GM.structureManager.BuyStructure(toBuild);
         Spot tmpSpot = GetClosestSpot(buildCenter);
         batchSpots.Add(tmpSpot);
         tmpSpot.filled = true;
     }
     for(int i = 0; i < buildCount; i++){
         yield return new WaitForSeconds(0.005f);
         lastSpot = batchSpots[i];
         BuildOnSpot(toBuild, false);
     }
 }
示例#42
0
 IEnumerator AnimPush(Spot lastS, float sizeScale, bool instant = false)
 {
     float maxDist = 20f * sizeScale;
     Collider[] hitColliders = Physics.OverlapSphere(lastSpot.transform.position, maxDist);
     List<Vector3> endPositions = new List<Vector3>();
     List<Collider> endColliders = new List<Collider>();
     foreach(Collider hc in hitColliders){
         if(hc.transform == lastSpot.transform)
             continue;
         Vector3 heading = hc.transform.position - lastSpot.transform.position;
         float dist = heading.magnitude;
         if(dist >= maxDist)
             continue;
         Vector3 dir = heading / dist;
         //Debug.Log(dir);
         dist = maxDist - dist;
         dist /= maxDist;
         dist *= sizeScale - 1f;
         //Debug.Log(dist);
         endColliders.Add(hc);
         endPositions.Add(hc.transform.position + (dir * dist * 2f));
     }
     if(!instant){
         float currentT = 0f;
         float animT = 0.2f;
         //Debug.Log(endColliders.Count + " : " + endPositions.Count);
         while(currentT < animT){
             currentT += Time.deltaTime;
             for(int i = 0; i < endColliders.Count; i++)
                 endColliders[i].transform.position = Vector3.Lerp(endColliders[i].transform.position, endPositions[i], currentT / animT);
             yield return new WaitForEndOfFrame();
         }
     }
     for(int i = 0; i < endColliders.Count; i++)
         endColliders[i].transform.position = endPositions[i];
 }
示例#43
0
 private void FillSpot(NFLPlayer plyr)
 {
     //  starters only
     #if DEBUG
      Utility.Announce("NFLTeam.FillSpot: for " + plyr.PlayerName);
      if (plyr.PlayerCode.Equals("GOREFR01"))
     DumpSpots();
     #endif
      if (plyr.PlayerRole == "S")
      {
     //  Q: Why these other spots? Ans: there are two spots for these
     if (IsVacant(plyr.PlayerPos, _spotList) ||
         (plyr.PlayerPos.IndexOf("WR") > -1) ||
         (plyr.PlayerPos == "DE") || (plyr.PlayerPos == "ILB") ||
         (plyr.PlayerPos == "RT") || (plyr.PlayerPos == "LT") ||
         (plyr.PlayerPos == "OLB"))
     {
        var spot = new Spot(ConvertSpot(plyr.PlayerPos, _spotList), plyr);
     #if DEBUG
        Utility.Announce(string.Format("NFLTeam.FillSpot {0} with {1}", spot.SpotName, plyr.PlayerName));
     #endif
        if (_spotList == null) _spotList = new ArrayList();
        _spotList.Add(spot);
     }
      }
 }
 /// <summary>
 /// Hazard를 추가하는 함수
 /// </summary>
 /// <param name="Hazard"></param>
 public void AddHazardPoint(Spot Hazard)
 {
     if (Hazard == null || Map ==null) return;
     HazardList.Add(Hazard);
     Map.AddObj((int)Hazard.x, (int)Hazard.y, HAZARD);
 }
示例#45
0
    void Update()
    {
        if (Input.GetButtonDown("Throw_rope"))
        {
            if (spots.Count > 0)
            {
                spots[spots.Count - 1].Stop();
            }
        }
        if (Input.GetButton("Throw_rope"))
        {
            direction = new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
            direction.Normalize();
            direction *= currentSourceAmount;
            Debug.DrawLine(transform.position, transform.position + direction, Color.red);
        }
        if (Input.GetButtonUp("Throw_rope"))
        {
            if (currentSourceAmount > 1 && direction.sqrMagnitude != 0)
            {
                var target = transform.position + direction;
                bool forbiddenDirection = false;
                var newVector = target - transform.position;
                for (var i = 0; i < spots.Count; i++)
                {
                    var spotVector = spots[i].position - transform.position;
                    newVector.Normalize();
                    spotVector.Normalize();
                    if (Vector3.Dot(newVector, spotVector) > 0.92f)
                    {
                        forbiddenDirection = true;
                        break;
                    }
                }
                if (!forbiddenDirection)
                {
                    var spot = new Spot(target, speed, gameObject, debugObject);
                    spots.Add(spot);
                }
            }

        }
        for (var i = 0; i < spots.Count; i++)
        {
            var spot = spots[i];
            if (i == spots.Count - 1 && spot.isStoped)
            {
                transform.position = Vector3.MoveTowards(transform.position, spot.position, speed);
            }
            else if (spot.isStoped)
            {
                spot.ContinueMoving();
            }

            if (spot.isDestroed)
            {
                spots.Remove(spot);
            }
            else
            {
                currentSourceAmount -= spot.UpdatePosition();
                Debug.DrawLine(transform.position, spot.position, Color.green);
            }
        }
        if (spots.Count == 0 && currentSourceAmount < sourceCapacity)
        {
            currentSourceAmount = Mathf.MoveTowards(currentSourceAmount, sourceCapacity, speed * regenerationSpeedMultiplier);
        }
    }
示例#46
0
    /// <summary>
    /// Given a <c>Spot</c> in the <see cref="OriginalBounds"/> and a new <c>Point</c>,
    /// compute the new <c>Rect</c>.
    /// </summary>
    /// <param name="newPoint"></param>
    /// <param name="spot">The <see cref="Spot"/> in the rectangular bounds for which the <see cref="Handle"/> is being dragged</param>
    /// <param name="min">the computed rectangle must be at least as large as these dimensions</param>
    /// <param name="max">the computed rectangle must be no larger than these dimensions</param>
    /// <param name="reshape">whether the aspect ratio of the rectangle may change</param>
    /// <returns></returns>
    protected virtual Rect ComputeResize(Point newPoint, Spot spot, Size min, Size max, bool reshape) {
      if (spot.IsNoSpot) spot = Spot.Center;
      newPoint = Geo.RotatePoint(newPoint, Spot.Center.PointInRect(this.OriginalBounds), -this.Angle);

      Rect origRect = this.OriginalBounds;
      double left = origRect.X;
      double top = origRect.Y;
      double right = origRect.X + origRect.Width;
      double bottom = origRect.Y + origRect.Height;

      double oldratio = 1;
      if (!reshape) {
        double oldw = origRect.Width;
        double oldh = origRect.Height;
        if (oldw <= 0) oldw = 1;
        if (oldh <= 0) oldh = 1;
        oldratio = oldh/oldw;
      }

      Size cellSize = this.EffectiveCellSize;
      newPoint = DraggingTool.FindNearestInfiniteGridPoint(newPoint, new Point(0, 0), new Point(left, top), cellSize);

      Rect newRect = origRect;
      if (spot.X <= 0) {  // left
        if (spot.Y <= 0) {  // top-left
          newRect.X = Math.Max(newPoint.X, right - max.Width);
          newRect.X = Math.Min(newRect.X, right - min.Width);
          newRect.Width = Math.Max(right - newRect.X, min.Width);

          newRect.Y = Math.Max(newPoint.Y, bottom - max.Height);
          newRect.Y = Math.Min(newRect.Y, bottom - min.Height);
          newRect.Height = Math.Max(bottom - newRect.Y, min.Height);

          if (!reshape) {
            double newratio = newRect.Height/newRect.Width;
            if (oldratio < newratio) {
              newRect.Height = oldratio*newRect.Width;
              newRect.Y = bottom - newRect.Height;
            } else {
              newRect.Width = newRect.Height/oldratio;
              newRect.X = right - newRect.Width;
            }
          }
        } else if (spot.Y >= 1) {  // bottom-left
          newRect.X = Math.Max(newPoint.X, right - max.Width);
          newRect.X = Math.Min(newRect.X, right - min.Width);
          newRect.Width = Math.Max(right - newRect.X, min.Width);

          newRect.Height = Math.Max(Math.Min(newPoint.Y - top, max.Height), min.Height);

          if (!reshape) {
            double newratio = newRect.Height/newRect.Width;
            if (oldratio < newratio) {
              newRect.Height = oldratio*newRect.Width;
            } else {
              newRect.Width = newRect.Height/oldratio;
              newRect.X = right - newRect.Width;
            }
          }
        } else {  // middle-left
          newRect.X = Math.Max(newPoint.X, right - max.Width);
          newRect.X = Math.Min(newRect.X, right - min.Width);
          newRect.Width = Math.Max(right - newRect.X, min.Width);
        }
      } else if (spot.X >= 1) {  // right
        if (spot.Y <= 0) {  // top-right
          newRect.Width = Math.Max(Math.Min(newPoint.X - left, max.Width), min.Width);

          newRect.Y = Math.Max(newPoint.Y, bottom - max.Height);
          newRect.Y = Math.Min(newRect.Y, bottom - min.Height);
          newRect.Height = Math.Max(bottom - newRect.Y, min.Height);

          if (!reshape) {
            double newratio = newRect.Height/newRect.Width;
            if (oldratio < newratio) {
              newRect.Height = oldratio*newRect.Width;
              newRect.Y = bottom - newRect.Height;
            } else {
              newRect.Width = newRect.Height/oldratio;
            }
          }
        } else if (spot.Y >= 1) {  // bottom-right
          newRect.Width = Math.Max(Math.Min(newPoint.X - left, max.Width), min.Width);
          newRect.Height = Math.Max(Math.Min(newPoint.Y - top, max.Height), min.Height);

          if (!reshape) {
            double newratio = newRect.Height/newRect.Width;
            if (oldratio < newratio) {
              newRect.Height = oldratio*newRect.Width;
            } else {
              newRect.Width = newRect.Height/oldratio;
            }
          }
        } else {  // middle-right
          newRect.Width = Math.Max(Math.Min(newPoint.X - left, max.Width), min.Width);
        }
      } else {  // middle-X
        if (spot.Y <= 0) {  // top-middle
          newRect.Y = Math.Max(newPoint.Y, bottom - max.Height);
          newRect.Y = Math.Min(newRect.Y, bottom - min.Height);
          newRect.Height = Math.Max(bottom - newRect.Y, min.Height);
        } else if (spot.Y >= 1) {  // bottom-middle
          newRect.Height = Math.Max(Math.Min(newPoint.Y - top, max.Height), min.Height);
        } else {
          // handle is in the middle-middle -- don't do anything
        }
      }
      return newRect;
    }
示例#47
0
 private static long getFishingDelay(Player p, Spot fishingSpot)
 {
     int[] time = fishingSpot.isSecondOption() ? SECOND_SPOT_TIME : FIRST_SPOT_TIME;
     int[] minTime = fishingSpot.isSecondOption() ? SECOND_SPOT_MINTIME : FIRST_SPOT_MINTIME;
     int baseTime = time[fishingSpot.getSpotindex()];
     int min = minTime[fishingSpot.getSpotindex()];
     int finalDelay = baseTime -= misc.random(min);
     return finalDelay;
 }