public void Validate(IDirector root, IDirectable parent) { this.parent = parent; ValidateAnimParams(); hideFlags = HideFlags.HideInHierarchy; OnAfterValidate(); }
//basically store last clip selected so that we can show multiple clip curves from different tracks at the same time static void OnDirectableSelectionChange(IDirectable directable) { if (directable is IKeyable && directable.parent is CutsceneTrack) { (directable.parent as CutsceneTrack).showCurvesClip = (IKeyable)directable; } }
static void Main(string[] args) { MoonRover lunokhod = new MoonRover("Lunokhod 1", 1970); MoonRover apollo = new MoonRover("Apollo 15", 1971); MarsRover sojourner = new MarsRover("Sojourner", 1997); Satellite sputnik = new Satellite("Sputnik", 1957); Rover[] rov = new Rover[] { lunokhod, apollo, sojourner }; DirectAll(rov); Object[] all = new Object[] { lunokhod, apollo, sojourner, sputnik }; foreach (Object al in all) { Console.WriteLine($"Tracking a {al.GetType()}…"); } IDirectable[] dict = new IDirectable[] { lunokhod, apollo, sojourner, sputnik }; }
///Validate the track and it's clips public void Validate(IDirector root, IDirectable parent) { this.parent = parent; clips = GetComponents <ActionClip>().OrderBy(a => a.startTime).ToList(); layerOrder = parent.children.Where(t => t.GetType() == this.GetType() && t.isActive).Reverse().ToList().IndexOf(this); OnAfterValidate(); }
private void Awake() { _directable = GetComponent <IDirectable>(); info = new DamageInfo(); info.damage = damage; info.dealer = gameObject; }
public static float GetWeight(this IDirectable directable, float time, float blendIn, float blendOut) { var length = GetLength(directable); if (time <= 0) { return(blendIn <= 0 ? 1 : 0); } if (time >= length) { return(blendOut <= 0 ? 1 : 0); } if (time < blendIn) { return(time / blendIn); } if (time > length - blendOut) { return((length - time) / blendOut); } return(1); }
static void Main(string[] args) { MoonRover lunokhod = new MoonRover("Lunokhod 1", 1970); MoonRover apollo = new MoonRover("Apollo 15", 1971); MarsRover sojourner = new MarsRover("Sojourner", 1997); Satellite sputnik = new Satellite("Sputnik", 1957); Rover[] rovers = new Rover[] { lunokhod, apollo, sojourner }; DirectAll(rovers); Object[] allSpaceObjects = new Object[] { lunokhod, apollo, sojourner, sputnik }; foreach (Object spaceObject in allSpaceObjects) { Type t = spaceObject.GetType(); Console.WriteLine($"Tracking a {t}..."); } IDirectable[] spaceObjects = new IDirectable[] { lunokhod, apollo, sojourner, sputnik }; Console.WriteLine(" "); DirectAll(spaceObjects); Console.ReadLine(); }
static void Main(string[] args) { MoonRover lunokhod = new MoonRover("Lunokhod 1", 1970); MoonRover apollo = new MoonRover("Apollo 15", 1971); MarsRover sojourner = new MarsRover("Sojourner", 1997); Satellite sputnik = new Satellite("Sputnik", 1957); Rover[] theRovers = new Rover[] { lunokhod, apollo, sojourner }; Object o1 = lunokhod; Object o2 = apollo; Object o3 = sojourner; Object o4 = sputnik; Object[] objects = new Object[] { o1, o2, o3, o4 }; foreach (Object o in objects) { Console.WriteLine($"Tracking a {o.GetType()}..."); } IDirectable[] theDirectables = new IDirectable[] { lunokhod, apollo, sojourner, sputnik }; DirectAll(theDirectables); }
public static StagPoint.Eval.Environment GetExpressionEnvironment(this IDirectable directable) { var env = directable.root.CreateExpressionEnvironment().Push(); Slate.Expressions.ExpressionsUtility.Wrap(directable, env); return(env); }
public static IDirectable GetNextSibling(this IDirectable directable) { if (directable.parent != null) { return(directable.parent.children.FirstOrDefault(d => d != directable && d.startTime > directable.startTime)); } return(null); }
public static IDirectable GetPreviousSibling(this IDirectable directable) { if (directable.parent != null) { return(directable.parent.children.LastOrDefault(d => d != directable && d.startTime < directable.startTime)); } return(null); }
///---------------------------------------------------------------------------------------------- ///Returns the first child directable of provided name public static IDirectable FindChild(this IDirectable directable, string name) { if (directable.children == null) { return(null); } return(directable.children.FirstOrDefault(d => d.name.ToLower() == name.ToLower())); }
/// <summary> /// Invoked when a directable starts moving along /// this path. /// </summary> public void OnPathStarted(IDirectable iDirectable) { _occupancy++; if (_onPathStarted != null) { _onPathStarted(this, iDirectable); } }
///---------------------------------------------------------------------------------------------- ///Utility to check if delta (time - previous time) are close enough to trigger something that should only trigger when they are public static bool WithinBufferTriggerRange(this IDirectable directable, float time, float previousTime, bool bypass = false) { if (directable.root.isReSampleFrame) { return(false); } return((time - previousTime) <= (0.1f * directable.root.playbackSpeed) || bypass); }
/// <summary> /// Invoked whenever we have had a plan exit it's path /// </summary> private void OnExitedPath(Flightpath flightPath, IDirectable iDirectable) { flightPath.drawPath = flightPath.occupancy > 0; Rigidbody dRigidBody = iDirectable.GetComponent <Rigidbody>(); dRigidBody.constraints = RigidbodyConstraints.FreezeAll; Destroy((Object)iDirectable); }
private void OnTriggerEnter(Collider other) { IDirectable iDirectable = other.GetComponent <IDirectable>(); if (iDirectable != null) { _landingZone.OnNodeEntered(this, iDirectable); } }
public static Quaternion TransformRotation(this IDirectable directable, Vector3 euler, TransformSpace space) { var t = directable.GetSpaceTransform(space); if (t != null) { return(t.rotation * Quaternion.Euler(euler)); } return(Quaternion.Euler(euler)); }
public static Vector3 InverseTransformRotation(this IDirectable directable, Quaternion rot, TransformSpace space) { var t = directable.GetSpaceTransform(space); if (t != null) { return((Quaternion.Inverse(t.rotation) * rot).eulerAngles); } return(rot.eulerAngles); }
///Should two provided directables be able to cross-blend? public static bool CanCrossBlend(this IDirectable directable, IDirectable other) { if (directable == null || other == null) { return(false); } if ((directable.canCrossBlend || other.canCrossBlend) && directable.GetType() == other.GetType()) { return(true); } return(false); }
/// <summary> /// Invoked when this path has been completed or /// they left it /// </summary> public void OnPathExited(IDirectable iDirectable) { _occupancy--; if (_onPathExited != null) { _onPathExited(this, iDirectable); } if (_occupancy <= 0) { // Destroy } }
///Going upwards, returns the first parent of type T public static T GetFirstParentOfType <T>(this IDirectable directable) where T : IDirectable { var current = directable.parent; while (current != null) { if (current is T) { return((T)current); } current = current.parent; } return(default(T)); }
static void Main(string[] args) { MoonRover lunokhod = new MoonRover("Lunokhod 1", 1970); MoonRover apollo = new MoonRover("Apollo 15", 1971); MarsRover sojourner = new MarsRover("Sojourner", 1997); Satellite sputnik = new Satellite("Sputnik", 1957); // Object[] objects = new Object[4]{lunokhod, apollo, sojourner, sputnik}; // DirectAll(objects); IDirectable[] probes = new IDirectable[4] { lunokhod, apollo, sojourner, sputnik }; DirectAll(probes); Console.ReadLine(); }
///In SceneGUI, shows a rotation handle for target vector of target directable public static bool DoVectorRotationHandle(IDirectable directable, TransformSpace space, Vector3 position, ref Vector3 euler) { EditorGUI.BeginChangeCheck(); var pos = directable.TransformPosition(position, space); var rot = directable.TransformRotation(euler, space); var newRot = Handles.RotationHandle(rot, pos); Handles.SphereHandleCap(-10, pos, Quaternion.identity, 0.1f, EventType.Repaint); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(directable as Object, "Rotation Change"); euler = directable.InverseTransformRotation(newRot, space); EditorUtility.SetDirty(directable as Object); return(true); } return(false); }
//Validate the group and it's tracks public void Validate(IDirector root, IDirectable parent) { this.root = root; var foundTracks = GetComponentsInChildren <CutsceneTrack>(true); for (var i = 0; i < foundTracks.Length; i++) { if (!tracks.Contains(foundTracks[i])) { tracks.Add(foundTracks[i]); } } if (tracks.Any(t => t == null)) { tracks = foundTracks.ToList(); } sections = sections.OrderBy(s => s.time).ToList(); }
public void OnNodeEntered(LandingNode landingNode, IDirectable directable) { LandingState state = GetLandingState(directable); state.OnEnteredGate(landingNode.id); if (landingNode.id == _landingNodes.Count - 1) { if (state.isValid) { int index = UnityEngine.Random.Range(0, _tailsHooks.Length); _tailsHooks[index].LandDirectable(directable); } //directable.OnLandingAttempted(state.isValid && !state.hitWall, this); _landingStates.Remove(state); } }
private LandingState GetLandingState(IDirectable directable) { for (int i = 0; i < _landingStates.Count; i++) { if (_landingStates[i].target == directable) { if (_landingStates[i].timeout < Time.timeSinceLevelLoad) { _landingStates.RemoveAt(i); break; } return(_landingStates[i]); } } LandingState landingState = new LandingState(); landingState.target = directable; landingState.timeout = _landingTimeout + Time.timeSinceLevelLoad; _landingStates.Add(landingState); return(landingState); }
private void Spawn() { float angle = ((Mathf.PI * 2) * Random.value); float sin = Mathf.Sin(angle); float cos = Mathf.Cos(angle); // Pick a spawn position Vector3 spawnPosition = _root.position; spawnPosition.x += _radius * sin; spawnPosition.z += _radius * cos; GameObject go = _factory.CreateRandomPlane(spawnPosition, Quaternion.identity); go.transform.SetParent(_root); // Grab our directable component IDirectable iDirectable = go.GetComponent <IDirectable>(); // Set our primary travel position Vector3 primaryTravelPosition = _root.position; primaryTravelPosition.x += (_radius - _primaryTargetRadiusOffset) * sin; primaryTravelPosition.z += (_radius - _primaryTargetRadiusOffset) * cos; primaryTravelPosition.y += _primaryTargetHeightOffset; // Secondary Point angle = ((Mathf.PI * 2) * Random.value); Vector3 holdingPosition = _playerTransform.position; float hpRadius = Random.value * _holdingPositionRadius * _playerTransform.scale; holdingPosition.x += sin * hpRadius; holdingPosition.z += cos * hpRadius; Flightpath flightPath = new Flightpath(primaryTravelPosition); flightPath.drawPath = false; flightPath.AddPosition(holdingPosition); flightPath.Finialized(); iDirectable.AssignPath(flightPath, true); }
static void Main(string[] args) { MoonRover lunokhod = new MoonRover("Lunokhod 1", 1970); MoonRover apollo = new MoonRover("Apollo 15", 1975); MarsRover sojourner = new MarsRover("Sojourner", 1997); Satellite sputnik = new Satellite("Sputnik", 1957); Rover[] rovers = new Rover[] { lunokhod, apollo, sojourner }; Object[] probesList = new object[] { lunokhod, apollo, sojourner, sputnik }; IDirectable[] directProbes = new IDirectable[] { lunokhod, apollo, sojourner, sputnik }; foreach (Object item in probesList) { Console.WriteLine($"Tracking a : {item.GetType()}"); } Console.WriteLine("*************************************************\n"); DirectAll(rovers); }
///---------------------------------------------------------------------------------------------- ///Returns the transform object used for specified Space transformations. Null if World Space. public static Transform GetSpaceTransform(this IDirectable directable, TransformSpace space, GameObject actorOverride = null) { if (space == TransformSpace.CutsceneSpace) { return(directable.root != null ? directable.root.context.transform : null); } var actor = actorOverride != null ? actorOverride : directable.actor; if (actor != null) { if (space == TransformSpace.ActorSpace) { return(actor != null ? actor.transform : null); } if (space == TransformSpace.ParentSpace) { return(actor != null ? actor.transform.parent : null); } } return(null); //world space }
///After creation public void PostCreate(IDirectable parent) { this.parent = parent; CreateAnimationDataCollection(); OnCreate(); }