Esempio n. 1
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Quantity;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (ValueElement != null)
                {
                    dest.ValueElement = (Hl7.Fhir.Model.FhirDecimal)ValueElement.DeepCopy();
                }
                if (ComparatorElement != null)
                {
                    dest.ComparatorElement = (Code <Hl7.Fhir.Model.Quantity.QuantityComparator>)ComparatorElement.DeepCopy();
                }
                if (UnitElement != null)
                {
                    dest.UnitElement = (Hl7.Fhir.Model.FhirString)UnitElement.DeepCopy();
                }
                if (SystemElement != null)
                {
                    dest.SystemElement = (Hl7.Fhir.Model.FhirUri)SystemElement.DeepCopy();
                }
                if (CodeElement != null)
                {
                    dest.CodeElement = (Hl7.Fhir.Model.Code)CodeElement.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
Esempio n. 2
0
        private UnitElement <S, T> ExtractUnitElement(UnitElement <S, T> unitElement, string data, int noPosition, int unitStartPos, int unitStopPos, int powerStartPos, int powerStopPos, bool divideNextElement)
        {
            long power = 1;

            if (powerStartPos == noPosition && powerStopPos != noPosition)
            {
                throw new UnitParserException(string.Format("Incohenrent power state : power stop pos = ({0}) while there is no power start pos", powerStopPos));
            }
            if (powerStartPos != noPosition && powerStopPos == noPosition)
            {
                throw new UnitParserException(string.Format("Incohenrent power state : power start pos = ({0}) while there is no power stop pos", powerStartPos));
            }
            if (powerStartPos != noPosition && powerStopPos != noPosition)
            {
                power = ParsePower(data.Substring(powerStartPos, powerStopPos - powerStartPos));
            }
            var unitName      = GetUnitName(data.Substring(unitStartPos, unitStopPos - unitStartPos));
            var unitNamePower = new UnitNamePower <S, T>(unitName, divideNextElement ? -power : power);

            if (unitElement == null)
            {
                unitElement = new UnitElement <S, T>(unitNamePower);
            }
            else
            {
                unitElement = new UnitElement <S, T>(unitElement.GetUnitNamePowers().Concat(new UnitNamePower <S, T>[] { unitNamePower }));
            }
            return(unitElement);
        }
Esempio n. 3
0
        public UnitValue <S, T> Convert(UnitValue <S, T> value, UnitElement <S, T> unitElement)
        {
            var s = new S();
            var unitValueTarget = new UnitValue <S, T>(s.GetNeutral() as S, unitElement);

            return(Convert(value, unitValueTarget));
        }
Esempio n. 4
0
 public void EndTurn()
 {
     Turn++;
     CurrentUnit = GetCurrentUnit();
     CleanGrid();
     SetTurnMode(EnumTurnMode._noneMode);
 }
Esempio n. 5
0
    public void Hit(UnitElement enemy)
    {
        int HPD = (int)(DamageForHP * 0.01f * Damage);
        int APD = (int)(DamageForAP * 0.01f * Damage);

        HPD      = enemy.AP - APD < APD ? APD - (enemy.AP - APD) : 0;
        enemy.HP = Mathf.Clamp(enemy.HP - HPD, 0, enemy.HP);
        enemy.AP = Mathf.Clamp(enemy.AP - APD, 0, enemy.AP);
    }
Esempio n. 6
0
        protected void AddReference(UnitElement <S, T> reference)
        {
            var dimension = reference.GetDimension();

            if (dimension.QuantityCount == 1)
            {
                var quantity = UnitDimension.UnitBaseQuantities.Where(q => dimension.GetPower(q) != 0).Single();
                ReferenceByQuantity[quantity] = reference;
            }
            References.Add(reference);
        }
Esempio n. 7
0
 void Start()
 {
     ManagerStatic = this;
     GridMap.CreateGrid();
     SetEnemyOnZone();
     SetFriendOnZone();
     CurrentUnit = GetCurrentUnit();
     ModeButtons[0].onClick.AddListener(() => SetTurnMode(EnumTurnMode._moveMode));
     ModeButtons[1].onClick.AddListener(() => SetTurnMode(EnumTurnMode._attackMode));
     ModeButtons[2].onClick.AddListener(() => SetTurnMode(EnumTurnMode._percMode));
 }
Esempio n. 8
0
 public virtual void MakeShoot(Node node)
 {
     if (_bullet == null)
     {
         _bullet = Resources.Load <GameObject>("Staff/Bullet") as GameObject;
     }
     if (node.Unit == null)
     {
         return;
     }
     targetUnit = node.Unit;
     StartCoroutine(MoveBullet(node));
 }
Esempio n. 9
0
 public static void SetUnit(UnitElement unit)
 {
     if (CurUnit == unit)
     {
         unit = null;
     }
     instance.gameObject.SetActive(unit);
     if (unit)
     {
         instance.maxValue   = unit.MaxHP;
         instance.value      = unit.HP;
         instance.label.text = unit.HP + " / " + unit.MaxHP + " (" + unit.AP + ")";
     }
     CurUnit = unit;
 }
Esempio n. 10
0
        private static string GenerateCronValue(UnitElement unit)
        {
            switch (unit.Type)
            {
            case ScheduleType.All:
                return("*");

            case ScheduleType.Values:
                return(unit.Values);

            case ScheduleType.Interval:
                return($"{unit.Start}/{unit.Interval}");

            case ScheduleType.Range:
                return($"{unit.From}-{unit.To}");

            default:
                throw new InvalidOperationException($"ScheduleType: '{unit.Type}' is not supported. Please check your configuration file.");
            }
        }
    public void OnPointerDown(PointerEventData eventData)
    {
        string even = eventData.pointerEnter.name.ToString();

        switch (even)
        {
        case "BuildButton":
            element = ButtonList[0].GetComponent <ButtonElement>();
            element.Showon("BuildButton");
            break;

        case "SoilderButton":
            element = ButtonList[1].GetComponent <ButtonElement>();
            element.Showon("SoilderButton");
            break;

        case "UnitBuild1":
            UnitElement = UnitBuildList[0].GetComponent <UnitElement>();
            UnitElement.InBuldUnitClick(1);
            break;

        case "UnitBuild2":
            UnitElement = UnitBuildList[1].GetComponent <UnitElement>();
            UnitElement.InBuldUnitClick(2);
            break;

        case "UnitBuild3":
            UnitElement = UnitBuildList[2].GetComponent <UnitElement>();
            UnitElement.InBuldUnitClick(3);
            break;

        case "UnitBuild4":
            UnitElement = UnitBuildList[3].GetComponent <UnitElement>();
            UnitElement.InBuldUnitClick(4);
            break;

        case "UnitBuild5":
            UnitElement = UnitBuildList[4].GetComponent <UnitElement>();
            UnitElement.InBuldUnitClick(5);
            break;

        case "UnitBuild6":
            UnitElement = UnitBuildList[5].GetComponent <UnitElement>();
            UnitElement.InBuldUnitClick(6);
            break;

        case "UnitBuild7":
            UnitElement = UnitBuildList[6].GetComponent <UnitElement>();
            UnitElement.InBuldUnitClick(7);
            break;

        case "UnitBuild8":
            UnitElement = UnitBuildList[7].GetComponent <UnitElement>();
            UnitElement.InBuldUnitClick(8);
            break;



        case "UnitSoilder1":
            UnitElement = UnitSoilderList[0].GetComponent <UnitElement>();
            UnitElement.InSoilderUnitClick(1);
            break;

        case "UnitSoilder2":
            UnitElement = UnitSoilderList[1].GetComponent <UnitElement>();
            UnitElement.InSoilderUnitClick(2);
            break;

        case "UnitSoilder3":
            UnitElement = UnitSoilderList[2].GetComponent <UnitElement>();
            UnitElement.InSoilderUnitClick(3);
            break;

        case "UnitSoilder4":
            UnitElement = UnitSoilderList[3].GetComponent <UnitElement>();
            UnitElement.InSoilderUnitClick(4);
            break;

        case "UnitSoilder5":
            UnitElement = UnitSoilderList[4].GetComponent <UnitElement>();
            UnitElement.InSoilderUnitClick(5);
            break;

        case "UnitSoilder6":
            UnitElement = UnitSoilderList[5].GetComponent <UnitElement>();
            UnitElement.InSoilderUnitClick(6);
            break;

        case "UnitSoilder7":
            UnitElement = UnitSoilderList[6].GetComponent <UnitElement>();
            UnitElement.InSoilderUnitClick(7);
            break;

        case "UnitSoilder8":
            UnitElement = UnitSoilderList[7].GetComponent <UnitElement>();
            UnitElement.InSoilderUnitClick(8);
            break;
        }
    }
Esempio n. 12
0
        public UnitElement <S, T> ParseUnit(string data)
        {
            const int          noPosition        = -1;
            int                unitStartPos      = noPosition;
            int                unitStopPos       = noPosition;
            int                powerStartPos     = noPosition;
            int                powerStopPos      = noPosition;
            bool               divideNextElement = false;
            UnitElement <S, T> unitElement       = null;

            for (int index = 0; index < data.Length; index++)
            {
                char item = data[index];
                if (unitStartPos == noPosition)
                {
                    if (!IsSpaceALike(item))
                    {
                        unitStartPos = index;
                    }
                }
                else if (unitStartPos != noPosition && unitStopPos == noPosition)
                {
                    if (IsSpaceALike(item))
                    {
                        unitStopPos = index;
                    }
                    else if (IsPower(item))
                    {
                        unitStopPos   = index;
                        powerStartPos = index;
                    }
                }
                else if (unitStopPos == noPosition && powerStartPos != noPosition)
                {
                    if (!IsPower(item))
                    {
                        powerStopPos = index;
                    }
                }
                else if (unitStopPos != noPosition && powerStartPos == noPosition)
                {
                    if (IsPower(item))
                    {
                        powerStartPos = index;
                    }
                }
                else if (unitStopPos != noPosition && powerStartPos != noPosition && powerStopPos == noPosition)
                {
                    if (!IsPower(item))
                    {
                        powerStopPos = index;
                    }
                }

                if (unitStartPos != noPosition)
                {
                    if (IsElementSepator(item))
                    {
                        if (unitStopPos == noPosition)
                        {
                            unitStopPos = index;
                        }
                        unitElement = ExtractUnitElement(unitElement, data, noPosition, unitStartPos, unitStopPos, powerStartPos, powerStopPos, divideNextElement);

                        unitStartPos  = noPosition;
                        unitStopPos   = noPosition;
                        powerStartPos = noPosition;
                        powerStopPos  = noPosition;

                        divideNextElement = (item == '/');
                    }
                }
            }
            if (unitStartPos != noPosition)
            {
                if (powerStartPos != noPosition && powerStopPos == noPosition)
                {
                    powerStopPos = data.Length;
                }
                if (unitStartPos != noPosition && unitStopPos == noPosition)
                {
                    unitStopPos = data.Length;
                }
                unitElement = ExtractUnitElement(unitElement, data, noPosition, unitStartPos, unitStopPos, powerStartPos, powerStopPos, divideNextElement);
            }
            if (unitElement == null)
            {
                throw new UnitParserException("No unit found");
            }
            return(unitElement);
        }
Esempio n. 13
0
        public UnitValue <S, T> Parse(string data)
        {
            const int          noPosition        = -1;
            int                valueStartPos     = noPosition;
            int                valueStopPos      = noPosition;
            int                unitStartPos      = noPosition;
            int                unitStopPos       = noPosition;
            int                powerStartPos     = noPosition;
            int                powerStopPos      = noPosition;
            bool               divideNextElement = false;
            S                  value             = null;
            UnitElement <S, T> unitElement       = null;

            for (int index = 0; index < data.Length; index++)
            {
                char item = data[index];
                if (valueStartPos == noPosition)
                {
                    if (!IsSpaceALike(item))
                    {
                        valueStartPos = index;
                        if (IsNotValueAnymore(item))
                        {
                            valueStopPos = index;
                            value        = ParseValue("1");
                            unitStartPos = index;
                        }
                    }
                }
                else if (valueStopPos == noPosition)
                {
                    if (IsNotValueAnymore(item))
                    {
                        valueStopPos = index;
                        if (valueStartPos == valueStopPos)
                        {
                            throw new UnitParserException(string.Format("Parsing error : no valid value found (Start value pos ({0}) == Stop value pos ({1}))", valueStartPos, valueStopPos));
                        }
                        value = ParseValue(data.Substring(valueStartPos, valueStopPos - valueStartPos));
                        if (!IsSpaceALike(item))
                        {
                            unitStartPos = index;
                        }
                    }
                }
                else if (value != null && unitStartPos == noPosition)
                {
                    if (!IsSpaceALike(item))
                    {
                        unitStartPos = index;
                    }
                }
                else if (value != null && unitStartPos != noPosition && unitStopPos == noPosition)
                {
                    if (IsSpaceALike(item))
                    {
                        unitStopPos = index;
                    }
                    else if (IsPower(item))
                    {
                        unitStopPos   = index;
                        powerStartPos = index;
                    }
                }
                else if (value != null && unitStopPos == noPosition && powerStartPos != noPosition)
                {
                    if (!IsPower(item))
                    {
                        powerStopPos = index;
                    }
                }
                else if (value != null && unitStopPos != noPosition && powerStartPos == noPosition)
                {
                    if (IsPower(item))
                    {
                        powerStartPos = index;
                    }
                }
                else if (value != null && unitStopPos != noPosition && powerStartPos != noPosition && powerStopPos == noPosition)
                {
                    if (!IsPower(item))
                    {
                        powerStopPos = index;
                    }
                }

                if (value != null && unitStartPos != noPosition)
                {
                    if (IsElementSepator(item))
                    {
                        if (unitStopPos == noPosition)
                        {
                            unitStopPos = index;
                        }
                        unitElement = ExtractUnitElement(unitElement, data, noPosition, unitStartPos, unitStopPos, powerStartPos, powerStopPos, divideNextElement);

                        unitStartPos  = noPosition;
                        unitStopPos   = noPosition;
                        powerStartPos = noPosition;
                        powerStopPos  = noPosition;

                        divideNextElement = (item == '/');
                    }
                }
            }
            if (value != null && unitStartPos != noPosition)
            {
                if (powerStartPos != noPosition && powerStopPos == noPosition)
                {
                    powerStopPos = data.Length;
                }
                if (unitStartPos != noPosition && unitStopPos == noPosition)
                {
                    unitStopPos = data.Length;
                }
                unitElement = ExtractUnitElement(unitElement, data, noPosition, unitStartPos, unitStopPos, powerStartPos, powerStopPos, divideNextElement);
            }

            if (value == null)
            {
                value = ParseValue("1");
            }

            if (unitElement == null)
            {
                unitElement = new UnitElement <S, T>();
            }
            return(new UnitValue <S, T>(value, unitElement));
        }
Esempio n. 14
0
 protected UnitValue <S, T> CreateUnit(float value, UnitElement <S, T> unitElement) => new UnitValue <S, T>(GetNewScalar(value), unitElement);