Beispiel #1
0
        /// <summary>
        /// Validates the given data to make 0 input possible.
        /// </summary>
        /// <param name="self"></param>
        private void validateData(ObjectInteractionListener self)
        {
            if (_positionAnimated.x == 0)
            {
                _positionAnimated.x = _positionBase.x;
            }

            if (_positionAnimated.y == 0)
            {
                _positionAnimated.y = _positionBase.y;
            }

            if (_positionAnimated.z == 0)
            {
                _positionAnimated.z = _positionBase.z;
            }

            _rotationAnimated = Quaternion.Euler(self.RotationAnimated);

            _scaleAnimated = self.ScaleAnimated;
            if (_scaleAnimated.x == 0)
            {
                _scaleAnimated.x = _scaleBase.x;
            }

            if (_scaleAnimated.y == 0)
            {
                _scaleAnimated.y = _scaleBase.y;
            }

            if (_scaleAnimated.z == 0)
            {
                _scaleAnimated.z = _scaleBase.z;
            }
        }
Beispiel #2
0
//End of new animation Methodes

//Calculations

        /// <summary>
        /// Writes the data of the given Object listener to the Animation Controller.
        /// </summary>
        /// <param name="self"></param>
        private void WriteData(ObjectInteractionListener self)
        {
            _meshGameObject                     = self.MeshGameObject;
            _positionBase                       = _meshGameObject.transform.localPosition;
            _rotationBase                       = _meshGameObject.transform.localRotation;
            _scaleBase                          = _meshGameObject.transform.localScale;
            _animationStepsPerKlick             = self.AnimationStepsPerKlick;
            _positionAnimated                   = self.PositionAnimated;
            _activateObjectPhysikAfterAnimation = self.ActivateGravityAtEnd;
            _rotationAnimated                   = Quaternion.Euler(self.RotationAnimated);
            _onedirectionAnimation              = self.OnedirectionAnimation;
            _animationType                      = self.AnimationType;
            _keyType = self.KeyType;
            _animationDurationInFrames = self.AnimationDurationInFrames;
        }
Beispiel #3
0
        /// <summary>
        /// Forms the link between GameObject and the animation
        /// </summary>
        /// <param name="linkedGameObject"></param>
        /// <param name="self"></param>
        public void StartNewAnimation(GameObject linkedGameObject, ObjectInteractionListener self)
        {
            _objectInteractionListener = self;
            if (_childAnimationActive || _childAnimationOpen)
            {
                return;
            }
            _frameCount = 0;
            WriteData(self);

            validateData(self);


            CalculateSteps();

            _dataRead = true;


            if (_animationActive && _animationType == AnimationType.Open)
            {
                return;
            }

            if (_activateObjectPhysikAfterAnimation)
            {
                if (_meshGameObject.GetComponent <Rigidbody>() == null)
                {
                    _meshGameObject.AddComponent <Rigidbody>();
                }

                _rigidbody = _meshGameObject.GetComponent <Rigidbody>();
                if (_rigidbody.useGravity == true)
                {
                    _rigidbody.useGravity = false;
                }

                _rigidbody.isKinematic = true;
            }

            var a = _meshGameObject.GetComponent <Rigidbody>();

            _linkedMeshGameObject = linkedGameObject;
        }
Beispiel #4
0
//End of Methodes for Moving


//New animation methode

        /// <summary>
        /// Reverses Rotation values for animation and activates animations
        /// </summary>
        /// <param name="self"></param>
        /// <exception cref="ArgumentException"></exception>
        public void StartNewAnimation(ObjectInteractionListener self)
        {
            _objectInteractionListener = self;
            _meshGameObject            = _objectInteractionListener.MeshGameObject;
            if (_animationType == AnimationType.Open && _dataRead != true)
            {
                WriteData(self);
                _dataRead = true;
            }

            if (_animationType != AnimationType.Open)
            {
                WriteData(self);
            }

            validateData(self);

            CalculateSteps();

            _dataRead = true;

            if (_animationActive && _animationType == AnimationType.Open)
            {
                return;
            }

            if (_activateObjectPhysikAfterAnimation)
            {
                if (_meshGameObject.GetComponent <Rigidbody>() == null)
                {
                    _meshGameObject.AddComponent <Rigidbody>();
                }

                _rigidbody = _meshGameObject.GetComponent <Rigidbody>();
                if (_rigidbody.useGravity == true)
                {
                    _rigidbody.useGravity = false;
                }

                _rigidbody.isKinematic = true;
            }

            var a = _meshGameObject.GetComponent <Rigidbody>();

            if (_animationType == AnimationType.GhostMoveOnKeySmash || _animationType == AnimationType.GhostActivateOnKeyHold)
            {
                _ghostDrivenAnimationActive = true;
            }

            if (!_open && _animationType == AnimationType.GhostActivateOnKeyHold)
            {
                _frameCount = 0;
            }

            if (_onedirectionAnimation && _animationType == AnimationType.GhostMoveOnKeySmash)
            {
                _frameCount = 0;
            }
            if (_keyType == KeyType.A && _animationType == AnimationType.GhostMoveOnKeySmash)
            {
                throw new ArgumentException("Key Type can not be A for a GhostMoveOnSmash animation");
            }

            _animationActive = true;
            if (_open)
            {
                _objectInteractionListener.Source.clip = _objectInteractionListener.CloseSound;
            }
            else
            {
                _objectInteractionListener.Source.clip = _objectInteractionListener.OpenSound;
            }
            _objectInteractionListener.Source.Play();
        }