Esempio n. 1
0
        public void Attach(string objectToAttach, string host, Frame3D relativePosition)
        {
            this.Log("Attach", objectToAttach, host, relativePosition);

            var parent     = GameObject.Find(host);
            var attachment = GameObject.Find(objectToAttach);

            attachment.transform.position = parent.transform.position;
            attachment.transform.rotation = parent.transform.rotation;

            var rp = relativePosition.ToUnityBasis();

            attachment.transform.position += Quaternion.Euler(parent.transform.eulerAngles) *
                                             new Vector3((float)rp.X, (float)rp.Y, (float)rp.Z);
            attachment.transform.rotation *= Quaternion.Euler((float)rp.Pitch.Grad, (float)rp.Yaw.Grad, (float)rp.Roll.Grad);

            var joint = attachment.AddComponent <FixedJoint>();

            joint.connectedBody       = parent.GetComponent <Rigidbody>();
            joint.enableCollision     = false;
            joint.breakForce          = Single.PositiveInfinity;
            joint.enablePreprocessing = false;

            attachedParams.Add(attachment, new Tuple <float, float>(attachment.GetComponent <Rigidbody>().drag, attachment.GetComponent <Rigidbody>().angularDrag));
            attachment.GetComponent <Rigidbody>().drag = attachment.GetComponent <Rigidbody>().angularDrag = 0;
        }
Esempio n. 2
0
        public void MakeDaggerExplosion(Frame3D location)
        {
            this.Log("MakeDaggerExplosion", location);

            var unityExpLoc = location.ToUnityBasis();

            var daggerExplosion = GameObject.Instantiate <GameObject>(_daggerExplosionPrefab);

            daggerExplosion.name = "DaggerExplosion";
            daggerExplosion.transform.position = new Vector3((float)unityExpLoc.X, (float)unityExpLoc.Y, (float)unityExpLoc.Z);
        }
Esempio n. 3
0
        public void SetAbsoluteSpeed(string id, Frame3D speed)
        {
            this.Log("SetAbsoluteSpeed", id, speed);

            requestedAbsoluteSpeed[id] = speed.ToUnityBasis();

            if (requestedRelativeSpeed.ContainsKey(id))
            {
                requestedRelativeSpeed.Remove(id);
            }
        }
Esempio n. 4
0
        public void CreateWard(string objId, Frame3D location)
        {
            // Dispatcher.CurrentLog.Log("CreateWard", objId, location);

            var unityWardLoc = location.ToUnityBasis();

            var ward = GameObject.Instantiate <GameObject>(_wardPrefab);

            ward.name = objId;
            ward.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0));
            ward.transform.position = new Vector3((float)unityWardLoc.X, (float)unityWardLoc.Y, (float)unityWardLoc.Z);
        }
Esempio n. 5
0
        public void SetAbsoluteLocation(string id, Frame3D location)
        {
            this.Log("SetAbsoluteLocation", id, location);

            var obj           = ObjectsCache.FindGameObject(id);
            var unityLocation = location.ToUnityBasis();
            var newPosition   = new Vector3(
                (float)unityLocation.X,
                (float)unityLocation.Y,
                (float)unityLocation.Z);
            var newRotation = new Vector3(
                (float)unityLocation.Pitch.Simplify360().Grad,
                (float)unityLocation.Yaw.Simplify360().Grad,
                (float)unityLocation.Roll.Simplify360().Grad);

            obj.transform.position = newPosition;
            obj.transform.rotation = Quaternion.Euler(newRotation);
        }