/// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A <see cref="Acceleration"/>.</returns>
 public static Acceleration ToAcceleration <TValue>(
     this TValue value,
     SelectUnit <AccelerationUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Acceleration(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A <see cref="Temperature"/>.</returns>
 public static Temperature ToTemperature <TValue>(
     this TValue value,
     SelectUnit <TemperatureUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Temperature(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A <see cref="Illuminance"/>.</returns>
 public static Illuminance ToIlluminance <TValue>(
     this TValue value,
     SelectUnit <IlluminanceUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Illuminance(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A <see cref="LuminousFlux"/>.</returns>
 public static LuminousFlux ToLuminousFlux <TValue>(
     this TValue value,
     SelectUnit <LuminousFluxUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new LuminousFlux(Convert.ToDouble(value), unitSelector));
 }
Esempio n. 5
0
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The solid angle value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="SolidAngle"/>.</returns>
 public static SolidAngle ToSolidAngle <TValue>(
     this TValue value,
     SelectUnit <SolidAngleUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new SolidAngle(Convert.ToDouble(value), unitSelector));
 }
Esempio n. 6
0
    void UnitChoice(SelectUnit unit)
    {
        switch (unit)
        {
        case SelectUnit.Sword:
            createUnit(SwordMan, SwordFolder, PresetSword);
            break;

        case SelectUnit.Bow:
            createUnit(Archer, ArcherFolder, PresetArcher);
            break;

        case SelectUnit.Spear:
            createUnit(SpearMan, SpearFolder, PresetSpear);
            break;

        case SelectUnit.Work:
            createUnit(Worker, WorkerFolder, PresetWorker);
            break;

        case SelectUnit.Horse:
            createUnit(HorseMan, HorseFolder, PresetHorse);
            break;

        case SelectUnit.Catapult:
            createUnit(Catapult, CatapultFolder, PresetCatapult);
            break;

        default:
            break;
        }
    }
Esempio n. 7
0
 private void Selecting()
 {
     if (Input.GetMouseButton(0))
     {
         Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position);
         camPos.y = SelectUnit.InvertMouseY(camPos.y);
         contain  = SelectUnit.selection.Contains(camPos, true);
     }
     if (contain)
     {
         selected = true;
         transform.GetComponentInChildren <HPBar>().visible();
     }
     else if (SelectUnit.isDragged == true)
     {
         selected = false;
         transform.GetComponentInChildren <HPBar>().invisible();
     }
     else if (SelectUnit.isUnit == true)
     {
         selected = false;
         transform.GetComponentInChildren <HPBar>().invisible();
         if (SelectUnit.hitInfo.collider.transform.position == transform.position)
         {
             selected = true;
             transform.GetComponentInChildren <HPBar>().visible();
         }
     }
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The magnetic flux density value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="MagneticFluxDensity"/>.</returns>
 public static MagneticFluxDensity ToMagneticFluxDensity <TValue>(
     this TValue value,
     SelectUnit <MagneticFluxDensityUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new MagneticFluxDensity(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The electric current value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="ElectricCurrent"/>.</returns>
 public static ElectricCurrent ToElectricCurrent <TValue>(
     this TValue value,
     SelectUnit <ElectricCurrentUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new ElectricCurrent(Convert.ToDouble(value), unitSelector));
 }
Esempio n. 10
0
    private void Awake()
    {
        InitStats();

        navMeshAgent = GetComponent <NavMeshAgent>();
        FindObjectOfType <PathCreator>().OnNewPathCreated += SetPoints;
        selectUnit = GameObject.Find("UnitSelection").GetComponent <SelectUnit>();
        InitRange();
    }
Esempio n. 11
0
    // Start is called before the first frame update
    void Start()
    {
        Button     btn        = this.GetComponent <Button>();
        SelectUnit selectUnit = GameObject.Find("PlayerParty").GetComponent <SelectUnit>();

        btn.onClick.AddListener(
            delegate
        {
            selectUnit.SelectAction(type);
        });
    }
        /// <summary>
        /// Determines whether the specified value is within the interval.
        /// </summary>
        /// <typeparam name="TQuantity">The type of the quantity.</typeparam>
        /// <typeparam name="TUnitSelector">The type of the unit selector.</typeparam>
        /// <param name="quantity">The quantity.</param>
        /// <param name="min">The minimum.</param>
        /// <param name="max">The maximum.</param>
        /// <param name="unitSelector">The unit selector.</param>
        /// <param name="intervalMode">The interval mode.</param>
        /// <returns>
        ///   <c>true</c> if the specified quantity is within the interval, otherwise <c>false</c>.
        /// </returns>
        public static bool IsWithin <TQuantity, TUnitSelector>(
            this IQuantity <TQuantity, TUnitSelector> quantity,
            double min,
            double max,
            SelectUnit <TUnitSelector> unitSelector,
            IntervalMode intervalMode = IntervalMode.Inclusive)
            where TQuantity : IQuantity
        {
            var unit = UnitBuilder.BuildUnit(unitSelector(quantity.CreateUnitSelector()));

            return(quantity.ToDouble(unit).IsWithinInterval(min, max, intervalMode));
        }
Esempio n. 13
0
        protected override void OnUpdate()
        {
            Entity hitEntity;

            Entities
            .WithoutBurst()
            .WithStructuralChanges()
            .ForEach((
                         Entity entity,
                         int entityInQueryIndex,
                         ref MouseInput mouseInput
                         ) => {
                if (mouseInput.primaryAction == 0)
                {
                    return;
                }

                hitEntity = RaycastUtils.Raycast(
                    mouseInput.mousePosition,
                    out RaycastHit hit,
                    buildPhysicsWorldSystem
                    );

                if (hitEntity == Entity.Null)
                {
                    return;
                }

                if (EntityManager.HasComponent <SettlerTag>(hitEntity))
                {
                    SelectUnit.Create(hitEntity);
                    // EntityManager.AddComponentData<Selected>(hitEntity, new Selected {});
                    mouseInput.primaryAction = 0;

                    return;
                }

                HexCoordinates coordinates = CoordinatesService.GetCoordinatesFromPosition(hit.Position);
                Entity selectedEntity      = HexCellService.FindBy(coordinates);

                if (EntityManager.HasComponent <Selected>(selectedEntity))
                {
                    SelectCommand.Remove(coordinates);
                }
                else
                {
                    SelectCommand.Create(coordinates);
                }

                mouseInput.primaryAction = 0;
            })
            .Run();
        }
Esempio n. 14
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Ajoutez ici votre code d'initialisation
            puzzle = new Puzzle(Content);

            map   = new Map(Content, abscisseMap);
            units = new List <Unit>
            {
                new Unit(Content, abscisseMap / 32 + 1, 1, 7),
                new Unit(Content, abscisseMap / 32 + 5, 2, 7)
            };

            //Selection d'unités
            select = new SelectUnit(Content, units, map);

            base.Initialize();
        }
Esempio n. 15
0
    // When left mouse up
    private void RealeaseSelection()
    {
        SelectionBox.gameObject.SetActive(false);
        _selection = false;

        // If selection made by box
        if (_boxSelection)
        {
            Vector2 min = SelectionBox.anchoredPosition - (SelectionBox.sizeDelta / 2);
            Vector2 max = SelectionBox.anchoredPosition + (SelectionBox.sizeDelta / 2);

            // If there are units
            SelectUnits?.Invoke(min, max, _selectedUnits);
            _boxSelection = false;
            ShowUnitsInfo();
        }
        // If selection made by left mouse click
        else
        {
            // Drawing Raycast to detect if there is selectable object
            Vector3      worldPos = _manager.GameCamera.ScreenToWorldPoint(_startPos);
            RaycastHit2D hit      = Physics2D.Raycast(worldPos, Vector3.back, Mathf.Infinity);
            Debug.DrawRay(worldPos, Vector3.forward, Color.blue, 10f);

            // Publishing selection request to buildings
            SelectBuilding?.Invoke(hit, _selectedBuildings);

            // If there is building
            if (_selectedBuildings.Count > 0)
            {
                int          buildingIndex = _selectedBuildings[0].BuildingIndex;
                BuildingData buildingData  = _manager.GameConfig.Buildings[buildingIndex];
                _informationMenu.ShowBuildingInfo(buildingData);
            }
            // Else if there is unit
            else
            {
                // Publishing selection request to units
                SelectUnit?.Invoke(hit, _selectedUnits);
                ShowUnitsInfo();
            }
        }
    }
Esempio n. 16
0
 private void OnUnitListItemClick(UnitListItem item)
 {
     SelectUnit?.Invoke(item.UnitType);
 }
Esempio n. 17
0
 /// <summary>
 /// Converts the specified <see cref="TimeSpan"/> to <see cref="Time"/> with the specified unit.
 /// </summary>
 /// <param name="timeSpan">The time span.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>The <see cref="Time"/> quantity.</returns>
 public static Time ToTime(this TimeSpan timeSpan, SelectUnit <TimeUnitSelector> unitSelector)
 {
     return(((Time)timeSpan).ToUnit(unitSelector));
 }
Esempio n. 18
0
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The area value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Area"/>.</returns>
 public static Area ToArea <TValue>(this TValue value, SelectUnit <AreaUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Area(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The mass value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Mass"/>.</returns>
 public static Mass ToMass <TValue>(this TValue value, SelectUnit <MassUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Mass(Convert.ToDouble(value), unitSelector));
 }
Esempio n. 20
0
 private void GetSelectUnit()
 {
     SelectUnit = GameObject.Find("mainGame").GetComponent <mainGame>().SelectUnit; //fixme: 不知道有沒有更好的寫法
 }
Esempio n. 21
0
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The volume value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Volume"/>.</returns>
 public static Volume ToVolume <TValue>(this TValue value, SelectUnit <VolumeUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Volume(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A <see cref="Velocity"/>.</returns>
 public static Velocity ToVelocity <TValue>(this TValue value, SelectUnit <VelocityUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Velocity(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Converts the specified <see cref="TimeSpan"/> to <see cref="Time"/> with the specified unit.
 /// </summary>
 /// <param name="timeSpan">The time span.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>The <see cref="Time"/> quantity.</returns>
 public static Time ToTime(this TimeSpan timeSpan, SelectUnit<TimeUnitSelector> unitSelector)
 {
     return ((Time)timeSpan).ToUnit(unitSelector);
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Frequency"/>.</returns>
 public static Frequency ToFrequency <TValue>(this TValue value, SelectUnit <FrequencyUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Frequency(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The momentum value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Momentum"/>.</returns>
 public static Momentum ToMomentum <TValue>(this TValue value, SelectUnit <MomentumUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Momentum(Convert.ToDouble(value), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The energy value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Energy"/>.</returns>
 public static Energy ToEnergy <TValue>(this TValue value, SelectUnit <EnergyUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Energy(Convert.ToDouble(value), unitSelector));
 }
 public SelectUnitDescriptor(SelectUnit <T> unit) : base(unit)
 {
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The charge value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Charge"/>.</returns>
 public static Charge ToCharge <TValue>(this TValue value, SelectUnit <ChargeUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Charge(Convert.ToDouble(value), unitSelector));
 }
Esempio n. 29
0
    // Update is called once per frame
    void Update()
    {
        if (!photonView.isMine)
        {
            return;
        }
        if (Input.GetMouseButton(0))
        {
            Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position);
            camPos.y = SelectUnit.InvertMouseY(camPos.y);
            contain  = SelectUnit.selection.Contains(camPos, true);
        }
        if (contain)
        {
            if (transform.gameObject.layer == 11 && !SelectUnit.SelectedUnit.Contains(gameObject))
            {
                selected = true;
                SelectUnit.SelectedUnit.Add(gameObject);
            }
            else if (transform.gameObject.layer == 10)
            {
                if (!SelectUnit.SelectedBuilding.Contains(gameObject))
                {
                    if (SelectUnit.SelectedUnit.Count == 0)
                    {
                        selected = true;
                        SelectUnit.SelectedBuilding.Add(gameObject);
                    }
                    else
                    {
                        selected = false;
                    }
                }
                else
                {
                    if (SelectUnit.SelectedUnit.Count > 0)
                    {
                        selected = false;
                        SelectUnit.SelectedBuilding.Remove(gameObject);
                    }
                }
            }
        }
        else if (SelectUnit.isDragged == true)
        {
            selected = false;
            if (gameObject.layer == 11)
            {
                SelectUnit.SelectedUnit.Remove(gameObject);
            }
            else
            {
                SelectUnit.SelectedBuilding.Remove(gameObject);
            }

            /*if (transform.gameObject.layer == 11)
             * {
             *  SelectUnit.SelectedUnit.Remove(gameObject);
             * }
             * else if (SelectUnit.SelectedUnit.Count == 0)
             * {
             *  SelectUnit.SelectedBuilding.Remove(gameObject);
             * }*/
        }
        else if (SelectUnit.isUnit)
        {
            selected = false;
            if (gameObject.layer == 11)
            {
                SelectUnit.SelectedUnit.Remove(gameObject);
            }
            else
            {
                SelectUnit.SelectedBuilding.Remove(gameObject);
            }
            if (gameObject.layer == 11 && SelectUnit.hitInfo.collider.transform.position == transform.position) // 수정 하기 (핸드폰 단일선택 불가 문제)
            {
                selected = true;
                SelectUnit.SelectedUnit.Add(gameObject);
            }
        }
        else if (SelectUnit.isBuilding)
        {
            selected = false;
            if (gameObject.layer == 11)
            {
                SelectUnit.SelectedUnit.Remove(gameObject);
            }
            else
            {
                SelectUnit.SelectedBuilding.Remove(gameObject);
            }
            if (gameObject.layer == 10 && SelectUnit.hitInfo.collider.transform.position == transform.position) // 수정 하기 (핸드폰 단일선택 불가 문제)
            {
                selected = true;
                SelectUnit.SelectedBuilding.Add(gameObject);
            }
        }
        if (selected == true)
        {
            transform.GetComponentInChildren <HPBar>().visible();
        }
        else
        {
            transform.GetComponentInChildren <HPBar>().invisible();
        }
    }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="time">The time value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Time" />.</returns>
 public static Time ToTime <TValue>(this TValue time, SelectUnit <TimeUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Time(Convert.ToDouble(time), unitSelector));
 }
 /// <summary>
 /// Gets the value as the specified unit.
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="value">The power value.</param>
 /// <param name="unitSelector">The unit selector.</param>
 /// <returns>A new <see cref="Power"/>.</returns>
 public static Power ToPower <TValue>(this TValue value, SelectUnit <PowerUnitSelector> unitSelector)
     where TValue : struct, IComparable, IFormattable
 {
     return(new Power(Convert.ToDouble(value), unitSelector));
 }