Exemplo n.º 1
0
    void Animate(AnimationInfo animationSet)
    {
        frameTime -= Time.deltaTime;
        if (frameTime <= 0)
        {
            frameTime = timePrFrame;
            frameIndex++;
        }

        if (frameIndex < animationSet.frameStart)
        {
            frameIndex = animationSet.frameStart;
        }

        if (frameIndex >= (animationSet.frameStart + (animationSet.numerOfFrames)))
        {
            frameIndex = animationSet.frameStart;
        }

        float sizeY = 1.0f / numbersOfTilesY;
        Vector2 size = new Vector2(1.0f, sizeY);

        var vIndex = frameIndex / numbersOfTilesY;

        float offsetX = 1.0f;
        float offsetY = (1.0f - size.y) - (vIndex + frameIndex) * size.y;
        Vector2 offset = new Vector2(offsetX, offsetY);

        textureToAnimate.renderer.material.SetTextureOffset("_MainTex", offset);
        textureToAnimate.renderer.material.SetTextureScale("_MainTex", size);
    }
	void Update()
	{
		if ( AnimationStack.Count == 0 ) return;

        TryIdle();

		// Check for a new animation
		int maxanim = AnimationStack.Count - 1;
		if ( CurrentAnimation != maxanim )
		{
			CurrentAnimation = maxanim;

			// Store the information about this animation for rendering currently
			CurrentAnimationInfo = (AnimationInfo) AnimationStack.ToArray()[CurrentAnimation];
			CurrentAnimationInfo.LerpCompleteTime = Time.time + CurrentAnimationInfo.LerpTime;
			CurrentAnimationInfo.HoldCompleteTime = -1;

            LastAnimationChange = Time.time;
        }

		// Lerp to new animation position
		if ( !AnimationKeyFrames[CurrentAnimationInfo.Index] ) return;
		// For each part of this arm, lerp to new key frame position
		Transform[] keyframes = AnimationKeyFrames[CurrentAnimationInfo.Index].GetComponentsInChildren<Transform>();
		int index = 0;
		float progress = Mathf.Clamp( 1 - ( CurrentAnimationInfo.LerpTime * ( CurrentAnimationInfo.LerpCompleteTime - Time.time ) ), 0, 1 );
		foreach ( Transform transform in GetComponentsInChildren<Transform>() )
		{
			if ( index >= ( keyframes.Length ) ) break;

			transform.localPosition = Vector3.Lerp(
				transform.localPosition,
				keyframes[index].localPosition,
				progress
			);
			transform.localRotation = Quaternion.Lerp(
				transform.localRotation,
				keyframes[index].localRotation,
				progress
			);
			index++;
		}
		// Begin holding the animation until the end
		if ( ( progress == 1 ) && ( CurrentAnimationInfo.HoldCompleteTime == -1 ) )
		{
			if ( CurrentAnimationInfo.HoldTime != -1 )
			{
				CurrentAnimationInfo.HoldCompleteTime = Time.time + CurrentAnimationInfo.HoldTime;
			}
		}

		// Pop animation when finished
		if ( ( CurrentAnimationInfo.HoldCompleteTime != -1 ) && ( CurrentAnimationInfo.HoldCompleteTime <= Time.time ) )
		{
			PopAnimation();
		}
	}
Exemplo n.º 3
0
 public Walk(ActionList ownerList, Actor owner)
 {
     this.ownerList = ownerList;
     this.owner = owner;
     if(owner.animations.ContainsKey("walk"))
         animationInfo = owner.animations["walk"];
     else
         animationInfo = new AnimationInfo("default_walk", 10, 12, 0, 0);
     duration = animationInfo.frames / animationInfo.fps;
 }
Exemplo n.º 4
0
 public void AddAnimation(string name, int startFrame, int endFrame, long timeLength)
 {
     AnimationInfo info = new AnimationInfo();
     info.animationName = name;
     info.startFrame = startFrame;
     info.endFrame = endFrame;
     int numFrames = endFrame - startFrame;
     info.timeStep = timeLength / numFrames;
     Animations.Add(name, info);
 }
Exemplo n.º 5
0
 private void setAnimationInfo()
 {
     if (owner.activeWeapon != null)
     {
         animationInfo = owner.animations[owner.activeWeapon.animations["holding_weapon_walk"]];
     }
     else
     {
         animationInfo = owner.animations["unarmed_walk"];
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a new animation controller.
 /// </summary>
 /// <param name="game">The game to which this controller will be attached.</param>
 /// <param name="sourceAnimation">The source animation that the controller will use.
 /// This is stored in the ModelAnimator class.</param>
 public AnimationController(
     Game game,
     AnimationInfo sourceAnimation)
     : base(game)
 {
     animation = sourceAnimation;
     // This is set so that the controller updates before the
     // ModelAnimator by default
     base.UpdateOrder = 0;
     game.Components.Add(this);
 }
Exemplo n.º 7
0
 private void setAnimationInfo()
 {
     if (owner.activeWeapon != null && owner.animations.ContainsKey(owner.activeWeapon.animations["light_weapon_attack"]))
     {
         this.animationInfo = owner.animations[owner.activeWeapon.animations["light_weapon_attack"]];
     }
     else if (owner.animations.ContainsKey("unnarmed_light_attack"))
     {
         this.animationInfo = owner.animations["unnarmed_light_attack"];
     }
 }
    public void TriggerAnim(AnimationInfo info)
    {
        switch (info.animType) {
            case (AnimationInfo.AnimType.Attack):

                //Debug.Log("set this shit");

                animController.SetInteger("AttackTypeInt", (int)info.animAttackType);
                animController.SetTrigger("AttackTrig");

                //HandleAttackAnim(info);
                break;
        }
    }
Exemplo n.º 9
0
        public AnimatedSprite()
        {
            Rows = 0;
            Columns = 0;
            AnimationTimer = new Stopwatch();
            Animations = new Dictionary<string, AnimationInfo>();
            CurrentAnimaion = new AnimationInfo();
            Rotation = 0.0f;
            Depth = 1.0f;

            Flip = false;

            BoundingBox = new Rectangle(0, 0, 0, 0);
        }
	void Start()
	{
		AnimationInfo idle = new AnimationInfo();
		{
			idle.Index = 0;
			idle.LerpTime = 1;
			idle.HoldTime = -1; // Hold until a new animation is added
		}
		AnimationStack.Add( idle );

        if ( IsLeft )
        {
            LastAnimationChange += 1000;
        }
	}
Exemplo n.º 11
0
        public bool Initialize(String daeFileName)
        {
            var fi = new FileInfo(daeFileName);

            if (!fi.Exists)
            {
                return(false);
            }

            var scene = LoadDaeScene(fi.FullName);

            if (scene == null)
            {
                return(false);
            }

            foreach (var t in BodyMeshes)
            {
                t.Destroy();
            }
            BodyMeshes.Clear();
            Bones.Clear();
            bonesMapping.Clear();
            Animations.Clear();
            Poses.Clear();
            rootNode         = null;
            СurrentAnimation = null;

            m_globalInverseTransform = FromMatrix(scene.RootNode.Transform);
            m_globalInverseTransform.Invert();

            var title = Path.GetFileNameWithoutExtension(fi.FullName);

            LoadBodyMeshes(fi.FullName, scene, scene.RootNode, null);
            LoadBonesInfo(rootNode);
            LoadAnimations(scene, title);

            return(true);
        }
Exemplo n.º 12
0
    public void Remove(MachineTile mt)
    {
        AnimationInfo needsDeleting = null;

        foreach (AnimationInfo i in info)
        {
            if (i.machines.Contains(mt))
            {
                i.machines.Remove(mt);
                if (i.machines.Count <= 0)
                {
                    needsDeleting = i;
                }
                break;
            }
        }

        if (needsDeleting != null)
        {
            info.Remove(needsDeleting);
        }
    }
    /// <summary>
    /// Given a SetPositionRotation message, extracts the new position and rotation.
    /// </summary>
    /// <returns>The position rotation message.</returns>
    /// <param name="message">Message.</param>
    /// <param name="avatarId">The avatar being moved</param>
    /// <param name="x">The x coordinate.</param>
    /// <param name="z">The z coordinate.</param>
    /// <param name="r">The rotation component.</param>
    public static void UnmarshallPositionRotationMessage(
        byte[] message, out byte avatarId, out float x, out float z, out float r, out byte m)
    {
        Debug.Assert(message.Length >= 14);
        Debug.Assert(GetMessageType(message) == setAvatarPositionRotation);
        Debug.Assert(message[1] == flora || message[1] == tommy);

        avatarId = message[1];

        m = message[2];
        Debug.Assert(AnimationInfo.IsLegalMovementState(m));

        // Format is:
        //	 - byte 0: message type
        //   - byte 1: avatar id
        //	 - byte 2: movement state
        //   - bytes 3-4: x value
        //   - bytes 5-6: z value
        //   - bytes 7-8: rotation (degrees around y-axis)
        // ...

        // X position
        byte [] x_bytes = new byte[] { message[3], message[4] };
        short   x_val   = BitConverter.ToInt16(x_bytes, 0);

        x = (float)x_val / 100f;

        // Z position
        byte [] z_bytes = new byte[] { message[5], message[6] };
        short   z_val   = BitConverter.ToInt16(z_bytes, 0);

        z = (float)z_val / 100f;

        // R position
        byte [] r_bytes = new byte[] { message[7], message[8] };
        short   r_val   = BitConverter.ToInt16(r_bytes, 0);

        r = (float)r_val / 100f;
    }
Exemplo n.º 14
0
    void Start()
    {
        // get animation clips
        anim.gameObject.SetActive(true);
        animClips         = anim.runtimeAnimatorController.animationClips;
        numberOfAnimClips = animClips.Length;
        animClipDict      = new Dictionary <string, int>();
        aniInfos          = new AnimationInfo[numberOfAnimClips];
        for (int i = 0; i < numberOfAnimClips; i++)
        {
            animClipDict.Add(animClips[i].name, i);
            aniInfos[i] = new AnimationInfo(this, animClips[i]);
            aniInfos[i].InitDeltaCalc(anim);
        }

        // lineRenderer = GetComponent<LineRenderer>();
        // LinesToLineRenderer();

        Debug.Log("Animator Inspector is done.");

        // anim.gameObject.SetActive(false);
    }
Exemplo n.º 15
0
        private void toolStripButtonCopyAnimation_Click(object sender, EventArgs e)
        {
            int selCnt = listViewAnimations.SelectedIndices.Count;

            int[] selIndices = new int[selCnt];
            listViewAnimations.SelectedIndices.CopyTo(selIndices, 0);
            for (int i = 0; i < selCnt; i++)
            {
                AnimationInfo selAnim     = this.AnimatedSprite.Animations[selIndices[i]];
                string        newAnimName = GetNewAnimationName(selAnim.Name + "_");
                AnimationInfo newAnim     = new AnimationInfo(newAnimName);
                selAnim.CopyValuesTo(newAnim, this.AnimatedSprite);
                newAnim.Name = newAnimName;
                this.AnimatedSprite.AddAnimation(newAnim);
                listViewAnimations.Items.Add(newAnim.Name);
                if (i == 0)
                {
                    listViewAnimations.SelectedIndices.Clear();
                }
                listViewAnimations.SelectedIndices.Add(this.AnimatedSprite.Animations.Count - 1);
            }
        }
Exemplo n.º 16
0
        /*protected override void Starting()
         * {
         *  base.Starting();
         *  Console.WriteLine("{0} Starting", GetType().Name);
         * }
         *
         * protected override void Completing()
         * {
         *  base.Completing();
         *  Console.WriteLine("{0} Completing", GetType().Name);
         * }*/
#endif
        #endregion

        #region Game Loop
        #endregion

        #region Animations
        public Task FloatAnimation(int duration, float startValue, float endValue, Action <float> valueStep, TweeningFunction easingFunction = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (duration <= 0)
            {
                throw new ArgumentOutOfRangeException("duration", "Duration must be greater than zero");
            }

            if (valueStep == null)
            {
                throw new ArgumentNullException("valueStep");
            }

            AnimationInfo info = new AnimationInfo
            {
                Completion      = new TaskCompletionSource <bool>(),
                Cancellation    = cancellationToken,
                CurrentDuration = 0,
                Duration        = duration,
                ValueStep       = valueStep,
                StartValue      = startValue,
                EndValue        = endValue,
                EasingFunction  = easingFunction,
            };

            if (cancellationToken != CancellationToken.None)
            {
                info.Cancellation.Register(() => info.Completion.TrySetCanceled());
            }

            if (_animations.Count == 0)
            {
                DrawContext.BeforeLoop += UpdateAnimations;
            }

            _animations.Add(info);
            info.NotifyValue();
            return(info.Completion.Task);
        }
    void UpdateParameters()
    {
        for (int i = 0; i < 3; i++)
        {
            if (i == UserInfo.Hit / 3)
            {
                _agentsLeft[i].gameObject.SetActive(true);
                _agentsRight[i].gameObject.SetActive(true);
                _agentLeft  = _agentsLeft[UserInfo.Hit / 3];
                _agentRight = _agentsRight[UserInfo.Hit / 3];
            }
            else
            {
                _agentsLeft[i].gameObject.SetActive(false);
                _agentsRight[i].gameObject.SetActive(false);
            }
        }



        for (int i = 0; i < 5; i++)
        {
            if (i == _taskQInd % _qCnt)
            {
                _agentRight.GetComponent <PersonalityComponent>().Personality[i] = 1;
                _agentLeft.GetComponent <PersonalityComponent>().Personality[i]  = -1;
            }
            else
            {
                _agentRight.GetComponent <PersonalityComponent>().Personality[i] = 0;
            }
            _agentLeft.GetComponent <PersonalityComponent>().Personality[i] = 0;
        }


        _agentRight.AnimName = _agentRight.AnimNames[UserInfo.Hit % 3];
        _agentLeft.AnimName  = _agentLeft.AnimNames[UserInfo.Hit % 3];
    }
Exemplo n.º 18
0
    private void Awake() {

#if DEBUGMODE
        _targetRPrev = new List<Vector3>();
        _targetLPrev = new List<Vector3>();

        //_handRPrev = new List<Vector3>();
        //_handRTime = new List<float>();

        //  _handCurve = GameObject.Find("HandCurve");

#endif



        _animInfo = GetComponent<AnimationInfo>();

        _fbIk = GetComponent<FullBodyBipedIK>();
        _laIk = GetComponentInChildren<LookAtIK>();


        EncSpr = new float[3];
        SinRis = new float[3];
        RetAdv = new float[3];

        ShapeTi = 0f;


        _torso = GetComponent<TorsoController>();




        Reset();



    }
Exemplo n.º 19
0
    static int get_weight(IntPtr L)
    {
        object o = LuaScriptMgr.GetLuaObject(L, 1);

        if (o == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name weight");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index weight on a nil value");
            }
        }

        AnimationInfo obj = (AnimationInfo)o;

        LuaScriptMgr.Push(L, obj.weight);
        return(1);
    }
Exemplo n.º 20
0
        private Animation CopyAnimation(AnimationInfo AI)
        {
            Animation AM = new Animation();

            AM.Name      = AI.Name;
            AM.FixedTime = AI.FixedTimeAmount;
            AM.FixedTimeBetweenFrames = AI.FixedTimeBewteenFrames;
            AM.Loop    = AI.Loop;
            AM.Speed   = AI.Speed;
            AM.SR      = SceneManager.ActiveScene.FindGameObjectWithName(DraggedGO).GetComponent <SpriteRenderer>();
            AM.Reverse = AI.PlayReverse;
            AM.Frames  = new List <Frame>(AI.Frames.Count);

            for (int i = 0; i < AI.Frames.Count; i++)
            {
                AM.Frames.Add(new Frame()
                {
                    Tex = AI.Frames[i].Tex, SourceRectangle = AI.Frames[i].SourceRectangle, Time = AI.Frames[i].Time
                });
            }

            return(AM);
        }
Exemplo n.º 21
0
        void Awake()
        {
            _AnimatorComponent  = GetComponent <Animator>();
            _AnimationComponent = GetComponent <Animation>();
            _AnimationInfo      = GetComponent <AnimationInfo>();
            _HangPointHolder    = GetComponent <HangPointHolder>();

            if (_AnimationComponent != null)
            {
                _UnloadWeaponState = GetAnimationStateByName(UNLOAD_WEAPON);
                if (null != _HangPointHolder && null != _HangPointHolder.HangPoint_WaistTrans)
                {
                    _WaistTrans = _HangPointHolder.HangPoint_WaistTrans.transform;
                }
                else
                {
                    _WaistTrans = transform.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Spine2");
                    if (_WaistTrans == null)
                    {
                        _WaistTrans = transform.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1");
                    }
                }

                if (_UnloadWeaponState != null && _WaistTrans != null)
                {
                    _UnloadWeaponState.wrapMode = WrapMode.Once;
                    _UnloadWeaponState.layer    = 1;
                    _UnloadWeaponState.weight   = 1f;
                    _UnloadWeaponState.enabled  = false;
                    _UnloadWeaponState.AddMixingTransform(_WaistTrans);
                }
                _AnimationComponent.cullingType = AnimationCullingType.AlwaysAnimate;
            }
            else if (null != _AnimatorComponent)
            {
            }
        }
Exemplo n.º 22
0
    /// <summary>
    /// 根据当前出战武学的武器类型重置角色动作
    /// </summary>
    public static AnimationProxy ResetAllActions(GameObject go, List <string> actionNameList, List <string> actionPathList)
    {
        AnimationProxy animProxy = go.GetComponent <AnimationProxy>();

        if (animProxy)
        {
            if (animProxy.mAnimation)
            {
                DestroyImmediate(animProxy.mAnimation);
            }
            DestroyImmediate(animProxy);
        }

        animProxy             = go.AddComponent <AnimationProxy>();
        animProxy.mAnimations = new AnimationInfo[actionNameList.Count];
        AnimationInfo animInfo;
        AnimationInfo mainAnimInfo = null;

        for (int i = 0; i < actionNameList.Count; i++)
        {
            animInfo         = new AnimationInfo();
            animInfo.strName = actionNameList[i];
            animInfo.strPath = actionPathList[i];
            if (animInfo.strName.Equals("idle"))
            {
                mainAnimInfo         = new AnimationInfo();
                mainAnimInfo.strName = actionNameList[i];
                mainAnimInfo.strPath = actionPathList[i];
            }
            animProxy.mAnimations[i] = animInfo;
        }
        animProxy.mMainClip = mainAnimInfo;
        animProxy.Awake();              //AddComponent的时候会执行Awake,但没事数据,现在有数据后,需要再次执行下

        return(animProxy);
    }
Exemplo n.º 23
0
        private void Reset()
        {
            Movement = new MovementInfo()
            {
                Gravity  = -9.81f,
                MaxSpeed = 9,
                //Friction = 6,
                //Acceleration = 6,
                MinimalVelocityThreshold = 0.1f,
                MinimalForceThreshold    = 0.01f
            };

            Jump = new JumpInfo()
            {
                JumpHeight = 2,
                JumpSpeed  = 9
            };

            Animation = new AnimationInfo()
            {
                MovementBlend = "Forward",
                AirBoolean    = "InAir"
            };
        }
Exemplo n.º 24
0
    public void Register(MachineTile machine)
    {
        bool hasRegistered = false;

        foreach (AnimationInfo i in info)
        {
            if (i.machines[0].machine.machineName == machine.machine.machineName)
            {
                i.machines.Add(machine);
                hasRegistered = true;
                break;
            }
        }

        if (!hasRegistered)
        {
            AnimationInfo ai = new AnimationInfo()
            {
                speed = 15
            };
            ai.machines.Add(machine);
            info.Add(ai);
        }
    }
Exemplo n.º 25
0
    // Use this for initialization
    void Start()
    {
        // Initialize animation info
        spawnInfo = new AnimationInfo("enemy_spawn", 38, 12);
        idleInfo  = new AnimationInfo("enemy_idle", 16, 8);

        // Initialize sound info
        audioSource = GetComponent <AudioSource>();
        flameSFX    = (AudioClip)Resources.Load("Flame2_sfx");

        // Initialize projectile
        fireballPrefab = (GameObject)Resources.Load("Fireball");

        // Initialize character
        InitChar(BASE_HEALTH, WALK_SPEED, JUMP_FORCE);
        bounceBack = BOUNCE_BACK;

        // Disable character collision
        Physics2D.IgnoreCollision(GetComponent <Collider2D>(), player.GetComponent <Collider2D>());

        // Initialize timers
        fireballTimer.Set(FIRE_DELAY);
        moveTimer.Set(MOVE_TIME);
    }
Exemplo n.º 26
0
 /// <summary>
 /// Almacena una lista de frames con su correspondiente ángulo, considerando el ejercicio especificado, por ejemplo, para rodilla puede importar el ángulo que se genera entre los segmentos involucrados con el plano sagital
 /// </summary>
 /// <param name="exercise">Ejercicio al cual se le quieren extraer los ángulo de interés</param>
 /// <param name="action">Callback especificado para guardar los frames que se van generando</param>
 /// <returns></returns>
 private void SaveTimesAngle(AnimatorStateInfo animatorState) //ref List<AnimationInfo> aInfo)
 {
     JointTypePlanoResult tempJointTypePlanoResult = MovementJointMatch.movementJointMatch[new MovementLimbKey(movement, limb)];
     ArticulacionClass joint = AnimatorScript.instance.utils.getArticulacion(tempJointTypePlanoResult.jointType);
     AnimationInfo tempAnimationInfo = new AnimationInfo();
     float time = animatorState.normalizedTime * animatorState.length;
     switch (tempJointTypePlanoResult.plain)
     {   
         case Plano.planos.planoFrontal:
             tempAnimationInfo = new AnimationInfo(time, joint.AngleFrontal);
             break;
         case Plano.planos.planoHorizontal:
             tempAnimationInfo = new AnimationInfo(time, joint.AngleHorizontal);
             break;
         case Plano.planos.planoSagital:
             tempAnimationInfo = new AnimationInfo(time, joint.AngleSagital);
             break;
         case Plano.planos.planoHorizontalAcostado:
             tempAnimationInfo = new AnimationInfo(time, joint.AngleHorizontalAcostado);
             break;
     }
     _timeAndAngles.Add(tempAnimationInfo);
 }
Exemplo n.º 27
0
        public static BakedData Bake(this GameObject model, AnimationClip animationClip, AnimationInfo animationInfo)
        {
            Mesh mesh = new Mesh
            {
                name = string.Format("{0}", model.name)
            };

            // Set root motion options.
            if (model.TryGetComponent(out Animator animator))
            {
                animator.applyRootMotion = animationInfo.applyRootMotion;
            }

            // Bake mesh for a copy and to apply the new UV's to.
            SkinnedMeshRenderer skinnedMeshRenderer = model.GetComponent <SkinnedMeshRenderer>();

            skinnedMeshRenderer.BakeMesh(mesh);
            mesh.RecalculateBounds();

            mesh.uv3 = mesh.BakePositionUVs(animationInfo);

            BakedAnimation bakedAnimation = BakeAnimation(model, animationClip, animationInfo);

            BakedData bakedData = new BakedData()
            {
                mesh         = mesh,
                positionMaps = new List <Texture2D>()
                {
                    bakedAnimation.positionMap
                },
                maxFrames = animationInfo.maxFrames,
                minBounds = bakedAnimation.minBounds,
                maxBounds = bakedAnimation.maxBounds
            };

            mesh.bounds = new Bounds()
            {
                max = bakedAnimation.maxBounds,
                min = bakedAnimation.minBounds
            };

            return(bakedData);
        }
Exemplo n.º 28
0
 public AnimationState(AnimationInfo info)
 {
     _info = info;
 }
Exemplo n.º 29
0
 public virtual void PlayAnimation(string name)
 {
     if (CurrentAnimaion.animationName != name)
     {
         if (Animations.ContainsKey(name))
         {
             CurrentAnimaion = Animations[name];
             CurrentFrame = CurrentAnimaion.startFrame;
             AnimationTimer.Restart();
         }
     }
 }
	public BaseInfo()
	{
		attackEffectInfo = new ActionEffectInfo();
		animationInfo = new AnimationInfo();
		audioInfo = new AudioInfo();
		
		attackModifierIcons = new List<string>();
		
		projectileInfo = null;
	}
Exemplo n.º 31
0
 public void AddAnimation(AnimationInfo newAnimation)
 {
     _animations.Add(newAnimation);
     newAnimation.Parent = this;
     UpdateBoundingRectSize();
 }
Exemplo n.º 32
0
 /// <summary>
 /// Creats a new InterpolationController.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="source">The source animation.</param>
 /// <param name="interpMethod">The interpolation method.</param>
 public InterpolationController(Game game, AnimationInfo source, InterpolationMethod interpMethod)
     : base(game, source)
 {
     this.interpMethod = interpMethod;
 }
Exemplo n.º 33
0
    /**
     * Create a new Placeholder and Initialize internal structures
     *
     * @return the Created <code>EscherContainerRecord</code> which holds shape data
     */
    protected EscherContainerRecord CreateSpContainer(int idx, bool IsChild) {
        _escherContainer = super.CreateSpContainer(idx, isChild);

        SetEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
        SetEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);

        EscherClientDataRecord cldata = new EscherClientDataRecord();
        cldata.SetOptions((short)0xF);
        _escherContainer.AddChildRecord(cldata);

        OEShapeAtom oe = new OEShapeAtom();
        InteractiveInfo info = new InteractiveInfo();
        InteractiveInfoAtom infoAtom = info.GetInteractiveInfoAtom();
        infoAtom.SetAction(InteractiveInfoAtom.ACTION_MEDIA);
        infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_NULL);

        AnimationInfo an = new AnimationInfo();
        AnimationInfoAtom anAtom = an.GetAnimationInfoAtom();
        anAtom.SetFlag(AnimationInfoAtom.Automatic, true);

        //convert hslf into ddf
        MemoryStream out = new MemoryStream();
        try {
            oe.WriteOut(out);
            an.WriteOut(out);
            info.WriteOut(out);
        } catch(Exception e){
            throw new HSLFException(e);
        }
        cldata.SetRemainingData(out.ToArray());

        return _escherContainer;
    }
Exemplo n.º 34
0
    public void Reset(){
        
		_animInfo = GetComponent<AnimationInfo>();        
    	_animInfo.InitKeyPoints(); //should always update interpolators
        _animInfo.InitInterpolators(Tval, Continuity, Bias);

        _interpolatorType = InterpolatorType.EndEffector;
		// FUNDA Effort2LowLevel(); //initialize low level parameters

        #if DEBUGMODE
        _targetRPrev = new List<Vector3>();
        _targetLPrev = new List<Vector3>();
        #endif

         _velArr = new List<float>();
        _tppArr = new List<float>();

    }
Exemplo n.º 35
0
    /// <summary>
    /// Obtiene el intervalo de tiempo en segundos y el ángulo más cercano al entregado por parámetro
    /// </summary>
    /// <param name="angle">Ángulo que se quiere buscar en la lista de frames</param>
    /// <param name="aiList">Lista de AnimationInfo que representan el tiempo en segundos y el ángulo en cada frame</param>
    /// <returns>Retorna una AnimationInfo que contiene el tiempo y el ángulo encontrado más cercano al solicitado</returns>
    AnimationInfo GetAnimationInfo(float angle, List<AnimationInfo> aiList)
    {
        //TODO: Quizás se pueda mejorar
        List<AnimationInfo> aiListTemp = aiList.GetRange(1, (int)aiList.Count / 2);
        aiListTemp.Reverse();
        AnimationInfo aiTemp = new AnimationInfo(float.MaxValue, float.MaxValue);
        bool wasNear = false;
        foreach (AnimationInfo ai in aiListTemp)
        {
            float dif = Math.Abs(ai.angle - angle);
            if ((dif <= 3) && !wasNear)
            {
                wasNear = true;
            }
            else if ((dif > 3) && wasNear)
            {
                return aiTemp;
            }

            if (dif < Math.Abs(aiTemp.angle - angle))
                aiTemp = ai;
            else
                continue;
        }
        
        return aiTemp;
    }
Exemplo n.º 36
0
    protected AnimationData CreateDataFromInfo(AnimationInfo info)
    {
        AnimationData lOut = new AnimationData();

        lOut.material = info.material;
        lOut.animationName = info.animationName;
        lOut.animationLength = info.animationLength;

        //动画中单幅图的像素信息
        //if(info.pixelVerticalNum)
        //	lOut.pixelVerticalNum=info.pixelVerticalNum;
        //else//use default
        lOut.pixelVerticalNum = defaultPixelVerticalNum;

        //if(info.pixelHorizonNum)
        //	lOut.pixelHorizonNum=info.pixelHorizonNum;
        //else
        lOut.pixelHorizonNum = defaultPixelHorizonNum;

        //开始的帧数,结束的帧数,数从0开始.将会播放从beginPicNum到endPicNum,共endPicNum-beginPicNum+1幅图
        lOut.beginPicNum = info.beginPicNum;
        lOut.endPicNum = info.endPicNum;

        lOut.loop = info.loop;

        /////////////////////////////////////////////////////////

        lOut.numOfHorizonPic = info.material.mainTexture.width / lOut.pixelHorizonNum;
        lOut.numOfVerticalPic = info.material.mainTexture.height / lOut.pixelVerticalNum;

        lOut.picRateInU = 1.0f / lOut.numOfHorizonPic;
        lOut.picRateInV = 1.0f / lOut.numOfVerticalPic;
        //numOfPic = numOfVerticaPic * numOfHorizonPic;
        lOut.numOfPic = lOut.endPicNum - lOut.beginPicNum + 1;
        //lOut.timeInOnePic = lOut.animationLength / lOut.numOfPic;

        return lOut;
    }
Exemplo n.º 37
0
        private static void LoadAnimation(AnimationInfo animInfo)
        {
            var animation = new Animation {Texture = G.Content.Load<Texture2D>(animInfo.AssetName), Frames = new List<Frame>()};

            foreach (var frameInfo in animInfo.Frames)
            {
                var sourceRect = GetIndexSourceRectangle(animation.Texture.Width, animation.Texture.Height,
                                                         animInfo.Width, animInfo.Height, frameInfo.Index);
                var frame = new Frame(sourceRect, frameInfo.Duration);
                animation.Frames.Add(frame);
            }

            Animations.Add(animInfo.Name, animation);
        }
Exemplo n.º 38
0
        public void SetAnimation(string animationName, bool isLooping)
        {
            _isAnimationLooping = isLooping;
            _hasAnimationEnded = false;

            AnimationInfo animationInfo;
            if (!_animations.TryGetValue(animationName, out animationInfo))
            {
                throw new ArgumentException(string.Format("Animation named \"{0}\" can't be found", animationName));
            }
            _currentAnimationName = animationName;
            _currentAnimationRange = animationInfo;

            _framePosition = animationInfo.Start;

            _frameTime = animationInfo.Time;
            base.UpdateSourceRectangle();
        }
Exemplo n.º 39
0
		/// <summary>
		/// Runs a delegate at regular intervals 
		/// </summary>
		/// <returns>
		/// An animation object. It can be disposed to stop the animation.
		/// </returns>
		/// <param name='animation'>
		/// The delegate to run. The return value if the number of milliseconds to wait until the delegate is run again.
		/// The execution will stop if the deletgate returns 0
		/// </param>
		public static IDisposable RunAnimation (Func<int> animation)
		{
			var ainfo = new AnimationInfo () {
				AnimationFunc = animation,
				NextDueTime = DateTime.Now
			};

			activeAnimations.Add (ainfo);
			
			// Don't immediately run the animation if we are going to do it in less than 20ms
			if (animationHandle == 0 || currentAnimationSpan > 20)
				ProcessAnimations ();
			return ainfo;
		}
Exemplo n.º 40
0
        private void AnimateOverlay(bool show)
        {
            if (show)
            {
                List <AnimationInfo> animInfoList   = new List <AnimationInfo>();
                AnimationInfo        animationInfo1 = new AnimationInfo();
                animationInfo1.target       = (DependencyObject)this.transformButton;
                animationInfo1.propertyPath = CompositeTransform.ScaleXProperty;
                animationInfo1.from         = this.transformButton.ScaleX;
                animationInfo1.to           = 1.0;
                animationInfo1.duration     = 150;
                CubicEase cubicEase1 = new CubicEase();
                int       num1       = 0;
                ((EasingFunctionBase)cubicEase1).EasingMode = ((EasingMode)num1);
                animationInfo1.easing = (IEasingFunction)cubicEase1;
                animInfoList.Add(animationInfo1);
                AnimationInfo animationInfo2 = new AnimationInfo();
                animationInfo2.target       = (DependencyObject)this.transformButton;
                animationInfo2.propertyPath = CompositeTransform.ScaleYProperty;
                animationInfo2.from         = this.transformButton.ScaleY;
                animationInfo2.to           = 1.0;
                animationInfo2.duration     = 150;
                CubicEase cubicEase2 = new CubicEase();
                int       num2       = 0;
                ((EasingFunctionBase)cubicEase2).EasingMode = ((EasingMode)num2);
                animationInfo2.easing = (IEasingFunction)cubicEase2;
                animInfoList.Add(animationInfo2);
                AnimationInfo animationInfo3 = new AnimationInfo();
                animationInfo3.target       = (DependencyObject)this.translateRecordOverlay;
                animationInfo3.propertyPath = TranslateTransform.XProperty;
                animationInfo3.from         = this.translateRecordOverlay.X;
                animationInfo3.to           = 0.0;
                animationInfo3.duration     = 150;
                CubicEase cubicEase3 = new CubicEase();
                int       num3       = 0;
                ((EasingFunctionBase)cubicEase3).EasingMode = ((EasingMode)num3);
                animationInfo3.easing = (IEasingFunction)cubicEase3;
                animInfoList.Add(animationInfo3);
                int?startTime = new int?();
                // ISSUE: variable of the null type

                AnimationUtil.AnimateSeveral(animInfoList, startTime, null);
            }
            else
            {
                List <AnimationInfo> animInfoList   = new List <AnimationInfo>();
                AnimationInfo        animationInfo1 = new AnimationInfo();
                animationInfo1.target       = (DependencyObject)this.transformButton;
                animationInfo1.propertyPath = CompositeTransform.ScaleXProperty;
                animationInfo1.from         = this.transformButton.ScaleX;
                animationInfo1.to           = 0.0;
                animationInfo1.duration     = 150;
                CubicEase cubicEase1 = new CubicEase();
                int       num1       = 0;
                ((EasingFunctionBase)cubicEase1).EasingMode = ((EasingMode)num1);
                animationInfo1.easing = (IEasingFunction)cubicEase1;
                animInfoList.Add(animationInfo1);
                AnimationInfo animationInfo2 = new AnimationInfo();
                animationInfo2.target       = (DependencyObject)this.transformButton;
                animationInfo2.propertyPath = CompositeTransform.ScaleYProperty;
                animationInfo2.from         = this.transformButton.ScaleY;
                animationInfo2.to           = 0.0;
                animationInfo2.duration     = 150;
                CubicEase cubicEase2 = new CubicEase();
                int       num2       = 0;
                ((EasingFunctionBase)cubicEase2).EasingMode = ((EasingMode)num2);
                animationInfo2.easing = (IEasingFunction)cubicEase2;
                animInfoList.Add(animationInfo2);
                AnimationInfo animationInfo3 = new AnimationInfo();
                animationInfo3.target       = (DependencyObject)this.translateRecordOverlay;
                animationInfo3.propertyPath = TranslateTransform.XProperty;
                animationInfo3.from         = this.translateRecordOverlay.X;
                animationInfo3.to           = base.ActualWidth;
                animationInfo3.duration     = 150;
                CubicEase cubicEase3 = new CubicEase();
                int       num3       = 1;
                ((EasingFunctionBase)cubicEase3).EasingMode = ((EasingMode)num3);
                animationInfo3.easing = (IEasingFunction)cubicEase3;
                animInfoList.Add(animationInfo3);
                int?   startTime = new int?();
                Action completed = new Action(this.UpdateVisibilityState);
                AnimationUtil.AnimateSeveral(animInfoList, startTime, completed);
            }
        }
Exemplo n.º 41
0
    void Start()
    {
        //FUNDA
        //   UserInfo.Hit = 0;


        for (int i = 0; i < _agentsLeft.Length; i++)
        {
            _agentsLeft[i]  = GameObject.Find("AgentPrefabLeft" + i).GetComponent <AnimationInfo>();
            _agentsRight[i] = GameObject.Find("AgentPrefabRight" + i).GetComponent <AnimationInfo>();


            //Make all invisible so that users can't see the models
            _agentsLeft[i].gameObject.SetActive(false);
            _agentsRight[i].gameObject.SetActive(false);
        }


        //TODO: Hits start from 0!!
        _agentsLeft[(UserInfo.Hit / 3)].gameObject.SetActive(true);
        _agentsRight[(UserInfo.Hit / 3)].gameObject.SetActive(true);

        for (int i = 0; i < 32; i++)
        {
            _driveParams[i] = new DriveParams();
        }

        _qCnt = 10;


#if DEBUGMODE
        UserInfo.Hit      = 0;
        UserInfo.IsMale   = true;
        UserInfo.IsNative = true;
        UserInfo.Age      = 20;
        UserInfo.UserId   = "fd";
#endif


        //_taskQInd = 9;

        _taskQInd = 0; //initial question's index

        _isSubmittedStr = new string[_qCnt];
        _isSubmitted    = new bool[_qCnt];
        _alreadyPlayed  = new bool[_qCnt];



        for (int i = 0; i < _isSubmittedStr.Length; i++)
        {
            _isSubmittedStr[i] = "";//"Answer NOT submitted";
        }
        for (int i = 0; i < _alreadyPlayed.Length; i++)
        {
            _alreadyPlayed[i] = false;
        }

        UpdateCameraBoundaries();


        //    _drivesAchieved = false;
        //Read all drive and shape parameters

#if !WEBMODE
        for (int i = 0; i < 32; i++)
        {
            _driveParams[i].ReadValuesDrives(i);
        }
#elif WEBMODE
        for (int i = 0; i < 32; i++)
        {
            this.StartCoroutine(_driveParams[i].GetValuesDrives(i, "funda"));
        }
#endif



        _persMapper      = new PersonalityMapper();
        _firstQFirstPlay = true;

        _agentLeft  = GameObject.Find("AgentPrefabLeft" + (UserInfo.Hit / 3)).GetComponent <AnimationInfo>();
        _agentRight = GameObject.Find("AgentPrefabRight" + (UserInfo.Hit / 3)).GetComponent <AnimationInfo>();


        if ((UserInfo.Hit % 3) == 2)   //walking
        {
            _agentLeft.transform.position  -= Vector3.forward * 10;
            _agentRight.transform.position -= Vector3.forward * 10;
        }

        Reset(_agentLeft);
        Reset(_agentRight);
    }
Exemplo n.º 42
0
        private void MoveToInitial()
        {
            if (this._isInInitial)
            {
                return;
            }
            this._isInInitial = true;
            ((Shape)this.ellipseVolume).Fill = ((Brush)Application.Current.Resources["PhoneBlue300_GrayBlue400Brush"]);
            List <AnimationInfo> animInfoList   = new List <AnimationInfo>();
            AnimationInfo        animationInfo1 = new AnimationInfo();

            animationInfo1.target       = (DependencyObject)this.transformButton;
            animationInfo1.propertyPath = CompositeTransform.TranslateXProperty;
            animationInfo1.from         = this.transformButton.TranslateX;
            animationInfo1.to           = 0.0;
            animationInfo1.duration     = 200;
            CubicEase cubicEase1 = new CubicEase();
            int       num1       = 0;

            ((EasingFunctionBase)cubicEase1).EasingMode = ((EasingMode)num1);
            animationInfo1.easing = (IEasingFunction)cubicEase1;
            animInfoList.Add(animationInfo1);
            AnimationInfo animationInfo2 = new AnimationInfo();

            animationInfo2.target       = (DependencyObject)this.translateRecordDuration;
            animationInfo2.propertyPath = TranslateTransform.XProperty;
            animationInfo2.from         = this.translateRecordDuration.X;
            animationInfo2.to           = 0.0;
            animationInfo2.duration     = 200;
            CubicEase cubicEase2 = new CubicEase();
            int       num2       = 0;

            ((EasingFunctionBase)cubicEase2).EasingMode = ((EasingMode)num2);
            animationInfo2.easing = (IEasingFunction)cubicEase2;
            animInfoList.Add(animationInfo2);
            AnimationInfo animationInfo3 = new AnimationInfo();

            animationInfo3.target       = (DependencyObject)this.borderCancel;
            animationInfo3.propertyPath = UIElement.OpacityProperty;
            animationInfo3.from         = ((UIElement)this.borderCancel).Opacity;
            animationInfo3.to           = 0.0;
            CubicEase cubicEase3 = new CubicEase();
            int       num3       = 1;

            ((EasingFunctionBase)cubicEase3).EasingMode = ((EasingMode)num3);
            animationInfo3.easing = (IEasingFunction)cubicEase3;
            int num4 = 200;

            animationInfo3.duration = num4;
            animInfoList.Add(animationInfo3);
            AnimationInfo animationInfo4 = new AnimationInfo();

            animationInfo4.target       = (DependencyObject)this.panelSlideToCancel;
            animationInfo4.propertyPath = UIElement.OpacityProperty;
            animationInfo4.from         = ((UIElement)this.panelSlideToCancel).Opacity;
            animationInfo4.to           = 1.0;
            CubicEase cubicEase4 = new CubicEase();
            int       num5       = 0;

            ((EasingFunctionBase)cubicEase4).EasingMode = ((EasingMode)num5);
            animationInfo4.easing = (IEasingFunction)cubicEase4;
            int num6 = 200;

            animationInfo4.duration = num6;
            animInfoList.Add(animationInfo4);
            int?startTime = new int?();

            // ISSUE: variable of the null type

            AnimationUtil.AnimateSeveral(animInfoList, startTime, null);
        }
Exemplo n.º 43
0
 /// <summary>
 /// _plays the specified anim.
 /// Internal use only
 /// </summary>
 /// <param name="anim">The anim.</param>
 public void _play(AnimationInfo anim)
 {
     _curAnimationInfo = anim;
     _curFrameTime = _curAnimationInfo.frameTime;
     _subImageIndex = _curAnimationInfo.beginIndex;
 }
Exemplo n.º 44
0
 public void AddFadeOutAnimation <TModal>(string propertyName, CompositionAnimation animation)
     where TModal : ModalView
 {
     fadeOutAnimationInfos[typeof(TModal)] = new AnimationInfo(propertyName, animation);
 }
Exemplo n.º 45
0
        public static BakedAnimation BakeAnimation(this GameObject model, AnimationClip animationClip, AnimationInfo animationInfo)
        {
            // Create positionMap Texture without MipMaps which is Linear and HDR to store values in a bigger range.
            Texture2D positionMap = new Texture2D(animationInfo.textureWidth, animationInfo.textureHeight, TextureFormat.RGBAHalf, false, true);

            // Keep track of min/max bounds.
            Vector3 min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            Vector3 max = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            // Create instance to sample from.
            GameObject          inst = GameObject.Instantiate(model);
            SkinnedMeshRenderer skinnedMeshRenderer = inst.GetComponent <SkinnedMeshRenderer>();

            int y = 0;

            for (int f = 0; f < animationInfo.frames; f++)
            {
                animationClip.SampleAnimation(inst, (animationClip.length / animationInfo.frames) * f);

                Mesh sampledMesh = new Mesh();
                skinnedMeshRenderer.BakeMesh(sampledMesh);

                List <Vector3> verts = new List <Vector3>();
                sampledMesh.GetVertices(verts);
                List <Vector3> normals = new List <Vector3>();
                sampledMesh.GetNormals(normals);

                int x = 0;
                for (int v = 0; v < verts.Count; v++)
                {
                    min = Vector3.Min(min, verts[v]);
                    max = Vector3.Max(max, verts[v]);

                    positionMap.SetPixel(x, y,
                                         new Color(verts[v].x, verts[v].y, verts[v].z,
                                                   VectorUtils.EncodeFloat3ToFloat1(normals[v]))
                                         );

                    x++;
                    if (x >= animationInfo.textureWidth)
                    {
                        x = 0;
                        y++;
                    }
                }
                y += animationInfo.frameSpacing;
            }

            GameObject.DestroyImmediate(inst);

            positionMap.name       = string.Format("VA_N-{0}_F-{1}_MF-{2}_FPS-{3}", NamingConventionUtils.ConvertToValidString(animationClip.name), animationInfo.frames, animationInfo.maxFrames, animationInfo.fps);
            positionMap.filterMode = FilterMode.Point;
            positionMap.Apply(false, true);

            return(new BakedAnimation()
            {
                positionMap = positionMap,
                minBounds = min,
                maxBounds = max
            });
        }
Exemplo n.º 46
0
        private void RunContentAnimation(Dictionary <Type, AnimationInfo> animations, Type modalType, AnimationInfo defaultAnimation)
        {
            var animationInfo = animations.ContainsKey(modalType)
                ? animations[modalType]
                : defaultAnimation;

            animationInfo.Animation.SetScalarParameter("Width", (float)ActualWidth);
            animationInfo.Animation.SetScalarParameter("Height", (float)ActualHeight);
            animationInfo.Start(contentVisual);
        }
        private AnimationInfo LoadAnimations(Scene scene, string title, bool pose = false)
        {
            var prevAnimation = СurrentAnimation;
            var animation = default(AnimationInfo);
            if (scene.AnimationCount == 0)
                return animation;
            const int firstAnimationIndex = 0;

            //for (int i = 0; i < scene.AnimationCount; i++)            // in one file always one animation
            {
                animation = new AnimationInfo(title, pose);
                СurrentAnimation = animation;
                animation.TicksPerSecond = (float)scene.Animations[firstAnimationIndex].TicksPerSecond;
                animation.DurationInTicks = (float)scene.Animations[firstAnimationIndex].DurationInTicks;
                FillAnimationNode(scene, scene.RootNode, firstAnimationIndex);
                if (pose)
                    Poses.Add(title, animation);
                else
                    Animations.Add(title, animation);
            }
            // СurrentAnimation = prevAnimation;
            return animation;
        }
		public bool BlendAnimationClip(BlendData blendData)
		{
			AnimationInfo info = new AnimationInfo ();
			info.Animation = blendData.Animation;
			info.BlendInfo = blendData;

			AnimationInfo last = GetLastAnimation ();
			if (last == null) {
				info.BlendAmount = 1f;
			}
			if ((last == null) || (last.Animation != info.Animation)) {
				animationInfoList.Add (info);
				return true;
			}

			return false;
		}
Exemplo n.º 49
0
 private void RegistAniList()
 {
     if (this.AniList.Count == 0 && this.MainObject)
     {
         Animation[] componentsInChildren = this.MainObject.GetComponentsInChildren <Animation>();
         if (componentsInChildren.Length > 0)
         {
             Animation[] array = componentsInChildren;
             for (int i = 0; i < array.Length; i++)
             {
                 Animation animation = array[i];
                 foreach (AnimationState animationState in animation)
                 {
                     this.AniList.Add(animationState.clip.name);
                 }
                 this.AniObj.Add(animation.gameObject);
             }
             if (0 < this.AniObj.Count && 0 < this.AniList.Count)
             {
                 GameObject gameObject          = this.AniObj[0].gameObject;
                 Animation  componentInChildren = gameObject.GetComponentInChildren <Animation>();
                 this.MainInfo = string.Concat(new object[]
                 {
                     "INFO:",
                     gameObject.name,
                     " Ani:",
                     componentInChildren.GetClipCount()
                 });
             }
         }
         else
         {
             Animator[] componentsInChildren2 = this.MainObject.GetComponentsInChildren <Animator>();
             if (componentsInChildren2.Length > 0)
             {
                 Animator[] array2 = componentsInChildren2;
                 for (int j = 0; j < array2.Length; j++)
                 {
                     Animator animator = array2[j];
                     for (int k = 0; k < animator.layerCount; k++)
                     {
                         AnimationInfo[] currentAnimationClipState = animator.GetCurrentAnimationClipState(k);
                         AnimationInfo[] array3 = currentAnimationClipState;
                         for (int l = 0; l < array3.Length; l++)
                         {
                             AnimationInfo animationInfo = array3[l];
                             this.AniList.Add(animationInfo.clip.name);
                         }
                         this.AniObj.Add(animator.gameObject);
                     }
                 }
                 if (0 < this.AniObj.Count && 0 < this.AniList.Count)
                 {
                     GameObject gameObject2          = this.AniObj[0].gameObject;
                     Animator   componentInChildren2 = gameObject2.GetComponentInChildren <Animator>();
                     this.MainInfo = string.Concat(new object[]
                     {
                         "INFO:",
                         gameObject2.name,
                         " Ani:",
                         componentInChildren2.layerCount
                     });
                 }
             }
         }
     }
 }
Exemplo n.º 50
0
        private void RunAnimation(Action callback)
        {
            List <AnimationInfo> animInfoList   = new List <AnimationInfo>();
            AnimationInfo        animationInfo1 = new AnimationInfo();

            animationInfo1.duration = PreviewBehavior.PUSH_ANIMATION_DURATION;
            animationInfo1.easing   = PreviewBehavior.PUSH_ANIMATION_EASING;
            double scaleX = (this.imagePreview.RenderTransform as ScaleTransform).ScaleX;

            animationInfo1.from = scaleX;
            double num1 = 1.0;

            animationInfo1.to = num1;
            Transform renderTransform1 = this.imagePreview.RenderTransform;

            animationInfo1.target = (DependencyObject)renderTransform1;
            DependencyProperty dependencyProperty1 = ScaleTransform.ScaleXProperty;

            animationInfo1.propertyPath = (object)dependencyProperty1;
            animInfoList.Add(animationInfo1);
            AnimationInfo animationInfo2 = new AnimationInfo();

            animationInfo2.duration = PreviewBehavior.PUSH_ANIMATION_DURATION;
            animationInfo2.easing   = PreviewBehavior.PUSH_ANIMATION_EASING;
            double scaleY = (this.imagePreview.RenderTransform as ScaleTransform).ScaleY;

            animationInfo2.from = scaleY;
            double num2 = 1.0;

            animationInfo2.to = num2;
            Transform renderTransform2 = this.imagePreview.RenderTransform;

            animationInfo2.target = (DependencyObject)renderTransform2;
            DependencyProperty dependencyProperty2 = ScaleTransform.ScaleYProperty;

            animationInfo2.propertyPath = (object)dependencyProperty2;
            animInfoList.Add(animationInfo2);
            AnimationInfo animationInfo3 = new AnimationInfo();

            animationInfo3.duration = PreviewBehavior.PUSH_ANIMATION_DURATION;
            animationInfo3.easing   = PreviewBehavior.PUSH_ANIMATION_EASING;
            double opacity = this.rect.Opacity;

            animationInfo3.from = opacity;
            double num3 = 0.4;

            animationInfo3.to = num3;
            Rectangle rectangle = this.rect;

            animationInfo3.target = (DependencyObject)rectangle;
            DependencyProperty dependencyProperty3 = UIElement.OpacityProperty;

            animationInfo3.propertyPath = (object)dependencyProperty3;
            animInfoList.Add(animationInfo3);
            int?   startTime = new int?(0);
            Action completed = (Action)(() =>
            {
                this._animationRan = true;
                callback();
            });

            AnimationUtil.AnimateSeveral(animInfoList, startTime, completed);
        }
Exemplo n.º 51
0
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        clockBehaviour.Update();
        if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
        {
            if (!animator.IsInTransition(0))
                animator.speed = 0;
            return;
        }
                
        #region Interpolate
        //Si no estamos en estado Stopped 
        //Y estamos preparados para hacer Lerp
        //Y el tiempo que ha transcurrido de la ultima rep es mayor al tiempo de pause entre repeticiones. O no ha habido última rep.
       
        if (_BehaviourState != AnimationBehaviourState.STOPPED && ReadyToLerp
            && (endRepTime == null || new TimeSpan(0, 0, (int)_currentParams.SecondsBetweenRepetitions) <= DateTime.Now - endRepTime))
        {
            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) && 
                this._BehaviourState != AnimationBehaviourState.PREPARING_WEB && 
                this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS && 
                this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
            {
                OnRepetitionReallyStart();
                BeginRep = true;
            }
            //if(_LerpBehaviourState == LerpBehaviourState.STOPPED)
            float timeSinceStarted = Time.time - timeStartedLerping;
            float percentageComplete = 0f;
            /*
            switch (_currentLerpState)
            {
                case LerpState.Forward:
                    
                    percentageComplete = timeSinceStarted / timeTakenDuringForwardLerp;
                    Debug.Log("1 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringForwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime );
                    break;

                case LerpState.Stopped:
                    if (_lastLerpState == LerpState.Forward)
                    {
                        percentageComplete = timeSinceStarted / timeTakenDuringForwardLerp;
                        Debug.Log("2 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringForwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
                    }

                    //De ser true, indica que termino una repeticion
                    else if (_lastLerpState == LerpState.Backward)
                    {
                        percentageComplete = timeSinceStarted / timeTakenDuringBackwardLerp;
                        Debug.Log("3 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringBackwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
                    }
                    break;

                case LerpState.Backward:
                    percentageComplete = timeSinceStarted / timeTakenDuringBackwardLerp;
                    Debug.Log("4 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringBackwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
                    break;
            }*/

            percentageComplete = animator.GetCurrentAnimatorStateInfo(0).normalizedTime;

            //float normalizedSpeed;
            //if (percentageComplete < 0.5)
            //    normalizedSpeed = timeSinceStarted/timeTakenDuringForwardLerp * 4;
            //else
            //    normalizedSpeed = 4f- timeSinceStarted / timeTakenDuringForwardLerp * 4;
            //Aplico el suavizado "Smotherstep"
            //percentageComplete = percentageComplete * percentageComplete * (3f - 2f * percentageComplete);
            //float percentageSmotherstep = timeSinceStarted * timeSinceStarted * timeSinceStarted * (timeSinceStarted * (6f * timeSinceStarted - 15f) + 10f);

            float sp = endPosition + startPosition;


            if (!holdingPose)
            {
                animator.StartRecording(0);
                animator.speed = sp;// Mathf.Lerp(startPosition, endPosition, normalizedSpeed);
                                    //Debug.Log("% "+ percentageComplete + "normalized speed " + normalizedSpeed + "  speed " + animator.speed);
                animator.StopRecording();
            }

            float DELTA = 0.03f;
            if ((animator.speed > 0  && percentageComplete >= 1.0f - DELTA) ||
                (animator.speed < 0 && percentageComplete <= 0f + DELTA))
            {
                Debug.Log("int end " + percentageComplete);
                InterpolationEnd();
            }
        }
        else if(this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
        {
            animator.speed = 0;
        }


        if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
        {
            timeSinceCapture += Time.deltaTime;
            if (timeSinceCapture > INTERVAL)
            {
                timeSinceCapture = timeSinceCapture - INTERVAL;
                /*
                if (exerciseDataGenerator == null)
                    exerciseDataGenerator = GameObject.FindObjectOfType<Detector.ExerciseDataGenerator>();
                if (this.exerciseDataGenerator != null)
                    this.exerciseDataGenerator.CaptureData();*/
            }
        }

        
        #endregion
        if (_BehaviourState == AnimationBehaviourState.PREPARING_DEFAULT || _BehaviourState == AnimationBehaviourState.PREPARING_WEB)
            this.SaveTimesAngle(stateInfo);
        lastReadyToLerp = ReadyToLerp;


        JointTypePlanoResult tempJointTypePlanoResult = MovementJointMatch.movementJointMatch[new MovementLimbKey(movement, limb)];
        ArticulacionClass joint = AnimatorScript.instance.utils.getArticulacion(tempJointTypePlanoResult.jointType);
        AnimationInfo tempAnimationInfo = new AnimationInfo();
        float time = stateInfo.normalizedTime; //* stateInfo.length;
        switch (tempJointTypePlanoResult.plain)
        {
            case Plano.planos.planoFrontal:
                tempAnimationInfo = new AnimationInfo(time, joint.AngleFrontal);
                break;
            case Plano.planos.planoHorizontal:
                tempAnimationInfo = new AnimationInfo(time, joint.AngleHorizontal);
                break;
            case Plano.planos.planoSagital:
                tempAnimationInfo = new AnimationInfo(time, joint.AngleSagital);
                break;
            case Plano.planos.planoHorizontalAcostado:
                tempAnimationInfo = new AnimationInfo(time, joint.AngleHorizontalAcostado);
                break;
        }
        //GameObject.FindGameObjectWithTag("angulotexto").GetComponent<Text>().text = "Angulo " + joint.articulacion.ToString() + " : " + tempAnimationInfo.angle.ToString();

    }
Exemplo n.º 52
0
        public override void LoadContent(ContentManager content)
        {
            loader.Load();
            // Is the level loading succesfull
            if (loader.LevelLoaded)
            {
                backgroundGrid = new Grid();
                backgroundGrid.LoadFromLevelInfo(loader.level);

                drawAbleItems.Add(backgroundGrid);
                GameObjects.Add(backgroundGrid);

                List <ClickAbleInfo> click = loader.level.clickObjectsInfo;

                foreach (ClickAbleInfo info in click)
                {
                    if (info.texturePath.Contains("car"))
                    {
                        Car clickObj = new Car();
                        // Check if the object has an custom bounds
                        if (info.useCustomBounds)
                        {
                            clickObj.SetCustomBounds(new Rectangle(info.X, info.Y, info.Width, info.Height));
                        }

                        if (info.texturePath.Contains("blue"))
                        {
                            clickObj.Position      = info.position - new Vector2(400, 0);
                            clickObj.StartPosition = clickObj.Position;
                        }
                        else
                        {
                            clickObj.StartPosition = info.position;
                            clickObj.Position      = info.position;
                        }
                        clickObj.moveToPosition = info.moveToPosition;
                        clickObj.TexturePath    = info.texturePath;

                        // Check if the object has an animation
                        if (IOHelper.Instance.DoesFileExist(Constants.CONTENT_DIR + info.texturePath + ".ani"))
                        {
                            AnimationInfo aInfo = JsonConvert.DeserializeObject <AnimationInfo>(IOHelper.Instance.ReadFile(Constants.CONTENT_DIR + info.texturePath + ".ani"));
                            clickObj.Animation = new Animation(content.Load <Texture2D>(info.texturePath), aInfo.width, aInfo.height, aInfo.cols, aInfo.rows, aInfo.totalFrames, aInfo.fps);
                        }
                        else
                        {
                            clickObj.Image = content.Load <Texture2D>(info.texturePath);
                        }
                        clickObj.ObjectiveID = info.objectiveID;

                        if (info.useCustomBounds)
                        {
                            clickObj.SetCustomBounds(new Rectangle(info.X, info.Y, info.Width, info.Height));
                        }

                        clickObj.onClick += OnClickHandler;

                        objectives.Add(new Objective("Objective " + info.objectiveID));

                        drawAbleItems.Add(clickObj);
                        GameObjects.Add(clickObj);
                    }
                    else if (info.texturePath.Contains("plank"))
                    {
                        Plank clickObj = new Plank();
                        // Check if the object has an custom bounds
                        if (info.useCustomBounds)
                        {
                            clickObj.SetCustomBounds(new Rectangle(info.X, info.Y, info.Width, info.Height));
                        }

                        clickObj.StartPosition  = info.position;
                        clickObj.Position       = info.position;
                        clickObj.moveToPosition = info.moveToPosition;
                        clickObj.TexturePath    = info.texturePath;

                        // Check if the object has an animation
                        if (IOHelper.Instance.DoesFileExist(Constants.CONTENT_DIR + info.texturePath + ".ani"))
                        {
                            AnimationInfo aInfo = JsonConvert.DeserializeObject <AnimationInfo>(IOHelper.Instance.ReadFile(Constants.CONTENT_DIR + info.texturePath + ".ani"));
                            clickObj.Animation = new Animation(content.Load <Texture2D>(info.texturePath), aInfo.width, aInfo.height, aInfo.cols, aInfo.rows, aInfo.totalFrames, aInfo.fps);
                        }
                        else
                        {
                            clickObj.Image = content.Load <Texture2D>(info.texturePath);
                        }
                        clickObj.ObjectiveID = info.objectiveID;

                        if (info.useCustomBounds)
                        {
                            clickObj.SetCustomBounds(new Rectangle(info.X, info.Y, info.Width, info.Height));
                        }

                        clickObj.onClick += OnClickHandler;

                        objectives.Add(new Objective("Objective " + info.objectiveID));

                        drawAbleItems.Add(clickObj);
                        GameObjects.Add(clickObj);
                    }
                    else
                    {
                        ClickableObject clickObj = new ClickableObject();
                        // Check if the object has an custom bounds
                        if (info.useCustomBounds)
                        {
                            clickObj.SetCustomBounds(new Rectangle(info.X, info.Y, info.Width, info.Height));
                        }

                        clickObj.StartPosition  = info.position;
                        clickObj.Position       = info.position;
                        clickObj.moveToPosition = info.moveToPosition;
                        clickObj.TexturePath    = info.texturePath;

                        // Check if the object has an animation
                        if (IOHelper.Instance.DoesFileExist(Constants.CONTENT_DIR + info.texturePath + ".ani"))
                        {
                            AnimationInfo aInfo = JsonConvert.DeserializeObject <AnimationInfo>(IOHelper.Instance.ReadFile(Constants.CONTENT_DIR + info.texturePath + ".ani"));
                            clickObj.Animation = new Animation(content.Load <Texture2D>(info.texturePath), aInfo.width, aInfo.height, aInfo.cols, aInfo.rows, aInfo.totalFrames, aInfo.fps);
                        }
                        else
                        {
                            clickObj.Image = content.Load <Texture2D>(info.texturePath);
                        }
                        clickObj.ObjectiveID = info.objectiveID;

                        if (info.useCustomBounds)
                        {
                            clickObj.SetCustomBounds(new Rectangle(info.X, info.Y, info.Width, info.Height));
                        }

                        clickObj.onClick += OnClickHandler;

                        objectives.Add(new Objective("Objective " + info.objectiveID));

                        drawAbleItems.Add(clickObj);
                        GameObjects.Add(clickObj);
                    }
                }

                {// create scope for info
                    PlayerInfo info = loader.level.playerInfo;
                    player = new Player();
                    player.StartPosition = loader.level.playerInfo.position;
                    player.StartMovement = loader.level.playerInfo.startMovement;
                    player.LoadContent(content);
                    player.ChangeMovement(loader.level.playerInfo.startMovement);

                    if (loader.level.playerInfo.useCustomBoundingbox)
                    {
                        player.SetCustomBoundingbox(new Rectangle(info.x, info.y, info.width, info.height));
                    }
                    drawAbleItems.Add(player);
                }

                GameObjects.Add(player);

                foreach (MovementTileInfo info in loader.level.moveTiles)
                {
                    if (info.WinningTile)
                    {
                        GameObjects.Add(new WinTile(new Rectangle(info.X, info.Y, info.Width, info.Height)));
                    }
                    else
                    {
                        GameObjects.Add(new MovementTile(new Rectangle(info.X, info.Y, info.Width, info.Height), info.movement, testing));
                    }
                }

                foreach (DecorationInfo info in loader.level.decoration)
                {
                    Decoration decoration = new Decoration();
                    decoration.Position = info.position;
                    decoration.Image    = content.Load <Texture2D>(info.ImagePath);
                    drawAbleItems.Add(decoration);
                    GameObjects.Add(decoration);
                }

                drawAbleItems = drawAbleItems.OrderBy(o => o.DrawIndex()).ToList();
            }
            else
            {
                // TODO: show error
                player.Won = true;
            }

            pause = new Button();
            pause.LoadImage(@"buttons\pause");
            pause.Position = new Vector2(Game1.Instance.ScreenRect.Width - pause.Hitbox.Width - 10, 10);
            pause.OnClick += Pause_OnClick;

            pauseBack = new Button();
            pauseBack.LoadImage(@"buttons\menu");
            pauseBack.Position = new Vector2(Game1.Instance.ScreenRect.Width / 2 - pauseBack.Hitbox.Width / 2, Game1.Instance.ScreenRect.Height / 2 - pauseBack.Hitbox.Height / 2);
            pauseBack.OnClick += Pause_OnClick;

            backButton = new ClickableObject();

            backButton.TexturePath = @"buttons\reset";
            backButton.Image       = content.Load <Texture2D>(backButton.TexturePath);

            backButton.onClick    += OnClickHandler;
            backButton.ObjectiveID = -1;
            backButton.Position    = new Vector2(Game1.Instance.ScreenRect.Width - backButton.Image.Width - 20, Game1.Instance.ScreenRect.Height - backButton.Image.Height - 20);

            base.LoadContent(content);
        }
        public bool Initialize(String daeFileName)
        {
            var fi = new FileInfo(daeFileName);
            if (!fi.Exists)
                return false;

            var scene = LoadDaeScene(fi.FullName);
            if (scene == null)
                return false;

            foreach (var t in BodyMeshes)
                t.Destroy();
            BodyMeshes.Clear();
            Bones.Clear();
            bonesMapping.Clear();
            Animations.Clear();
            Poses.Clear();
            rootNode = null;
            СurrentAnimation = null;

            m_globalInverseTransform = FromMatrix(scene.RootNode.Transform);
            m_globalInverseTransform.Invert();

            var title = Path.GetFileNameWithoutExtension(fi.FullName);
            LoadBodyMeshes(fi.FullName, scene, scene.RootNode, null);
            LoadBonesInfo(rootNode);
            LoadAnimations(scene, title);

            return true;
        }
Exemplo n.º 54
0
    /// <summary>
    /// Updates this sprite.
    /// </summary>
    /// <remarks></remarks>
    void Update()
    {
        if (_curAnimationInfo != null)
        {
            _curFrameTime -= Time.deltaTime;
            if (_curFrameTime <= 0.0f)
            {
                _curFrameTime += _curAnimationInfo.frameTime;
                ++_subImageIndex;

                if (_subImageIndex > _curAnimationInfo.endIndex)
                {
                    if (_curAnimationInfo.isloop)
                    {
                        _subImageIndex = _curAnimationInfo.beginIndex;
                    }
                    else
                    {
                        //
                        if (onComplete != null)
                            onComplete(this);

                        //
                        _curAnimationInfo = null;

                        //
                        if (autoDestroy)
                            Destroy(gameObject);

                        return;
                    }
                }

                //
                updateSubImage();

            }
        }
    }
Exemplo n.º 55
0
    public Transform I_endGameScreen;//

    private void Awake()
    {
        animationInfo  = I_animationInfo;
        shotgunSurgery = I_shotgunSurgery;
        endGameScreen  = I_endGameScreen;
    }
Exemplo n.º 56
0
        public void InsertOrUpdateAnimation(AnimationInfo animationInfo)
        {
            lock (this.dbLock)
            {

                using (SQLiteConnection sqlCon = new SQLiteConnection(this.AnimationDBPath))
                {

                    sqlCon.Execute(WZConstants.DBClauseSyncOff);

                    Type animationInfoType = typeof(AnimationInfo);
                    Type frameInfoType = typeof(FrameInfo);
                    Type layerInfoType = typeof(LayerInfo);
                    Type drInfoType = typeof(DrawingInfo);
                    Type trInfoType = typeof(TransitionInfo);
                    Type trSettingsType = typeof(TransitionEffectSettings);
                    Type brushItemType = typeof(BrushItem);

                    Type audioItemType = typeof(AnimationAudioInfo);

                    sqlCon.BeginTransaction();

                    try
                    {

                        //
                        // AnimationInfo
                        //
                        if (sqlCon.Execute("UPDATE AnimationInfo SET " +
                            "MessageGuid=?, " +
                            "StepNumber=?, " +
                            "CreatedOn=?, " +
                            "OriginalCanvasSizeWidth=?, " +
                            "OriginalCanvasSizeHeight=?, " +
                            "IsEditing=?, " +
                            "IsSent=? " +
                            "WHERE DBID=?",
                                           animationInfo.MessageGuid,
                                           animationInfo.StepNumber,
                                           animationInfo.CreatedOn,
                                           animationInfo.OriginalCanvasSizeWidth,
                                           animationInfo.OriginalCanvasSizeHeight,
                                           animationInfo.IsEditing,
                                           animationInfo.IsSent,
                                           animationInfo.DBID) == 0)
                        {

                            sqlCon.Insert(animationInfo, animationInfoType);

                        }//end if

                        foreach (FrameInfo eachFrameInfo in animationInfo.FrameItems.Values)
                        {

                            eachFrameInfo.AnimationDBID = animationInfo.DBID;
                            if (sqlCon.Execute("UPDATE FrameInfo SET " +
                                "ID=?, " +
                                "AnimationDBID=? " +
                                "WHERE DBID=?",
                                               eachFrameInfo.ID,
                                               eachFrameInfo.AnimationDBID,
                                               eachFrameInfo.DBID) == 0)
                            {

                                sqlCon.Insert(eachFrameInfo, frameInfoType);

                            }//end if

                            foreach (LayerInfo eachLayerInfo in eachFrameInfo.Layers.Values)
                            {

                                eachLayerInfo.FrameDBID = eachFrameInfo.DBID;
                                if (sqlCon.Execute("UPDATE LayerInfo SET " +
                                    "ID=?, " +
                                    "FrameDBID=?, " +
                                    "CanvasSizeWidth=?, " +
                                    "CanvasSizeHeight=?, " +
                                    "IsCanvasActive=? " +
                                    "WHERE DBID=?",
                                                   eachLayerInfo.ID,
                                                   eachLayerInfo.FrameDBID,
                                                   eachLayerInfo.CanvasSizeWidth,
                                                   eachLayerInfo.CanvasSizeHeight,
                                                   eachLayerInfo.IsCanvasActive,
                                                   eachLayerInfo.DBID) == 0)
                                {

                                    sqlCon.Insert(eachLayerInfo, layerInfoType);

                                }//end if

                                foreach (DrawingInfo eachDrawingInfo in eachLayerInfo.DrawingItems.Values)
                                {

                                    eachDrawingInfo.LayerDBID = eachLayerInfo.DBID;
                                    if (null != eachDrawingInfo.Brush)
                                    {

                                        if (sqlCon.Execute("UPDATE BrushItem SET " +
                                            "Thickness=?, " +
                                            "BrushType=?, " +
                                            "BrushImageBuffer=?, " +
                                            "BrushColorBuffer=?, " +
                                            "InactiveBrushColorBuffer=?, " +
                                            "IsSprayBrushActive=? " +
                                            "WHERE DBID=?",
                                                           eachDrawingInfo.Brush.Thickness,
                                                           eachDrawingInfo.Brush.BrushType,
                                                           eachDrawingInfo.Brush.BrushImageBuffer,
                                                           eachDrawingInfo.Brush.BrushColorBuffer,
                                                           eachDrawingInfo.Brush.InactiveBrushColorBuffer,
                                                           eachDrawingInfo.Brush.IsSprayBrushActive,
                                                           eachDrawingInfo.Brush.DBID) == 0)
                                        {
                                            sqlCon.Insert(eachDrawingInfo.Brush, brushItemType);
                                        }//end sqlCon

                                        eachDrawingInfo.BrushItemDBID = eachDrawingInfo.Brush.DBID;
                                    }//end if

                                    if (sqlCon.Execute("UPDATE DrawingInfo SET " +
                                        "DrawingID=?, " +
                                        "LayerDBID=?, " +
                                        "BrushItemDBID=?, " +
                                        "LineColorBuffer=?, " +
                                        "DrawingType=?, " +
                                        "ImageBuffer=?, " +
                                        "ImageFrameX=?, " +
                                        "ImageFrameY=?, " +
                                        "ImageFrameWidth=?, " +
                                        "ImageFrameHeight=?, " +
                                        "RotationAngle=?, " +
                                        "RotatedImageBoxX=?, " +
                                        "RotatedImageBoxY=?, " +
                                        "RotatedImageBoxWidth=?, " +
                                        "RotatedImageBoxHeight=?, " +
                                        "ContentPackItemID=?, " +
                                        "CalloutText=?, " +
                                        "CalloutTextRectX=?, " +
                                        "CalloutTextRectY=?, " +
                                        "CalloutTextRectWidth=?, " +
                                        "CalloutTextRectHeight=? " +
                                        "WHERE DBID=?",
                                                       eachDrawingInfo.DrawingID,
                                                       eachDrawingInfo.LayerDBID,
                                                       eachDrawingInfo.BrushItemDBID,
                                                       eachDrawingInfo.LineColorBuffer,
                                                       eachDrawingInfo.DrawingType,
                                                       eachDrawingInfo.ImageBuffer,
                                                       eachDrawingInfo.ImageFrameX,
                                                       eachDrawingInfo.ImageFrameY,
                                                       eachDrawingInfo.ImageFrameWidth,
                                                       eachDrawingInfo.ImageFrameHeight,
                                                       eachDrawingInfo.RotationAngle,
                                                       eachDrawingInfo.RotatedImageBoxX,
                                                       eachDrawingInfo.RotatedImageBoxY,
                                                       eachDrawingInfo.RotatedImageBoxWidth,
                                                       eachDrawingInfo.RotatedImageBoxHeight,
                                                       eachDrawingInfo.ContentPackItemID,
                                                       eachDrawingInfo.CalloutText,
                                                       eachDrawingInfo.CalloutTextRectX,
                                                       eachDrawingInfo.CalloutTextRectY,
                                                       eachDrawingInfo.CalloutTextRectWidth,
                                                       eachDrawingInfo.CalloutTextRectHeight,
                                                       eachDrawingInfo.DBID) == 0)
                                    {

                                        sqlCon.Insert(eachDrawingInfo, drInfoType);

                                    }//end if

                                    if (eachDrawingInfo.DrawingType == DrawingLayerType.Drawing)
                                    {

                                        List<PathPointDB> drPoints = eachDrawingInfo.GetPathPointsForDB();
                                        // DELETE path points for this drawing item. No need to try to update each one individually.
                                        sqlCon.Execute("DELETE FROM PathPointDB WHERE DrawingInfoDBID=?", eachDrawingInfo.DBID);
                                        // And INSERT
                                        sqlCon.InsertAll(drPoints);

                                    }//end if

                                }//end foreach

                                foreach (TransitionInfo eachTrInfo in eachLayerInfo.Transitions.Values)
                                {

                                    eachTrInfo.LayerDBID = eachLayerInfo.DBID;
                                    if (sqlCon.Execute("UPDATE TransitionInfo SET " +
                                        "ID=?, " +
                                        "LayerDBID=?, " +
                                        "FadeOpacity=?, " +
                                        "RotationAngle=?, " +
                                        "EndSizeWidth=?, " +
                                        "EndSizeHeight=?, " +
                                        "EndSizeFixedPointX=?, " +
                                        "EndSizeFixedPointY=?, " +
                                        "EndLocationX=?, " +
                                        "EndLocationY=? " +
                                        "WHERE DBID=?",
                                                       eachTrInfo.ID,
                                                       eachTrInfo.LayerDBID,
                                                       eachTrInfo.FadeOpacity,
                                                       eachTrInfo.RotationAngle,
                                                       eachTrInfo.EndSizeWidth,
                                                       eachTrInfo.EndSizeHeight,
                                                       eachTrInfo.EndSizeFixedPointX,
                                                       eachTrInfo.EndSizeFixedPointY,
                                                       eachTrInfo.EndLocationX,
                                                       eachTrInfo.EndLocationY,
                                                       eachTrInfo.DBID) == 0)
                                    {

                                        sqlCon.Insert(eachTrInfo, trInfoType);

                                    }//end if

                                    foreach (TransitionEffectSettings eachTrSetting in eachTrInfo.Settings.Values)
                                    {

                                        eachTrSetting.TransitionInfoDBID = eachTrInfo.DBID;
                                        if (sqlCon.Execute("UPDATE TransitionEffectSettings SET " +
                                            "TransitionID=?, " +
                                            "TransitionInfoDBID=?, " +
                                            "FrameID=?, " +
                                            "LayerID=?, " +
                                            "EffectType=?, " +
                                            "Duration=?, " +
                                            "RotationCount=?, " +
                                            "Delay=? " +
                                            "WHERE DBID=?",
                                                          eachTrSetting.TransitionID,
                                                          eachTrSetting.TransitionInfoDBID,
                                                          eachTrSetting.FrameID,
                                                          eachTrSetting.LayerID,
                                                          eachTrSetting.EffectType,
                                                          eachTrSetting.Duration,
                                                          eachTrSetting.RotationCount,
                                                          eachTrSetting.Delay,
                                                          eachTrSetting.DBID) == 0)
                                        {

                                            sqlCon.Insert(eachTrSetting, trSettingsType);

                                        }//end if

                                    }//end foreach

                                }//end foreach

                            }//end foreach

                        }//end foreach

                        foreach (AnimationAudioInfo eachAudioItem in animationInfo.AudioItems.Values)
                        {

                            FrameInfo frameItem = null;
                            if (animationInfo.FrameItems.TryGetValue(eachAudioItem.FrameID, out frameItem))
                            {
                                eachAudioItem.FrameDBID = frameItem.DBID;
                            }//end if

                            if (sqlCon.Execute("UPDATE AnimationAudioInfo SET " +
                                "ID=?, " +
                                "FrameID=?, " +
                                "FrameDBID=?, " +
                                "AudioBuffer=?, " +
                                "Duration=? " +
                                "WHERE DBID=?",
                                               eachAudioItem.ID,
                                               eachAudioItem.FrameID,
                                               eachAudioItem.FrameDBID,
                                               eachAudioItem.AudioBuffer,
                                               eachAudioItem.Duration,
                                               eachAudioItem.DBID) == 0)
                            {

                                sqlCon.Insert(eachAudioItem, audioItemType);

                            }//end if

                        }//end foreach

                        sqlCon.Commit();

                    } catch (Exception ex)
                    {

                        sqlCon.Rollback();

                        throw ex;

                    }//end try catch

                }//end using sqlCon

            }//end lock
        }
Exemplo n.º 57
0
    void PlayAnim(int ind)
    {
        GameObject agent        = GameObject.Find("AgentPrefab");
        GameObject agentControl = GameObject.Find("AgentControlPrefab");

        if (agent.GetComponent <ArmAnimator>().ArmC == null || agent.GetComponent <TorsoAnimator>().TorsoC == null)
        {
            Debug.Log("Controller not assigned");
            return;
        }

        AnimationInfo animInfo = agent.GetComponent <AnimationInfo>();

        animInfo.IsContinuous = _toggleContinuous;
        if (agentControl)
        {
            agentControl.GetComponent <AnimationInfo>().IsContinuous = _toggleContinuous;
        }

        agent.animation.Stop(); //in order to restart animation
        if (agentControl)
        {
            agentControl.animation.Stop(); //in order to restart animation
        }
        switch (ind)
        {
        case 0:
            InitAgent(agent, "Knocking_Neutral_1");
            if (agentControl)
            {
                InitAgent(agentControl, "Knocking_Neutral_1");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }

            break;

        case 1:
            InitAgent(agent, "Pointing_to_Spot_Netural_02");
            if (agentControl)
            {
                InitAgent(agentControl, "Pointing_to_Spot_Netural_02");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }
            break;

        case 2:
            InitAgent(agent, "Lifting_Netural_01");
            if (agentControl)
            {
                InitAgent(agentControl, "Lifting_Netural_01");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }

            break;

        case 3:
            InitAgent(agent, "Picking_Up_Pillow_Netural_01");
            if (agentControl)
            {
                InitAgent(agentControl, "Picking_Up_Pillow_Netural_01");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }

            break;

        case 4:
            InitAgent(agent, "Punching_Netural_02");
            if (agentControl)
            {
                InitAgent(agentControl, "Punching_Netural_02");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }

            break;

        case 5:
            InitAgent(agent, "Pushing_Netural_02");
            if (agentControl)
            {
                InitAgent(agentControl, "Pushing_Netural_02");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }

            break;

        case 6:
            InitAgent(agent, "Throwing_Netural_02");
            if (agentControl)
            {
                InitAgent(agentControl, "Throwing_Netural_02");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }

            break;

        case 7:
            InitAgent(agent, "Walking_Netural_02");
            if (agentControl)
            {
                InitAgent(agentControl, "Walking_Netural_02");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }

            break;

        case 8:
            InitAgent(agent, "Waving_Netural_02");
            if (agentControl)
            {
                InitAgent(agentControl, "Waving_Netural_02");
                agentControl.animation[animInfo.AnimName].speed = animInfo.DefaultAnimSpeed;
            }

            break;
        }

        if (animInfo.IsContinuous)
        {
            agent.animation[animInfo.AnimName].wrapMode = WrapMode.Loop;
            if (agentControl)
            {
                agentControl.animation[animInfo.AnimName].wrapMode = WrapMode.Loop;
            }
        }
        else
        {
            agent.animation[animInfo.AnimName].wrapMode = WrapMode.Once;
            if (agentControl)
            {
                agentControl.animation[animInfo.AnimName].wrapMode = WrapMode.Once;
            }
        }
    }
Exemplo n.º 58
0
    void UpdateParameters()
    {
        for (int i = 0; i < 3; i++)
        {
            if (i == UserInfo.Hit / 3)
            {
                _agentsLeft[i].gameObject.SetActive(true);
                _agentsRight[i].gameObject.SetActive(true);
                _agentLeft  = _agentsLeft[UserInfo.Hit / 3];
                _agentRight = _agentsRight[UserInfo.Hit / 3];
            }
            else
            {
                _agentsLeft[i].gameObject.SetActive(false);
                _agentsRight[i].gameObject.SetActive(false);
            }
        }

        //Personality question
        int persInd = 0;
        int persVal = 0;

        switch (_taskQInd)
        {
        case 0:
            persInd = 4;
            persVal = -1;
            break;

        case 1:
            persInd = 2;
            persVal = -1;
            break;

        case 2:
            persInd = 1;
            persVal = 1;
            break;

        case 3:
            persInd = 3;
            persVal = 1;
            break;

        case 4:
            persInd = 0;
            persVal = -1;
            break;

        case 5:
            persInd = 3;
            persVal = -1;
            break;

        case 6:
            persInd = 0;
            persVal = 1;
            break;

        case 7:
            persInd = 2;
            persVal = 1;
            break;

        case 8:
            persInd = 4;
            persVal = 1;
            break;

        case 9:
            persInd = 1;
            persVal = -1;
            break;
        }

        _agentRight.GetComponent <PersonalityComponent>().Personality[persInd] = persVal;

        for (int i = 0; i < 5; i++)  //right
        {
            if (persInd != i)
            {
                _agentRight.GetComponent <PersonalityComponent>().Personality[i] = 0;
            }
        }

        for (int i = 0; i < 5; i++) //left is allways zero
        {
            _agentLeft.GetComponent <PersonalityComponent>().Personality[0] = 0;
        }

        _agentRight.AnimName = _agentRight.AnimNames[UserInfo.Hit % 3];
        _agentLeft.AnimName  = _agentLeft.AnimNames[UserInfo.Hit % 3];
    }
Exemplo n.º 59
0
		static void StopAnimation (AnimationInfo a)
		{
			activeAnimations.Remove (a);
			if (activeAnimations.Count == 0 && animationHandle != 0) {
				GLib.Source.Remove (animationHandle);
				animationHandle = 0;
			}
		}
	public void PushAnimation( int animindex, float animlerptime, float animholdtime )
	{
		AnimationInfo newanim = new AnimationInfo();
		{
			newanim.Index = animindex;
			newanim.LerpTime = animlerptime;
			newanim.HoldTime = animholdtime;
		}
		AnimationStack.Add( newanim );
	}