예제 #1
0
 public void Validate(IDirector root, IDirectable parent)
 {
     this.parent = parent;
     ValidateAnimParams();
     hideFlags = HideFlags.HideInHierarchy;
     OnAfterValidate();
 }
예제 #2
0
 //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;
     }
 }
예제 #3
0
        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
            };
        }
예제 #4
0
 ///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();
 }
예제 #5
0
 private void Awake()
 {
     _directable = GetComponent <IDirectable>();
     info        = new DamageInfo();
     info.damage = damage;
     info.dealer = gameObject;
 }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #9
0
        public static StagPoint.Eval.Environment GetExpressionEnvironment(this IDirectable directable)
        {
            var env = directable.root.CreateExpressionEnvironment().Push();

            Slate.Expressions.ExpressionsUtility.Wrap(directable, env);
            return(env);
        }
예제 #10
0
 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);
 }
예제 #11
0
 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);
 }
예제 #12
0
        ///----------------------------------------------------------------------------------------------

        ///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()));
        }
예제 #13
0
 /// <summary>
 /// Invoked when a directable starts moving along
 /// this path.
 /// </summary>
 public void OnPathStarted(IDirectable iDirectable)
 {
     _occupancy++;
     if (_onPathStarted != null)
     {
         _onPathStarted(this, iDirectable);
     }
 }
예제 #14
0
        ///----------------------------------------------------------------------------------------------

        ///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);
        }
예제 #15
0
    /// <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);
        }
    }
예제 #17
0
        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));
        }
예제 #18
0
        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);
        }
예제 #19
0
 ///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);
 }
예제 #20
0
    /// <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
        }
    }
예제 #21
0
        ///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));
        }
예제 #22
0
        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();
        }
예제 #23
0
        ///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);
        }
예제 #24
0
        //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);
    }
예제 #27
0
    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);
    }
예제 #28
0
        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);
        }
예제 #29
0
        ///----------------------------------------------------------------------------------------------

        ///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
        }
예제 #30
0
 ///After creation
 public void PostCreate(IDirectable parent)
 {
     this.parent = parent;
     CreateAnimationDataCollection();
     OnCreate();
 }