/// <summary>
        /// Compare outputs in text files and SQLite database for given SWAT unit
        /// </summary>
        /// <param name="source">SWAT unit type</param>
        /// <returns>Average R2</returns>
        /// <remarks>
        /// 1. R2 is calculated for each column
        /// 2. A text file would be created on desktop to record R2 for all columns
        /// </remarks>
        public double Compare(UnitType source)
        {
            using(StreamWriter file = new StreamWriter(
                Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop), source.ToString() + "_" + _extractText.OutputInterval.ToString() + "_validation.txt")))
                {
                    string[] cols = ExtractSWAT_SQLite.GetSQLiteColumns(source);
                    if (cols == null) return -99.0;

                    double mean_R2 = 0;
                    int num_R2 = 0;
                    foreach (string col in cols)
                    {
                        double R2 = Compare(source, col,file);
                        if (R2 > -99)
                        {
                            mean_R2 += R2;
                            num_R2 += 1;
                        }
                    }

                    if (num_R2 > 0)
                        return mean_R2 / num_R2;
                    return -99.0;
                }
        }
 protected AbstractStructure(CityType requiredCityType, decimal buildCost, int capacity, UnitType unitType)
 {
     RequiredCityType = requiredCityType;
     BuildCost = buildCost;
     Capacity = capacity;
     UnitType = unitType;
 }
        public double Compare(UnitType source)
        {
            //System.Diagnostics.Debug.WriteLine("------------------" + source.ToString() + "------------------");

            using(System.IO.StreamWriter file = new System.IO.StreamWriter(
                System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop), source.ToString() + "_validation.txt")))
                {
                    string[] cols = ExtractSWAT_SQLite.GetSQLiteColumns(source);
                    if (cols == null) return -99.0;

                    double mean_R2 = 0;
                    int num_R2 = 0;
                    foreach (string col in cols)
                    {
                        double R2 = Compare(source, col,file);
                        if (R2 > -99)
                        {
                            mean_R2 += R2;
                            num_R2 += 1;
                        }
                    }

                    if (num_R2 > 0)
                        return mean_R2 / num_R2;
                    return -99.0;
                }
        }
 public void UpdatePlayerState(UnitType playerState)
 {
     foreach (NPC npc in Units)
     {
         npc.ToggleSpotted(npc.UnitType == playerState);
     }
 }
        /// <summary>
        /// Validate SQLite results for given unit type and column. Here same column name are assumed for bother
        /// SQLite and regular text file. But some column names have been changed in SQLite results. For these 
        /// columns, a lookup table should be used.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="var"></param>
        /// <returns></returns>
        public double Compare(UnitType source, string var, System.IO.StreamWriter file)
        {
            //System.Diagnostics.Debug.WriteLine("***************" + var.Trim() + "***************");

            int num = getNumberofUnit(source);
            if (source == UnitType.RSV) num = getNumberofUnit(UnitType.SUB);
            if (num == -1) return -99.0;

            double mean_R2 = 0;
            int num_R2 = 0;

            for (int i = 1; i <= num; i++)
            {
                double R2 = Compare(_startYear, _endYear, source, i, var);
                if (R2 > -99)
                {
                    mean_R2 += R2;
                    num_R2 += 1;
                    System.Diagnostics.Debug.WriteLine(string.Format("{0}-{1}-{2},{3:F4}", source, i, var.Trim(), R2));
                    file.WriteLine(string.Format("{0},{1},{2},{3:F4}", source, i, var.Trim(), R2));
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("{0}-{1}-{2},No Record", source, i, var.Trim()));
                    file.WriteLine(string.Format("{0},{1},{2},NoRecord", source, i, var.Trim()));
                }
            }

            if (num_R2 > 0)
                return mean_R2 / num_R2;
            return -99.0;
        }
        public void DrawUnit(HexTilePosition pos, UnitType type)
        {
            Vector3 mapPos = RenderHex.HexPositionToMapPosition(pos);
            render.PushWorldMatrix(Matrix.CreateTranslation(mapPos));

            switch (type)
            {
                case UnitType.Unknown:
                    DrawUnknown();
                    break;

                case UnitType.Infantry:
                    DrawInfantry();
                    break;

                case UnitType.Armor:
                    DrawArmor();
                    break;

                case UnitType.Artillery:
                    DrawArtillery();
                    break;

                default:
                    DrawInvalid();
                    break;
            }

            render.PopWorldMatrix();
        }
Beispiel #7
0
 /// <summary>
 /// Create a new FieldData object
 /// </summary>
 /// <param name="name">The name of the field</param>
 /// <param name="typeIn">The AssemblyQualifiedName of the Field's data type</param>
 /// <param name="unit">The unit type of the Field (set to UT_Undefined for non-floating point types</param>
 /// <param name="subSchema">The SchemaWrapper of the field's subSchema, if the field is of type "Entity"</param>
 public FieldData(string name, string typeIn, UnitType unit, SchemaWrapper subSchema)
 {
     m_Name = name;
      m_Type = typeIn;
      m_Unit = unit;
      m_SubSchema = subSchema;
 }
    // ------------------------------------------------------------------------------------ //
    public static UnitBase createNewUnit(UnitType unitType)
    {
        GameObject unitGameObject = new GameObject ("Unit" + unitType.ToString());
        unitGameObject.tag = UnitBase.UNIT_TAG;

        UnitBase unitBase = null;

        if (unitType == UnitType.ZombieSober) {
            unitBase = unitGameObject.AddComponent<UnitZombieSober>();
        }
        else if (unitType == UnitType.ZombieDrunk) {
            unitBase = unitGameObject.AddComponent<UnitZombieDrunk>();
        }
        else if (unitType == UnitType.ManDrunk) {
            unitBase = unitGameObject.AddComponent<UnitManDrunk>();
        }
        else {
            SLog.logError("UnitFactory createNewUnit(): unknown type == " + unitType.ToString());
        }

        if (unitBase != null)
        {
            unitBase.setUnitType(unitType);
            unitBase.initialize();
        }

        return unitBase;
    }
Beispiel #9
0
    //constructor
    public static Unit CreateComponent( UnitType unitType, Tile location, Village v, GameObject PeasantPrefab )
    {
        Tile toplace = null;
        foreach (Tile a in location.getNeighbours())
        {
            if(a.prefab == null && a.getOccupyingUnit() == null && a.getColor() == location.getColor())
            {
                toplace = a;
            }
        }
        if(toplace == null)
        {
            toplace = location;
        }
        GameObject o = Instantiate(PeasantPrefab, new Vector3(toplace.point.x, 0.15f, toplace.point.y), toplace.transform.rotation) as GameObject;
        Unit theUnit = o.AddComponent<Unit>();
        theUnit.locatedAt = toplace;

        theUnit.myType = unitType;
        theUnit.myVillage = v;
        theUnit.myAction = UnitActionType.ReadyForOrders;

        location.setOccupyingUnit (theUnit);
        return theUnit;
    }
Beispiel #10
0
 public ArmyStructure(CityType requiredCityType, decimal buildCost, int capacity, UnitType unitType)
 {
     this.RequiredCityType = requiredCityType;
     this.BuildCost = buildCost;
     this.Capacity = capacity;
     this.UnitType = unitType;
 }
Beispiel #11
0
 public Unit(House owner, UnitType type, bool alive, string name)
 {
     Owner = owner;
     Type = type;
     Alive = alive;
     Name = name;
 }
Beispiel #12
0
 public void buyUnit(UnitType unitType_)
 {
     Unit newUnit = new Unit(unitType_, _players[_currentPlayerIndex]._race);
     //map.placeNewUnit(_players[currentPlayerIndex],newUnit); //beállítja a pozíciót a unitnál-is!!!!!
     _players[_currentPlayerIndex]._units.Add(newUnit);
     _players[_currentPlayerIndex]._money -= newUnit._stats._price;
 }
Beispiel #13
0
 public Unit(int value)
 {
     if (value < -32768 || value > 0x7fff)
         throw new ArgumentOutOfRangeException("value");
     _value = value;
     _type = UnitType.Pixel;
 }
Beispiel #14
0
        public static IUnit Create(UnitType type, string name, int x, int y)
        {
            IUnit unit;

            switch (type)
            {
                case UnitType.IceGiant:
                    unit = new IceGiant(x, y, name, new IceGigantCombatHandler());
                    break;

                case UnitType.Mage:
                    unit = new Mage(x, y, name, new MageCombatHandler());
                    break;

                case UnitType.Warrior:
                    unit = new Warrior(x, y, name, new WarriorCombatHandler());
                    break;

                default:
                    throw new NotImplementedException();
            }

            unit.CombatHandler.Unit = unit;

            return unit;
        }
 internal CSSPrimitiveValue(HtmlColor value)
 {
     _text = value.ToCss();
     _type = CssValueType.PrimitiveValue;
     unit = UnitType.Rgbcolor;
     data = value;
 }
Beispiel #16
0
 public Unit(string unitId, String unitName, UnitType uType, List<string> components)
 {
     this.ID            = unitId;
     this.Name          = unitName;
     this.unitType      = uType;
     this.ComponentSpec = components ?? new List<string>();
 }
Beispiel #17
0
    public int GetUnitCountByType(UnitType type)
    {
        if(!mUnitsByType.ContainsKey(type))
            return 0;

        return mUnitsByType[type].Count;
    }
 /// <summary>
 /// Sets the primitive value to the given number.
 /// </summary>
 /// <param name="unitType">The unit of the number.</param>
 /// <param name="value">The value of the number.</param>
 /// <returns>The CSS primitive value instance.</returns>
 public CSSPrimitiveValue SetFloatValue(UnitType unitType, Single value)
 {
     _text = value.ToString(CultureInfo.InvariantCulture) + ConvertUnitTypeToString(unitType);
     unit = unitType;
     data = value;
     return this;
 }
Beispiel #19
0
 public BirdModel(UnitType type, double maxJumpSpeed, double minJumpFactor)
     : base(type)
 {
     JumpSpeed = maxJumpSpeed;
     MinJumpFactor = minJumpFactor;
     Position = new Vector { X = 0, Y = 0 };
 }
Beispiel #20
0
 /// <devdoc>
 /// <para> Initializes a new instance of the <see cref='System.Web.UI.WebControls.Unit'/> structure with the 
 ///    specified double-precision
 ///    floating point number as the unit value and <see langword='Pixel'/>
 ///    as the (default) unit type.</para>
 /// </devdoc>
 public Unit(double value) {
     if ((value < MinValue) || (value > MaxValue)) {
         throw new ArgumentOutOfRangeException("value");
     }
     this.value = (int)value;
     this.type = UnitType.Pixel;
 }
Beispiel #21
0
	public void Initialise(UnitBaseData data){
		Type = data.Type;
		BaseData = data;
		CurrentBaseHP = data.HP;
		Prisoner = false;
		Defending = false;
	}
Beispiel #22
0
 /// <summary>Creates a new <see cref="Unit"/> instance.
 /// </summary>
 /// <param name="type">Type.</param>
 /// <param name="power">Power.</param>
 /// <param name="location">Location.</param>
 public Unit(UnitType type, Power power, Location location)
 {
     this.type = type;
     this.power = power;
     this.location = location;
     this.retreatLocations = new LocationCollection();
 }
Beispiel #23
0
 public UnitType GetHallucination(UnitType t)
 {
     switch (t)
     {
         case UnitType.Probe:
             return UnitType.ProbeHallucination;
         case UnitType.Zealot:
             return UnitType.ZealotHallucination;
         case UnitType.Stalker:
             return UnitType.StalkerHallucination;
         case UnitType.HighTemplar:
             return UnitType.HighTemplarHallucination;
         case UnitType.Archon:
             return UnitType.ArchonHallucination;
         case UnitType.Immortal:
             return UnitType.ImmortalHallucination;
         case UnitType.WarpPrism:
             return UnitType.WarpPrismHallucination;
         case UnitType.WarpPrismPhasing:
             return UnitType.WarpPrismPhasingHallucination;
         case UnitType.Colossus:
             return UnitType.ColossusHallucination;
         case UnitType.Phoenix:
             return UnitType.PhoenixHallucination;
         case UnitType.VoidRay:
             return UnitType.VoidRayHallucination;
         default:
             return UnitType.Unknown; // Could throw, but it doesn't break the parser.
     }
 }
        /// <summary>
        /// Gets the unit of a type.
        /// </summary>
        /// <param name="unitType">The unit type.</param>
        /// <returns>The Unit object.</returns>
        public IFCUnit GetIFCProjectUnit(UnitType unitType)
        {
            IFCUnit projectUnit = null;
            if (m_ProjectUnitsDictionary.TryGetValue(unitType, out projectUnit))
            {
                return projectUnit;
            }
            else
            {
                //default units
                if (unitType == UnitType.UT_Length)
                {
                    IFCUnit unit = IFCUnit.ProcessIFCDefaultUnit(unitType, UnitSystem.Metric, UnitName.DUT_METERS, 1.0 / 0.3048);
                    m_ProjectUnitsDictionary[unitType] = unit;
                    return unit;
                }
                else if (unitType == UnitType.UT_Area)
                {
                    IFCUnit projectLengthUnit = GetIFCProjectUnit(UnitType.UT_Length);

                    UnitSystem unitSystem = projectLengthUnit.UnitSystem;
                    UnitName unitName = unitSystem == UnitSystem.Metric ?
                        UnitName.DUT_SQUARE_METERS : UnitName.DUT_SQUARE_FEET;
                    double scaleFactor = unitSystem == UnitSystem.Metric ?
                        (1.0 / 0.3048) * (1.0 / 0.3048) : 1.0;

                    IFCUnit unit = IFCUnit.ProcessIFCDefaultUnit(unitType, unitSystem, unitName, scaleFactor);
                    m_ProjectUnitsDictionary[unitType] = unit;
                    return unit;
                }
                else if (unitType == UnitType.UT_Volume)
                {
                    IFCUnit projectLengthUnit = GetIFCProjectUnit(UnitType.UT_Length);

                    UnitSystem unitSystem = projectLengthUnit.UnitSystem;
                    UnitName unitName = unitSystem == UnitSystem.Metric ?
                        UnitName.DUT_CUBIC_METERS : UnitName.DUT_CUBIC_FEET;
                    double scaleFactor = unitSystem == UnitSystem.Metric ?
                        (1.0 / 0.3048) * (1.0 / 0.3048) * (1.0 / 0.3048) : 1.0;

                    IFCUnit unit = IFCUnit.ProcessIFCDefaultUnit(unitType, unitSystem, unitName, scaleFactor);
                    m_ProjectUnitsDictionary[unitType] = unit;
                    return unit;
                }
                else if (unitType == UnitType.UT_Angle)
                {
                    IFCUnit unit = IFCUnit.ProcessIFCDefaultUnit(unitType, UnitSystem.Metric, UnitName.DUT_DECIMAL_DEGREES, Math.PI / 180);
                    m_ProjectUnitsDictionary[unitType] = unit;
                    return unit;
                }
                else if (unitType == UnitType.UT_HVAC_Temperature)
                {
                    IFCUnit unit = IFCUnit.ProcessIFCDefaultUnit(unitType, UnitSystem.Metric, UnitName.DUT_KELVIN, 1.0);
                    m_ProjectUnitsDictionary[unitType] = unit;
                    return unit;
                }
            }
            return null;
        }
Beispiel #25
0
 public static UnitInfo Get(UnitType t)
 {
     if (infos == null)
         infos = new SortedDictionary<UnitType, UnitInfo>();
     if (!infos.ContainsKey(t))
         Create(t);
     return infos[t];
 }
Beispiel #26
0
 private static Feature CreateFeature(double x, double y, UnitType unitType)
 {
     return new Feature
     {
         Geometry = new Point(x, y),
         Styles = new List<IStyle> {new SymbolStyle {UnitType = unitType}}
     };
 }
Beispiel #27
0
    public void UnitTypeIDTest()
    {
        UnitType testObj = new UnitType ();

        testObj.ID = 99;

        Assert.AreEqual (99, testObj.ID);
    }
Beispiel #28
0
	public Unit AddUnit(UnitType type) {
		Unit u = ScriptableObject.CreateInstance<Unit>();
		u.Initialise(_UnitDataManager.GetData(type));
		units.Add(u);
		u.OnUpdate += unitUpdated;
		OnAddUnit(u);
		return u;
	}
Beispiel #29
0
    public void UnitTypeNameTest()
    {
        UnitType testObj = new UnitType ();

        testObj.Name = "Test Name";

        Assert.AreEqual ("Test Name", testObj.Name);
    }
Beispiel #30
0
    /// <summary>
    /// Initializes a new instance of the Unit class.
    /// Throws System.ArgumentException if <code>type</code> is invalid.
    /// </summary>
    public Unit(double value, UnitType type)
    {
      if (!Enum.IsDefined(typeof(UnitType), type))
        throw new InvalidEnumArgumentException("type", (int)type, type.GetType());

      this.value = (float)value;
      this.type = type;
      this.initialized = true;
    }
Beispiel #31
0
    void OnMouseDown()
    {
        Debug.Log("ClickIcon()");

        // selected unit's coords
        int posX = GlobalVariables.selectedUnit.x;
        int posY = GlobalVariables.selectedUnit.y;

        // reset Icon animations
        if (GlobalVariables.freezeIconHUD)
        {
            GlobalFunctions.CleanUpHUDIcons();
        }
        // light up this icon
        if (!GlobalVariables.freezeIconHUD && GlobalVariables.unitsMatrix[GlobalVariables.selectedUnit.x, GlobalVariables.selectedUnit.y].canAct)            // || true
        {
            this.GetComponent <HoverIcon>().PlayLit();
            GlobalVariables.freezeIconHUD = true;
        }
        else
        {
            GlobalVariables.freezeIconHUD = false;
        }

        if (!GlobalVariables.freezeHUD)           // || true

        // reset status icon LOWER
        {
            if (!GlobalVariables.freezeIconHUD)
            {
                GlobalFunctions.DestroyGameObject("statusIconLOWER");
            }

            // clean up available cells
            GlobalFunctions.RemoveAvailableCellsFromAllUnits();
            GlobalFunctions.RemoveDisplayAvailableCellsFromAllUnits();
            // bool thisUnitCanAct =  GlobalVariables.unitsMatrix[ GlobalVariables.selectedUnit.x,GlobalVariables.selectedUnit.y ].canAct;
            UnitType thisUnit = GlobalVariables.unitsMatrix[GlobalVariables.selectedUnit.x, GlobalVariables.selectedUnit.y];
            // wipe upper panel battle log
            GlobalFunctions.CleanUpBattleLog();

            if (thisUnit.canAct && thisUnit.stamina >= GlobalVariables.lightAttackSTAcost && lightAttack)
            {
                GlobalFunctions.DisplayBattleOptionInfo(Enums.BattleOption.LightAttack);
                // determine threat cells
                GlobalVariables.unitsMatrix[posX, posY].threatCells = GlobalFunctions.FindThreatCells(GlobalVariables.unitsMatrix[posX, posY].lightAttackRange, posX, posY);
                // set battleOption and display threat cells
                if (GlobalVariables.freezeIconHUD)
                {
                    GlobalFunctions.DisplayThreatCells(posX, posY);
                    GlobalVariables.unitsMatrix[posX, posY].battleOption = Enums.BattleOption.LightAttack;
                }
                else
                {
                    GlobalFunctions.DestroyGameObject("battleOptionIcon");
                }
            }
            else if (thisUnit.canAct && thisUnit.stamina >= GlobalVariables.heavyAttackSTAcost && heavyAttack)
            {
                GlobalFunctions.DisplayBattleOptionInfo(Enums.BattleOption.HeavyAttack);
                // determine threat cells
                GlobalVariables.unitsMatrix[posX, posY].threatCells = GlobalFunctions.FindThreatCells(GlobalVariables.unitsMatrix[posX, posY].heavyAttckRange, posX, posY);
                // set battleOption and display threat cells
                if (GlobalVariables.freezeIconHUD)
                {
                    GlobalFunctions.DisplayThreatCells(posX, posY);
                    GlobalVariables.unitsMatrix[posX, posY].battleOption = Enums.BattleOption.HeavyAttack;
                }
                else
                {
                    GlobalFunctions.DestroyGameObject("battleOptionIcon");
                }
            }
            else if (thisUnit.canAct && useItem)
            {
                GlobalFunctions.DisplayBattleOptionInfo(Enums.BattleOption.UseItem);
                Debug.Log("Use Item clicked!");
            }
            else if (thisUnit.canAct && rally)
            {
                GlobalFunctions.DisplayBattleOptionInfo(Enums.BattleOption.Rally);
                // perform Rally
                GlobalFunctions.CombatRally(posX, posY);
                // set battleOption
                if (GlobalVariables.freezeIconHUD)
                {
                    GlobalVariables.unitsMatrix[posX, posY].battleOption = Enums.BattleOption.Rally;
                }
            }
            else if (thisUnit.canAct && castSpell)
            {
                GlobalFunctions.DisplayBattleOptionInfo(Enums.BattleOption.CastSpell);
                // Debug.Log("Cast Spell clicked!");
            }
            else if (thisUnit.canAct && specialAbility)
            {
                GlobalFunctions.DisplayBattleOptionInfo(Enums.BattleOption.SpecialAbility);
                // Debug.Log("Special Ability clicked!");
            }
            else if (endTurn)
            {
                // Debug.Log("End Turn clickd!");
                GlobalFunctions.DisplayBattleOptionInfo(Enums.BattleOption.EndTurn);
                GlobalFunctions.CombatEndTurn(GlobalVariables.initRoster[0].posX, GlobalVariables.initRoster[0].posY);
                // CombatEndTurn > CheckForEndOfTurn wipes selectedUnit values, but we still need them in this scenario
                GlobalVariables.selectedUnit.x = posX;
                GlobalVariables.selectedUnit.y = posY;
                // lift the freeze, we're done here
                GlobalVariables.freezeIconHUD = false;
            }
        }         // if canAct
    }
Beispiel #32
0
 public UnitModel(UnitType unitType)
 {
     UnitType = unitType;
 }
Beispiel #33
0
 public static void UnitSprite(Graphics g, UnitType type, bool isSleeping, bool isFortified, int zoom, Point dest)
 {
     UnitSprite(g, (int)type, isSleeping, isFortified, zoom, dest);
 }
 public FontUnit(double value, UnitType type)
 {
 }
        public override bool Selectunit(int syn = 0) // 0 "dBm", 1 "W"
        {
            lock (syncRoot)
            {
                bool   flag        = false;
                string strUnitType = "";

                switch (UnitType)
                {
                case "0":
                    strUnitType = "dBm";
                    break;

                case "1":
                    strUnitType = "W";
                    break;

                default:
                    strUnitType = "dBm";
                    break;
                }

                try
                {
                    if (syn == 0)
                    {
                        Log.SaveLogToTxt("PowerMeterSlot is " + PowerMeterSlot +
                                         ", DeviceChannel is " + DeviceChannel + ", UnitType is " + strUnitType);
                        return(this.WriteString(":SENSe:POWer:UNIT " + PowerMeterSlot + "," + DeviceChannel + "," + UnitType));
                    }
                    else
                    {
                        bool   tempFlag = false;
                        string readtemp = "";
                        int    k        = 0;

                        for (int i = 0; i < 3; i++)
                        {
                            tempFlag = this.WriteString(":SENSe:POWer:UNIT " + PowerMeterSlot + "," + DeviceChannel + "," + UnitType);

                            if (tempFlag)
                            {
                                break;
                            }
                        }

                        if (tempFlag)
                        {
                            for (k = 0; k < 3; k++)
                            {
                                Thread.Sleep(100);
                                this.WriteString(":SENSe:POWer:UNIT? " + PowerMeterSlot + "," + DeviceChannel);

                                readtemp = this.ReadString();
                                if (readtemp.Trim().ToUpper() == UnitType.Trim().ToUpper())
                                {
                                    break;
                                }
                            }

                            if (k <= 2)
                            {
                                Log.SaveLogToTxt("PowerMeterSlot is " + PowerMeterSlot +
                                                 ", DeviceChannel is " + DeviceChannel + ", UnitType is " + strUnitType);
                                flag = true;
                            }
                            else
                            {
                                Log.SaveLogToTxt("PowerMeter Select UnitType wrong");
                            }
                        }

                        return(flag);
                    }
                }
                catch (Exception error)
                {
                    Log.SaveLogToTxt(error.ToString());

                    return(false);
                }
            }
        }
Beispiel #36
0
        internal Unit(string value, CultureInfo culture, UnitType defaultType)
        {
            if (String.IsNullOrEmpty(value))
            {
                this.value = 0;
                this.type  = (UnitType)0;
            }
            else
            {
                if (culture == null)
                {
                    culture = CultureInfo.CurrentCulture;
                }

                // This is invariant because it acts like an enum with a number together.
                // The enum part is invariant, but the number uses current culture.
                var trimLcase = value.Trim().ToLower(CultureInfo.InvariantCulture);
                var len       = trimLcase.Length;

                var lastDigit = -1;
                for (var i = 0; i < len; i++)
                {
                    var ch = trimLcase[i];
                    if (((ch < '0') || (ch > '9')) && (ch != '-') && (ch != '.') && (ch != ','))
                    {
                        break;
                    }
                    lastDigit = i;
                }
                if (lastDigit == -1)
                {
                    // TODO: Localize
                    //throw new FormatException(SR.GetString(SR.UnitParseNoDigits, value));
                    throw new FormatException();
                }
                if (lastDigit < len - 1)
                {
                    type = (UnitType)GetTypeFromString(trimLcase.Substring(lastDigit + 1).Trim());
                }
                else
                {
                    type = defaultType;
                }

                var numericPart = trimLcase.Substring(0, lastDigit + 1);
                // Cannot use Double.FromString, because we don't use it in the ToString implementation
                try
                {
                    TypeConverter converter = new SingleConverter();
                    this.value = (Single)converter.ConvertFromString(null, culture, numericPart);

                    if (type == UnitType.Pixel)
                    {
                        this.value = (int)this.value;
                    }
                }
                catch
                {
                    // TODO: Localize
                    //throw new FormatException(SR.GetString(SR.UnitParseNumericPart, value, numericPart, type.ToString("G")));
                    throw new FormatException();
                }
                if ((this.value < MinValue) || (this.value > MaxValue))
                {
                    throw new ArgumentOutOfRangeException("value");
                }
            }
        }
Beispiel #37
0
 public CellGroup(UnitType uT)
 {
     _groupType = uT;
     index      = 0;
 }
Beispiel #38
0
        /// <summary>
        /// Gets the unit type from an IFC data.
        /// </summary>
        /// <param name="data">The IFC data.</param>
        /// <param name="defaultType">The default value, if no type is found.</param>
        /// <returns>The unit type.</returns>
        public static UnitType GetUnitTypeFromData(IFCData data, UnitType defaultType)
        {
            string propertyType;

            return(GetUnitTypeFromData(data, defaultType, out propertyType));
        }
Beispiel #39
0
        public Bullet(Vector2 direction, float distance, float speed, float attack, Vector2 position, float height, float rotation, float radius, UnitType type, int ownerUnitID, Team team, Entity root) : base(position, height, rotation, CollisionType.None, radius, type, ownerUnitID, team, root)
        {
            AddInheritedType(typeof(Bullet));

            this.direction = direction;
            this.distance  = distance;
            this.speed     = speed;
            this.attack    = attack;

            remainDistance = distance;
        }
Beispiel #40
0
        public static DisplayUnitType DisplayUnitType(this UnitType unitType)
        {
            if (unitType == UnitType.UT_Number)
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_UNDEFINED);
            }

            IEnumerable <DisplayUnitType> displayUnitTypes = UnitUtils.GetValidDisplayUnits(unitType);

            if (displayUnitTypes == null || displayUnitTypes.Count() == 0)
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_UNDEFINED);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_UNDEFINED))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_UNDEFINED);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_METERS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_METERS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_KILOGRAMS_MASS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_KILOGRAMS_MASS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_CELSIUS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_CELSIUS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_AMPERES))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_AMPERES);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_WATTS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_WATTS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_WATTS_PER_CUBIC_METER))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_WATTS_PER_CUBIC_METER);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_CUBIC_METERS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_CUBIC_METERS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_SQUARE_METERS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_SQUARE_METERS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_CUBIC_METERS_PER_SECOND))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_CUBIC_METERS_PER_SECOND);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_WATTS_PER_SQUARE_METER))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_WATTS_PER_SQUARE_METER);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_VOLTS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_VOLTS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_KILOGRAMS_FORCE))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_KILOGRAMS_FORCE);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_LUX))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_LUX);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_LUMENS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_LUMENS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_LUMENS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_LUMENS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_PASCALS))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_PASCALS);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_PASCALS_PER_METER))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_PASCALS_PER_METER);
            }

            if (displayUnitTypes.Contains(Autodesk.Revit.DB.DisplayUnitType.DUT_KILOGRAMS_PER_CUBIC_METER))
            {
                return(Autodesk.Revit.DB.DisplayUnitType.DUT_KILOGRAMS_PER_CUBIC_METER);
            }

            return(Autodesk.Revit.DB.DisplayUnitType.DUT_UNDEFINED);
        }
Beispiel #41
0
 public MyUnit(UnitType type, int id)
     : base(type, id)
 {
     Init();
 }
Beispiel #42
0
 public MyUnit(UnitType type)
     : base(type)
 {
     Init();
 }
    /// <summary>
    /// 创建单位
    /// </summary>
    /// <param name="unitType">单位类型</param>
    /// <param name="dataId">数据ID</param>
    /// <returns>地图单元类</returns>
    public T CreateUnit <T>(UnitType unitType, int dataId) where T : MapCellBase
    {
        // 地图单元与障碍物使用相同单元替换Image的方式进行服用, 来解决创建单位过多问题
        MapCellBase result = null;

        switch (unitType)
        {
        // ---------------------------加载数据进行替换模式----------------------------
        case UnitType.MapCell:     // 地图单元
        {
            result = new MapCell(null, dataId, MapManager.MapBaseLayer);
        }
        break;

        case UnitType.Obstacle:     // 障碍物
        {
            var go = GetGameObject(MapCellTableName,
                                   dataId,
                                   MapDrawer.Single.ItemParentList[MapManager.MapObstacleLayer]);

            result  = new Obstacle(go, dataId, MapManager.MapObstacleLayer);
            go.name = result.MapCellId.ToString();
            go.SetActive(true);
        }
        break;

        // ---------------------------------加载预设模式---------------------------------
        case UnitType.FightUnit:     // 战斗单位
        {
            var go = GetGameObject(MapCellTableName,
                                   dataId,
                                   MapDrawer.Single.ItemParentList[MapManager.MapPlayerLayer]);

            result  = new FightUnit(go, dataId, MapManager.MapPlayerLayer);
            go.name = result.MapCellId.ToString();
            go.SetActive(true);
        }
        break;

        case UnitType.NPC:     // NPC
        {
            var go = GetGameObject(MapCellTableName,
                                   dataId,
                                   MapDrawer.Single.ItemParentList[MapManager.MapNpcLayer]);

            // TODO 区分出兵点入兵点
            switch (dataId)
            {
            case 301:
                // 出兵点
                result = new OutMonsterPoint(go, dataId, MapManager.MapObstacleLayer);
                break;

            case 302:
                // 入兵点
                result = new InMonsterPoint(go, dataId, MapManager.MapObstacleLayer);
                break;

            case 401:
                // 塔基
                result = new TowerPoint(go, dataId, MapManager.MapObstacleLayer);
                break;

            default:
                result = new Npc(go, dataId, MapManager.MapNpcLayer);
                break;
            }
            go.name = result.MapCellId.ToString();
            go.SetActive(true);
        }
        break;

        case UnitType.Tower:
        {
            // 创建塔
            var go = GetGameObject(MapCellTableName,
                                   dataId,
                                   MapDrawer.Single.ItemParentList[MapManager.MapNpcLayer]);
            result = new Tower(go, dataId, MapManager.MapPlayerLayer);
            // 设置数据
            go.name = result.MapCellId.ToString();
            go.SetActive(true);
        }
        break;

        case UnitType.TowerCell:
        {
            // 创建塔单元
            var go = GetGameObject(MapCellTableName,
                                   dataId,
                                   MapDrawer.Single.ItemParentList[MapManager.MapPlayerLayer]);
            result = new TheFiveCellBase(go, dataId, MapManager.MapPlayerLayer);
            // 设置数据
            go.name = result.MapCellId.ToString();
            go.SetActive(true);
        }
        break;
        }



        return((T)result);
    }
Beispiel #44
0
        public static bool DoesMoveMinRequest(Move move, UnitType unitType, Unit unit)
        {
            // Minimal requests ok?
            if (move.UnitId == "Engine" && unitType.MinEngineLevel > 0)
            {
                if (unit == null || unit.Engine == null || unit.Engine.Level < unitType.MinEngineLevel)
                {
                    return(true);
                }
            }
            if (move.UnitId == "Armor" && unitType.MinArmorLevel > 0)
            {
                if (unit == null || unit.Armor == null || unit.Armor.Level < unitType.MinArmorLevel)
                {
                    return(true);
                }
            }
            if (move.UnitId == "Weapon" && unitType.MinWeaponLevel > 0)
            {
                if (unit == null || unit.Weapon == null || unit.Weapon.Level < unitType.MinWeaponLevel)
                {
                    return(true);
                }
            }

            if (move.UnitId == "Assembler" && unitType.MinAssemblerLevel > 0)
            {
                if (unit == null || unit.Assembler == null || unit.Assembler.Level < unitType.MinAssemblerLevel)
                {
                    return(true);
                }
            }

            if (move.UnitId == "Extractor" && unitType.MinExtractorLevel > 0)
            {
                if (unit == null || unit.Extractor == null || unit.Extractor.Level < unitType.MinExtractorLevel)
                {
                    return(true);
                }
            }
            if (move.UnitId == "Container" && unitType.MinContainerLevel > 0)
            {
                if (unit == null || unit.Container == null || unit.Container.Level < unitType.MinContainerLevel)
                {
                    return(true);
                }
            }
            if (move.UnitId == "Reactor" && unitType.MinReactorLevel > 0)
            {
                if (unit == null || unit.Reactor == null || unit.Reactor.Level < unitType.MinReactorLevel)
                {
                    return(true);
                }
            }
            if (move.UnitId == "Radar" && unitType.MinRadarLevel > 0)
            {
                if (unit == null || unit.Radar == null || unit.Radar.Level < unitType.MinRadarLevel)
                {
                    return(true);
                }
            }

            if (unit != null)
            {
                // Optional requests?
                if (move.UnitId == "Engine" && unit.Engine != null && unit.Engine.Level < unitType.MaxEngineLevel)
                {
                    return(true);
                }
                if (move.UnitId == "Armor" && unit.Armor != null && unit.Armor.Level < unitType.MaxArmorLevel)
                {
                    return(true);
                }
                if (move.UnitId == "Weapon" && unit.Weapon != null && unit.Weapon.Level < unitType.MaxWeaponLevel)
                {
                    return(true);
                }
                if (move.UnitId == "Extractor" && unit.Extractor != null && unit.Extractor.Level < unitType.MaxExtractorLevel)
                {
                    return(true);
                }
                if (move.UnitId == "Container" && unit.Container != null && unit.Container.Level < unitType.MaxContainerLevel)
                {
                    return(true);
                }
                if (move.UnitId == "Reactor" && unit.Reactor != null && unit.Reactor.Level < unitType.MaxReactorLevel)
                {
                    return(true);
                }
                if (move.UnitId == "Radar" && unit.Radar != null && unit.Radar.Level < unitType.MaxRadarLevel)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #45
0
 public Unit GetUnitByType(UnitType type)
 {
     return(units[type]);
 }
Beispiel #46
0
 private static extern SNRESULT ProcessSetMemoryX86(int target, UnitType unit, uint processId, ulong threadId, ulong address, int count, byte[] buffer);
Beispiel #47
0
 public void Selected(UnitType selected)
 {
     transform.parent.GetChild(1).GetComponent <Buying>().Selected(selected);
 }
    // --- Priority access

    public float Get(UnitType type)
    {
        return(priorities[type]);
    }
Beispiel #49
0
 internal async Task <IList <UnitOfMeasure> > GetUnitsOfMeasureByType(UnitType unitType)
 {
     return(await UnitsOfMeasure.Where(u => u.UnitType == unitType).ToListAsync());
 }
Beispiel #50
0
        public bool HasValidLocalPathfinding(PathNode positionNode, Vector3 validityPosition, UnitType type)
        {
            AbstractActor pathfindingActor = GetPathFindingActor(type);

            SetupPathfindingActor(positionNode.Position, pathfindingActor);

            AccessTools.Field(typeof(PathNodeGrid), "open").SetValue(pathfindingActor.Pathing.CurrentGrid, new List <PathNode>()
            {
                positionNode
            });
            pathfindingActor.Pathing.UpdateBuild(10000);
            pathfindingActor.Pathing.UpdateFreePath(validityPosition, validityPosition, false, false);

            Vector3 vectorToTarget   = pathfindingActor.Pathing.ResultDestination - pathfindingActor.CurrentPosition;
            float   distanceToTarget = vectorToTarget.magnitude;

            if (distanceToTarget > pathfindingActor.MaxWalkDistance)
            {
                vectorToTarget = vectorToTarget.normalized * pathfindingActor.MaxWalkDistance;
            }

            pathfindingActor.Pathing.UpdateFreePath(validityPosition, validityPosition, false, false);
            if (pathfindingActor.Pathing.HasPath)
            {
                return(true);
            }

            return(false);
        }
Beispiel #51
0
        internal async Task <bool> UpdateUnitOfMeasure(int id, string name, string value, UnitType unitType)
        {
            var unit = await UnitsOfMeasure.SingleOrDefaultAsync(u => u.Id == id);

            if (unit != null)
            {
                unit.Name     = name;
                unit.Value    = value;
                unit.UnitType = unitType;

                return(await _context.SaveChangesAsync() >= 0);
            }

            return(false);
        }
 public bool IsUnitSupported(UnitType type) => controller.IsUnitSupported(type);
Beispiel #53
0
        public bool HasValidNeighbours(PathNode positionNode, Vector3 validityPosition, UnitType type)
        {
            int           count            = 0;
            AbstractActor pathfindingActor = GetPathFindingActor(type);

            SetupPathfindingActor(positionNode.Position, pathfindingActor);

            AccessTools.Field(typeof(PathNodeGrid), "open").SetValue(pathfindingActor.Pathing.CurrentGrid, new List <PathNode>()
            {
                positionNode
            });
            pathfindingActor.Pathing.CurrentGrid.UpdateBuild(1);
            List <PathNode> neighbours = AccessTools.Field(typeof(PathNodeGrid), "open").GetValue(pathfindingActor.Pathing.CurrentGrid) as List <PathNode>;

            foreach (PathNode neighbourNode in neighbours)
            {
                float cost = pathfindingActor.Pathing.CurrentGrid.GetTerrainModifiedCost(positionNode, neighbourNode, pathfindingActor.MaxWalkDistance);
                Main.LogDebug($"[PFM.HasValidNeighbours] Cost of neighbour is {cost} with max pathfinder cost being {pathfindingActor.MaxWalkDistance}");
                if (cost < pathfindingActor.MaxWalkDistance)
                {
                    count++;
                }
                if (count >= 2)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #54
0
 private bool IsSubUnit(UnitType type)
 {
     return(PossibleSubUnits.Contains(type));
 }
Beispiel #55
0
        public bool IsSpawnValid(GameObject spawnGo, Vector3 position, Vector3 validityPosition, UnitType type, string identifier)
        {
            CombatGameState    combatState        = UnityGameInstance.BattleTechGame.Combat;
            EncounterLayerData encounterLayerData = MissionControl.Instance.EncounterLayerData;
            MapTerrainDataCell cellData           = combatState.MapMetaData.GetCellAt(position);

            Main.LogDebug($"");
            Main.LogDebug($"-------- [PFM.IsSpawnValid] [{identifier}] --------");

            if (position.IsTooCloseToAnotherSpawn(spawnGo))
            {
                Main.LogDebug($"[PFM] Position '{position}' is too close to another spawn point. Not a valid location.");
                return(false);
            }

            if (cellData.cachedSteepness > MAX_SLOPE_FOR_PATHFINDING)
            {
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Spawn point of '{cellData.cachedSteepness}' is too steep (> {MAX_SLOPE_FOR_PATHFINDING}). Not a valid spawn");
                return(false);
            }

            if (IsCellImpassableOrDeepWater(cellData))
            {
                return(false);
            }
            if (!encounterLayerData.IsInEncounterBounds(position))
            {
                return(false);
            }
            if (cellData.cachedHeight > (cellData.terrainHeight + 50f))
            {
                return(false);
            }

            float         pathFindingZoneRadius = 25f;
            AbstractActor pathfindingActor      = GetPathFindingActor(type);

            SetupPathfindingActor(position, pathfindingActor);

            PathNode positionPathNode = null;

            try {
                PathNodeGrid pathfinderPathGrid = pathfindingActor.Pathing.CurrentGrid;
                positionPathNode = pathfinderPathGrid.GetValidPathNodeAt(position, pathfindingActor.Pathing.MaxCost);
                if (positionPathNode == null)
                {
                    Reset();
                    return(false);
                }
            } catch (Exception e) {
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Caught error in 'pathfinderPathGrid.GetValidPathNodeAt' chunk. Flagging as invalid spawn. Select a new spawn point. {e.Message}, {e.StackTrace}");
                WasABadPathfindTest(validityPosition);
                return(false);
            }

            if (positionPathNode == null)
            {
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] PositionPathNode not set from 'pathfinderPathGrid.GetValidPathNodeAt'. No valid path found so not a valid spawn.");
                WasABadPathfindTest(validityPosition);
                return(false);
            }

            List <Vector3> path = null;

            try {
                DynamicLongRangePathfinder.PointWithCost pointWithCost = new DynamicLongRangePathfinder.PointWithCost(combatState.HexGrid.GetClosestHexPoint3OnGrid(positionPathNode.Position), 0, (validityPosition - positionPathNode.Position).magnitude);
                path = DynamicLongRangePathfinder.GetDynamicPathToDestination(new List <DynamicLongRangePathfinder.PointWithCost>()
                {
                    pointWithCost
                }, validityPosition, float.MaxValue, pathfindingActor, false, new List <AbstractActor>(), pathfindingActor.Pathing.CurrentGrid, pathFindingZoneRadius);
            } catch (Exception e) {
                // TODO: Sometimes this gets triggered in very large amounts. It's usually because the SpawnLogic.GetClosestValidPathFindingHex is increasing
                // the radius larger and larger and the checks keep going off the map
                // I need a way to hard abort out of this and either use the original origin of the focus or trigger the rule logic again (random, around a position etc)
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Caught error in 'DynamicLongRangePathfinder' chunk. Flagging as invalid spawn. Select a new spawn point. {e.Message}, {e.StackTrace}");
                WasABadPathfindTest(validityPosition);
                return(false);
            }

            if (path == null)
            {
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Path not set from DynamicLongRangePathfinder so not a valid spawn.");
                WasABadPathfindTest(validityPosition);
                return(false);
            }

            // List<Vector3> path = DynamicLongRangePathfinder.GetPathToDestination(position, float.MaxValue, pathfindingActor, true, pathFindingZoneRadius);
            // List<Vector3> path = DynamicLongRangePathfinder.GetDynamicPathToDestination(position, float.MaxValue, pathfindingActor, true, new List<AbstractActor>(), pathfindingActor.Pathing.CurrentGrid, pathFindingZoneRadius);

            Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Path count is: '{path.Count}', Current position is: '{position}'");

            // GUARD: Against deep water and other impassables that have slipped through
            if (HasPathImpassableOrDeepWaterTiles(combatState, path))
            {
                return(false);
            }

            if (path != null && path.Count > 1 && (path[path.Count - 1].DistanceFlat(validityPosition) <= pathFindingZoneRadius))
            {
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Path count is: '{path.Count}', Current position is: '{position}'");
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Last point is '{path[path.Count - 1]}', Validity position is '{validityPosition}'");
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Distance from last path to valdity position is: '{(path[path.Count - 1].DistanceFlat(validityPosition))}' and is it within zone radius? '{(path[path.Count - 1].DistanceFlat(validityPosition) <= pathFindingZoneRadius)}'");
                Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Has valid long range path finding");
                if (HasValidNeighbours(positionPathNode, validityPosition, type))
                {
                    Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Has at least two valid neighbours");

                    if (HasValidLocalPathfinding(positionPathNode, validityPosition, type))
                    {
                        Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Has a valid path");
                        Reset();
                        Main.LogDebug($"-------- END [PFM.IsSpawnValid] [{identifier}] END --------");
                        Main.LogDebug($"");
                        return(true);
                    }
                    else
                    {
                        Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Does NOT have a valid path");
                    }
                }
                else
                {
                    Main.LogDebug($"[PFM.IsSpawnValid] [{identifier}] Does not have two valid neighbours");
                }
            }

            /* // Failed attempt to improve spawn checks
             * List<Vector3> path = DynamicLongRangePathfinder.GetDynamicPathToDestination(validityPosition, float.MaxValue, pathfindingActor, true, new List<AbstractActor>(), pathfindingActor.Pathing.CurrentGrid, pathFindingZoneRadius);
             * if (path != null && (path[path.Count - 1].DistanceFlat(validityPosition) <= pathFindingZoneRadius)) {
             * if (path.Count > 4) { // very strong pathfinding location
             *  return true;
             * } else {
             *  Main.Logger.Log($"[PFM] Spawn point is valid due to proximity but is not strong enough success for pathing. Attempting to confirm.");
             *  CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat;
             *  List<Vector3> pointsAroundPosition = combatState.HexGrid.GetGridPointsAroundPointWithinRadius(position, 3, 5);
             *
             *  foreach (Vector3 point in pointsAroundPosition) {
             *    List<Vector3> secondaryPath = DynamicLongRangePathfinder.GetDynamicPathToDestination(point, float.MaxValue, pathfindingActor, true, new List<AbstractActor>(), pathfindingActor.Pathing.CurrentGrid, 2);
             *    if (path != null && path.Count > 2) {
             *      Main.Logger.Log($"[PFM] Spawn point is valid. It is close to the validation point but can be moved away from. Success.");
             *      return true;
             *    }
             *  }
             * }
             * }
             */


            Main.LogDebug($"-------- END [PFM.IsSpawnValid] [{identifier}] END --------");
            Main.LogDebug($"");
            Reset();
            return(false);
        }
Beispiel #56
0
 public static GameObject getModel(UnitType uType)
 {
     return(singleton.unitModels[(int)uType]);
 }
 public IEnumerable <string> GetSupportedUnits(UnitType type) => controller.GetSupportedUnits(type);
Beispiel #58
0
 public static Sprite getIcon(UnitType uType)
 {
     return(singleton.icons[(int)uType]);
 }
Beispiel #59
0
 public ConvertionMap(UnitType unitType, int fromUnit, int toUnit)
 {
     _unitType = unitType;
     _fromUnit = fromUnit;
     _toUnit   = toUnit;
 }
Beispiel #60
0
 /// <summary>
 /// Returns a test Hand object.
 /// </summary>
 public static Hand MakeTestHand(bool isLeft,
                                 int frameId       = 0, int handId = 0,
                                 UnitType unitType = UnitType.LeapUnits)
 {
     return(MakeTestHand(isLeft, LeapTransform.Identity, frameId, handId, unitType));
 }