Example #1
0
        /// <summary>
        /// Used to print over the voucher image
        /// </summary>
        /// <returns></returns>
        public static VoucherProcessDelegate CreatePrintOnImageDelegate()
        {
            var method = new VoucherProcessDelegate((Voucher data, StateObj state) =>
            {
                var printLocation = SettingsTable.Get <Point>(Strings.VScan_PrintAreaLocation, Point.Empty);
                if (printLocation == Point.Empty)
                {
                    var ex = new ApplicationException("Cannot find 'print on image' configuration.");
                    ex.AddNext(new MethodInvoker(() =>
                    {
                        string id    = Strings.VScan_EditItem.Uniqueue();
                        data.Message = ex.Message;
                        DataSlot.Set(id, data);
                        WinMsg.SendText(state.Scan, state.Main, id);
                    }));
                    throw ex;
                }

                var aliases           = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
                aliases["[DATE]"]     = new Func <string>(() => DateTime.Now.ToString());
                aliases["[OPERATOR]"] = new Func <string>(() => SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject, UserAuth.Default).Name);
                aliases["[PCNAME]"]   = new Func <string>(() => PTFUtils.GetMachine());
                aliases["[SITEID]"]   = new Func <string>(() => data.SiteCode);
                aliases["[NUMBER]"]   = new Func <string>(() => Convert.ToString(SettingsTable.Get <int>(Strings.VScan_ScanCount, 0)));

                string voucherTemplate = SettingsTable.Get <string>(Strings.VScan_ImPrinterTemplate, Strings.VScan_ImPrinterTemplateDefault);
                string voucherText     = voucherTemplate.format(aliases);

                using (var g = Graphics.FromImage(data.VoucherImage))
                    g.DrawString(voucherText, SystemFonts.CaptionFont, Brushes.Red, printLocation);
            });

            return(method);
        }
Example #2
0
        /// <summary>
        /// Used to find and cover the card code by a mark on the voucher image
        /// </summary>
        /// <returns></returns>
        public static VoucherProcessDelegate CreateHideCardDetailsDelegateByMark()
        {
            var method = new VoucherProcessDelegate((Voucher data, StateObj state) =>
            {
                var markArea = SettingsTable.Get <MarkAreaCfg>(Strings.VScan_MarkAreaConfiguration, MarkAreaCfg.Empty);

                if (markArea.Equals(MarkAreaCfg.Empty))
                {
                    var ex = new ApplicationException("Cannot find 'hide area' configuration.");
                    ex.AddNext(new MethodInvoker(() =>
                    {
                        string id    = Strings.VScan_EditItem.Uniqueue();
                        data.Message = ex.Message;
                        DataSlot.Set(id, data);
                        WinMsg.SendText(state.Scan, state.Main, id);
                    }));
                    throw ex;
                }

                Rectangle hiddenArea;

                using (var bmp2 = data.VoucherImage.ToBlackWhite(markArea.BlackWhiteThreshold))
                    hiddenArea = bmp2.FindRectangle(Point.Empty, markArea.BackColor, markArea.MinAreaSize, markArea.MaxAreaSize, markArea.Threshold);

                var hiddenAreaDraw = SettingsTable.Get <HiddenAreaDrawingCfg>(Strings.VScan_DistanceFromBarcodeBottomLeftToHiddenArea, HiddenAreaDrawingCfg.Default);

                using (var g = Graphics.FromImage(data.VoucherImage))
                    g.FillRectangleHatch(hiddenArea, hiddenAreaDraw.ForeColor, hiddenAreaDraw.BackColor, hiddenAreaDraw.Style);
            });

            return(method);
        }
Example #3
0
        public bool TakeEntityOnPositionInHandTry(DataSlot slot, Vector2 positionCreateHand)
        {
            if (slot == null)
            {
                throw new ArgumentNullException(nameof(slot));
            }
            var entitySource = DatabaseReadOnly.GetEntityOrNull(slot);

            if (entitySource == null)
            {
                return(false);
            }
            if (Debug.DebugMode)
            {
                _point = Debug.PointForDebug.InstantiateOnRootCanvas().transform;
                _point.SetAsLastSibling();
            }

            TakeEntityInHand(entitySource);
            var entityComponent = _bindComponentToDataDbRead.GetEntityComponent(entitySource);

            _handView = new HandView(entityComponent, HandData.DataEntityHand);
            _handView.PositionSet(positionCreateHand);
            return(true);
        }
        public override void Execute(Level level)
        {
            var defaultdatbase = level.GetPlayerAvatar().QuickTrain1;

            if (Database == 1)
            {
                defaultdatbase.Clear();
            }
            else if (Database == 2)
            {
                defaultdatbase = level.GetPlayerAvatar().QuickTrain2;
                defaultdatbase.Clear();
            }
            else if (Database == 3)
            {
                defaultdatbase = level.GetPlayerAvatar().QuickTrain3;
                defaultdatbase.Clear();
            }
            else
            {
                throw new NullReferenceException("Unknown Database Detected");
            }

            foreach (var i in UnitsToAdd)
            {
                DataSlot ds = new DataSlot(i.Data, i.Count);
                defaultdatbase.Add(ds);
            }
        }
        /// <summary>
        /// If we move a one-handed item and there is a two-handed item in the second hand - refusal
        /// </summary>
        /// <param name="slotTarget"></param>
        /// <param name="entityOneHanded"></param>
        /// <returns></returns>
        private bool ValidateEntityOneHanded(DataSlot slotTarget, DataEntity entityOneHanded)
        {
            if (slotTarget.DataInventory == _dummy.DataInventory &&
                entityOneHanded is DataEntityEquipment equipment &&
                equipment.BodyPart == DataSlotDummy.BodyPartEnum.Hand &&
                !equipment.IsTwoHanded
                )
            {
                var slotsHand  = GetSlotsHand();
                var slotSource = DatabaseReadOnly.GetSlotOrNull(entityOneHanded);

                // исключаем SourceSlot и TargetSlot
                slotsHand = slotsHand.Except(new List <DataSlot>()
                {
                    slotSource, slotTarget
                });

                var secondHandIsTwoHandedEntity = slotsHand.
                                                  Any(slot =>
                                                      (DatabaseReadOnly.GetEntityOrNull(slot) is DataEntityEquipment equipmentInSlot && equipmentInSlot.IsTwoHanded)
                                                      );
                return(!secondHandIsTwoHandedEntity);
            }
            return(true);
        }
        public override void Execute(Level level)
        {
            var defaultDatabase = level.GetPlayerAvatar().QuickTrain1;

            if (Database == 1)
            {
                defaultDatabase.Clear();
            }
            else if (Database == 2)
            {
                defaultDatabase = level.GetPlayerAvatar().QuickTrain2;
                defaultDatabase.Clear();
            }
            else if (Database == 3)
            {
                defaultDatabase = level.GetPlayerAvatar().QuickTrain3;
                defaultDatabase.Clear();
            }
            else
            {
                throw new InvalidDataException("Unknown database in AddQuickTrainingTroopCommand.");
            }

            foreach (var i in UnitsToAdd)
            {
                DataSlot ds = new DataSlot(i.Data, i.Count);
                defaultDatabase.Add(ds);
            }
        }
Example #7
0
		public void Split(string fieldName, string captionName, params string[] args)
		{
			DataSlot dataset = new DataSlot();
			DataSlotCollection rows = this["rows"] as DataSlotCollection;
			if (rows == null || rows.Count < 1)
			{
				return;
			}
			DataSlot prevRow = rows[0];
			object prevValue = prevRow[fieldName];
			DataSlotCollection temp = new DataSlotCollection();
			foreach (DataSlot i in rows)
			{
				object v = i[fieldName];
				if (!Equals(v, prevValue))
				{
					AddPreviousCategory(captionName, dataset, prevRow, temp, args);
					temp = new DataSlotCollection();
					prevRow = i;
					prevValue = v;
				}
				temp.Add(i);
			}
			AddPreviousCategory(captionName, dataset, prevRow, temp, args);
			this["dataset"] = dataset;
			Remove("rows");
		}
Example #8
0
        private void PutHandInSlotTryData([NotNull] DataSlot slotLeftTop)
        {
            if (slotLeftTop.DataInventory == null)
            {
                throw GetExceptionUnBindInventoryComponent();
            }

            var entitySource  = HandData.EntitySource;
            var amountWantPut = HandData.DataEntityHand.Amount;

            HandData.ReturnAmountInSource();
            var slotLeftTopPrevious = DatabaseReadOnly.GetSlotOrNull(entitySource);

            if (slotLeftTopPrevious != slotLeftTop)
            {
                var command = Commands.CreateForHand <PutCommand>()
                              .EnterData(new PutInputData(entitySource, slotLeftTop, amountWantPut));
                var success = command.ExecuteTry();

                if (!success)
                {
                    var noValidOnlyForFilters = FactoryCommandNoValidOnlyForFilters.Create(command);

                    // event
                    if (noValidOnlyForFilters.IsCommandNoValidOnlyForFilters)
                    {
                        NoValidFiltersEvent.Invoke(noValidOnlyForFilters.GetImpossibleOnlyForThisFilters());
                    }
                }
            }
            HandData.Clear();
            StatusWasChanged.Invoke();
        }
Example #9
0
 public CheckIntersectionOfPositions(DataEntity first, DataSlot slotFirst, DataEntity second, DataSlot slotSecond)
 {
     First      = first;
     Second     = second;
     SlotFirst  = slotFirst;
     SlotSecond = slotSecond;
 }
 public SwapPrimaryInputData([NotNull] DataEntity entityDisplacing, [NotNull] DataSlot slotNewPositionEntityDisplacing,
                             [NotNull] DataEntity entityTarget, [NotNull] DataSlot slotNewPositionEntityTarget) : base(entityDisplacing, slotNewPositionEntityDisplacing)
 {
     SlotNewPositionEntityTarget     = slotNewPositionEntityTarget;
     SlotOldPositionEntityDisplacing = DatabaseReadOnly.GetSlotOrNull(entityDisplacing);
     EntityTarget = entityTarget;
 }
        public override void Execute(Level level)
        {
            List <DataSlot> units  = level.GetPlayerAvatar().GetUnits();
            List <DataSlot> spells = level.GetPlayerAvatar().GetSpells();

            foreach (UnitToRemove unitToRemove in UnitsToRemove)
            {
                if (unitToRemove.Data.ToString().StartsWith("400"))
                {
                    CombatItemData _Troop   = (CombatItemData)CSVManager.DataTables.GetDataById(unitToRemove.Data);
                    DataSlot       dataSlot = units.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _Troop.GetGlobalID()));
                    if (dataSlot != null)
                    {
                        dataSlot.Value = dataSlot.Value - 1;
                    }
                }
                else if (unitToRemove.Data.ToString().StartsWith("260"))
                {
                    SpellData _Spell   = (SpellData)CSVManager.DataTables.GetDataById(unitToRemove.Data);
                    DataSlot  dataSlot = spells.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _Spell.GetGlobalID()));
                    if (dataSlot != null)
                    {
                        dataSlot.Value = dataSlot.Value - 1;
                    }
                }
            }
        }
Example #12
0
        /// <summary>
        /// Used to find and cover the cardcode by using the barcode location
        /// </summary>
        /// <returns></returns>
        public static VoucherProcessDelegate CreateHideCardDetailsDelegateByBarcode()
        {
            var method = new VoucherProcessDelegate((Voucher data, StateObj state) =>
            {
                var distanceToHiddenArea = SettingsTable.Get <Point>(Strings.VScan_DistanceFromBarcodeBottomLeftToHiddenArea, Point.Empty);
                if (distanceToHiddenArea == Point.Empty)
                {
                    var ex = new ApplicationException("Cannot find chunk configuration.");
                    ex.AddNext(new MethodInvoker(() =>
                    {
                        string id    = Strings.VScan_EditItem.Uniqueue();
                        data.Message = ex.Message;
                        DataSlot.Set(id, data);
                        WinMsg.SendText(state.Scan, state.Main, id);
                    }));
                    throw ex;
                }

                Size hideAreaSize        = SettingsTable.Get <Size>(Strings.VScan_HiddenAreaSize, Size.Empty);
                Point hiddenAreaLocation = new Point(data.BarCodeArea.Left, data.BarCodeArea.Bottom);

                hiddenAreaLocation.Offset(distanceToHiddenArea);
                Rectangle hiddenArea = new Rectangle(hiddenAreaLocation, hideAreaSize);

                var hiddenAreaDraw = SettingsTable.Get <HiddenAreaDrawingCfg>(Strings.VScan_HiddenAreaDrawingCfg, HiddenAreaDrawingCfg.Default);

                using (var g = Graphics.FromImage(data.VoucherImage))
                    g.FillRectangleHatch(hiddenArea, hiddenAreaDraw.ForeColor, hiddenAreaDraw.BackColor, hiddenAreaDraw.Style);
            });

            return(method);
        }
Example #13
0
        public override void Execute(Level level)
        {
            var player = level.GetPlayerAvatar();
            var units  = player.GetUnits();

            if (DataSlotID == 1)
            {
                foreach (var i in player.QuickTrain1)
                {
                    var ds = new DataSlot(i.Data, i.Value);
                    units.Add(ds);
                }
            }
            else if (DataSlotID == 2)
            {
                foreach (var i in player.QuickTrain2)
                {
                    var ds = new DataSlot(i.Data, i.Value);
                    units.Add(ds);
                }
            }
            else if (DataSlotID == 3)
            {
                foreach (var i in player.QuickTrain3)
                {
                    var ds = new DataSlot(i.Data, i.Value);
                    units.Add(ds);
                }
            }
        }
        public override void Process(Level level)
        {
            for (int i = 0; i < 31; i++)
            {
                var unitData   = CSVManager.DataTables.GetDataById(4000000 + i);
                var combatData = (CharacterData)unitData;
                var maxLevel   = combatData.GetUpgradeLevelCount();
                var unitSlot   = new DataSlot(unitData, 6969);

                level.GetPlayerAvatar().GetUnits().Add(unitSlot);
                level.GetPlayerAvatar().SetUnitUpgradeLevel(combatData, maxLevel - 1);
            }

            for (int i = 0; i < 19; i++)
            {
                var spellData  = CSVManager.DataTables.GetDataById(26000000 + i);
                var combatData = (SpellData)spellData;
                var maxLevel   = combatData.GetUpgradeLevelCount();
                var spellSlot  = new DataSlot(spellData, 6969);

                level.GetPlayerAvatar().GetSpells().Add(spellSlot);
                level.GetPlayerAvatar().SetUnitUpgradeLevel(combatData, maxLevel - 1);
            }

            new NpcDataMessage(Client, level, this).Send();
        }
Example #15
0
 protected ChangeInputData([NotNull] DataEntity dataEntitySource, [NotNull] DataSlot slotTo)
 {
     SlotTo       = slotTo;
     EntitySource = dataEntitySource;
     AmountSource = EntitySource.Amount;
     SlotFrom     = DatabaseReadOnly.GetSlotOrNull(EntitySource);
 }
        public override void Execute(Level level)
        {
            List <DataSlot> _PlayerUnits  = level.GetPlayerAvatar().GetUnits();
            List <DataSlot> _PlayerSpells = level.GetPlayerAvatar().GetSpells();

            foreach (UnitToRemove _Unit in UnitsToRemove)
            {
                if (_Unit.Data.ToString().StartsWith("400"))
                {
                    CombatItemData _Troop    = (CombatItemData)CSVManager.DataTables.GetDataById(_Unit.Data);;
                    DataSlot       _DataSlot = _PlayerUnits.Find(t => t.Data.GetGlobalID() == _Troop.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value - 1;
                    }
                }
                else if (_Unit.Data.ToString().StartsWith("260"))
                {
                    SpellData _Spell    = (SpellData)CSVManager.DataTables.GetDataById(_Unit.Data);;
                    DataSlot  _DataSlot = _PlayerSpells.Find(t => t.Data.GetGlobalID() == _Spell.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value - 1;
                    }
                }
            }
        }
Example #17
0
        internal override void Process()
        {
            List <DataSlot> _PlayerUnits  = this.Device.Player.Avatar.GetUnits();
            List <DataSlot> _PlayerSpells = this.Device.Player.Avatar.GetSpells();

            foreach (UnitToRemove _Unit in UnitsToRemove)
            {
                if (_Unit.Data.ToString().StartsWith("400"))
                {
                    CombatItemData _Troop    = (CombatItemData)CSVManager.DataTables.GetDataById(_Unit.Data);;
                    DataSlot       _DataSlot = _PlayerUnits.Find(t => t.Data.GetGlobalID() == _Troop.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value - _Unit.Count;
                    }
                }
                else if (_Unit.Data.ToString().StartsWith("260"))
                {
                    SpellData _Spell    = (SpellData)CSVManager.DataTables.GetDataById(_Unit.Data);;
                    DataSlot  _DataSlot = _PlayerSpells.Find(t => t.Data.GetGlobalID() == _Spell.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value - _Unit.Count;
                    }
                }
            }
        }
Example #18
0
 public SwapInputData([NotNull] DataEntity entityDisplacing,
                      [NotNull] DataSlot slotNewPositionEntityDisplacing, [NotNull] DataEntity entityTarget, [CanBeNull] IComparer <DataSlot> comparer = null)
     : base(entityDisplacing, slotNewPositionEntityDisplacing)
 {
     SlotOldPositionEntityDisplacing = DatabaseReadOnly.GetSlotOrNull(entityDisplacing);
     EntityTarget = entityTarget;
     Comparer     = comparer ?? DatabaseReadOnly.ComparerSlotsDefault;
 }
Example #19
0
 public CheckNoValidEntitiesInTargetSlots(DataEntity entitySource, DataSlot slotLeftTop, int amountWantPut,
                                          IEnumerable <DataEntity> validEntities = null)
 {
     Entity        = entitySource;
     Slot          = slotLeftTop;
     AmountWantPut = amountWantPut;
     ValidEntities = validEntities ?? new List <DataEntity>();
 }
        public void SetData(DataSlot dataSlot)
        {
            var oldDataSlot = _dataSlotConcrete;

            _dataSlotConcrete = (T)dataSlot;
            SetNewDataEvent.Invoke(oldDataSlot, _dataSlotConcrete);
            //Debug.Log($"{oldDataSlot} => {_dataSlotConcrete})");
        }
 public CauseIntersectionOfPositions([NotNull] DataEntity first,
                                     [NotNull] DataSlot slotFirst, [NotNull] DataEntity second, [NotNull] DataSlot slotSecond)
 {
     First      = first;
     Second     = second;
     SlotFirst  = slotFirst;
     SlotSecond = slotSecond;
 }
        public override void Execute(Level level)
        {
            var player = level.GetPlayerAvatar();
            var units  = player.GetUnits();

            if (DataSlotID == 1)
            {
                foreach (DataSlot i in player.QuickTrain1)
                {
                    List <DataSlot> _PlayerUnits = level.GetPlayerAvatar().GetUnits();
                    DataSlot        _DataSlot    = _PlayerUnits.Find(t => t.Data.GetGlobalID() == i.Data.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value + i.Value;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(i.Data, i.Value);
                        _PlayerUnits.Add(ds);
                    }
                }
            }
            else if (DataSlotID == 2)
            {
                foreach (DataSlot i in player.QuickTrain2)
                {
                    List <DataSlot> _PlayerUnits = level.GetPlayerAvatar().GetUnits();
                    DataSlot        _DataSlot    = _PlayerUnits.Find(t => t.Data.GetGlobalID() == i.Data.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value + i.Value;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(i.Data, i.Value);
                        _PlayerUnits.Add(ds);
                    }
                }
            }
            else if (DataSlotID == 3)
            {
                foreach (DataSlot i in player.QuickTrain3)
                {
                    List <DataSlot> _PlayerUnits = level.GetPlayerAvatar().GetUnits();
                    DataSlot        _DataSlot    = _PlayerUnits.Find(t => t.Data.GetGlobalID() == i.Data.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value + i.Value;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(i.Data, i.Value);
                        _PlayerUnits.Add(ds);
                    }
                }
            }
        }
 void Start()
 {
     animator         = GetComponent <Animator> ();
     dslot            = GetComponentInChildren <DataSlot> ();
     animator.enabled = false;
     initPosition     = animator.transform.position;
     endPosition      = initPosition;
     startPosition    = endPosition;
 }
Example #24
0
    public void SetCurrentDataSlot(DataSlot slot)
    {
        if (currentSlot >= 0 && currentSlot < dataSlots.Length)
        {
            dataSlots[currentSlot] = slot;

            Save();
        }
    }
        internal override void Process()
        {
            var player = this.Device.Player.Avatar;

            if (DataSlotID == 1)
            {
                foreach (DataSlot i in player.QuickTrain1)
                {
                    List <DataSlot> _PlayerUnits = player.GetUnits();
                    DataSlot        _DataSlot    = _PlayerUnits.Find(t => t.Data.GetGlobalID() == i.Data.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value + i.Value;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(i.Data, i.Value);
                        _PlayerUnits.Add(ds);
                    }
                }
            }
            else if (DataSlotID == 2)
            {
                foreach (DataSlot i in player.QuickTrain2)
                {
                    List <DataSlot> _PlayerUnits = player.GetUnits();
                    DataSlot        _DataSlot    = _PlayerUnits.Find(t => t.Data.GetGlobalID() == i.Data.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value + i.Value;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(i.Data, i.Value);
                        _PlayerUnits.Add(ds);
                    }
                }
            }
            else if (DataSlotID == 3)
            {
                foreach (DataSlot i in player.QuickTrain3)
                {
                    List <DataSlot> _PlayerUnits = player.GetUnits();
                    DataSlot        _DataSlot    = _PlayerUnits.Find(t => t.Data.GetGlobalID() == i.Data.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value + i.Value;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(i.Data, i.Value);
                        _PlayerUnits.Add(ds);
                    }
                }
            }
        }
Example #26
0
 public MoveInputData([NotNull] DataEntity entitySource, [NotNull] DataSlot slotLeftTop, int amountWantPut)
     : base(entitySource, slotLeftTop)
 {
     if (amountWantPut <= 0)
     {
         throw new ArgumentOutOfRangeException(nameof(amountWantPut));
     }
     AmountWantPut      = amountWantPut;
     IsCreatedNewEntity = AmountSource != AmountWantPut;
 }
Example #27
0
        protected virtual void Create(DataEntity entity, DataSlot toSlotLeftTop)
        {
            var tryGetInventoryComponent = _bindComponentToDataDbRead.TryGetInventoryComponent(entity.DataInventory, out _);

            if (tryGetInventoryComponent)
            {
                _instantiator.AddEntity(entity, toSlotLeftTop);
            }
            //Debug.Log("Create: "+entity);
        }
Example #28
0
 public PutInputData([NotNull] DataEntity entitySource, [NotNull] DataSlot slotLeftTop, int amountWantPut)
 {
     if (amountWantPut <= 0)
     {
         throw new ArgumentOutOfRangeException(nameof(amountWantPut));
     }
     EntitySource  = entitySource;
     SlotLeftTop   = slotLeftTop;
     AmountWantPut = amountWantPut;
 }
Example #29
0
        public override void Execute(Level level)
        {
            DataSlot dataSlot = level.GetPlayerAvatar().GetSpells().Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == this.Spell.GetGlobalID()));

            if (dataSlot == null)
            {
                return;
            }
            dataSlot.Value = dataSlot.Value - 1;
        }
Example #30
0
        public override void Execute(Level level)
        {
            for (int i = 0; i < 31; i++)
            {
                var unitData   = CSVManager.DataTables.GetDataById(4000000 + i);
                var combatData = (CharacterData)unitData;
                var maxLevel   = combatData.GetUpgradeLevelCount();
                var unitSlot   = new DataSlot(unitData, 6969);

                level.GetPlayerAvatar().GetUnits().Add(unitSlot);
                level.GetPlayerAvatar().SetUnitUpgradeLevel(combatData, maxLevel - 1);
            }

            for (int i = 0; i < 18; i++)
            {
                var spellData  = CSVManager.DataTables.GetDataById(26000000 + i);
                var combatData = (SpellData)spellData;
                var maxLevel   = combatData.GetUpgradeLevelCount();
                var spellSlot  = new DataSlot(spellData, 6969);

                level.GetPlayerAvatar().GetSpells().Add(spellSlot);
                level.GetPlayerAvatar().SetUnitUpgradeLevel(combatData, maxLevel - 1);
            }

            var l = ObjectManager.GetRandomOnlinePlayer();

            if (l != null)
            {
                l.Tick();
                level.GetPlayerAvatar().State = ClientAvatar.UserState.Searching;

                var trophyDiff = Math.Abs(level.GetPlayerAvatar().GetScore() - l.GetPlayerAvatar().GetScore());
                var reward     = (int)Math.Round(Math.Pow((5 * trophyDiff), 0.25) + 5d);
                var lost       = (int)Math.Round(Math.Pow((2 * trophyDiff), 0.35) + 5d);

                var info = new ClientAvatar.AttackInfo
                {
                    Attacker = level,
                    Defender = l,

                    Lost      = lost,
                    Reward    = reward,
                    UsedTroop = new List <DataSlot>()
                };

                level.GetPlayerAvatar().AttackingInfo.Add(l.GetPlayerAvatar().GetId(), info); //Use UserID For a while..Working on AttackID soon

                l.Tick();
                new EnemyHomeDataMessage(level.GetClient(), l, level).Send();
            }
            else
            {
                new EnemyHomeDataMessage(level.GetClient(), l, level).Send();
            }
        }
 private void PutOnlyInHotBarSpot(DataSlot slot)
 {
     if (slot.DataInventory == SlotComponent.InventoryComponent.DataInventory)
     {
         Hand.PutHandInSlotTry(slot);
     }
     else
     {
         Hand.RemoveEntityInHand();
     }
 }
Example #32
0
		public GridSlot(IDataReader reader, DataSlot style = null, object defaultStyle = null)
			: this()
		{
			if (defaultStyle == null)
			{
				DataSlot dStyle = new DataSlot();
				dStyle["width"] = "70px";
				this["defaultStyle"] = dStyle;				
			}
			if (style == null)
			{
				style = new DataSlot();
			}
			this["styles"] = style;
			Retrieve(reader);
		}
Example #33
0
		private static void AddPreviousCategory(string captionName, DataSlot dataset, DataSlot prevRow, DataSlotCollection temp, params string [] args)
		{
			DataSlot data = dataset.Set<DataSlot>(Convert.ToString(prevRow[captionName]));
			foreach (string i in args)
			{
				string[] item = i.Split('=');
				if (item.Length == 1 && prevRow.ContainsKey(item[0]))
				{
					data[i] = prevRow[item[0]];
				}
				else if (item.Length > 1)
				{
					string key = item[0];
					item[0] = string.Empty;
					data[key] = string.Join("=", item).Substring(1);
				}
			}
			data["rows"] = temp;
		}
Example #34
0
    public void SetCurrentDataSlot(DataSlot slot)
    {
        if (currentSlot >= 0 && currentSlot < dataSlots.Length)
        {
            dataSlots[currentSlot] = slot;

            Save();
        }
    }
Example #35
0
    public void Delete(int index)
    {
        if (index >= 0 && index < 4)
        {
            var slot = new DataSlot();
            slot.isEmpty = true;
            dataSlots[index] = slot;

            Save();
        }
    }
Example #36
0
    private DataSlot CreateSlot()
    {
        var slot = new DataSlot();
        slot.isEmpty = false;
        slot.AddPlayer(0);

        slot.pillarsNeeded = new List<PillarType>()
        {
            GameData.PillarType.Blue,
            GameData.PillarType.Red,
            GameData.PillarType.Green,
            GameData.PillarType.Yellow,
            GameData.PillarType.Orange,
            GameData.PillarType.Purple
        };

        return slot;
    }