Ejemplo n.º 1
0
        public void HandleTemperature()
        {
            var    convertModel = new ConvertModel(1, "DegreeCelsius", "DegreeFahrenheit");
            double result       = UnitHandler.ConvertInput(convertModel, UnitsNet.QuantityType.Temperature);

            Assert.AreEqual(33.79999999999999d, result);
        }
Ejemplo n.º 2
0
        public void HandleNanometerToKilometer()
        {
            var    convertModel = new ConvertModel(1, "nanometer", "kilometer");
            double result       = UnitHandler.ConvertInput(convertModel, UnitsNet.QuantityType.Length);

            Assert.AreEqual(1E-12, result);
        }
Ejemplo n.º 3
0
        public void HandleLength()
        {
            var    convertModel = new ConvertModel(1, "meter", "centimeter");
            double result       = UnitHandler.ConvertInput(convertModel, UnitsNet.QuantityType.Length);

            Assert.AreEqual(100, result);
        }
Ejemplo n.º 4
0
        public void HandlesByteCapitals()
        {
            var    convertModel = new ConvertModel(1, "kB", "kb");
            double result       = UnitHandler.ConvertInput(convertModel, UnitsNet.QuantityType.Information);

            Assert.AreEqual(8, result);
        }
Ejemplo n.º 5
0
        public void HandleInvalidModel()
        {
            var convertModel = new ConvertModel(1, "aa", "bb");
            var results      = UnitHandler.Convert(convertModel);

            Assert.AreEqual(0, results.Count());
        }
Ejemplo n.º 6
0
    public void SetUnitCount(int Count)
    {
        // Iterate the existing units and destroy them
        for (int i = 0; i < Units.Count; i++)
        {
            Destroy(Units[i].Unit);
        }
        Units.Clear();
        // Create new units
        float AngleIncrement = 360f / Count;

        for (int i = 0; i < Count; i++)
        {
            float     UnitAngle  = i * AngleIncrement;
            Transform UnitObject = Instantiate(PlayerPrefab, transform);
            UnitObject.gameObject.layer = 8;
            UnitObject.localScale       = Size;
            UnitObject.GetComponent <SpriteRenderer>().sortingOrder = 3;
            UnitObject.GetComponent <SpriteRenderer>().color        = CurrentColor;
            // Add a collider
            BoxCollider2D Collider = UnitObject.gameObject.AddComponent <BoxCollider2D>();
            Collider.isTrigger = true;
            Rigidbody2D Body = UnitObject.gameObject.AddComponent <Rigidbody2D>();
            Body.isKinematic            = true;
            Body.collisionDetectionMode = CollisionDetectionMode2D.Continuous;
            // Add the unit class
            UnitHandler Handler = UnitObject.gameObject.AddComponent <UnitHandler>();
            Handler.Parent = this;

            Units.Add(new PlayerUnit(UnitObject.gameObject, UnitAngle));
        }
    }
Ejemplo n.º 7
0
Archivo: Unit.cs Proyecto: qrogers/VSCX
    public void Initialize(Vector3 position, Vector3 coordinates, Faction faction, UnitHandler unitHandler)
    {
        this.position      = position;
        this.coordinates   = coordinates;
        this.faction       = faction;
        this.unitHandler   = unitHandler;
        ready              = true;
        moving             = false;
        transform.position = position;
        targetVector       = transform.position;

        abilities = new Dictionary <string, Ability>();
        attacks   = new Dictionary <string, Ability>();

        Material[] materials = gameObject.GetComponent <MeshRenderer>().materials;
        switch (this.faction)
        {
        case Faction.Player:
            materials[0].color = new Color(0.0f, 0.0f, 1.0f);
            gameObject.GetComponent <MeshRenderer>().materials = materials;
            break;

        case Faction.Enemy:
            materials[0].color = new Color(1.0f, 0.0f, 0.0f);
            gameObject.GetComponent <MeshRenderer>().materials = materials;
            break;

        default:
            return;
        }
    }
Ejemplo n.º 8
0
        public void HandlesNanometerToParsec()
        {
            var convertModel = new ConvertModel(1, "nanometer", "parsec");
            var result       = UnitHandler.Convert(convertModel).Single();
            var str          = result.ToString(System.Globalization.CultureInfo.InvariantCulture);

            Assert.AreEqual(3.2408000000000005E-26, result.ConvertedValue);
            Assert.AreEqual("3.2408e-26 parsec", str);
        }
Ejemplo n.º 9
0
        public void HandlesParsecToNanometer()
        {
            var convertModel = new ConvertModel(1, "parsec", "nanometer");
            var result       = UnitHandler.Convert(convertModel).Single();
            var str          = result.ToString(System.Globalization.CultureInfo.InvariantCulture);

            Assert.AreEqual(3.0857000000000004E+25, result.ConvertedValue);
            Assert.AreEqual("3.0857e+25 nanometer", str);
        }
Ejemplo n.º 10
0
    private void Start()
    {
        uh   = this.GetComponent <UnitHandler>();
        ui_h = this.GetComponent <UIHandler>();

        if (cursor_main == null || cursor_inspect == null || cursor_grab == null)
        {
            DebugHandler.printWarning("MouseController", "Missing cursor texture, using defaults");
        }
    }
        /// <summary>
        /// Clear all of the currently displayed ActionUIs
        /// </summary>
        void ClearDisplayedActions()
        {
            Helper.LoopList_ForEach <GameObject>(DisplayedActions, (GameObject da) =>
            {
                Destroy(da);
            });

            DisplayedActions.Clear();
            DisplayedUnit = null;
        }
Ejemplo n.º 12
0
    private void Start()
    {
        GridSizeX = 2;
        GridSizeY = 2;

        completed = false;
        Name      = "Turret";
        ObjRadius = 40;

        state = TurretStates.Idle;

        units = GameObject.FindGameObjectWithTag("Units").GetComponent <UnitHandler>();
    }
Ejemplo n.º 13
0
        public Form1()
        {
            InitializeComponent();

            _messageHub = new MessageHub();
            _session    = new Session(_messageHub);
            _session.Init();

            var graphics = new WinFormGraphics(canvas);

            _scene = new Scene(_session, graphics);

            _mapHandler = new Editor.MapEditor(_messageHub, _session, canvas.Width / 20, canvas.Height / 20);
            // todo: replace with an OnChecked handler
            _mapHandler.ShowGrid(gridChk.Checked);
            _mapHandler.Init();

            _unitHandler = new UnitHandler(_messageHub, _session);
            _unitHandler.Init();

            // todo: is cameraHandler the responsibility of Map class?
            _cameraHandler = new CameraHandler(_messageHub, new Point(0, 0), canvas.Width, canvas.Height);
            _cameraHandler.Init();

            _input            = new Editor.EditorInput(_messageHub, _cameraHandler);
            _mouseState       = new MouseState();
            canvas.MouseMove += (sender, eventArgs) =>
            {
                _mouseState.GetState(eventArgs.Location, eventArgs.Button);
                _input.OnMouseEvent(_mouseState);
            };
            KeyPreview = true;
            KeyPress  += (sender, eventArgs) =>
            {
                _input.OnKeyboardEvent(eventArgs);
            };

            LoadTerrains();
            LoadUnits();

            var timer = new Timer();

            timer.Tick    += Update;
            timer.Interval = 100; // in miliseconds
            timer.Start();
        }
Ejemplo n.º 14
0
    /// <summary>
    /// 챔피언 구매시 빈 인벤토리 슬롯에 챔프를 배치하는 함수
    /// </summary>
    /// <param name="champ">상점에서 구입한 챔프</param>
    void CollocateChamp(ChampInstance champ)
    {
        UnitHandler unitHandler = champ.champion.GetComponentInChildren <UnitHandler>();

        // 빈 인벤토리 슬롯 찾아서 챔프를 옮긴다.
        foreach (var ele in _squareTiles)
        {
            if (ele.isEmpty)
            {
                champ.champion.transform.position = ele.tile.transform.position;
                champ.standingTile         = ele;
                champ.standingTile.isEmpty = false;
                champ.champion.SetActive(true);
                break;
            }
        }
    }
 /// <summary>
 /// Get the AIAgent to display the actions of
 /// </summary>
 void GetDisplayAgent()
 {
     DisplayedUnit = Helper.GetComponent <UnitHandler>(Selector.ClientInstance.GetFirstSelected);
     if (DisplayedUnit == null)
     {
         Helper.LoopList_ForEach <GameObject>(Selector.ClientInstance.SelectedObjects,
                                              // Loop Action
                                              (GameObject go) =>
         {
             DisplayedUnit = Helper.GetComponent <UnitHandler>(go);
         },
                                              // BreakOut Action
                                              () =>
         {
             return(DisplayedUnit);
         });
     }
 }
Ejemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        // Error Handling
        if (uiCanvas == null)
        {
            DebugHandler.printError("UIHandler", "No Canvas was found, please add one");
        }

        if ((uh = GetComponent <UnitHandler>()) == null)
        {
            DebugHandler.printError("UIHandler", "No UnitHandler was found on this object, please add one");
        }

        #region UI - Unit Selector
        // UI - Unit Selector (in the top)
        if (ui_unitSelectorPrefab == null)
        {
            DebugHandler.printWarning("UIHandler", "No UI Image (prefab) was found, if you want unit selection, then please add one");
        }
        else
        {
            // if no default image is found, then simply print out a warning message
            if (ui_unitSelector_defaultSprite == null)
            {
                DebugHandler.printWarning("UIHandler", "No default icon was found, if none is found, then a white box will be displayed");
            }

            unitSelectors = new ArrayList(uh.size);
            // Loop through all the unit actors and add a selection box for each one
            for (int i = 0; i < uh.size; i++)
            {
                Image img = Instantiate(ui_unitSelectorPrefab);

                // Game Object properties
                img.transform.SetParent(uiCanvas.transform);
                img.transform.position = new Vector2((unitSelector_rightOffset + img.rectTransform.rect.width + unitSelector_distanceBetween) * (i + 1),
                                                     uiCanvas.GetComponent <RectTransform>().rect.height - (img.rectTransform.rect.height / 2) - unitSelector_topOffset);   // divided by 2, since the anchor point is in the center of the image
                img.transform.name = "inst_UI_UnitSelector" + i;

                // +Properties handling
                for (int j = 0; j < img.transform.childCount; j++)
                {
                    // Placing a face icon on the unit selector (if none is found, then put the default one)
                    if (img.transform.GetChild(j).tag == TagHandler.UI_ICON)
                    {
                        Sprite tempSprite = ui_unitSelector_defaultSprite;

                        if (uh[i].GetComponent <UnitController>().Icon != null)
                        {
                            tempSprite = uh[i].GetComponent <UnitController>().Icon;
                        }

                        img.transform.GetChild(j).GetComponent <Image>().sprite = tempSprite;
                    }
                }

                // Setting the max health of the player and his current Health
                img.GetComponent <UI_UnitSelectorController>().MaxHealth = uh[i].GetComponent <UnitController>().maxHealth;

                unitSelectors.Add(img.GetComponent <UI_UnitSelectorController>());
            }
        }
        #endregion

        // FaceCam
        if (faceCamCanvas == null)
        {
            DebugHandler.printWarning("UIHandler", "No RawImage was found to hold the face cam");
        }


        #region Inventory
        // Inventory init
        if (ui_inventoryPrefab == null)
        {
            DebugHandler.printError("UIHandler", "No UI Inventory prefab was found");
        }
        else
        {
            if (ui_inventoryPrefab.GetComponent <BoxCollider2D>() == null)
            {
                DebugHandler.printError("UIHandler", "No box collider 2d was found! This component makes sure that you can drag items out of the units inventory");
            }
            else
            {
                unitInventory     = CreateInventoryWindow("inst_ui_Inventory_player(PRIMARY)", 0f);
                externalInventory = CreateInventoryWindow("inst_ui_Inventory_external(SECONDARY)", inventoryWindowOffset);

                unitInventory.GetComponent <UI_InventoryController>().ExternalInventoryBoundsReference     = externalInventory.GetComponent <BoxCollider2D>();
                externalInventory.GetComponent <UI_InventoryController>().ExternalInventoryBoundsReference = unitInventory.GetComponent <BoxCollider2D>();
            }
        }
        #endregion

        // Inventory Button
        if (ui_inventoryButton == null)
        {
            DebugHandler.printWarning("UIHandler", "No inventory button was found!");
        }

        if (ui_inspectorButton == null)
        {
            DebugHandler.printWarning("UIHandler", "No inspector button was found!");
        }

        // If the unit has a UnitMovementController scripts attached then give it a reference to this UIHandler, so that it can manipulate it
        for (int i = 0; i < uh.size; i++)
        {
            if (uh[i].GetComponent <UnitMovementController>() != null)
            {
                uh[i].GetComponent <UnitMovementController>().UI_Reference = this;
            }
        }
    }
Ejemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HomePageViewModel"/> class.
        /// Creates and sets defaults for the view model.
        /// </summary>
        public HomePageViewModel()
        {
            this.GoHome = null;

            this.Sync = new AsyncCommand(async(obj) =>
            {
                this.IsSyncing      = true;
                IApiRequest request = ServiceResolver.Resolve <IApiRequest>();
                var handler         = ServiceResolver.Resolve <IFileHandler>();

                var regions = await request.GetAsync <List <RegionModel> >(
                    $"{Constants.Endpoints.Regions}?{Constants.ApiOptions.ExcludeDeleted}");
                var regionResult = new RegionHandler()
                {
                    Regions = regions
                };
                await handler.SaveFileAsync(Constants.FileNames.Regions, regionResult);

                var stations = await request.GetAsync <List <StationModel> >(
                    $"{Constants.Endpoints.Stations}?{Constants.ApiOptions.ExcludeDeleted}");

                foreach (var station in stations)
                {
                    var stationItems = await request.GetAsync <List <ItemModel> >(
                        $"{Constants.Endpoints.Stations}/{station.Id}/items?{Constants.ApiOptions.ExcludeDeleted}");
                    station.Items = stationItems;
                }

                var stationResult = new StationHandler()
                {
                    Stations = stations
                };
                await handler.SaveFileAsync(Constants.FileNames.Stations, stationResult);

                var units = await request.GetAsync <List <UnitOfMeasureModel> >(
                    $"{Constants.Endpoints.Units}?{Constants.ApiOptions.ExcludeDeleted}");
                var unitResult = new UnitHandler()
                {
                    Units = units
                };
                await handler.SaveFileAsync(Constants.FileNames.Units, unitResult);

                //upload the current round. This needs to hapen first, so we can set all RoundId values on the readings.
                //var round = await UploadRoundAsync();
                //if(round != null && round.Id != Guid.Empty)
                //{
                //    //update the RoundId on all the readings PRIOR to sending to the server.
                //    await UploadReadingsAsync(round.Id);
                //}
                this.IsSyncing = false;
            }, this.CanSync);

            this.StartRound = new StartRoundCommand();
            var settings = ServiceResolver.Resolve <ISettings>();

            IsAdmin = settings.GetValue <bool>(Constants.UserAdminKey);

#if DEBUG
            IsAdmin = true;
#endif
        }
Ejemplo n.º 18
0
        public void RoundBigValue()
        {
            double result = UnitHandler.Round(1234567890123456.0);

            Assert.AreEqual(1234600000000000.0, result);
        }
Ejemplo n.º 19
0
        public void RoundNegativeValue()
        {
            double result = UnitHandler.Round(-3.141592653589793);

            Assert.AreEqual(-3.1416, result);
        }
Ejemplo n.º 20
0
        public void RoundNinesValue()
        {
            double result = UnitHandler.Round(999999999999.9998);

            Assert.AreEqual(1000000000000.0, result);
        }
Ejemplo n.º 21
0
 // Start is called before the first frame update
 void Start()
 {
     unitHandler = GetComponent <UnitHandler>();
 }
 private void Start()
 {
     u        = GetComponent <Unit>();
     uHandler = GetComponent <UnitHandler>();
 }
Ejemplo n.º 23
0
        public void RoundZero()
        {
            double result = UnitHandler.Round(0.0);

            Assert.AreEqual(0, result);
        }
Ejemplo n.º 24
0
        public void RoundSmallValue()
        {
            double result = UnitHandler.Round(1.23456789012345E-16);

            Assert.AreEqual(1.2346E-16, result);
        }
Ejemplo n.º 25
0
        public void RoundNormalValue()
        {
            double result = UnitHandler.Round(3.141592653589793);

            Assert.AreEqual(3.1416, result);
        }