public void ShowResource(string inResourceName, BehaviorData inData) { GameObject gameObject = base.ShowResource(inResourceName); AudioSource audioSource = gameObject.GetComponent <AudioSource>(); audioSource.PlayDelayed((ulong)inData.delay); }
public IMyBot CreateBot(MyPlayer player, MyObjectBuilder_Bot botBuilder, MyBotDefinition botDefinition) { MyObjectBuilderType invalid = MyObjectBuilderType.Invalid; if (botBuilder != null) { invalid = botBuilder.TypeId; } else { invalid = botDefinition.Id.TypeId; botBuilder = m_objectFactory.CreateObjectBuilder <MyObjectBuilder_Bot>(m_objectFactory.GetProducedType(invalid)); } if (!this.m_botDataByBehaviorType.ContainsKey(botDefinition.BehaviorType)) { return(null); } BehaviorData data = this.m_botDataByBehaviorType[botDefinition.BehaviorType]; IMyBot bot = this.CreateBot(m_objectFactory.GetProducedType(invalid), player, botDefinition); this.CreateActions(bot, data.BotActionsType); this.CreateLogic(bot, data.LogicType, botDefinition.BehaviorSubtype); bot.Init(botBuilder); return(bot); }
private string CreateMethodBody(BehaviorData b, string append) { StringBuilder resule = new StringBuilder(); if (b is IParameterData) { var parameters = ((IParameterData)b).ParameterDifinition; if (parameters != null && parameters.Count > 0) { foreach (var p in parameters) { string type = p.Type.ToString().ToLower(); string pName = p.Name.Substring(0, 1).ToLower(); if (p.Name.Length > 1) { pName += p.Name.Substring(1); } resule.AppendLine(string.Format("// {0} {1} = ({0})parameters[\"{2}\"];", type, pName, p.Name)); } } } if (!string.IsNullOrEmpty(append)) { resule.AppendLine(append); } return(resule.ToString()); }
protected override void Excute(BehaviorData inData) { if (inData.ContainForm("SPEAKER")) { _dialogue.characterName = inData.speaker; } else if (inData.ContainForm("TALK")) { string talk = inData.talk.Replace("\\n", "\n"); if (GameDataManager.getInstance.scriptPlayMode == GameDataManager.EScriptPlayMode.Load || GameDataManager.getInstance.scriptPlayMode == GameDataManager.EScriptPlayMode.Skip) { // 대화를 바로 실행한다 _dialogue.talkMessage = talk; } else { _dialogue.PrintMessage(talk, 0, 0.05f); } } else { Debug.LogError(StringHelper.Format("[{0}] 대화 명령어가 등록되지 않았습니다!", inData.form)); } }
public override bool Equals(BehaviorData data) { if (GetType().Equals(data)) { return(bytes.Equals((data as UnknownBehaviorData).bytes)); } return(false); }
public override bool Equals(BehaviorData data) { if (GetType().Equals(data)) { return(projectedData.Equals((data as BeatmapDataBehaviorData).projectedData)); } return(false); }
public override bool Equals(BehaviorData data) { if (GetType().Equals(data)) { return(packID == (data as LevelPackBehaviorData).packID); } return(false); }
public override bool Equals(BehaviorData data) { if (GetType().Equals(data)) { return(levels.Equals((data as LevelCollectionBehaviorData).levels)); } return(false); }
public override bool Equals(BehaviorData data) { if (GetType().Equals(data)) { SimpleColor c = data as SimpleColor; return(r == c.r && g == c.g && b == c.b && a == c.a); } return(false); }
public bool ExcuteBehavior(BehaviorData inData) { if (inData.ContainForm(LoadKey)) { Excute(inData); return(true); } return(false); }
public override bool Equals(BehaviorData data) { if (GetType().Equals(data)) { var cm = data as ColorManager; return(playerModel.Equals(cm.playerModel) && colorA.Equals(cm.colorA) && colorB.Equals(cm.colorB)); } return(false); }
/// <summary> /// Force exit behavior when overridden by other behaviors. Behavior Pattern handles its exit (Usually just call exit), and ForceExitCallback will be called for behaviors to exit /// </summary> /// <param name="isDriven">A bool used to call all partners to stop, but do not reference its self back, just leave as default</param> public void ForceExit() { if (activeBehaviorPattern != null) // Happens when cooperating animal gets removed { activeBehaviorPattern.ForceExit(this.gameObject); activeBehavior.ForceExitCallback.Invoke(this.gameObject); activeBehavior = null; } }
public IHttpActionResult Post(BehaviorData behavior) { behavior.Created = DateTime.Now.ToUniversalTime(); behavior.IP = HttpContext.Current.Request.UserHostAddress; behavior.UserAgent = HttpContext.Current.Request.UserAgent; behavior.Referrer = behavior.Referrer ?? (HttpContext.Current.Request.UrlReferrer != null ? HttpContext.Current.Request.UrlReferrer.AbsoluteUri : String.Empty); _messageQueue.Publish(behavior); return(this.StatusCode(HttpStatusCode.Created)); }
/// <summary> /// If weight of behavior is not default value write line of code to set value /// </summary> /// <param name="behavior">behavior</param> private void SetBehaviorParameters(BehaviorData behavior) { if (behavior.Weight != 1) { _CreateTreeMethodBody.AppendLine(SetProperty(behavior.Name, "Weight", behavior.Weight.ToString() + "f")); } if (behavior.Concurrency != ConcurrencyMode.Unlimit) { _CreateTreeMethodBody.AppendLine(SetProperty(behavior.Name, "Concurrency", "Skill.Framework.AI.ConcurrencyMode." + behavior.Concurrency.ToString())); } }
protected override void Excute(BehaviorData inData) { if (inData.ContainForm("BGM")) { _bgm.HideAllResource(); } else { Debug.LogError(StringHelper.Format("[{0}] 중단 명령어가 등록되지 않았습니다!", inData.form)); } }
private bool IsInBehavior(BehaviorData behavior) { foreach (var item in _Behaviors) { if (item.Id == behavior.Id) { return(true); } } return(false); }
protected void LoadBotData(Assembly assembly) { var allTypes = assembly.GetTypes(); foreach (var type in allTypes) { if (!type.IsAbstract && type.IsSubclassOf(typeof(MyBotActionsBase))) { var typeAttrs = type.GetCustomAttributes(true); string behaviorName = ""; var behaviorData = new BehaviorData(type); foreach (var typeAttr in typeAttrs) { if (typeAttr is MyBehaviorDescriptorAttribute) { var behaviorPropertiesAttr = typeAttr as MyBehaviorDescriptorAttribute; Debug.Assert(!m_botDataByBehaviorType.ContainsKey(behaviorPropertiesAttr.DescriptorCategory), "Bot type already declared in the factory"); behaviorName = behaviorPropertiesAttr.DescriptorCategory; } else if (typeAttr is BehaviorActionImplAttribute) { var behaviorImplAttr = typeAttr as BehaviorActionImplAttribute; behaviorData.LogicType = behaviorImplAttr.LogicType; } } if (!string.IsNullOrEmpty(behaviorName) && behaviorData.LogicType != null) { m_botDataByBehaviorType[behaviorName] = behaviorData; } else { Debug.Assert(false, "Invalid bot data. Definition will be removed"); } } else if (!type.IsAbstract && type.IsSubclassOf(typeof(MyBotLogic))) { foreach (var typeAttr in type.GetCustomAttributes(typeof(BehaviorLogicAttribute), true)) { var subtypeAttr = typeAttr as BehaviorLogicAttribute; m_logicDataByBehaviorSubtype[subtypeAttr.BehaviorSubtype] = new LogicData(type); } } else if (!type.IsAbstract && typeof(MyAiTargetBase).IsAssignableFrom(type)) { foreach (var typeAttr in type.GetCustomAttributes(typeof(TargetTypeAttribute), true)) { var tarTypeAttr = typeAttr as TargetTypeAttribute; m_TargetTypeByName[tarTypeAttr.TargetType] = type; } } } }
// Executes the code the block represents, either returning a value or performing // some action and calling evaluate on the block's successor public BehaviorData Evaluate() { BehaviorData result = InnerEvaluate(); if (result.GetReturnType() != OutputType()) { throw new SystemException("Unexpected return type."); } next.Evaluate(); return(result); }
/// <summary> /// 캐릭터 등장 액션 /// </summary> /// <param name="inData"></param> public void FadeIn(BehaviorData inData) { GameObject moveCharacter = FindResource(inData.name); if (moveCharacter == null) { Debug.LogError("타겟 캐릭터를 찾지 못했습니다."); return; } moveCharacter.SetActive(true); LeanTween.moveLocal(moveCharacter, new Vector2(-400 + (int)inData.direction * 400, 0), inData.time).setEase(LeanTweenType.easeInOutSine); LeanTween.alphaCanvas(moveCharacter.GetComponent <CanvasGroup>(), 1, inData.time).setEase(LeanTweenType.easeInOutSine); }
/// <summary> /// called often, must return promptly. It is a thread safe function. /// </summary> public override void Process() { StartedLoop(); // every cycle we create new behaviorData, populating it with existing data objects: IBehaviorData behaviorData = new BehaviorData() { sensorsData = this.currentSensorsData, robotState = this.robotState, robotPose = this.robotPose }; // use sensor data to update robotPose: robotSlam.EvaluatePoseAndState(behaviorData, driveController); // populate all behaviors with current behaviorData: foreach (ISubsumptionTask task in subsumptionTaskDispatcher.Tasks) { BehaviorBase behavior = task as BehaviorBase; if (behavior != null) { behavior.behaviorData = behaviorData; } } subsumptionTaskDispatcher.Process(); // calls behaviors, which take sensor outputs, and may compute drive inputs // look at ActiveTasksCount - it is an indicator of behaviors completed or removed. Zero count means we may need new behaviors combo. MonitorDispatcherActivity(); // when active behavior is waiting (yielding), no action items are computed. // otherwise driveInputs will be non-null: if (behaviorData.driveInputs != null) { //Debug.WriteLine("ShortyTheRobot: Process() - have drive inputs V=" + behaviorData.driveInputs.velocity + " Omega=" + behaviorData.driveInputs.omega); driveController.driveInputs = behaviorData.driveInputs; driveController.Drive(); // apply driveInputs to motors robotState.velocity = behaviorData.driveInputs.velocity; robotState.omega = behaviorData.driveInputs.omega; } this.BehaviorData = behaviorData; // for tracing sensorsController.Process(); // let sensorsController do maintenance EndingLoop(); }
private static BehaviorData GetData(TextBlock textBlock) { BehaviorData data; if (s_storage.TryGetValue(textBlock, out data)) { return(data); } s_storage[textBlock] = data = new BehaviorData(); s_textPropertyDescriptor.AddValueChanged(textBlock, TextBlockTrimming.TextBlock_TextChanged); textBlock.SizeChanged += TextBlockTrimming.TextBlock_SizeChanged; data.OriginalText = textBlock.Text; return(data); }
private BehaviorData FindOneParent(BehaviorData child) { foreach (var b in _Behaviors) { if (b.BehaviorType == BehaviorType.Decorator || b.BehaviorType == BehaviorType.Composite) { if (b.Contains(child)) { return(b); } } } return(null); }
private void AddToBehaviors(BehaviorData behavior) { if (behavior == null) { return; } if (!IsInBehavior(behavior)) { _Behaviors.Add(behavior); } foreach (var item in behavior) { AddToBehaviors(item); } }
protected override void Excute(BehaviorData inData) { if (inData.ContainForm("BGM")) { _bgm.ShowResource(inData.name, inData); } else if (inData.ContainForm("SE")) { _se.ShowResource(inData.name, inData); } else if (inData.ContainForm("DISTRACTOR")) { // 선택지 히스토리를 따름 if (GameDataManager.getInstance.scriptPlayMode == GameDataManager.EScriptPlayMode.Load) { GameDataManager.getInstance.followDistactor = GameDataManager.getInstance.distractorHistory[GameDataManager.getInstance.readDistractorHistory]; if (GameDataManager.getInstance.followDistactor == GameDataManager.getInstance.NONE_SELECT_DISTRACTOR) { GameDataManager.getInstance.readCount = GameDataManager.getInstance.FindDisractorStartArea(GameDataManager.getInstance.NONE_SELECT_DISTRACTOR); } GameDataManager.getInstance.readDistractorHistory++; } else { GameDataManager.getInstance.stopBehavior = true; _distractor.ClearDistractorList(); string[] splitMessage = inData.distractorList.Split('-'); for (int i = 0; i < splitMessage.Length; i++) { if (i == 0) { continue; } _distractor.CreateDistractor(splitMessage[i], inData.notChooseDistractorTime); } _distractor.RefreshDistractorPosition(); } } else if (inData.ContainForm("BACKGROUND")) { _background.ShowResource(inData.name); } else { Debug.LogError(StringHelper.Format("[{0}] 실행 명령어가 등록되지 않았습니다!", inData.form)); } }
public void Publish(BehaviorData data) { lock (_locker) { var bodyData = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(data)); var basicProperties = _channel.CreateBasicProperties(); basicProperties.DeliveryMode = 1; basicProperties.ContentType = "application/json"; _channel.BasicPublish(exchange: _nameExchange, routingKey: _route, basicProperties: basicProperties, body: bodyData); } }
public void Create(BehaviorData behavior) { using (var connection = new SqlConnection(_connectionString)) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = _create; command.CommandType = CommandType.Text; command.Parameters.AddWithValue("@Name", behavior.Name); command.Parameters.AddWithValue("@Created", behavior.Created); command.Parameters.AddWithValue("@IP", behavior.IP); command.Parameters.AddWithValue("@Referrer", behavior.Referrer); command.Parameters.AddWithValue("@Url", behavior.Url); command.Parameters.AddWithValue("@UserAgent", behavior.UserAgent); command.Parameters.AddWithValue("@DataBag", Newtonsoft.Json.JsonConvert.SerializeObject(behavior.DataBag)); command.ExecuteNonQuery(); } }
/// <summary> /// 선택지 끝 판별 /// </summary> /// <param name="distractorNumber">선택지 종료</param> /// <returns></returns> public int FindDisractorEndArea(int distractorNumber) { int result = -1; for (int i = 0; i < GameDataManager.getInstance._behaviorList.Count; i++) { BehaviorData data = GameDataManager.getInstance._behaviorList[i]; if (data._read) { continue; } if (data.ContainForm("DISTRACTOR_END") && data.distractorNumber.CompareTo(distractorNumber) == 0) { result = i; break; } } return(result + 1); }
protected override void Excute(BehaviorData inData) { if (GameDataManager.getInstance.scriptPlayMode == GameDataManager.EScriptPlayMode.Load) { inData.time = 0; } if (inData.ContainForm("RAIN_START")) { _rainScript.gameObject.SetActive(true); _rainScript.RainStart(inData.time); } else if (inData.ContainForm("RAIN_END")) { _rainScript.RainEnd(inData.time); } else { Debug.LogError(StringHelper.Format("[{0}] 파티클 명령어가 등록되지 않았습니다!", inData.form)); } }
/// <summary> /// 실행 스크립트 /// </summary> void ParsePlay() { if (_splitArray[1] == "BGM") { GameDataManager.getInstance._behaviorList.Add(new BehaviorData() { hashTable = VNCommon.Hash("Form", "PLAY_BGM", "Name", VNCommon.GetSplitValue(_splitArray, 2), "Loop", VNCommon.GetSplitValue(_splitArray, 3, "반복안함"), "Delay", VNCommon.GetSplitValue(_splitArray, 4, "0")) }); } else if (_splitArray[1] == "SE") { GameDataManager.getInstance._behaviorList.Add(new BehaviorData() { hashTable = VNCommon.Hash("Form", "PLAY_SE", "Name", VNCommon.GetSplitValue(_splitArray, 2), "Delay", VNCommon.GetSplitValue(_splitArray, 3, "0"), "Loop", VNCommon.GetSplitValue(_splitArray, 4, "반복안함")) }); } else if (_splitArray[1] == "선택지") { if (_writeBehaviorData != null) { DevelopeLog.LogError("작성중인 선택지 데이터가 있습니다"); } _writeBehaviorData = new BehaviorData(); _writeBehaviorData.hashTable.Add("Form", "PLAY_DISTRACTOR"); _writeBehaviorData.hashTable.Add("DistractorList", ""); _writeBehaviorData.hashTable.Add("ValueCount", VNCommon.GetSplitValue(_splitArray, 2, "2")); _writeBehaviorData.hashTable.Add("NotChooseTime", VNCommon.GetSplitValue(_splitArray, 3, "0")); } else if (_splitArray[1] == "배경") { GameDataManager.getInstance._behaviorList.Add(new BehaviorData() { hashTable = VNCommon.Hash("Form", "PLAY_BACKGROUND", "Name", VNCommon.GetSplitValue(_splitArray, 2)) }); } else { DevelopeLog.LogError(StringHelper.Format("실행 명령어를 찾을수 없습니다! [{0}]", _readLine)); } }
protected override void Excute(BehaviorData inData) { if (inData.ContainForm("CHARACTER")) { _character.LoadResource(inData.name, inData); } else if (inData.ContainForm("BGM")) { _bgm.LoadResource(inData.name); } else if (inData.ContainForm("BACKGROUND")) { _background.LoadResource(inData.name); } else if (inData.ContainForm("SE")) { _se.LoadResource(inData.name); } else { Debug.LogError(StringHelper.Format("[{0}] 로드 명령어가 등록되지 않았습니다!", inData.form)); } }
protected void LoadBotData(Assembly assembly) { var allTypes = assembly.GetTypes(); foreach (var type in allTypes) { if (!type.IsAbstract && type.IsSubclassOf(typeof(MyBotActionsBase))) { var typeAttrs = type.GetCustomAttributes(true); string behaviorName = ""; var behaviorData = new BehaviorData(type); foreach (var typeAttr in typeAttrs) { if (typeAttr is MyBehaviorDescriptorAttribute) { var behaviorPropertiesAttr = typeAttr as MyBehaviorDescriptorAttribute; Debug.Assert(!m_botDataByBehaviorType.ContainsKey(behaviorPropertiesAttr.DescriptorCategory), "Bot type already declared in the factory"); behaviorName = behaviorPropertiesAttr.DescriptorCategory; } else if (typeAttr is BehaviorActionImplAttribute) { var behaviorImplAttr = typeAttr as BehaviorActionImplAttribute; behaviorData.LogicType = behaviorImplAttr.LogicType; } } if (!string.IsNullOrEmpty(behaviorName) && behaviorData.LogicType != null) { m_botDataByBehaviorType[behaviorName] = behaviorData; } else { Debug.Assert(false, "Invalid bot data. Definition will be removed"); } } else if (!type.IsAbstract && type.IsSubclassOf(typeof(MyBotLogic))) { var typeAttrs = type.GetCustomAttributes(true); foreach (var typeAttr in typeAttrs) { if (typeAttr is BehaviorLogicAttribute) { var subtypeAttr = typeAttr as BehaviorLogicAttribute; m_logicDataByBehaviorSubtype[subtypeAttr.BehaviorSubtype] = new LogicData(type); } } } else if (!type.IsAbstract && typeof(IMyBot).IsAssignableFrom(type)) { var typeAttrs = type.GetCustomAttributes(true); foreach (var typeAttr in typeAttrs) { if (typeAttr is BehaviorTypeAttribute) { var behTypeAttr = typeAttr as BehaviorTypeAttribute; m_botTypeByDefinitionType[behTypeAttr.BehaviorType] = new BehaviorTypeData(type); } } } } }
protected void LoadBotData(Assembly assembly) { #if XB1 // XB1_ALLINONEASSEMBLY System.Diagnostics.Debug.Assert(m_botDataLoaded == false); if (m_botDataLoaded == true) return; m_botDataLoaded = true; var allTypes = MyAssembly.GetTypes(); #else // !XB1 var allTypes = assembly.GetTypes(); #endif // !XB1 foreach (var type in allTypes) { if (!type.IsAbstract && type.IsSubclassOf(typeof(MyBotActionsBase))) { var typeAttrs = type.GetCustomAttributes(true); string behaviorName = ""; var behaviorData = new BehaviorData(type); foreach (var typeAttr in typeAttrs) { if (typeAttr is MyBehaviorDescriptorAttribute) { var behaviorPropertiesAttr = typeAttr as MyBehaviorDescriptorAttribute; Debug.Assert(!m_botDataByBehaviorType.ContainsKey(behaviorPropertiesAttr.DescriptorCategory), "Bot type already declared in the factory"); behaviorName = behaviorPropertiesAttr.DescriptorCategory; } else if (typeAttr is BehaviorActionImplAttribute) { var behaviorImplAttr = typeAttr as BehaviorActionImplAttribute; behaviorData.LogicType = behaviorImplAttr.LogicType; } } if (!string.IsNullOrEmpty(behaviorName) && behaviorData.LogicType != null) { m_botDataByBehaviorType[behaviorName] = behaviorData; } else { Debug.Assert(false, "Invalid bot data. Definition will be removed"); } } else if (!type.IsAbstract && type.IsSubclassOf(typeof(MyBotLogic))) { foreach (var typeAttr in type.GetCustomAttributes(typeof(BehaviorLogicAttribute), true)) { var subtypeAttr = typeAttr as BehaviorLogicAttribute; m_logicDataByBehaviorSubtype[subtypeAttr.BehaviorSubtype] = new LogicData(type); } } else if (!type.IsAbstract && typeof(MyAiTargetBase).IsAssignableFrom(type)) { foreach (var typeAttr in type.GetCustomAttributes(typeof(TargetTypeAttribute), true)) { var tarTypeAttr = typeAttr as TargetTypeAttribute; m_TargetTypeByName[tarTypeAttr.TargetType] = type; } } } }