public MecanimEvent(MecanimEvent other) { normalizedTime = other.normalizedTime; functionName = other.functionName; paramType = other.paramType; switch(paramType) { case MecanimEventParamTypes.Int32: intParam = other.intParam; break; case MecanimEventParamTypes.Float: floatParam = other.floatParam; break; case MecanimEventParamTypes.String: stringParam = other.stringParam; break; case MecanimEventParamTypes.Boolean: boolParam = other.boolParam; break; } condition = new EventCondition(); condition.conditions = new List<EventConditionEntry>(other.condition.conditions); critical = other.critical; isEnable = other.isEnable; }
public async Task <IActionResult> Put(int eventConditionId, [FromBody] EventConditionViewModel eventConditionVM) { if (ModelState.IsValid) { if (eventConditionVM == null) { return(BadRequest($"{nameof(eventConditionVM)} cannot be null")); } if (eventConditionId != eventConditionVM.EventConditionId) { return(BadRequest("Conflicting EventCondition EventConditionId in parameter and model data")); } _repository.Update(_mapper.Map <EventCondition>(eventConditionVM)); await _unitOfWork.SaveChangesAsync(); EventCondition updatedEventCondition = await _repository.FindAsync(eventConditionId); eventConditionVM = _mapper.Map <EventConditionViewModel>(updatedEventCondition); return(Ok(eventConditionVM)); } else { return(BadRequest(ModelState)); } }
public async Task <IActionResult> Post([FromBody] EventConditionViewModel eventConditionVM) { if (ModelState.IsValid) { if (eventConditionVM == null) { return(BadRequest($"{nameof(eventConditionVM)} cannot be null")); } if (eventConditionVM?.DataPoint?.DataPointId > 0) { eventConditionVM.DataPoint = null; } if (eventConditionVM.Event != null) { eventConditionVM.Event = null; } EventCondition eventCondition = _mapper.Map <EventCondition>(eventConditionVM); EntityEntry <EventCondition> addedEventCondition = await _repository.InsertAsync(eventCondition); await _unitOfWork.SaveChangesAsync(); eventConditionVM = _mapper.Map <EventConditionViewModel>(addedEventCondition.Entity); return(CreatedAtAction("GetByEventConditionId", new { eventConditionId = eventConditionVM.EventConditionId }, eventConditionVM)); } else { return(BadRequest(ModelState)); } }
public async Task <IActionResult> Patch(int eventConditionId, [FromBody] JsonPatchDocument <EventConditionViewModel> patch) { if (ModelState.IsValid) { if (patch == null) { return(BadRequest($"{nameof(patch)} cannot be null")); } EventConditionViewModel eventConditionVM = _mapper.Map <EventConditionViewModel>(await _repository.FindAsync(eventConditionId)); patch.ApplyTo(eventConditionVM, e => ModelState.AddModelError("", e.ErrorMessage)); if (ModelState.IsValid) { _repository.Update(_mapper.Map <EventCondition>(eventConditionVM)); await _unitOfWork.SaveChangesAsync(); EventCondition updatedEventCondition = await _repository.FindAsync(eventConditionId); eventConditionVM = _mapper.Map <EventConditionViewModel>(updatedEventCondition); return(Ok(eventConditionVM)); } } return(BadRequest(ModelState)); }
public void Copy(MecanimEvent other) { this.normalizedTime = other.normalizedTime; this.functionName = other.functionName; this.paramType = other.paramType; switch (this.paramType) { case MecanimEventParamTypes.Int32: this.intParam = other.intParam; break; case MecanimEventParamTypes.Float: this.floatParam = other.floatParam; break; case MecanimEventParamTypes.String: this.stringParam = other.stringParam; break; case MecanimEventParamTypes.Boolean: this.boolParam = other.boolParam; break; } this.condition = new EventCondition(); this.condition.conditions = new List <EventConditionEntry>(other.condition.conditions); this.critical = other.critical; this.isEnable = other.isEnable; }
public MecanimEvent(MecanimEvent other) { normalizedTime = other.normalizedTime; functionName = other.functionName; paramType = other.paramType; switch (paramType) { case MecanimEventParamTypes.Int32: intParam = other.intParam; break; case MecanimEventParamTypes.Float: floatParam = other.floatParam; break; case MecanimEventParamTypes.String: stringParam = other.stringParam; break; case MecanimEventParamTypes.Boolean: boolParam = other.boolParam; break; } condition = new EventCondition(); condition.conditions = new List <EventConditionEntry>(other.condition.conditions); critical = other.critical; isEnable = other.isEnable; }
public void OnDisable() { if (NrTSingleton <NrEventTriggerInfoManager> .Instance.IsATB(this.EventTriggerUnique, EventTriggerInfo.EventTriggerATB.Repeat)) { base.Enable(true); } else if (this.EventConditionList != null) { foreach (GameObject current in this.EventConditionList) { if (!(current == null)) { EventCondition component = current.GetComponent <EventCondition>(); if (component != null) { component.CleanEvent(); } } } } if (this.BehaviorList != null) { foreach (GameObject current2 in this.BehaviorList) { if (!(current2 == null)) { EventTriggerItem_Behavior component2 = current2.GetComponent <EventTriggerItem_Behavior>(); if (!(component2 == null)) { component2.OnDisableTrigger(); } } } } }
public bool IsVerifyEvent() { bool flag = false; if (this.EventConditionList.Count > 0) { foreach (GameObject current in this.EventConditionList) { if (!(current == null)) { EventCondition component = current.GetComponent <EventCondition>(); if (component.Verify) { flag = true; } component.Verify = false; } } } else { flag = true; } if (flag && EventTrigger.m_DebugMode) { TsLog.Log("[{0}] Verify EventCondition: {1}", new object[] { base.GetType().Name, base.name }); } return(flag); }
public EventCondition(EventCondition condition) { type = condition.type; @operator = condition.@operator; value_1 = new DynamicValue(condition.value_1); value_2 = new DynamicValue(condition.value_2); }
private void ConditionControlDeleted(object sender, EventArgs e) { SmsConditionControl control = (SmsConditionControl)sender; EventCondition cond = control.EventCondition; if (cond.ItemId > 0 && MessageBox.Show("Do you really want to delete event condition?", "Deleting confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { //если информация о состоянии сохранена в БД //и получен положительный ответ на ее удаление try { GlobalObjects.CasEnvironment.NewKeeper.Delete(cond); _smsEvent.EventConditions.Remove(cond); } catch (Exception ex) { Program.Provider.Logger.Log("Error while removing data", ex); } flowLayoutPanelConditions.Controls.Remove(control); control.Deleted -= ConditionControlDeleted; control.Dispose(); } else if (cond.ItemId <= 0) { flowLayoutPanelConditions.Controls.Remove(control); control.Deleted -= ConditionControlDeleted; control.Dispose(); } }
public GameEvent(int eventId, EventCondition condition, Action <IGameAction> action) { this.EventId = eventId; this.Condition = condition; this.actionDelegate = action; this.IsActive = true; }
public void SetupCondition() { if (IsEvent && !(LayerCondition is EventCondition)) { LayerCondition = new EventCondition(); } else if (!IsEvent && !(LayerCondition is DataModelCondition)) { LayerCondition = new DataModelCondition(); } }
public override object Clone() { var condition = new EventCondition(); condition.type = type; condition.@operator = @operator; condition.value_1 = new DynamicValue(value_1); condition.value_2 = new DynamicValue(value_2); return(condition); }
public async Task <IActionResult> Get(int eventConditionId) { EventCondition eventCondition = await _repository.FindAsync(eventConditionId); if (eventCondition == null) { return(NotFound(eventConditionId)); } else { return(Ok(_mapper.Map <EventConditionViewModel>(eventCondition))); } }
private void Update() { if (haveCondition) { EventCondition.Invoke(); if (!isMeetCondition) { return; } } if (isActive) { NPCTrigger(); } }
public void OnEnable() { this.SetStateOperation(); if (this.EventConditionList != null) { foreach (GameObject current in this.EventConditionList) { EventCondition component = current.GetComponent <EventCondition>(); if (component != null) { component.Verify = false; component.RegisterEvent(); } } } }
public async Task <IActionResult> Delete(int eventConditionId) { EventCondition eventCondition = await _repository.FindAsync(eventConditionId); if (eventCondition == null) { return(NotFound(eventConditionId)); } _repository.Delete(eventCondition); await _unitOfWork.SaveChangesAsync(); EventConditionViewModel eventConditionVM = _mapper.Map <EventConditionViewModel>(eventCondition); return(Ok(eventConditionVM)); }
// PUT: odata/EventConditions(5) public IHttpActionResult Put([FromODataUri] int key, Delta <EventCondition> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } EventCondition eventCondition = db.EventConditions.Find(key); if (eventCondition == null) { return(NotFound()); } Event @event = db.Events.Find(eventCondition.EventId); var check = AuthorizeLogic.VerifyEventEditPermission(@event); if (check) { patch.Put(eventCondition); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EventConditionExists(key)) { return(NotFound()); } else { throw; } } return(Updated(eventCondition)); } else { return(Unauthorized()); } }
public ICollection <EventCondition> Convert(ICollection <EventConditionViewModel> source, ICollection <EventCondition> destination, ResolutionContext context) { if (source == null) { return(null); } if (destination == null) { destination = new List <EventCondition>(); } if (destination.Count == 0 && source.Count > 0) { foreach (EventConditionViewModel sourceItem in source) { EventCondition destinitionItem = _unitOfWork.GetRepository <EventCondition>().GetFirstOrDefault(predicate: ec => ec.EventConditionId == sourceItem.EventConditionId); destination.Add(destinitionItem != null ? context.Mapper.Map(sourceItem, destinitionItem) : context.Mapper.Map <EventCondition>(sourceItem)); } } else { foreach (EventConditionViewModel sourceItem in source) { EventCondition destinationItem = destination.Where(d => d.EventConditionId == sourceItem.EventConditionId).SingleOrDefault(); if (destinationItem == null) { destinationItem = _unitOfWork.GetRepository <EventCondition>().GetFirstOrDefault(ec => ec, ec => ec.EventConditionId == sourceItem.EventConditionId); if (destinationItem == null) { destinationItem = context.Mapper.Map <EventCondition>(sourceItem); } destination.Add(destinationItem); } else { destinationItem = context.Mapper.Map(sourceItem, destinationItem); } } } return(destination); }
private void OnTriggerEnter2D(Collider2D other) { if (haveCondition) { EventCondition.Invoke(); if (!isMeetCondition) { return; } } if (other.tag == "Player" && isActive) { EventManager.GetInstance.TriggerEvent(eventName); if (isActiveOnce) { isActive = false; } } }
// POST: odata/EventConditions public IHttpActionResult Post(EventCondition eventCondition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Event @event = db.Events.Find(eventCondition.EventId); var check = AuthorizeLogic.VerifyEventEditPermission(@event); if (check) { db.EventConditions.Add(eventCondition); db.SaveChanges(); return(Created(eventCondition)); } else { return(Unauthorized()); } }
public override bool DrawGui(GUIStyle textStyle, GUIStyle buttonStyle) { bool changed = false; #if UNITY_EDITOR GUILayout.BeginHorizontal(); GUILayout.Space(20); var animationLabels = AnimationEvents.GetValues(); var index = System.Array.IndexOf(animationLabels, EventName); var newIndex = UnityEditor.EditorGUILayout.Popup("Event", index, animationLabels); if (newIndex >= 0) { EventName = animationLabels[newIndex]; UnityEditor.EditorUtility.SetDirty(this); } if (!Loop) { if (GUILayout.Button("Add Loop Condition", buttonStyle)) { Loop = true; LoopCondition = new EventCondition(); changed = true; } } GUILayout.Space(20); GUILayout.EndHorizontal(); if (Loop && LoopCondition != null) { LoopCondition.DrawGui(this, textStyle, buttonStyle); } if (changed) { UnityEditor.EditorUtility.SetDirty(this); } #endif return(changed); }
// DELETE: odata/EventConditions(5) public IHttpActionResult Delete([FromODataUri] int key) { EventCondition eventCondition = db.EventConditions.Find(key); if (eventCondition == null) { return(NotFound()); } Event @event = db.Events.Find(eventCondition.EventId); var check = AuthorizeLogic.VerifyEventEditPermission(@event); if (check) { db.EventConditions.Remove(eventCondition); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); } else { return(Unauthorized()); } }
public GameEventCondition(EventCondition condition) : base(condition) { }
/// <summary> /// Контрол редактирует данные об условии наступления события /// </summary> public SmsConditionControl(EventCondition eventCondition) : this() { AttachedObject = eventCondition; Program.MainDispatcher.ProcessControl(this); }
//============================================================================================== // 非公開メソッド /// <summary>イベントのコマンドデータからイベントを生成する</summary> private Event createEvent(string[][] commands, string eventName, int[] numbers, int beginLineCount) { List <string> targets = new List <string>(); List <EventCondition> conditions = new List <EventCondition>(); List <string[]> actions = new List <string[]>(); List <int> lineNumbers = new List <int>(); DebugManager debug_manager = GameObject.FindGameObjectWithTag("DebugManager").GetComponent <DebugManager>(); bool isPrologue = false; bool doContinue = false; int i = 0; foreach (string[] commandParams in commands) { switch (commandParams[0].ToLower()) { // ターゲットオブジェクト. case "target": if (commandParams.Length >= 2) { targets.Add(commandParams[1]); } else { Debug.LogError("Failed to add a target."); } break; // プロローグイベント. case "prologue": isPrologue = true; break; // 発生条件. case "condition": if (commandParams.Length >= 4) { // 指定されたオブジェクトを探す. // ToDo: 現在の実装では非表示のオブジェクトが見つけられないので対策を検討する. GameObject go = GameObject.Find(commandParams[1]); if (go == null) { Debug.LogError("Can't find object." + " " + commandParams[1]); } else { BaseObject bo = go.GetComponent <BaseObject>(); if (bo != null) { EventCondition ec = new EventCondition(bo, commandParams[2], commandParams[3]); conditions.Add(ec); // (デバッグ用)ウォッチする条件変数を追加する. debug_manager.addWatchConditionVariable(commandParams[1], commandParams[2]); } else { Debug.LogError("Failed to add a condition." + " " + go.name + " " + commandParams[2]); } } } else { Debug.LogError("Failed to add a condition."); } break; // 継続評価. case "continue": doContinue = true; break; // それ以外はアクション (この段階ではパラメータを保存しておくだけ). default: actions.Add(commandParams); lineNumbers.Add(numbers[i]); break; } ++i; } if (isPrologue) { // プロローグイベントはターゲットオブジェクトが関係しないのでクリアしておく. targets.Clear(); } else { // プロローグイベントではないときはターゲットオブジェクトが最低 2 つはないと成り立たない. if (targets.Count < 2) { Debug.LogError("Failed to create an event."); return(null); } } if (actions.Count < 1) { // イベント処理は最低 1 つないと無意味. Debug.LogError("Failed to create an event at " + beginLineCount + "."); return(null); } Event ev = new Event(targets.ToArray(), conditions.ToArray(), actions.ToArray(), isPrologue, doContinue, eventName); ev.setActionLineNumbers(lineNumbers.ToArray()); return(ev); }
public MecanimEvent() { condition = new EventCondition(); }
public ExplorationEvent() { precondition = EventCondition.alwaysTrue(); }
private void ValueConditionField(EventCondition condition) { DynamicValueField(condition.value_1); condition.@operator = (RelationalOperator)EditorGUILayout.EnumPopup(condition.@operator); DynamicValueField(condition.value_2); }
private void EventConditionField(EventCondition condition) { GUILayout.Label("When event"); condition.value_1.constantValue = EditorGUILayout.IntField((int)condition.value_1.constantValue); GUILayout.Label(" is running."); }
private bool DrawConditionGroup <T>(string label, bool foldout, BaseConditionGroup <T> group) where T : class, IConditionable, new() { var list = group.conditions; var notList = new List <bool>(); var oprList = new List <LogicalOperator>(); GUILayout.BeginVertical("box"); GUILayout.BeginHorizontal(); foldout = EditorGUILayout.Foldout(foldout, label); GUI.backgroundColor = Color.green; if (GUILayout.Button("+", GUILayout.MaxWidth(50))) { if (list.Count > 0) { group.operators.Add(LogicalOperator.And); list.Add((T)list[list.Count - 1].Clone()); } else { list.Add(new T()); } } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); if (!foldout) { GUILayout.EndVertical(); return(foldout); } // Seperate Not from other two operators for (int i = 0; i < list.Count; i++) { notList.Add(false); } for (int i = 0, j = 0; i < group.operators.Count; i++) { if (group.operators[i] == LogicalOperator.Not) { notList[j] = true; } else { oprList.Add(group.operators[i]); j++; if (j >= list.Count) { break; } } } AddIndent(); GUILayout.BeginVertical(); for (int i = 0; i < list.Count; i++) { GUILayout.BeginHorizontal("box"); // Button for delete this condition GUI.backgroundColor = Color.red; if (GUILayout.Button("X", GUILayout.MaxWidth(50))) { list.RemoveAt(i); notList.RemoveAt(i); if (oprList.Count > i + 1) { oprList.RemoveAt(i); } else if (i - 1 >= 0) { oprList.RemoveAt(i - 1); } continue; } GUI.backgroundColor = Color.white; GUILayout.Space(3); // Draw event condition if ((list[i] as EventCondition) != null) { // Toggle for switch between EventCondition and ValueCondition var e = list[i] as EventCondition; var isEventCond = e.type == ConditionType.GameEvent; isEventCond = EditorGUILayout.Toggle(isEventCond); if ((e.type == ConditionType.GameEvent) != isEventCond) { e = new EventCondition() { type = isEventCond ? ConditionType.GameEvent : ConditionType.GameValue }; list[i] = e as T; } } // Button for toggle Not if (notList[i]) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } if (GUILayout.Button("Not", GUILayout.Width(45))) { notList[i] = !notList[i]; } GUI.backgroundColor = Color.white; // Draw event condition if ((list[i] as EventCondition) != null) { var e = list[i] as EventCondition; if (e.type == ConditionType.GameValue) { ValueConditionField(e); } else { EventConditionField(e); } } // Draw family condition if ((list[i] as FamilyCondition) != null) { var e = list[i] as FamilyCondition; FamilyConditionField(e); } // Logical operators between conditions, the last condition won't need one if (i < oprList.Count) { if (GUILayout.Button(oprList[i].ToString(), GUILayout.Width(45))) { if (oprList[i] == LogicalOperator.And) { oprList[i] = LogicalOperator.Or; } else { oprList[i] = LogicalOperator.And; } } } else { GUILayout.Space(50); } GUILayout.EndHorizontal(); } // Update operators group.operators.Clear(); for (int i = 0; i < notList.Count; i++) { if (notList[i]) { group.operators.Add(LogicalOperator.Not); } if (oprList.Count > i) { group.operators.Add(oprList[i]); } } GUILayout.EndVertical(); MinusIndent(); GUILayout.EndVertical(); return(foldout); }