Inheritance: TrackedReference
    static void AnimationState_length(JSVCall vc)
    {
        UnityEngine.AnimationState _this = (UnityEngine.AnimationState)vc.csObj;
        var result = _this.length;

        JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
    }
    static void AnimationState_clip(JSVCall vc)
    {
        UnityEngine.AnimationState _this = (UnityEngine.AnimationState)vc.csObj;
        var result = _this.clip;

        JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
    }
 static public int AddMixingTransform(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
             UnityEngine.Transform      a1;
             checkType(l, 2, out a1);
             self.AddMixingTransform(a1);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
             UnityEngine.Transform      a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             self.AddMixingTransform(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        /// <summary>
        /// Plays a given animation.
        /// </summary>
        /// <param name="name">The name of the animation to play.</param>
        public void Play(string name)
        {
            // Validate that we have an animation
            if (!_animation) {
                _animation = animation;

                if (!_animation) {
                    Debug.LogWarning("No valid animation attached to object.", this);
                    return;
                }
            }

            // Get and validate the animation state
            var state = animation[name];
            if (!state) {
                Debug.LogWarning(string.Format("No animation state named '{0}' found.", name), this);
                return;
            }

            _elapsedTime = 0f;
            _currentState = state;
            _currentState.normalizedTime = 0;
            _currentState.enabled = true;
            _currentState.weight = 1;
            _isPlaying = true;

            _callback0 = null;
            _callback1 = null;
        }
Beispiel #5
0
        public override void OnStart(PartModule.StartState state)
        {
            DragManager = part.gameObject.GetComponent<DragManager>();

            if (DragManager == null) {
                DragManager = part.gameObject.AddComponent<DragManager>();
                DragManager.SetPart(part);
            }

            anim = part.FindModelAnimators(AnimationName)[0];
            animState = anim[AnimationName];
            animState.wrapMode = WrapMode.Clamp;

            if (FixAnimLayers) {
                int i = 0;
                foreach (AnimationState s in anim)
                    s.layer = i++;
            }

            animState.normalizedSpeed = 0;
            if (engaged) {
                animState.normalizedTime = Drag / 100;
                spoilerState = ModuleLandingGear.GearStates.DEPLOYED;
            }
            else {
                animState.normalizedTime = 0;
                spoilerState = ModuleLandingGear.GearStates.RETRACTED;
            }
            anim.Play(AnimationName);
        }
 /// <summary>
 /// Updates the animation event arguments.
 /// </summary>
 /// <param name="state">State.</param>
 /// <param name="previousState">Previous state.</param>
 /// <param name="overrideState">Override State.</param>
 public virtual void UpdateAnimationEventArgs(AnimationState state, AnimationState previousState, string overrideState)
 {
     State = state;
     PreviousState = previousState;
     OverrideState = overrideState;
     Priority = 0;
 }
Beispiel #7
0
 static public int AddMixingTransform(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(UnityEngine.Transform), typeof(bool)))
         {
             UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
             UnityEngine.Transform      a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             self.AddMixingTransform(a1, a2);
             return(0);
         }
         else if (matchType(l, 2, typeof(UnityEngine.Transform)))
         {
             UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
             UnityEngine.Transform      a1;
             checkType(l, 2, out a1);
             self.AddMixingTransform(a1);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int CrossFadeQueued(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(string), typeof(float), typeof(UnityEngine.QueueMode), typeof(UnityEngine.PlayMode)))
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             UnityEngine.QueueMode a3;
             checkEnum(l, 4, out a3);
             UnityEngine.PlayMode a4;
             checkEnum(l, 5, out a4);
             UnityEngine.AnimationState ret = self.CrossFadeQueued(a1, a2, a3, a4);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2, typeof(string), typeof(float), typeof(UnityEngine.QueueMode)))
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             UnityEngine.QueueMode a3;
             checkEnum(l, 4, out a3);
             UnityEngine.AnimationState ret = self.CrossFadeQueued(a1, a2, a3);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2, typeof(string), typeof(float)))
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             UnityEngine.AnimationState ret = self.CrossFadeQueued(a1, a2);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2, typeof(string)))
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             UnityEngine.AnimationState ret = self.CrossFadeQueued(a1);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Beispiel #9
0
        public static bool isAnimationComplete(this Animation animation, AnimationClip clip)
        {
            Debug.Assert(clip != null);

            UnityEngine.AnimationState state = animation[clip.name];

            return(state.enabled == false || (Mathf.Abs(1f - state.normalizedTime) < 0.001f));
        }
 static public int set_blendMode(IntPtr l)
 {
     UnityEngine.AnimationState     o = (UnityEngine.AnimationState)checkSelf(l);
     UnityEngine.AnimationBlendMode v;
     checkEnum(l, 2, out v);
     o.blendMode = v;
     return(0);
 }
    static public int set_name(IntPtr l)
    {
        UnityEngine.AnimationState o = (UnityEngine.AnimationState)checkSelf(l);
        string v;

        checkType(l, 2, out v);
        o.name = v;
        return(0);
    }
    static public int set_normalizedSpeed(IntPtr l)
    {
        UnityEngine.AnimationState o = (UnityEngine.AnimationState)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.normalizedSpeed = v;
        return(0);
    }
        void Awake()
        {
            float frames = m_clip.frameRate * m_clip.length;
            m_startN = m_start / frames;
            m_endN = m_end / frames;
            m_animState = animation[m_clip.name];

               //         m_trail.Emit = false;
        }
    static public int set_layer(IntPtr l)
    {
        UnityEngine.AnimationState o = (UnityEngine.AnimationState)checkSelf(l);
        int v;

        checkType(l, 2, out v);
        o.layer = v;
        return(0);
    }
    static public int set_enabled(IntPtr l)
    {
        UnityEngine.AnimationState o = (UnityEngine.AnimationState)checkSelf(l);
        bool v;

        checkType(l, 2, out v);
        o.enabled = v;
        return(0);
    }
    static public int set_weight(IntPtr l)
    {
        UnityEngine.AnimationState o = (UnityEngine.AnimationState)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.weight = v;
        return(0);
    }
 public void ApplyStateParameters(UnityEngine.AnimationState state)
 {
     if (state != null)
     {
         state.layer     = _Layer;
         state.speed     = _Speed;
         state.blendMode = _BlendMode;
         state.wrapMode  = _WrapMode;
     }
 }
Beispiel #18
0
 public AMPlugAnimation(Animation aAnim, string clipName, WrapMode aWrap, bool aFadeIn, float aFadeInTime)
     : base(null, false)
 {
     ignoreAccessor = true;
     anim = aAnim;
     animState = anim[clipName];
     wrap = aWrap;
     fadeIn = aFadeIn;
     fadeInTime = aFadeInTime;
 }
 public static void pushValue(IntPtr l, UnityEngine.AnimationState o)
 {
     if (o == null)
     {
         LuaDLL.lua_pushnil(l);
     }
     else
     {
         pushObject(l, o);
     }
 }
 static public int get_blendMode(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         pushEnum(l, (int)self.blendMode);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_normalizedSpeed(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         pushValue(l, self.normalizedSpeed);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #22
0
 void DoEnableAnimation(GameObject go)
 {
     if (UpdateCache(go))
     {
         anim = animation[animName.Value];
         if (anim != null)
         {
             anim.enabled = enable.Value;
         }
     }
 }
 static public int get_weight(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         pushValue(l, self.weight);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_wrapMode(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.wrapMode);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_enabled(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.enabled);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #26
0
 static public int get_wrapMode(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         pushEnum(l, (int)self.wrapMode);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.AnimationState o;
			o=new UnityEngine.AnimationState();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Beispiel #28
0
 static public int get_enabled(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         pushValue(l, self.enabled);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimationState o;
         o = new UnityEngine.AnimationState();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #30
0
        public virtual void UpdateAvatar(UMAData umaData)
        {
            if (umaData)
            {
                AnimationState[] snapshot = null;
                if (umaData.animationController)
                {
                    var animator = umaData.animator;

					bool animating = false;
                    bool applyRootMotion = false;
                    bool animatePhysics = false;
                    AnimatorCullingMode cullingMode = AnimatorCullingMode.AlwaysAnimate;

                    if (animator)
                    {
						animating = animator.enabled;
                        applyRootMotion = animator.applyRootMotion;
                        animatePhysics = animator.animatePhysics;
                        cullingMode = animator.cullingMode;
                        
						if (umaData.animationController == animator.runtimeAnimatorController)
						{
							snapshot = new AnimationState[animator.layerCount];
							for (int i = 0; i < animator.layerCount; i++)
							{
								var state = animator.GetCurrentAnimatorStateInfo(i);
								snapshot[i].stateHash = state.nameHash;
								snapshot[i].stateTime = Mathf.Max(0, state.normalizedTime - Time.deltaTime / state.length);
							}
						}
						
						Object.DestroyImmediate(animator);
                    }
                    var oldParent = umaData.umaRoot.transform.parent;
                    umaData.umaRoot.transform.parent = null;
                    animator = CreateAnimator(umaData, umaData.umaRecipe.raceData.TPose, umaData.animationController, applyRootMotion, animatePhysics, cullingMode);
                    umaData.animator = animator;
                    umaData.umaRoot.transform.parent = oldParent;
                    if (snapshot != null)
                    {
                        for (int i = 0; i < animator.layerCount; i++)
                        {
                            animator.Play(snapshot[i].stateHash, i, snapshot[i].stateTime);
                        }
                
                        animator.Update(0);
                        animator.enabled = animating;
                    }
                }
            }
        }
 static public int set_normalizedSpeed(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.normalizedSpeed = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_name(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         string v;
         checkType(l, 2, out v);
         self.name = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #33
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimationState o;
         o = new UnityEngine.AnimationState();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimationState o;
         o=new UnityEngine.AnimationState();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Beispiel #35
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.AnimationState o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.AnimationState();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 static public int set_enabled(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.enabled = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int RemoveMixingTransform(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         UnityEngine.Transform      a1;
         checkType(l, 2, out a1);
         self.RemoveMixingTransform(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_blendMode(IntPtr l)
 {
     try {
         UnityEngine.AnimationState     self = (UnityEngine.AnimationState)checkSelf(l);
         UnityEngine.AnimationBlendMode v;
         checkEnum(l, 2, out v);
         self.blendMode = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #39
0
 static public int set_layer(IntPtr l)
 {
     try {
         UnityEngine.AnimationState self = (UnityEngine.AnimationState)checkSelf(l);
         int v;
         checkType(l, 2, out v);
         self.layer = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
        void DoEnableAnimation(GameObject go)
        {
            if (go == null) return;

            if (go.animation == null)
            {
                LogError("Missing animation component!");
                return;
            }

            anim = go.animation[animName.Value];

            if (anim != null)
            {
                anim.enabled = enable.Value;
            }
        }
		void DoPlayAnimation()
		{
			var go = Fsm.GetOwnerDefaultTarget(gameObject);
			if (go == null || string.IsNullOrEmpty(animName.Value))
			{
				Finish();
				return;
			}
			
			if (string.IsNullOrEmpty(animName.Value))
			{
				LogWarning("Missing animName!");
				Finish();
				return;
			}

			if (go.GetComponent<Animation>() == null)
			{
				LogWarning("Missing animation component!");
				Finish();
				return;
			}

			anim = go.GetComponent<Animation>()[animName.Value];

			if (anim == null)
			{
				LogWarning("Missing animation: " + animName.Value);
				Finish();
				return;
			}

			var time = blendTime.Value;
			if (time < 0.001f)
			{
				go.GetComponent<Animation>().Play(animName.Value, playMode);
			}
			else
			{
				go.GetComponent<Animation>().CrossFade(animName.Value, time, playMode);
			}

			prevAnimtTime = anim.time;
		}
	static int _CreateUnityEngine_AnimationState(IntPtr L)
	{
		try
		{
			int count = LuaDLL.lua_gettop(L);

			if (count == 0)
			{
				UnityEngine.AnimationState obj = new UnityEngine.AnimationState();
				ToLua.Push(L, obj);
				return 1;
			}
			else
			{
				return LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.AnimationState.New");
			}
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}
Beispiel #43
0
 public sAnimationState(AnimationState a)
 {
 }
Beispiel #44
0
        public override void OnStart(StartState state)
        {
            base.OnStart (state);

            ParseWeaponType();
            ParseBulletDragType();

            bulletBallisticCoefficient = bulletMass / bulletDragArea * 1000;        //1000 to convert from tonnes to kilograms

            if(shortName == string.Empty)
            {
                shortName = part.partInfo.title;
            }

            foreach(var emitter in part.FindModelComponents<KSPParticleEmitter>())
            {
                emitter.emit = false;
            }

            if(roundsPerMinute >= 1500)
            {
                Events["ToggleRipple"].guiActiveEditor = false;
                Fields["useRippleFire"].guiActiveEditor = false;
            }

            if(airDetonation)
            {
                var detRange = (UI_FloatRange)Fields["defaultDetonationRange"].uiControlEditor;
                detRange.maxValue = maxAirDetonationRange;
            }
            else
            {
                Fields["defaultDetonationRange"].guiActive = false;
                Fields["defaultDetonationRange"].guiActiveEditor = false;
            }

            muzzleFlashEmitters = new List<KSPParticleEmitter>();
            foreach(Transform mtf in part.FindModelTransforms("muzzleTransform"))
            {
                KSPParticleEmitter kpe = mtf.GetComponent<KSPParticleEmitter>();
                muzzleFlashEmitters.Add(kpe);
                kpe.emit = false;
            }

            if(HighLogic.LoadedSceneIsFlight)
            {
                if(eWeaponType != WeaponTypes.Laser)
                {
                    if(bulletPool == null)
                    {
                        SetupBulletPool();
                    }
                    if(shellPool == null)
                    {
                        SetupShellPool();
                    }
                }

                //setup transforms
                fireTransforms = part.FindModelTransforms(fireTransformName);
                shellEjectTransforms = part.FindModelTransforms(shellEjectTransformName);

                //setup emitters
                foreach(var pe in part.FindModelComponents<KSPParticleEmitter>())
                {
                    pe.maxSize *= part.rescaleFactor;
                    pe.minSize *= part.rescaleFactor;
                    pe.shape3D *= part.rescaleFactor;
                    pe.shape2D *= part.rescaleFactor;
                    pe.shape1D *= part.rescaleFactor;

                    if(pe.useWorldSpace && !oneShotWorldParticles)
                    {
                        BDAGaplessParticleEmitter gpe = pe.gameObject.AddComponent<BDAGaplessParticleEmitter>();
                        gpe.part = part;
                        gaplessEmitters.Add(gpe);
                    }
                }

                //setup projectile colors
                projectileColorC = Misc.ParseColor255(projectileColor);
                startColorC = Misc.ParseColor255(startColor);

                //init and zero points
                targetPosition = Vector3.zero;
                pointingAtPosition = Vector3.zero;
                bulletPrediction = Vector3.zero;

                //setup audio
                SetupAudio();

                //laser setup
                if(eWeaponType == WeaponTypes.Laser)
                {
                    SetupLaserSpecifics();
                }
            }
            else if(HighLogic.LoadedSceneIsEditor)
            {
                fireTransforms = part.FindModelTransforms(fireTransformName);
            }

            //turret setup
            foreach(var turr in part.FindModulesImplementing<ModuleTurret>())
            {
                if(turr.turretID == turretID)
                {
                    turret = turr;
                    turret.SetReferenceTransform(fireTransforms[0]);
                    break;
                }
            }

            if(!turret)
            {
                Fields["onlyFireInRange"].guiActive = false;
                Fields["onlyFireInRange"].guiActiveEditor = false;
            }

            //setup animations
            if(hasDeployAnim)
            {
                deployState = Misc.SetUpSingleAnimation(deployAnimName, this.part);
                deployState.normalizedTime = 0;
                deployState.speed = 0;
                deployState.enabled = true;
            }
            if(hasFireAnimation)
            {
                fireState = Misc.SetUpSingleAnimation (fireAnimName, this.part);
                fireState.enabled = false;
            }
            bulletInfo = BulletInfo.bullets[bulletType];
            if (bulletInfo == null)
                Debug.Log("Failed To load bullet!");
            BDArmorySettings.OnVolumeChange += UpdateVolume;
        }
Beispiel #45
0
        void Start()
        {
            _jesusDelegate = GameObject.Find("Jesus").GetComponent<Jesus>();

            _focusMarker = transform.Find("focus marker").gameObject;
            _armAnimation = GetComponent<Animation>()["elf arm work 2"];
            _armAnimation.speed = Random.Range(0.0f,1.0f);
            _focusMarker.gameObject.SetActive(false);

            _lastTimeStep = Time.time;

            _rigidbody = transform.GetComponent<Rigidbody>();

            GetComponent<AudioSource>().clip = hammerSoundArray[Random.Range(0,hammerSoundArray.Length)];

            _giftFactory = GameObject.Find("Gift Factory").GetComponent<GiftFactory>();
            _bloodAndGoreFactory = GameObject.Find("Blood And Gore Factory").GetComponent<BloodAndGoreFactory>();
            numHammerHits = 0;

            // for turning the Elf to color.black when he's on fire
            torsoRenderer = transform.Find("torso").GetComponent<Renderer>();
            //			Debug.Log("torsoRenderer = " + torsoRenderer);
            legLeftRenderer = transform.Find("leg - left").GetComponent<Renderer>();
            legRightRenderer = transform.Find("leg - right").GetComponent<Renderer>();
            armLeftRenderer = transform.Find("arm - left").GetComponent<Renderer>();
            armRightRenderer = transform.Find("Arm Right Joint/arm - right").GetComponent<Renderer>();
            handLeftRenderer = transform.Find("hand - left").GetComponent<Renderer>();
            handRightRenderer = transform.Find("Arm Right Joint/hand - right").GetComponent<Renderer>();
            headRenderer = transform.Find("head joint/head").GetComponent<Renderer>();
            hatRenderer = transform.Find("head joint/elf hat").GetComponent<Renderer>();
            noseRenderer = transform.Find("head joint/nose").GetComponent<Renderer>();
            hatBrimRenderer = transform.Find("head joint/brim").GetComponent<Renderer>();
            hatBallRenderer = transform.Find("head joint/ball").GetComponent<Renderer>();

            // The direction the Elf is looking when game starts.
            // He looks this direction any time when he can't see Jesus.
            HeadJoint = transform.Find("head joint");
            //Debug.Log("head joint = " + HeadJoint);
            originalDirection = HeadJoint.rotation;
            //			JesusLookTarget = GameObject.Find("Jesus/Jesus Parts Container/eye - left").transform;
            SantaLookTarget = GameObject.Find("Characters/Santa (1)/Santa/santa look target").transform;

            s_canAcknowledge = true;
            s_canBePushed = true;

            _acknowledgeSoundThreshold = 0.5f;
            _pushedSoundTreshold = 1.2f;
            _underGazeTime = Mathf.Infinity;
        }
Beispiel #46
0
        /// <summary>
        /// The method called by KSP when the PartModule is started. Called on each part, every time.
        /// </summary>
        /// <param name="state">The StartState indicating the starting condition of the part (and the vessel it's on)</param>
        public override void OnStart(StartState state)
        {
            if (!(part.FindModelAnimators("glowAnim").FirstOrDefault() == null))
            {
                partAnim = part.FindModelAnimators("glowAnim").FirstOrDefault();
                if (!(partAnim["glowAnim"] == null))
                {
                    glowAnim = partAnim["glowAnim"];
                    if (!(glowAnim.clip == null))
                    {
                        glowAnimClip = glowAnim.clip;
                    }
                }
            }
            UI_ChooseOption tsOptions = (UI_ChooseOption)this.Fields["timeScale"].uiControlEditor;
            tsOptions.options = timeScaleOptions;

            updateSecondsOptions();

            seconds = (time + 1) * timeScales[timeScale];

            checkColorValues();
            checkTimeValues();
            updateCurves();

            if (pulsing)
            {
                partAnim.wrapMode = WrapMode.PingPong;
            }
            else
            {
                partAnim.wrapMode = WrapMode.Once;
            }

            if (glowing)
            {
                Events["toggleGlow"].guiName = "Stop Glowing";
                glowAnim.normalizedTime = 1.0f;
                partAnim.Play("glowAnim");
            }
            else
            {
                Events["toggleGlow"].guiName = "Start Glowing";
                glowAnim.normalizedTime = 0.0f;
                partAnim.Play("glowAnim");
                partAnim.Stop("glowAnim");
            }

            checkLengthValue();
            if (throttleBound)
                this.Fields["seconds"].guiActive = false;
            Invoke("updateScale", 0.01f);
            if (part.symmetryCounterparts != null)
            {
                master = true;
                foreach (Part p in part.symmetryCounterparts)
                {
                    // If any counterpart considers itself the master, this isn't the master.
                    master = p.Modules.OfType<GlowStripAdaptive>().FirstOrDefault().master ? false : master;
                }
                Debug.Log("Counterparts :" + part.symmetryCounterparts.Count);
            }
            else
            {
                master = true;
                Debug.Log("No counterparts found");
            }
        }
Beispiel #47
0
        /// <summary>
        /// Updates the animation curves, based on the current set of values.
        /// </summary>
        protected void updateCurves()
        {
            if (!(glowAnimClip == null))
            {
                AnimationCurve redCurve = AnimationCurve.Linear(0.0f, 0.0f, (float)((time + 1) * timeScales[timeScale]), glowValue * glowRed);
                AnimationCurve greenCurve = AnimationCurve.Linear(0.0f, 0.0f, (float)((time + 1) * timeScales[timeScale]), glowValue * glowGreen);
                AnimationCurve blueCurve = AnimationCurve.Linear(0.0f, 0.0f, (float)((time + 1) * timeScales[timeScale]), glowValue * glowBlue);

                glowAnimClip = new AnimationClip();
                glowAnimClip.SetCurve("", typeof(Material), "_EmissiveColor.r", redCurve);
                glowAnimClip.SetCurve("", typeof(Material), "_EmissiveColor.g", greenCurve);
                glowAnimClip.SetCurve("", typeof(Material), "_EmissiveColor.b", blueCurve);

                partAnim.AddClip(glowAnimClip, "glowAnim");
                glowAnim = partAnim["glowAnim"];
            }
        }
Beispiel #48
0
        public virtual void SetupAnimations()
        {
            Log("SetupAnimations called.");

            Animation[] animations = this.part.FindModelAnimators(animationName);
            if (animations == null)
            {
                Log("No animations found.");
                return;
            }

            Animation anim = animations[0];
            if (anim == null)
                return;

            //Set layer
            animationState = anim[animationName];
            anim[animationName].layer = animationLayer;

            //Set toggle button
            Events["ToggleAnimation"].guiActive = guiIsVisible;
            Events["ToggleAnimation"].guiActiveEditor = guiIsVisible;
            Actions["ToggleAnimationAction"].guiName = actionGUIName;

            if (isDeployed)
            {
                Events["ToggleAnimation"].guiName = endEventGUIName;

                anim[animationName].normalizedTime = 1.0f;
                anim[animationName].speed = 10000f;
            }
            else
            {
                Events["ToggleAnimation"].guiName = startEventGUIName;

                anim[animationName].normalizedTime = 0f;
                anim[animationName].speed = -10000f;
            }
            anim.Play(animationName);
        }
 /// <summary>
 /// Start movement with the specified state.
 /// </summary>
 /// <param name="state">Animation state.</param>
 public virtual void Play(AnimationState state)
 {
     moveStarted = true;
     animationState = state;
 }
Beispiel #50
0
        /// <summary>
        /// The method called by KSP when the PartModule is started. Called on each part, every time.
        /// </summary>
        /// <param name="state">The StartState indicating the starting condition of the part (and the vessel it's on)</param>
        public override void OnStart(StartState state)
        {
            if (!(part.FindModelAnimators("glowAnim").FirstOrDefault() == null))
            {
                partAnim = part.FindModelAnimators("glowAnim").FirstOrDefault();
                if (!(partAnim["glowAnim"] == null))
                {
                    glowAnim = partAnim["glowAnim"];
                    if (!(glowAnim.clip == null))
                    {
                        glowAnimClip = glowAnim.clip;
                    }
                }
            }
            UI_ChooseOption tsOptions = (UI_ChooseOption)this.Fields["timeScale"].uiControlEditor;
            tsOptions.options = timeScaleOptions;

            updateSecondsOptions();

            seconds = (time + 1) * timeScales[timeScale];

            checkColorValues();
            checkTimeValues();
            updateCurves();

            if (pulsing)
            {
                partAnim.wrapMode = WrapMode.PingPong;
            }
            else
            {
                partAnim.wrapMode = WrapMode.Once;
            }

            if (glowing)
            {
                Events["toggleGlow"].guiName = "Stop Glowing";
                glowAnim.normalizedTime = 1.0f;
                partAnim.Play("glowAnim");
            }
            else
            {
                Events["toggleGlow"].guiName = "Start Glowing";
                glowAnim.normalizedTime = 0.0f;
                partAnim.Play("glowAnim");
                partAnim.Stop("glowAnim");
            }
        }
        public override void OnStart(PartModule.StartState state)
        {
            DragManager = part.gameObject.GetComponent<DragManager>();

            if (DragManager == null) {
                DragManager = part.gameObject.AddComponent<DragManager>();
                DragManager.SetPart(part);
            }

            gearHandler.Start(ID,part);
            anim = part.FindModelAnimators(AnimationName)[0];
            animState = anim[AnimationName];
            animState.wrapMode = WrapMode.Clamp;

            if (FixAnimLayers) {
                int i = 0;
                foreach (AnimationState s in anim)
                    s.layer = i++;
            }

            part.PhysicsSignificance = 1;

            Transform bounds = part.FindModelTransform("Bounds");
            if (bounds != null)
                UnityEngine.Object.DestroyImmediate(bounds.gameObject);

            gearState = Deployed ? ModuleLandingGear.GearStates.DEPLOYED : ModuleLandingGear.GearStates.RETRACTED;

            animState.normalizedTime = Deployed ? 1 : 0;

            animState.speed = Deployed ? Mathf.Abs(animState.speed) : -Mathf.Abs(animState.speed);

            UpdateDrag();

            anim.Play(AnimationName);

            HashSet<WheelCollider> tmp = new HashSet<WheelCollider>();
            part.transform.FindWheelColliders(ref tmp);
            foreach (WheelCollider w in tmp)
                w.enabled = true;
        }
 /// <summary>
 /// Stops playback of the animation.
 /// </summary>
 public void Stop()
 {
     _elapsedTime = 0f;
     _currentState = null;
     _callback0 = null;
     _callback1 = null;
     _isPlaying = false;
 }
Beispiel #53
0
        public override void OnStart(StartState state)
        {
            base.OnStart (state);

            ParseWeaponType();

            if(shortName == string.Empty)
            {
                shortName = part.partInfo.title;
            }

            if(!airDetonation)
            {
                Fields["defaultDetonationRange"].guiActive = false;
                Fields["defaultDetonationRange"].guiActiveEditor = false;
            }

            if(HighLogic.LoadedSceneIsFlight)
            {
                if(eWeaponType!=WeaponTypes.Laser)
                {
                    if(bulletPool == null)
                    {
                        SetupBulletPool();
                    }
                    if(shellPool == null)
                    {
                        SetupShellPool();
                    }
                }

                //setup transforms
                fireTransforms = part.FindModelTransforms(fireTransformName);
                shellEjectTransforms = part.FindModelTransforms(shellEjectTransformName);

                //setup emitters
                foreach(var pe in part.FindModelComponents<KSPParticleEmitter>())
                {
                    pe.maxSize *= part.rescaleFactor;
                    pe.minSize *= part.rescaleFactor;
                    pe.shape3D *= part.rescaleFactor;
                    pe.shape2D *= part.rescaleFactor;
                    pe.shape1D *= part.rescaleFactor;

                    if(pe.useWorldSpace && !oneShotWorldParticles)
                    {
                        BDAGaplessParticleEmitter gpe = pe.gameObject.AddComponent<BDAGaplessParticleEmitter>();
                        gpe.part = part;
                        gaplessEmitters.Add(gpe);
                    }
                }

                //setup projectile colors
                projectileColorC = Misc.ParseColor255(projectileColor);
                startColorC = Misc.ParseColor255(startColor);

                //init and zero points
                targetPosition = Vector3.zero;
                pointingAtPosition = Vector3.zero;
                bulletPrediction = Vector3.zero;

                //setup audio
                SetupAudio();

                //laser setup
                if(eWeaponType == WeaponTypes.Laser)
                {
                    SetupLaserSpecifics();
                }

            }

            //turret setup
            turret = part.FindModuleImplementing<ModuleTurret>();
            if(!turret)
            {
                Fields["onlyFireInRange"].guiActive = false;
                Fields["onlyFireInRange"].guiActiveEditor = false;
            }

            //setup animations
            if(hasDeployAnim)
            {
                deployState = Misc.SetUpSingleAnimation(deployAnimName, this.part);
                deployState.normalizedTime = 0;
                deployState.speed = 0;
                deployState.enabled = true;
            }
            if(hasFireAnimation)
            {
                fireState = Misc.SetUpSingleAnimation (fireAnimName, this.part);
                fireState.enabled = false;
            }

            BDArmorySettings.OnVolumeChange += UpdateVolume;
        }
Beispiel #54
0
 void PlayAnimation(Animation anim, string clip)
 {
     m_AccumTime = 0F;
     m_CurrClipName = clip;
     m_CurrState = anim[clip];
     m_CurrState.weight = 1;
     m_CurrState.blendMode = AnimationBlendMode.Blend;
     m_CurrState.wrapMode = WrapMode.Once;
     m_CurrState.normalizedTime = 0;
     m_CurrState.enabled = true;
     m_IsPlaying = true;
     m_IsEndAnim = false;
 }
Beispiel #55
0
 void Awake()
 {
     m_animationState = m_animation["Fly"];
     m_flockMovement.TookOff += BirdTookOff;
 }
        private void DoPlayAnimation()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (!UpdateCache(go))
            {
                Finish();
                return;
            }

            if (string.IsNullOrEmpty(animName.Value))
            {
                LogWarning("Missing animName!");
                Finish();
                return;
            }

            anim = animation[animName.Value];

            if (anim == null)
            {
                LogWarning("Missing animation: " + animName.Value);
                Finish();
                return;
            }

            var time = blendTime.Value;
            if (time < 0.001f)
            {
                animation.Play(animName.Value, playMode);
            }
            else
            {
                animation.CrossFade(animName.Value, time, playMode);
            }

            prevAnimtTime = anim.time;
        }
        public override void OnStart(PartModule.StartState state)
        {
            if(HighLogic.LoadedSceneIsFlight)
            {
                part.force_activate();

                aimerTexture = BDArmorySettings.Instance.greenPointCircleTexture;// GameDatabase.Instance.GetTexture("BDArmory/Textures/grayCircle", false);

                MakeRocketArray();
                UpdateRocketScales();

                if (shortName == string.Empty)
                {
                    shortName = part.partInfo.title;
                }

                UpdateAudio();
                BDArmorySettings.OnVolumeChange += UpdateAudio;

            }

            if(HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
            {
                foreach(var turr in part.FindModulesImplementing<ModuleTurret>())
                {
                    if(turr.turretID == turretID)
                    {
                        turret = turr;
                        targetInTurretView = false;
                        break;
                    }
                }

                if(turret)
                {
                    Events["GuiFire"].guiActive = false;
                    Events["Jettison"].guiActive = false;
                    Actions["AGFire"].active = false;

                    if(HighLogic.LoadedSceneIsFlight)
                    {
                        Events["ToggleTurret"].guiActive = true;
                    }
                }

                if(!string.IsNullOrEmpty(deployAnimationName))
                {
                    deployAnimState = Misc.SetUpSingleAnimation(deployAnimationName, part);
                    hasDeployAnimation = true;

                    readyToFire = false;
                }
            }
            SetupAudio();
        }
            /// <summary>
            /// Updates and check for the event frame.
            /// </summary>
            internal void Update()
            {
                AnimationClip c = parent.clip;
                Animation a = parent.view.animation;

                if (!a.IsPlaying(c.name)) return;

                state = a[c.name];

                //bool is_wrap = false;
                float t0 = m_last_time;
                float t1 = time;
                //if (t1 < t0) is_wrap = true;
                m_last_time = t1;

                if (useFrame)
                {
                    t0 = Mathf.Floor(t0 * c.frameRate);
                    t1 = Mathf.Floor(t1 * c.frameRate);
                }

                float i0 = interval.min;
                float i1 = interval.max;

                bool in_range = false;

                in_range = ((t1 >= i0) && (t1 < i1)) || ((t0 >= i0) && (t0 < i1));
                if(!in_range)
                {
                    in_range = (t1 >= i1) && (t0 <= i0);
                }

                //if (is_wrap) in_range = ((i0 >= t0) && (i0 > t1)) || ((i1 <= t0) && (i1 < t1));

                if (in_range)
                {
                    bool is_continuous = continuous && (Mathf.Abs(interval.max - interval.min) > 0f);
                    bool emmit = is_continuous || (!active);

                    if (emmit)
                    {
                        active = true;
                        parent.view.callback = this;
                        if (string.IsNullOrEmpty(notification))
                        {
                            parent.view.OnAnimationEvent(args);
                        }
                        else
                        {
                            string pn = parent.view.notification;
                            if (!string.IsNullOrEmpty(pn)) parent.view.OnAnimationEvent(pn + "." + notification, args);
                        }
                    }
                }
                else
                {
                    active = false;
                }
            }
 /// <summary>
 ///   <para>Creates a new animation event.</para>
 /// </summary>
 public AnimationEvent()
 {
   this.m_Time = 0.0f;
   this.m_FunctionName = string.Empty;
   this.m_StringParameter = string.Empty;
   this.m_ObjectReferenceParameter = (Object) null;
   this.m_FloatParameter = 0.0f;
   this.m_IntParameter = 0;
   this.m_MessageOptions = 0;
   this.m_Source = AnimationEventSource.NoSource;
   this.m_StateSender = (AnimationState) null;
 }
 private float EvalAnimationCompletionReversed(AnimationState[] states)
 {
     float checker = 1f;
     foreach (AnimationState state in states)
     {
         checker = Mathf.Min(state.normalizedTime, checker);
     }
     return checker;
 }