/// <summary>This is Executed when the Asset is created for the first time </summary> private void Reset() { ID = MTools.GetInstance <StateID>("Fall"); General = new AnimalModifier() { RootMotion = false, AdditivePosition = true, AdditiveRotation = true, Grounded = false, Sprint = false, OrientToGround = false, Gravity = true, CustomRotation = false, modify = (modifier)(-1), }; LowerBlendDistance = 0.1f; FallRayForward = 0.1f; fallRayMultiplier = 1f; FallSpeed.name = "FallSpeed"; ExitFrame = false; //IMPORTANT }
void SetModesListeners(MEventListener listener, string EventName, string ModeName) { MEvent e = MTools.GetInstance <MEvent>(EventName); if (listener.Events.Find(item => item.Event == e) == null) { var item = new MEventItemListener() { Event = e, useVoid = true, useInt = true, useBool = true, }; ModeID att2 = MTools.GetInstance <ModeID>(ModeName); UnityEditor.Events.UnityEventTools.AddObjectPersistentListener <ModeID>(item.ResponseBool, Mode_Pin, att2); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseBool, Mode_Pin_Input); UnityEditor.Events.UnityEventTools.AddObjectPersistentListener <ModeID>(item.ResponseInt, Mode_Pin, att2); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseInt, Mode_Pin_Ability); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.Response, Mode_Interrupt); listener.Events.Add(item); Debug.Log("<B>" + EventName + "</B> Added to the Event Listeners"); } }
void CreateListeners() { MEventListener listener = this.FindComponent <MEventListener>(); if (listener == null) { listener = transform.root.gameObject.AddComponent <MEventListener>(); } if (listener.Events == null) { listener.Events = new List <MEventItemListener>(); } MEvent BlendS = MTools.GetInstance <MEvent>("Blend Shapes"); if (listener.Events.Find(item => item.Event == BlendS) == null) { var item = new MEventItemListener() { Event = BlendS, useVoid = false, useString = true, useInt = true, useFloat = true }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseInt, _PinShape); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseString, _PinShape); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseFloat, _PinnedShapeSetValue); listener.Events.Add(item); Debug.Log("<B>Blend Shapes</B> Added to the Event Listeners"); } }
///This was left blank intentionally /// Callbacks: all the public functions and methods /// Logic: all Combat logic is there, Equip, Unequip, Aim Mode... /// Variables: All Variables and Properties #region RESET COMBAT VALUES WHEN THE SCRIPT IS CREATED ON THE EDITOR #if UNITY_EDITOR private void Reset() { var m_Aim = GetComponent <Aim>(); if (m_Aim == null) { m_Aim = gameObject.AddComponent <Aim>(); } BoolVar RiderCombatMode = MTools.GetInstance <BoolVar>("RC Combat Mode"); //MEvent RCCombatMode = MTools.GetInstance<MEvent>("RC Combat Mode"); MEvent RCEquipedWeapon = MTools.GetInstance <MEvent>("RC Equiped Weapon"); MEvent SetCameraSettings = MTools.GetInstance <MEvent>("Set Camera Settings"); if (RiderCombatMode != null) { UnityEditor.Events.UnityEventTools.AddPersistentListener(OnCombatMode, RiderCombatMode.SetValue); } // if (RCCombatMode != null) UnityEditor.Events.UnityEventTools.AddPersistentListener(OnCombatMode, RCCombatMode.Invoke); if (RCEquipedWeapon != null) { UnityEditor.Events.UnityEventTools.AddPersistentListener(OnEquipWeapon, RCEquipedWeapon.Invoke); } if (SetCameraSettings != null) { UnityEditor.Events.UnityEventTools.AddPersistentListener(m_Aim.OnAimSide, SetCameraSettings.Invoke); } }
private void Reset() { Director = GetComponent <PlayableDirector>(); MEvent timelineMEvent = MTools.GetInstance <MEvent>("Timeline"); if (timelineMEvent != null) { UnityEditor.Events.UnityEventTools.AddBoolPersistentListener(OnTimelinePlay, timelineMEvent.Invoke, true); UnityEditor.Events.UnityEventTools.AddBoolPersistentListener(OnTimelineStop, timelineMEvent.Invoke, false); } }
void Reset() { MTools.SetLayer(base.transform, 20); //Set all the Childrens to Animal Layer . gameObject.tag = "Animal"; //Set the Animal to Tag Animal AnimatorSpeed = 1; Anim = GetComponentInParent <Animator>(); //Cache the Animator RB = GetComponentInParent <Rigidbody>(); //Catche the Rigid Body if (RB == null) { RB = gameObject.AddComponent <Rigidbody>(); RB.useGravity = false; RB.constraints = RigidbodyConstraints.FreezeRotation; RB.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; } speedSets = new List <MSpeedSet>(1) { new MSpeedSet() { name = "Ground", StartVerticalIndex = new IntReference(1), TopIndex = new IntReference(3), states = new List <StateID>(2) { MTools.GetInstance <StateID>("Idle"), MTools.GetInstance <StateID>("Locomotion") }, Speeds = new List <MSpeed>(3) { new MSpeed("Walk", 1, 4, 4), new MSpeed("Trot", 2, 4, 4), new MSpeed("Run", 3, 4, 4) } } }; BoolVar useCameraInp = MTools.GetInstance <BoolVar>("Global Camera Input"); BoolVar globalSmooth = MTools.GetInstance <BoolVar>("Global Smooth Vertical"); FloatVar globalTurn = MTools.GetInstance <FloatVar>("Global Turn Multiplier"); if (useCameraInp != null) { useCameraInput.Variable = useCameraInp; } if (globalSmooth != null) { SmoothVertical.Variable = globalSmooth; } if (globalTurn != null) { TurnMultiplier.Variable = globalTurn; } }
void Reset() { ID = MTools.GetInstance <StateID>("Death"); General = new AnimalModifier() { modify = (modifier)(-1), Persistent = true, LockInput = true, LockMovement = true, AdditiveRotation = true, }; }
void CreateListeners() { MEventListener listener = GetComponent <MEventListener>(); if (listener == null) { listener = gameObject.AddComponent <MEventListener>(); } if (listener.Events == null) { listener.Events = new List <MEventItemListener>(); } MEvent effectEnable = MTools.GetInstance <MEvent>("Effect Enable"); MEvent effectDisable = MTools.GetInstance <MEvent>("Effect Disable"); if (listener.Events.Find(item => item.Event == effectEnable) == null) { var item = new MEventItemListener() { Event = effectEnable, useVoid = false, useString = true, useInt = true }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseInt, Effect_Enable); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseString, Effect_Enable); listener.Events.Add(item); Debug.Log("<B>Effect Enable</B> Added to the Event Listeners"); } if (listener.Events.Find(item => item.Event == effectDisable) == null) { var item = new MEventItemListener() { Event = effectDisable, useVoid = false, useString = true, useInt = true }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseInt, Effect_Disable); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseString, Effect_Disable); listener.Events.Add(item); Debug.Log("<B>Effect Disable</B> Added to the Event Listeners"); } }
void Reset() { ID = MTools.GetInstance <StateID>("Climb"); General = new AnimalModifier() { RootMotion = true, AdditivePosition = true, AdditiveRotation = true, Grounded = false, Sprint = false, OrientToGround = false, Gravity = false, CustomRotation = true, modify = (modifier)(-1), FreeMovement = false, IgnoreLowerStates = true, }; }
internal void Reset() { ID = MTools.GetInstance <StateID>("Jump"); Input = "Jump"; SleepFromState = new List <StateID>() { MTools.GetInstance <StateID>("Fall"), MTools.GetInstance <StateID>("Fly") }; SleepFromMode = new List <ModeID>() { MTools.GetInstance <ModeID>("Action"), MTools.GetInstance <ModeID>("Attack1") }; General = new AnimalModifier() { RootMotion = false, Grounded = false, Sprint = false, OrientToGround = false, CustomRotation = false, IgnoreLowerStates = true, //IMPORTANT! Persistent = true, AdditivePosition = true, AdditiveRotation = true, Gravity = false, modify = (modifier)(-1), }; ExitFrame = false; profiles = new List <JumpBasicProfile>(1) { new JumpBasicProfile() { Height = new FloatReference(5f), JumpTime = 0.33f, name = "Default", VerticalSpeed = 0 } }; }
//public override void JustWakeUp() //{ // if (animal.ActiveStateID == StateEnum.UnderWater) //Means is Underwater State.. // { // IsSleepFromState = true; //Keep Sleeping if you are in Underwater // } //} #if UNITY_EDITOR internal void Reset() { ID = MTools.GetInstance <StateID>("Jump"); Input = "Jump"; SleepFromState = new List <StateID>() { MTools.GetInstance <StateID>("Fall"), MTools.GetInstance <StateID>("Fly") }; SleepFromMode = new List <ModeID>() { MTools.GetInstance <ModeID>("Action"), MTools.GetInstance <ModeID>("Attack1") }; General = new AnimalModifier() { RootMotion = true, Grounded = false, Sprint = false, OrientToGround = false, CustomRotation = true, IgnoreLowerStates = true, //IMPORTANT! Persistent = false, AdditivePosition = true, AdditiveRotation = true, Gravity = false, modify = (modifier)(-1), }; ExitFrame = false; jumpProfiles = new List <JumpProfile>() { new JumpProfile() { name = "Jump", /*stepHeight = 0.1f,*/ fallingTime = 0.7f, /* fallRay = 2, ForwardMultiplier = 1,*/ HeightMultiplier = 1, JumpLandDistance = 1.7f } }; }
void Reset() { remainInState = MTools.GetInstance <MAIState>("Remain in State"); AIMovement = this.FindComponent <MAnimalAIControl>(); if (AIMovement) { //AIMovement.AutoInteract = false; AIMovement.AutoNextTarget = false; AIMovement.UpdateTargetPosition = false; AIMovement.MoveAgentOnMovingTarget = false; AIMovement.LookAtTargetOnArrival = false; if (Animal) { Animal.isPlayer.Value = false; //Make sure this animal is not the Main Player } } else { Debug.LogWarning("There's AI Control in this GameObject"); } }
void SetStateListeners(MEventListener listener, string EventName, string statename) { MEvent e = MTools.GetInstance <MEvent>(EventName); if (listener.Events.Find(item => item.Event == e) == null) { var item = new MEventItemListener() { Event = e, useVoid = false, useInt = true, useBool = true, }; StateID ss = MTools.GetInstance <StateID>(statename); UnityEditor.Events.UnityEventTools.AddObjectPersistentListener <StateID>(item.ResponseBool, State_Pin, ss); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseBool, State_Pin_ByInput); listener.Events.Add(item); Debug.Log("<B>" + EventName + "</B> Added to the Event Listeners"); } }
void ConnectToInput() { MInput input = GetComponent <MInput>(); if (input == null) { input = gameObject.AddComponent <MInput>(); } BoolVar RiderCombatMode = MTools.GetInstance <BoolVar>("RC Combat Mode"); BoolVar RCWeaponInput = MTools.GetInstance <BoolVar>("RC Weapon Input"); #region AIM INPUT var AIM = input.FindInput("Aim"); if (AIM == null) { AIM = new InputRow("Aim", "Aim", KeyCode.Mouse1, InputButton.Press, InputType.Key); input.inputs.Add(AIM); AIM.active.Variable = RiderCombatMode; AIM.active.UseConstant = false; UnityEditor.Events.UnityEventTools.AddPersistentListener(AIM.OnInputChanged, Aim_Set); Debug.Log("<B>Aim</B> Input created and connected to RiderCombat.SetAim()"); } #endregion #region RiderAttack1 INPUT var RCA1 = input.FindInput("RiderAttack1"); if (RCA1 == null) { RCA1 = new InputRow("RiderAttack1", "RiderAttack1", KeyCode.Mouse0, InputButton.Press, InputType.Key); input.inputs.Add(RCA1); RCA1.active.Variable = RiderCombatMode; RCA1.active.UseConstant = false; UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA1.OnInputDown, MainAttack); UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA1.OnInputUp, MainAttackReleased); Debug.Log("<B>RiderAttack1</B> Input created and connected to RiderCombat.MainAttack() and RiderCombat.MainAttackReleased()"); } #endregion #region RiderAttack2 INPUT var RCA2 = input.FindInput("RiderAttack2"); if (RCA2 == null) { RCA2 = new InputRow("RiderAttack2", "RiderAttack2", KeyCode.Mouse1, InputButton.Press, InputType.Key); input.inputs.Add(RCA2); RCA2.active.Variable = RiderCombatMode; RCA2.active.UseConstant = false; UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA2.OnInputDown, SecondAttack); UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA2.OnInputUp, SecondAttackReleased); Debug.Log("<B>RiderAttack2</B> Input created and connected to RiderCombat.SecondAttack() and RiderCombat.SecondAttackReleased() "); } #endregion #region Reload INPUT var Reload = input.FindInput("Reload"); if (Reload == null) { Reload = new InputRow("Reload", "Reload", KeyCode.R, InputButton.Down, InputType.Key); input.inputs.Add(Reload); Reload.active.Variable = RiderCombatMode; Reload.active.UseConstant = false; UnityEditor.Events.UnityEventTools.AddPersistentListener(Reload.OnInputDown, ReloadWeapon); Debug.Log("<B>Reload</B> Input created and connected to RiderCombat.ReloadWeapon() "); } #endregion EditorUtility.SetDirty(input); }
void CreateEventListeners() { MEvent RCSetAim = MTools.GetInstance <MEvent>("RC Set Aim"); MEvent RCMainAttack = MTools.GetInstance <MEvent>("RC Main Attack"); MEvent RCSecondaryAttack = MTools.GetInstance <MEvent>("RC Secondary Attack"); MEventListener listener = GetComponent <MEventListener>(); if (listener == null) { listener = gameObject.AddComponent <MEventListener>(); } if (listener.Events == null) { listener.Events = new List <MEventItemListener>(); } //*******************// if (listener.Events.Find(item => item.Event == RCSetAim) == null) { var item = new MEventItemListener() { Event = RCSetAim, useVoid = false, useBool = true, }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseBool, Aim_Set); listener.Events.Add(item); Debug.Log("<B>RC Set Aim</B> Added to the Event Listeners"); } //*******************// if (listener.Events.Find(item => item.Event == RCMainAttack) == null) { var item = new MEventItemListener() { Event = RCMainAttack, useVoid = false, useBool = true }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseBool, MainAttack); listener.Events.Add(item); Debug.Log("<B>RC MainAttack</B> Added to the Event Listeners"); } //*******************// if (listener.Events.Find(item => item.Event == RCSecondaryAttack) == null) { var item = new MEventItemListener() { Event = RCSecondaryAttack, useVoid = false, useBool = true }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseBool, SecondAttack); listener.Events.Add(item); Debug.Log("<B>RC SecondaryAttack</B> Added to the Event Listeners"); EditorUtility.SetDirty(listener); } }
void CreateListeners() { MEventListener listener = GetComponent <MEventListener>(); if (listener == null) { listener = gameObject.AddComponent <MEventListener>(); } if (listener.Events == null) { listener.Events = new List <MEventItemListener>(); } MEvent MovementMobile = MTools.GetInstance <MEvent>("Set Movement Mobile"); if (listener.Events.Find(item => item.Event == MovementMobile) == null) { var item = new MEventItemListener() { Event = MovementMobile, useVoid = true, useVector2 = true, }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseVector2, SetInputAxis); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.Response, UseCameraBasedInput); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseFloat, SetUpDownAxis); listener.Events.Add(item); Debug.Log("<B>Set Movement Mobile</B> Added to the Event Listeners"); } //********************************// SetModesListeners(listener, "Set Attack1", "Attack1"); SetModesListeners(listener, "Set Attack2", "Attack2"); SetModesListeners(listener, "Set Action", "Action"); /************************/ MEvent actionstatus = MTools.GetInstance <MEvent>("Set Action Status"); if (listener.Events.Find(item => item.Event == actionstatus) == null) { var item = new MEventItemListener() { Event = actionstatus, useVoid = false, useInt = true, useFloat = true }; ModeID ac = MTools.GetInstance <ModeID>("Action"); UnityEditor.Events.UnityEventTools.AddObjectPersistentListener(item.ResponseInt, Mode_Pin, ac); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseInt, Mode_Pin_Status); UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseFloat, Mode_Pin_Time); listener.Events.Add(item); Debug.Log("<B>Set Action Status</B> Added to the Event Listeners"); } /************************/ MEvent sprinting = MTools.GetInstance <MEvent>("Set Sprint"); if (listener.Events.Find(item => item.Event == sprinting) == null) { var item = new MEventItemListener() { Event = sprinting, useVoid = false, useBool = true, }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseBool, SetSprint); listener.Events.Add(item); Debug.Log("<B>Sprint Listener</B> Added to the Event Listeners"); } MEvent timeline = MTools.GetInstance <MEvent>("Timeline"); if (listener.Events.Find(item => item.Event == timeline) == null) { var item = new MEventItemListener() { Event = timeline, useVoid = false, useBool = true, }; UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseBool, SetTimeline); listener.Events.Add(item); Debug.Log("<B>Timeline Listener</B> Added to the Event Listeners"); } /************************/ SetStateListeners(listener, "Set Jump", "Jump"); SetStateListeners(listener, "Set Fly", "Fly"); /************************/ }