//public int[] HealthHistory = new int[50]; public PlayList(FlatHexPoint savePointLocation, MoveStyle saveMove, ActionStyle saveAction, EntityViewModel saveEnemyVM, EntityView saveEnemyView) { this.SavePointLocation = savePointLocation; this.SaveMove = saveMove; this.SaveAction = saveAction; this.SaveEnemyVM = saveEnemyVM; this.SaveEnemyView = saveEnemyView; //this.HealthHistory = healthHistory; }
public SummonUnitCommand(int id, EntityView card, UnitSlot slot) : base(id) { if(card.id <=0) { throw new System.Exception("Card was missing id"); } cardEntityId = card.id; x = slot.x; y = slot.y; }
public PlayPowerCommand(int id, EntityView card, UnitSlot slot) : base(id) { this.cardEntityId = card.id; if(slot != null) { this.x = slot.x; this.y = slot.y; } else { this.x = -1; this.y = -1; } }
public void entityItemView_equals_normal_should_behave_as_expected() { var expected = true; var dataSource = new List<Person>() { new Person(){ FirstName = "Mauro", LastName = "Servienti" } }; var view1 = new EntityView<Person>( dataSource ); var view2 = new EntityView<Person>( dataSource ); view1.ApplySort( "FirstName" ); var item1 = view1.ElementAt( 0 ); var item2 = view2.ElementAt( 0 ); var actual = item1.Equals( item2 ); actual.Should().Be.EqualTo( expected ); }
public void entityView_getCustomPropertyValue_should_return_initial_interceptor_value() { var expected = "initial value"; var actual = ""; Func<String> interceptor = () => { return expected; }; var target = new EntityView<Object>( new[] { new Object() } ); target.AddPropertyMapping<String>( "Foo", e => { return e.Item.GetCustomValue<String>( e.PropertyName ); }, interceptor ); var item = target.FirstOrDefault(); actual = item.GetCustomValue<String>( "Foo" ); actual.Should( "Not yet implemented" ).Be.EqualTo( expected ); }
public void entityView_custom_property_mapping_shuold_set_and_get_custom_values_as_expected() { var expected = "Hello World!"; EntityItemViewValueGetter<Object, String> getter = e => { return e.Item.GetCustomValue<String>( e.PropertyName ); }; EntityItemViewValueSetter<Object, String> setter = e => { e.Item.SetCustomValue( e.PropertyName, e.Value ); }; var target = new EntityView<Object>( new[] { new Object() } ); target.AddPropertyMapping<String>( "Foo", getter, setter ); target.First().SetCustomValue( "Foo", expected ); var actual = target.First().GetCustomValue<String>( "Foo" ); actual.Should( "Not yet implemented" ).Be.EqualTo( expected ); }
public void entityView_getCustomPropertyValue_using_never_used_custom_property_should_use_initial_value_interceptor_once() { var expected = 1; var actual = 0; Func<String> interceptor = () => { actual++; return "initial value"; }; var target = new EntityView<Object>( new[] { new Object() } ); target.AddPropertyMapping<String>( "Foo", e => { return e.Item.GetCustomValue<String>( e.PropertyName ); }, interceptor ); var item = target.FirstOrDefault(); item.GetCustomValue<String>( "Foo" ); item.GetCustomValue<String>( "Foo" ); item.GetCustomValue<String>( "Foo" ); actual.Should( "Not yet implemented" ).Be.EqualTo( expected ); }
private IEnumerator DeathCoroutine(EntityView view, float delay) { yield return(new WaitForSeconds(delay)); Recycle(view); }
public override void BindEntityView(EntityView view) { base.BindEntityView(view); this.view = view as HierarchyGOView; }
public abstract Task DoAction(CommercePipelineExecutionContext context, EntityView entityView, TEntity entity);
public override bool ShouldViewApply(CommercePipelineExecutionContext context, EntityView entityView, TEntity entity) { return(ActionName.Equals(entityView.Action, StringComparison.OrdinalIgnoreCase)); }
public void entityView_removePropertyMapping_should_remove_property_value_even_on_more_then_one_element() { var propertyName = "Foo"; var expectedFirst = "Hello world, from First!"; var expectedLast = "Hello world, from Last!"; EntityItemViewValueGetter<Object, String> getter = e => { return e.Item.GetCustomValue<String>( e.PropertyName ); }; EntityItemViewValueSetter<Object, String> setter = e => { e.Item.SetCustomValue( e.PropertyName, e.Value ); }; var target = new EntityView<Object>( new[] { new Object(), new Object() } ); target.AddPropertyMapping<String>( propertyName, getter, setter ); var firstItem = target.First(); firstItem.SetCustomValue<String>( propertyName, expectedFirst ); var lastItem = target.Last(); lastItem.SetCustomValue<String>( propertyName, expectedLast ); target.RemovePropertyMapping( propertyName ); target.AddPropertyMapping<String>( propertyName, getter, setter ); var actualFirst = target.First().GetCustomValue<String>( "Foo" ); var actualLast = target.Last().GetCustomValue<String>( "Foo" ); actualFirst.Should().Be.Null(); actualLast.Should().Be.Null(); }
public async Task UpdateAsync(Dictionary <string, object> item, object primaryKeyValue, List <CustomField> customFields, EntityView meta) { if (!string.IsNullOrWhiteSpace(meta.PrimaryKey)) { this.PrimaryKey = meta.PrimaryKey; } this.IdentityColumn = meta.Columns.FirstOrDefault(x => x.IsSerial)?.ColumnName; await this.UpdateAsync(item, primaryKeyValue, customFields).ConfigureAwait(false); }
public override Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull(this.Name + ": The argument cannot be null"); EntityViewArgument request = context.CommerceContext.GetObjects <EntityViewArgument>().FirstOrDefault(); if (request == null) { return(Task.FromResult(arg)); } bool isAddAction = request.ForAction.Equals(context.GetPolicy <KnownPricingActionsPolicy>().AddPriceSnapshot, StringComparison.OrdinalIgnoreCase); bool isEditAction = request.ForAction.Equals(context.GetPolicy <KnownPricingActionsPolicy>().EditPriceSnapshot, StringComparison.OrdinalIgnoreCase); if (string.IsNullOrEmpty(request?.ViewName) || !(request.Entity is PriceCard) || !request.ViewName.Equals(context.GetPolicy <KnownPricingViewsPolicy>().Master, StringComparison.OrdinalIgnoreCase) && !request.ViewName.Equals(context.GetPolicy <KnownPricingViewsPolicy>().PriceCardSnapshots, StringComparison.OrdinalIgnoreCase) && !request.ViewName.Equals(context.GetPolicy <KnownPricingViewsPolicy>().PriceSnapshotDetails, StringComparison.OrdinalIgnoreCase) || request.ViewName.Equals(context.GetPolicy <KnownPricingViewsPolicy>().PriceSnapshotDetails, StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(request.ItemId) && !isAddAction) { return(Task.FromResult(arg)); } PriceCard card = (PriceCard)request.Entity; if (request.ViewName.Equals(context.GetPolicy <KnownPricingViewsPolicy>().Master, StringComparison.OrdinalIgnoreCase) || request.ViewName.Equals(context.GetPolicy <KnownPricingViewsPolicy>().PriceCardSnapshots, StringComparison.OrdinalIgnoreCase)) { List <EntityView> views = new List <EntityView>(); this.FindViews(views, arg, context.GetPolicy <KnownPricingViewsPolicy>().PriceSnapshotDetails, context.CommerceContext); views.ForEach(snapshotDetailsView => { EntityView view = snapshotDetailsView; PriceCard priceCard = card; PriceSnapshotComponent snapshot = priceCard?.Snapshots.FirstOrDefault(s => s.Id.Equals(snapshotDetailsView.ItemId, StringComparison.OrdinalIgnoreCase)); int num1 = isAddAction ? 1 : 0; int num2 = isEditAction ? 1 : 0; this.PopulateSnapshotDetails(view, snapshot, num1 != 0, num2 != 0); }); return(Task.FromResult(arg)); } PriceSnapshotComponent snapshotComponent; if (isAddAction) { snapshotComponent = null; } else { PriceCard priceCard = card; snapshotComponent = priceCard?.Snapshots.FirstOrDefault(s => s.Id.Equals(request.ItemId, StringComparison.OrdinalIgnoreCase)); } PriceSnapshotComponent snapshot1 = snapshotComponent; this.PopulateSnapshotDetails(arg, snapshot1, isAddAction, isEditAction); var rawValue = arg.Properties.FirstOrDefault((p => p.Name.Equals("BeginDate", StringComparison.OrdinalIgnoreCase))).RawValue; CultureInfo cultureInfo = CultureInfo.GetCultureInfo(context.CommerceContext.CurrentLanguage()); string str = (string.IsNullOrEmpty(card.DisplayName) ? card.Name : card.DisplayName) + " (" + rawValue + ")"; ViewProperty viewProperty1 = arg.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName", StringComparison.OrdinalIgnoreCase)); if (viewProperty1 != null) { viewProperty1.RawValue = str; } else if (!isAddAction && !isEditAction) { List <ViewProperty> properties = arg.Properties; ViewProperty viewProperty2 = new ViewProperty { Name = "DisplayName", RawValue = str, IsReadOnly = true }; properties.Add(viewProperty2); } return(Task.FromResult(arg)); }
private void OnGizDestroy(EntityView view) { ConditionCompleted(); RemoveDestroyGizmoidListeners(); }
// P1 = Soldier // P2 = Enemy public void StartBattle(EntityViewModel P1, EntityViewModel P2, EntityView P1v, EntityView P2v, ActionStyle action) { Debug.Log("Running StartBattle"); List<EntityViewModel> soldiers = new List<EntityViewModel>(); List<EntityView> soldiersView = new List<EntityView>(); bool _battleFinished = false; bool TimerStarted = false; //soldiers.Insert(index1, P1); //soldiers.Insert(index2, P2); //soldiersView.Insert (index1, P1v); //soldiersView.Insert (index2, P2v); //soldiers[index1].Opponent = soldiers[index2]; //soldiers[index2].Opponent = soldiers[index1]; //soldiersView[index1].OpponentView = soldiersView[index2]; //soldiersView[index2].OpponentView = soldiersView[index1]; soldiers.Insert(0, P1); soldiers.Insert(1, P2); soldiersView.Insert (0, P1v); soldiersView.Insert (1, P2v); //Need to check if not the first guy, prevent to run these script //if(P1.BattleState == BattleState.WAITING) //{ soldiers[0].Opponent = soldiers[1]; soldiersView[0].OpponentView = soldiersView[1]; soldiers[0].TimeStarted = true; P1.BattleState = BattleState.FIGHTING; //} //check if P2 fighting to others, not match first if(P2.BattleState == BattleState.WAITING) { P2.Opponent = P1; soldiers[1].Opponent = soldiers[0]; soldiersView[1].OpponentView = soldiersView[0]; soldiers[1].TimeStarted = true; P2.BattleState = BattleState.FIGHTING; } for (int i = 0; i < soldiers.Count; i++) { Debug.Log ("soldiers.Count: " + soldiers.Count); soldiers[i].GetHealthProbabilities(); soldiers[i].starttime = Time.time; } WarStartTime = Time.time; //if(soldiers[0] != null) // soldiers[0].TimeStarted = true; //if(soldiers[1] != null) // soldiers[1].TimeStarted = true; _battleFinished = false; if(action == ActionStyle.ASSAULT) { float prob = Random.value; if(prob >= 0.25f) P1.BattleState = BattleState.CONFUSING; else if(prob < 0.5 && prob >= 0.5f) P2.BattleState = BattleState.CONFUSING; else if(prob < 0.5f && prob >= 0.75f) { P1.BattleState = BattleState.CONFUSING; P2.BattleState = BattleState.CONFUSING; } } //Observable.EveryUpdate().Where (_ => soldiers[0].TimeStarted == true && soldiers[1].TimeStarted).Subscribe(_ => Observable.EveryUpdate().Subscribe(_ => { if (soldiers.Count > 0) { //check if P1 finish battle from others if(P1.BattleState == BattleState.WAITING) { soldiers[0].Opponent = soldiers[1]; soldiersView[0].OpponentView = soldiersView[1]; _battleFinished = false; WarStartTime = Time.time; P1.BattleState = BattleState.FIGHTING; soldiers[0].GetHealthProbabilities(); soldiers[0].starttime = Time.time; soldiers[0].TimeStarted = true; soldiers[1].TimeStarted = true; } //check if P2 finish battle from others if(P2.BattleState == BattleState.WAITING) { soldiers[1].Opponent = soldiers[0]; soldiersView[1].OpponentView = soldiersView[0]; _battleFinished = false; WarStartTime = Time.time; P2.BattleState = BattleState.FIGHTING; soldiers[1].GetHealthProbabilities(); soldiers[1].starttime = Time.time; soldiers[0].TimeStarted = true; soldiers[1].TimeStarted = true; } for (int i=0; i < soldiers.Count; i++) { if (soldiers[i].TimeStarted && soldiers[i].Opponent != null && Time.time - soldiers[i].starttime >= 1f / soldiers[i].AttackSpeed) { Result (WarStartTime, soldiers[i], soldiersView[i], action); soldiers[i].starttime = Time.time; } if (!soldiers[i].TimeStarted) { Debug.Log ("Waiting from GameController"); if(P1 != null && P1.BattleState != BattleState.DEAD) P1.BattleState = BattleState.WAITING; if(P2 != null && P2.BattleState != BattleState.DEAD) P2.BattleState = BattleState.WAITING; _battleFinished = true; soldiers.Clear (); } } } }); }
public void RecycleDelayed(EntityView view, float delay) { StartCoroutine(DeathCoroutine(view, delay)); }
public MoveCommand(int id, EntityView unit, int x, int y) : base(id) { this.entityId = unit.id; this.x = x; this.y = y; }
public void entityView_removePropertyMapping_should_remove_property_value() { var value = "Hello world!"; EntityItemViewValueGetter<Object, String> getter = e => { return e.Item.GetCustomValue<String>( e.PropertyName ); }; EntityItemViewValueSetter<Object, String> setter = e => { e.Item.SetCustomValue( e.PropertyName, e.Value ); }; var target = new EntityView<Object>( new[] { new Object() } ); target.AddPropertyMapping<String>( "Foo", getter, setter ); var item = target.First(); item.SetCustomValue<String>( "Foo", value ); target.RemovePropertyMapping( "Foo" ); target.AddPropertyMapping<String>( "Foo", getter, setter ); var actual = target.First().GetCustomValue<String>( "Foo" ); actual.Should( "Not yet implemented" ).Not.Be.EqualTo( value ); actual.Should( "Not yet implemented" ).Be.Null(); }
public void CountEntityColumns() { EntityView entityView = Fixture().GetEntityView(); Assert.Null(entityView.Columns); }
private async Task AddSellableItemParentCategories(EntityView entityView, SellableItem entity, CommercePipelineExecutionContext context) { var viewsPolicy = context.GetPolicy <KnownCatalogViewsPolicy>(); if (entity == null || !entityView.Name.Equals(viewsPolicy.Master, StringComparison.OrdinalIgnoreCase) && !entityView.Name.Equals(viewsPolicy.Details, StringComparison.OrdinalIgnoreCase) && !entityView.Name.Equals(viewsPolicy.ConnectSellableItem, StringComparison.OrdinalIgnoreCase)) { return; } var parentCategoriesEntityView = new EntityView { Name = viewsPolicy.ParentCategories, EntityId = entity.Id, EntityVersion = entity.EntityVersion, UiHint = "Table" }; await this.SetListMetadata(parentCategoriesEntityView, viewsPolicy.ParentCategories, "PaginateCatalogItemList", context); var allCategories = await this.Commander.Pipeline <IGetCategoriesPipeline>().Run(new GetCategoriesArgument(" "), context); if (allCategories != null && !string.IsNullOrEmpty(entity.ParentCategoryList)) { var parentCategories = allCategories.Where(category => entity.ParentCategoryList.Split('|').Any(id => id.Equals(category.SitecoreId, StringComparison.OrdinalIgnoreCase))); foreach (var category in parentCategories) { var categoryView = new EntityView { EntityId = entity.Id, ItemId = category.Id, EntityVersion = category.EntityVersion, Name = viewsPolicy.Summary }; var viewProperty = new ViewProperty { Name = "Id", RawValue = category.Id, IsReadOnly = true, UiType = "EntityLink" }; categoryView.Properties.Add(viewProperty); var viewProperty1 = new ViewProperty { Name = "Name", RawValue = category.Name, IsReadOnly = true, }; categoryView.Properties.Add(viewProperty1); var viewProperty2 = new ViewProperty { Name = "DisplayName", RawValue = category.DisplayName, IsReadOnly = true }; categoryView.Properties.Add(viewProperty2); var viewProperty3 = new ViewProperty { Name = "Description", RawValue = category.Description ?? string.Empty, IsReadOnly = true }; categoryView.Properties.Add(viewProperty3); parentCategoriesEntityView.ChildViews.Add(categoryView); } } entityView.ChildViews.Add(parentCategoriesEntityView); }
public override async Task <EntityView> Run(EntityView entityView, CommercePipelineExecutionContext context) { GetReviewsListViewBlock reviewsListViewBlock = this; Condition.Requires(entityView).IsNotNull($"{reviewsListViewBlock.Name}: The argument cannot be null"); EntityViewArgument entityViewArgument = context.CommerceContext.GetObject <EntityViewArgument>(); if (string.IsNullOrEmpty(entityViewArgument?.ViewName) || !entityViewArgument.ViewName.Equals( context.GetPolicy <KnownReviewsViewsPolicy>().ReviewsList, StringComparison.OrdinalIgnoreCase) && !entityViewArgument.ViewName.Equals( context.GetPolicy <KnownReviewsViewsPolicy>().Reviews, StringComparison.OrdinalIgnoreCase)) { return(entityView); } EntityView reviews; if (entityViewArgument.ViewName.Equals( context.GetPolicy <KnownReviewsViewsPolicy>().Reviews, StringComparison.OrdinalIgnoreCase)) { EntityView reviewsEntityView = new EntityView { EntityId = string.Empty }; string reviewsList = context.GetPolicy <KnownReviewsViewsPolicy>().ReviewsList; reviewsEntityView.Name = reviewsList; reviews = reviewsEntityView; reviews.DisplayName = "All"; reviews.UiHint = "Table"; entityView.ChildViews.Add(reviews); } else { reviews = entityView; } var reviewsEntities = await this.findEntitiesInListPipeline.Run( new FindEntitiesInListArgument( typeof(Review), CommerceEntity.ListName <Review>(), 0, int.MaxValue), context); reviewsEntities.List.Items.ForEach( reviewEntity => { var review = reviewEntity as Review; EntityView entityView1 = new EntityView { EntityId = review.ProductReference.EntityTarget, ItemId = review.ProductReference.EntityTarget }; string summary = context.GetPolicy <KnownReviewsViewsPolicy>().Summary; entityView1.Name = summary; EntityView entityView2 = entityView1; List <ViewProperty> properties1 = entityView2.Properties; ViewProperty viewProperty1 = new ViewProperty { Name = "Product", DisplayName = "Product", Value = review.ProductReference.Name, UiType = "EntityLink" }; properties1.Add(viewProperty1); List <ViewProperty> properties2 = entityView2.Properties; ViewProperty viewProperty2 = new ViewProperty { Name = "Score", DisplayName = "Score", Value = review.Score.ToString() }; properties2.Add(viewProperty2); List <ViewProperty> properties3 = entityView2.Properties; ViewProperty viewProperty3 = new ViewProperty { Name = "Text", DisplayName = "Text", Value = review.Text }; properties3.Add(viewProperty3); List <ViewProperty> properties4 = entityView2.Properties; ViewProperty viewProperty4 = new ViewProperty { Name = "Author", DisplayName = "Author", Value = review.Author }; properties4.Add(viewProperty4); List <ViewProperty> properties5 = entityView2.Properties; ViewProperty viewProperty5 = new ViewProperty { Name = "Date", DisplayName = "Date", Value = review.DateCreated?.Date.ToLongDateString() }; properties5.Add(viewProperty5); reviews.ChildViews.Add(entityView2); }); return(entityView); }
public void AssociateToCatalogOrCategory(CommercePipelineExecutionContext context, EntityView entityView, EntityViewArgument request, string action) { var policy1 = context.GetPolicy <KnownCatalogViewsPolicy>(); var policy2 = context.CommerceContext.Environment.GetComponent <PolicySetsComponent>().GetPolicy <SearchScopePolicy>(); var policyList = new List <Policy> { new Policy() { PolicyId = "EntityType", Models = new List <Model>() { new Model() { Name = "SellableItem" } } }, policy2 }; var properties = entityView.Properties; var viewProperty = new ViewProperty { DisplayName = policy1.SellableItem, Name = policy1.SellableItem, IsRequired = true, Value = string.Empty, UiType = "Autocomplete", OriginalType = string.Empty.GetType().FullName, Policies = policyList }; properties.Add(viewProperty); }
public virtual void BindEntityView(EntityView view) { this.view = view; }
/// <summary> /// 获取实体ID对应的实体对象 /// </summary> /// <param name="id">实体ID</param> /// <returns></returns> public static GameObject getEntityGameObjectByID(ENTITY_ID id) { EntityView objev = EntityFactory.Instance.m_entityContainer.Get(id); return(objev != null ? objev.gameObject : null); }
protected virtual void PopulateSnapshotDetails(EntityView view, PriceSnapshotComponent snapshot, bool isAddAction, bool isEditAction) { if (view == null) { return; } var snapshotEndDateComponent = snapshot?.GetComponent <SnapshotEndDateComponent>(); List <ViewProperty> properties1 = view.Properties; ViewProperty viewPropertyEndDate = null; ViewProperty viewPropertyStartDate = null; ViewProperty viewProertyUseEndDate = null; bool isReadOnly = !isAddAction && !isEditAction; if (isReadOnly) { viewPropertyStartDate = new ViewProperty { Name = "BeginDate", RawValue = snapshot != null?snapshot.BeginDate.ToString("g") : DateTimeOffset.UtcNow.ToString("g"), IsReadOnly = true, UiType = "ItemLink" }; viewPropertyEndDate = new ViewProperty { Name = "EndDate", RawValue = snapshot != null && snapshotEndDateComponent != null && snapshotEndDateComponent.EndDate != DateTimeOffset.MinValue ? snapshotEndDateComponent.EndDate.ToString("g") : string.Empty, IsReadOnly = true, UiType = "ItemLink" }; } else { viewPropertyStartDate = new ViewProperty { Name = "BeginDate", RawValue = snapshot != null ? snapshot.BeginDate : DateTimeOffset.UtcNow, IsReadOnly = false, UiType = "ItemLink" }; viewPropertyEndDate = new ViewProperty { Name = "EndDate", RawValue = snapshot != null && snapshotEndDateComponent != null ? snapshotEndDateComponent.EndDate : DateTimeOffset.UtcNow, IsReadOnly = false, UiType = "ItemLink" }; viewProertyUseEndDate = new ViewProperty { Name = "UseEndDate", RawValue = true, IsReadOnly = false, UiType = "Checkbox" }; } if (viewPropertyStartDate != null) { properties1.Add(viewPropertyStartDate); } if (viewPropertyEndDate != null) { properties1.Add(viewPropertyEndDate); } if (viewProertyUseEndDate != null) { properties1.Add(viewProertyUseEndDate); } if (!isAddAction) { List <string> stringList = new List <string>(); if (snapshot?.Tags != null && snapshot.Tags.Any()) { stringList = snapshot?.Tags.Where((t => !t.Excluded)).Select((t => t.Name)).ToList(); } List <ViewProperty> properties2 = view.Properties; ViewProperty viewProperty2 = new ViewProperty(new List <Policy>()) { Name = "IncludedTags", RawValue = stringList.ToArray(), IsReadOnly = !isEditAction, IsRequired = false, UiType = isEditAction ? "Tags" : "List", OriginalType = "List" }; properties2.Add(viewProperty2); } if (isAddAction | isEditAction || snapshot == null) { return; } List <ViewProperty> properties3 = view.Properties; ViewProperty viewProperty3 = new ViewProperty { Name = "ItemId", RawValue = snapshot.Id, IsReadOnly = true, IsHidden = true }; properties3.Add(viewProperty3); List <ViewProperty> properties4 = view.Properties; ViewProperty viewProperty4 = new ViewProperty { Name = "Status", RawValue = snapshot.GetComponent <ApprovalComponent>().Status, IsReadOnly = true }; properties4.Add(viewProperty4); }
/// <summary> /// 是否存在此EntityView对象 /// </summary> static public bool IsExists(EntityView ev) { return(EntityFactory.Instance.m_entityContainer.IsExists(ev)); }
public async Task <object> AddAsync(Dictionary <string, object> item, List <CustomField> customFields, bool skipPrimaryKey, EntityView meta) { if (!string.IsNullOrWhiteSpace(meta.PrimaryKey)) { this.PrimaryKey = meta.PrimaryKey; } this.IdentityColumn = meta.Columns.FirstOrDefault(x => x.IsSerial)?.ColumnName; return(await this.AddAsync(item, customFields, skipPrimaryKey).ConfigureAwait(false)); }
private static GameObject entry_loadEntry(EntityView objev) { ENTITY_ID id = objev.ID; //已经被卸载了. if (EntityFactory.Instance.m_entityContainer.Get(id) == null) { return(null); } EntityViewItem evItem = objev.createinfo; ENTITY_TYPE entityType = (ENTITY_TYPE)evItem.EntityType; UnityEngine.Object objPrefab = PrefabManager.GetPrefab(entityType); if (null == objPrefab) { Trace.LogError("找不到对应的类型的prefab,请检查PrefabManager中的Init函数,是否忘记加载? " + entityType.ToString()); return(null); } GameObject entity = null; entity = objPrefab as GameObject; if (entity == null) { Trace.LogError("实例预设体对象失败! " + entityType.ToString()); return(null); } entity.name += "-" + id.ToString(); if (entity.transform.childCount > 0) { Trace.LogWarning("EntityView GameObject 有子节点!" + entity.transform.GetChild(0).name); } // 设置游戏对象 objev.SetGameObject(entity); // 设置创建数据 if (!objev.InitBuildeData(evItem)) { Trace.LogError("初始化实体对象数据失败! id=" + id.ToString()); return(null); } //如果是队友,则加入队友列表, if (objev.Type == ENTITY_TYPE.TYPE_PLAYER_ROLE && objev.CampFlag == CampFlag.CampFlag_Friend) { if (!m_friendPlayerList.Contains((uint)objev.ID)) { m_friendPlayerList.Add((uint)objev.ID); } } //string entityname = "UnKnow"; //Skin sk = SkinManager.GetSkin(objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_SKIN)); //if (sk != null) //{ // entityname = sk.ResSkinObj.AssetName; //} //entity.name = entityname; //entity.name += "(entity" + evItem.EntityID.ToString() + ")"; if (id == MainHeroID) { entity.transform.parent = null; MainHeroView = objev; if (CreateMainHeroEntityEvent != null) { CreateMainHeroEntityEventArgs e = new CreateMainHeroEntityEventArgs(); e.MainHeroID = evItem.nHeroID; e.MainHeroUID = MainHeroID; e.nMatchTypeID = GameLogicAPI.getCurRoomMatchType(); CreateMainHeroEntityEvent(e); LogicDataCenter.playerSystemDataManager.Reset(); } ViewEventHelper.Instance.SendCommand(GameLogicDef.GVIEWCMD_MASTER_VIEW_LOADED); Trace.Log("Load Hero Entry:" + entity.name); } else { entity.transform.parent = Instance.transform; } objPrefab = null; if (ENTITY_TYPE.TYPE_PLAYER_ROLE == entityType) { // 发送人物加载完指令到逻辑层 EntityEventHelper.Instance.SendCommand(id, EntityLogicDef.ENTITY_CMD_LOAD_COMPLETED); } BaseStateMachine bs = entity.GetComponent <BaseStateMachine>(); //已经有位置信息,创建模型时立即同步瞬移过去,之后的同步消息是走过去 if (objev.data.nActorID == evItem.EntityID) { Vector3 pos; pos.x = objev.data.fPosition_x; pos.y = objev.data.fPosition_y; pos.z = objev.data.fPosition_z; Vector3 rot; rot.x = objev.data.fRotation_x; rot.y = objev.data.fRotation_y; rot.z = objev.data.fRotation_z; //怪物要走传送,不能直接设置位置 if (entityType == ENTITY_TYPE.TYPE_MONSTER) { if (bs) { cmd_creature_transport data = new cmd_creature_transport(); data.fPosition_x = pos.x; data.fPosition_y = pos.y; data.fPosition_z = pos.z; data.fRotation_x = rot.x; data.fRotation_y = rot.y; data.fRotation_z = rot.z; data.bUseAngle = 1; bs.Transport(data); } } else { entity.transform.SetPosition(pos); entity.transform.eulerAngles = rot; } } CheckEntityMaskToRangeSearch(objev); //执行延迟处理的消息 EntityViewCommandHandler.onCommandsDelay(objev); return(entity); }
public abstract bool ShouldAddAction(CommercePipelineExecutionContext context, EntityView entityView, TEntity entity);
/// <summary> /// 释放实体 /// </summary> /// <param name="objev"></param> /// <returns></returns> public static bool ReleaseEntity(EntityView objev) { if (objev == null) { Trace.LogError("释放实体时找不到目标实体!"); return(false); } if (m_friendPlayerList.Count > 0) { if (m_friendPlayerListIndex >= 0 && m_friendPlayerListIndex < m_friendPlayerList.Count && objev.ID == m_friendPlayerList[m_friendPlayerListIndex]) { if (SoldierCamera.MainInstance() != null && EntityFactory.MainHeroView != null && EntityFactory.MainHeroView.gameObject != null) { SoldierCamera.MainInstance <SoldierCamera>().SwitchLookAtSolider(EntityFactory.MainHeroView); //切回到主角 } } if (m_friendPlayerList.Contains((uint)objev.ID)) { m_friendPlayerList.Remove((uint)objev.ID); } } ENTITY_ID id = objev.ID; ENTITY_TYPE type = objev.Type; m_NeedToLoadEntity.Remove(id); EntityFactory.Instance.m_entityContainer.Remove(ref objev); bool isHero = objev.IsHero; // 主角特殊处理一下 if (isHero) { Initialize.Instance.ResetGameManager(); MainHero = null; MainHeroView = null; MainHeroID = 0; } LogicDataCenter.warMinimapDataManager.RemoveObject(objev); LogicDataCenter.warOBDataManager.RemoveObject(objev); objev.Destroy(); EntityFactory.Instance.EntityNum--; switch (type) { case ENTITY_TYPE.TYPE_PLAYER_ROLE: { EntityFactory.Instance.ActorNum--; break; } case ENTITY_TYPE.TYPE_MONSTER: { EntityFactory.Instance.MonsterNum--; break; } default: break; } objev = null; if (type == ENTITY_TYPE.TYPE_PLAYER_ROLE) { if (isHero) { Trace.Log("释放主角实体对象, id=" + id.ToString() + ", type=" + type.ToString()); } else { Trace.Log("释放实体对象, id=" + id.ToString() + ", type=" + type.ToString()); } } return(true); }
public virtual string GetEntityView(CommercePipelineExecutionContext context, EntityView entityView) { return(entityView.Name); }
public EntityView Process(CommerceContext commerceContext, EntityView entityView) { using (CommandActivity.Start(commerceContext, this)) { var pluginPolicy = commerceContext.GetPolicy <PluginPolicy>(); try { var masterListEntityView = new EntityView { EntityId = string.Empty, ItemId = string.Empty, DisplayName = "topologies View", Name = "TopologiesView", UiHint = "List", Icon = pluginPolicy.Icon }; entityView.ChildViews.Add(masterListEntityView); var childView = new EntityView { EntityId = string.Empty, ItemId = "Topology01", DisplayName = "Topology01", Name = "Topology01", Icon = pluginPolicy.Icon }; childView.Properties.Add(new ViewProperty { Name = "Name", RawValue = "Topology01" }); childView.Properties.Add(new ViewProperty { Name = "Type", RawValue = "OneBox" }); childView.Properties.Add(new ViewProperty { Name = "Description", RawValue = "OneBox Topology" }); masterListEntityView.ChildViews.Add(childView); var childView2 = new EntityView { EntityId = string.Empty, ItemId = "Topology02", DisplayName = "Topology02", Name = "Topology02", Icon = pluginPolicy.Icon }; childView2.Properties.Add(new ViewProperty { Name = "Name", RawValue = "Topology02" }); childView2.Properties.Add(new ViewProperty { Name = "Type", RawValue = "SimpleHa" }); childView2.Properties.Add(new ViewProperty { Name = "Description", RawValue = "Simple HA configuration" }); masterListEntityView.ChildViews.Add(childView2); } catch (Exception ex) { commerceContext.Logger.LogError($"ChildViewEnvironments.Exception: Message={ex.Message}"); } return(entityView); } }
public static void doDone(CreateBallAction actionObject) { EntityView se = SceneViews.instance.getCurFBScene().createBall(actionObject.objectID, actionObject.prefab, actionObject.radius); se.setPosition(new Vector3(actionObject.position.x, 0.0f, actionObject.position.y)); }
private IEnumerator StartCreatingShip() { if (FreeEntities.Count == 0) { var loading = Resources.LoadAsync <GameObject>("Ship"); yield return(loading); GameObject go = Object.Instantiate(loading.asset) as GameObject; entity = go.GetComponent <EntityView>(); } else { entity = FreeEntities.Dequeue(); entity.gameObject.SetActive(true); } entity.transform.localScale = Vector3.one; entity.SetParent(ShipPosition); entity.ConnectedPlanet = ConnectedPlanet; entity.Player = entity.ConnectedPlanet.Player; entity.Health = 20; for (int i = 0; i < entity.Parts.Count; i++) { entity.Parts[i].SetScale(Vector3.zero); } yield return(null); entity.ResetPositionAndRotation(); Bodies = new Queue <EntityPartView>(); Weapons = new Queue <EntityPartView>(); Engines = new Queue <EntityPartView>(); for (int i = 0; i < entity.Parts.Count; i++) { entity.Parts[i].BuildTimer = 0; entity.Parts[i].MoveTimer = 0; if (entity.Parts[i].PartType == PartTypes.BODY) { entity.Parts[i].StartTarget = BodyFactory; Bodies.Enqueue(entity.Parts[i]); } if (entity.Parts[i].PartType == PartTypes.WEAPON) { entity.Parts[i].StartTarget = WeaponFactory; Weapons.Enqueue(entity.Parts[i]); } if (entity.Parts[i].PartType == PartTypes.ENGINE) { entity.Parts[i].StartTarget = EngineFactory; Engines.Enqueue(entity.Parts[i]); } entity.Parts[i].SetPosition(entity.Parts[i].StartTarget.position); entity.Parts[i].SetScale(Vector3.zero); } currentBody = Bodies.Dequeue(); currentWeapon = Weapons.Dequeue(); currentEngine = Engines.Dequeue(); BuildingShip = true; }
static void FillEntityView(EntityView entityView, object[] implementors, RemoveEntityImplementor removeEntity, string entityDescriptorName) { for (int index = 0; index < implementors.Length; index++) { var implementor = implementors[index]; if (implementor != null) { var type = implementor.GetType(); Type[] interfaces; if (_cachedTypes.TryGetValue(type, out interfaces) == false) { interfaces = _cachedTypes[type] = type.GetInterfacesEx(); } for (int iindex = 0; iindex < interfaces.Length; iindex++) { var componentType = interfaces[iindex]; #if DEBUG && !PROFILER Tuple <object, int> implementorHolder; if (implementorsByType.TryGetValue(componentType, out implementorHolder) == true) { implementorHolder.item2++; } else { implementorsByType[componentType] = new Tuple <object, int>(implementor, 1); } #else implementorsByType[componentType] = implementor; #endif } } #if DEBUG && !PROFILER else { Utility.Console.LogError(NULL_IMPLEMENTOR_ERROR.FastConcat(entityView.ToString())); } #endif } int count; //Very efficent way to collect the fields of every EntityViewType KeyValuePair <Type, CastedAction <EntityView> >[] setters = FasterList <KeyValuePair <Type, CastedAction <EntityView> > > .NoVirt.ToArrayFast(entityView.entityViewBlazingFastReflection, out count); var removeEntityComponentType = typeof(IRemoveEntityComponent); for (int i = 0; i < count; i++) { var keyValuePair = setters[i]; Type fieldType = keyValuePair.Key; if (fieldType != removeEntityComponentType) { #if DEBUG && !PROFILER Tuple <object, int> component; #else object component; #endif if (implementorsByType.TryGetValue(fieldType, out component) == false) { Exception e = new Exception(NOT_FOUND_EXCEPTION + " Component Type: " + fieldType.Name + " - EntityView: " + entityView.GetType().Name + " - EntityDescriptor " + entityDescriptorName); throw e; } #if DEBUG && !PROFILER if (component.item2 > 1) { Utility.Console.LogError(DUPLICATE_IMPLEMENTOR_ERROR.FastConcat( "Component Type: ", fieldType.Name, " implementor: ", component.item1.ToString()) + " - EntityView: " + entityView.GetType().Name + " - EntityDescriptor " + entityDescriptorName); } #endif #if DEBUG && !PROFILER keyValuePair.Value.Call(entityView, component.item1); #else keyValuePair.Value.Call(entityView, component); #endif } else { keyValuePair.Value.Call(entityView, removeEntity); } } implementorsByType.Clear(); }
public AttackCommand(int id, EntityView attacker, EntityView target) : base(id) { this.attackerId = attacker.id; this.x = target.column; this.y = target.row; }
public void Recycle(EntityView view) { view.SetVisible(false); activeViews.Remove(view); recycledViews.Add(view); }
public void SetupView(EntityView view) { View = view; }
protected virtual void CreateTierDetailsViews(PriceCard card, string snapshotId, EntityView pricingView, CommercePipelineExecutionContext context) { pricingView.UiHint = "Table"; if (card == null || !card.Snapshots.Any() || string.IsNullOrEmpty(snapshotId)) { return; } PriceSnapshotComponent snapshotComponent = card.Snapshots.FirstOrDefault(s => s.Id.Equals(snapshotId, StringComparison.OrdinalIgnoreCase)); if (snapshotComponent == null) { return; } var membershipTiersComponent = snapshotComponent.GetComponent <MembershipTiersComponent>(); if (membershipTiersComponent == null || !membershipTiersComponent.Tiers.Any()) { return; } List <CustomPriceTier> list = membershipTiersComponent.Tiers.ToList(); foreach (IGrouping <string, CustomPriceTier> grouping in list.GroupBy(t => t.Currency)) { pricingView.ChildViews.Add(new EntityView { EntityId = card.Id, ItemId = snapshotComponent.Id + "|" + grouping.Key, Name = context.GetPolicy <KnownCustomPricingViewsPolicy>().PriceCustomRow }); } }
public void RemoveView() { View = null; }
public AttackCommand(int id, EntityView attacker, EntityView target) : base(id) { this.attackerId = attacker.id; this.x = target.column; this.y = target.row; }
public void Result(float warStartTime, EntityViewModel p, EntityView pV, ActionStyle action){ float factor = 1.0f; float timeDiff = Time.time - warStartTime; /* if (action == ActionStyle.PIN){ factor = 0.5f; } */ //AcionStyle /* if(action == ActionStyle.ASSAULT) { float prob = Random.value; if(prob >= 0.25f) p.Opponent.BattleState = BattleState.CONFUSING; else if(prob < 0.5 && prob >= 0.5f) p.BattleState = BattleState.CONFUSING; else if(prob < 0.5f && prob >= 0.75f) { p.BattleState = BattleState.CONFUSING; p.Opponent.BattleState = BattleState.CONFUSING; } } */ /* else if(action == ActionStyle.RAID) { float prob = Random.value; if(prob >= 0.5f) p.Opponent.BattleState = BattleState.CONFUSING; } */ if(action == ActionStyle.FEINT) { if(timeDiff >= 1f) { p.TimeStarted = false; p.Counter++; return; } } else if(action == ActionStyle.PIN) { factor = 0.5f; } float health = p.Opponent.Health * Mathf.Pow (p.Opponent.noHurt, p.Health / (float)p.Opponent.Health); float d = p.Opponent.Health - Mathf.Pow (p.Opponent.noHurt + p.Opponent.hurt, p.Health / (float)p.Opponent.Health) * p.Opponent.Health; float ht = p.Opponent.Health - health - d; p.Opponent.Dead = d * factor; p.Opponent.Hurt = ht * factor; //healthHistory [nextCnt] = (healthHistory [counter] - Mathf.RoundToInt(d * factor) - Mathf.RoundToInt(ht*factor)); p.Opponent.Health = (p.Opponent.Health - p.Opponent.Dead - p.Opponent.Hurt) >= 0.5 ? p.Opponent.Health - p.Opponent.Dead - p.Opponent.Hurt : 0; //if(p.Opponent.Health > 0) pV.AtkAndUpdateHealth(); if (p.Opponent.Health <= 0) { p.TimeStarted = false; return; } //Debug.Log (Name + " Health: " + healthHistory [Counter]); string colorTag = p.Name != "Soldier3" ? "<color=red>" :"<color=yellow>"; colorTag = p.Name == "Soldier4" ? "<color=purple>" : colorTag; //call animation, but how to call the view??? Debug.Log (colorTag + "Time</color> " + timeDiff + "s, " + p.Opponent.Name + " Results: " + health + " " + ht + " " + d + " <color=blue>Opponent.Counter:</color> " + p.Counter); Debug.Log (colorTag + "Time</color> " + timeDiff + "s, " + p.Opponent.Name + " Actual Results: " + p.Opponent.Health + " " + p.Opponent.Hurt + " " + p.Opponent.Dead + " Total: " + (p.Opponent.Health + p.Opponent.Hurt + p.Opponent.Dead)); //Debug.Log (colorTag + "Round</color> " + roundCounter + ", " + p.Opponent.Name + " Results: " + health + " " + ht + " " + d + " <color=blue>Opponent.Counter:</color> " + p.Counter); //Debug.Log (colorTag + "Round</color> " + roundCounter + ", " + p.Opponent.Name + " Actual Results: " + p.Opponent.Health + " " + p.Opponent.Hurt + " " + p.Opponent.Dead + " Total: " + (p.Opponent.Health + p.Opponent.Hurt + p.Opponent.Dead)); p.Counter++; }