Inheritance: IUpdatable
コード例 #1
0
ファイル: Bone.cs プロジェクト: reneretz/spine-runtimes
 /// <param name="parent">May be null.</param>
 public Bone(BoneData data, Bone parent)
 {
     if (data == null) throw new ArgumentNullException("data cannot be null.");
     this.data = data;
     this.parent = parent;
     SetToSetupPose();
 }
コード例 #2
0
    void ChangeLocation()
    {
        if (string.IsNullOrEmpty(boneName))
        {
            return;
        }

        SkeletonAnimation skeletonAnimation = GetComponent <SkeletonAnimation>();

        if (skeletonAnimation != null)
        {
            if (skeletonAnimation.skeleton == null)
            {
                return;
            }

            if (!recordLocation)
            {
                originPosition = transform.localPosition;
                recordLocation = true;
            }

            Spine.Bone bone = skeletonAnimation.skeleton.FindBone(boneName);
            if (bone != null)
            {
                transform.localPosition = originPosition - new Vector3(bone.WorldX * transform.localScale.x, bone.WorldY * transform.localScale.y, 0);
            }
        }
    }
コード例 #3
0
    Vector3 GetTargetScreenPos()
    {
        Spine.Bone bone      = character.rootBone;
        Vector3    playerPos = cam.WorldToScreenPoint(target.TransformPoint(new Vector3(bone.worldX, bone.worldY, 0)));

        return(playerPos * scaleRatio);
    }
コード例 #4
0
ファイル: Slot.cs プロジェクト: KissCat/spine-runtimes
		public Slot (SlotData data, Bone bone) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			if (bone == null) throw new ArgumentNullException("bone cannot be null.");
			this.data = data;
			this.bone = bone;
			SetToSetupPose();
		}
コード例 #5
0
ファイル: Bone.cs プロジェクト: nagyistoce/RoboFight
 /** @param parent May be null. */
 public Bone(BoneData data, Bone parent)
 {
     if (data == null) throw new ArgumentNullException("data cannot be null.");
     Data = data;
     Parent = parent;
     SetToBindPose();
 }
コード例 #6
0
    public void Attack()
    {
        if (!bSoundPlayed)
        {
            bSoundPlayed = true;
            if (AttackSound.Length > 0)
            {
                audioSource.PlayOneShot(AttackSound[UnityEngine.Random.Range(0, AttackSound.Length)]);
            }
        }

        Spine.Bone bone = skeletonAnimation.skeleton.FindBone("drag_head5");
        Vector3    weaponSlotPosition      = skeletonAnimation.transform.TransformPoint(new Vector3(bone.WorldX, bone.WorldY, 0f));
        Vector2    ProjectileSpawnLocation = weaponSlotPosition;

        float angleStepSize = 360.0f / AmountOfProjectile;

        for (int angleStep = 0; angleStep < AmountOfProjectile; angleStep++)
        {
            float   rad = (angleStepSize * angleStep + AngleOffset) * Mathf.Deg2Rad;
            Vector2 Offset;
            Offset.x = -Radius *Mathf.Sin(rad);

            Offset.y = Radius * Mathf.Cos(rad);

            GameObject     go             = GameObject.Instantiate <GameObject>(Projectile, ProjectileSpawnLocation + Offset, Quaternion.identity);
            BossProjectile bossProjectile = go.GetComponent <BossProjectile>();
            bossProjectile.SetupVelocity(Offset);
        }

        AngleOffset += AngleStepBetweenAttack;
    }
コード例 #7
0
ファイル: Skeleton.cs プロジェクト: czlc/spine-runtimes
		public Skeleton (SkeletonData data) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			this.data = data;

			bones = new ExposedList<Bone>(data.bones.Count);
			foreach (BoneData boneData in data.bones) {
				Bone parent = boneData.parent == null ? null : bones.Items[data.bones.IndexOf(boneData.parent)];
				Bone bone = new Bone(boneData, this, parent);
				if (parent != null) parent.children.Add(bone);
				bones.Add(bone);
			}

			slots = new ExposedList<Slot>(data.slots.Count);
			drawOrder = new ExposedList<Slot>(data.slots.Count);
			foreach (SlotData slotData in data.slots) {
				Bone bone = bones.Items[data.bones.IndexOf(slotData.boneData)];
				Slot slot = new Slot(slotData, bone);
				slots.Add(slot);
				drawOrder.Add(slot);
			}

			ikConstraints = new ExposedList<IkConstraint>(data.ikConstraints.Count);
			foreach (IkConstraintData ikConstraintData in data.ikConstraints)
				ikConstraints.Add(new IkConstraint(ikConstraintData, this));

			transformConstraints = new ExposedList<TransformConstraint>(data.transformConstraints.Count);
			foreach (TransformConstraintData transformConstraintData in data.transformConstraints)
				transformConstraints.Add(new TransformConstraint(transformConstraintData, this));

			UpdateCache();
			UpdateWorldTransform();
		}
コード例 #8
0
ファイル: IkConstraint.cs プロジェクト: ClazzX1/BussStopOCD
		/// <summary>Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified
		/// in the world coordinate system.</summary>
		static public void apply (Bone bone, float targetX, float targetY, float alpha) {
			float parentRotation = (!bone.data.inheritRotation || bone.parent == null) ? 0 : bone.parent.worldRotation;
			float rotation = bone.rotation;
			float rotationIK = (float)Math.Atan2(targetY - bone.worldY, targetX - bone.worldX) * radDeg;
			if (bone.worldFlipX != (bone.worldFlipY != Bone.yDown)) rotationIK = -rotationIK;
			rotationIK -= parentRotation;
			bone.rotationIK = rotation + (rotationIK - rotation) * alpha;
		}
コード例 #9
0
		/// <param name="parent">May be null.</param>
		public Bone (BoneData data, Skeleton skeleton, Bone parent) {
			if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
			this.data = data;
			this.skeleton = skeleton;
			this.parent = parent;
			SetToSetupPose();
		}
コード例 #10
0
	void Start() {
		if (speedReference == null)
			speedReference = transform;

		skeletonAnimation = GetComponent<SkeletonAnimation>();
		bone = SpineBone.GetBone(boneName, skeletonAnimation);
		skeletonAnimation.UpdateLocal += UpdateLocal;
		lastPosition = speedReference.position;
	}
コード例 #11
0
ファイル: IkConstraint.cs プロジェクト: Chanisco/BeatThemUp
		/// <summary>Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified
		/// in the world coordinate system.</summary>
		static public void Apply (Bone bone, float targetX, float targetY, float alpha) {
			float parentRotation = bone.parent == null ? 0 : bone.parent.WorldRotationX;
			float rotation = bone.rotation;
			float rotationIK = MathUtils.Atan2(targetY - bone.worldY, targetX - bone.worldX) * MathUtils.radDeg - parentRotation;
			if (bone.worldSignX != bone.worldSignY) rotationIK = 360 - rotationIK;
			if (rotationIK > 180) rotationIK -= 360;
			else if (rotationIK < -180) rotationIK += 360;
			bone.UpdateWorldTransform(bone.x, bone.y, rotation + (rotationIK - rotation) * alpha, bone.scaleX, bone.scaleY);
		}
コード例 #12
0
		public IkConstraint (IkConstraintData data, Skeleton skeleton) {
			this.data = data;
			mix = data.mix;
			bendDirection = data.bendDirection;

			bones = new List<Bone>(data.bones.Count);
			foreach (BoneData boneData in data.bones)
				bones.Add(skeleton.FindBone(boneData.name));
			target = skeleton.FindBone(data.target.name);
		}
コード例 #13
0
ファイル: Slot.cs プロジェクト: kamaliang/spine-runtimes
 public Slot(SlotData data, Skeleton skeleton, Bone bone)
 {
     if (data == null) throw new ArgumentNullException("data cannot be null.");
     if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
     if (bone == null) throw new ArgumentNullException("bone cannot be null.");
     Data = data;
     Skeleton = skeleton;
     Bone = bone;
     SetToSetupPose();
 }
コード例 #14
0
		public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
			this.data = data;
			translateMix = data.translateMix;
			x = data.x;
			y = data.y;

			bone = skeleton.FindBone(data.bone.name);
			target = skeleton.FindBone(data.target.name);
		}
コード例 #15
0
		public void Reset () {
			bone = null;
			cachedTransform = transform;
			valid = skeletonUtility != null && skeletonUtility.skeletonRenderer != null && skeletonUtility.skeletonRenderer.valid;
			if (!valid)
				return;
			skeletonTransform = skeletonUtility.transform;
			skeletonUtility.OnReset -= HandleOnReset;
			skeletonUtility.OnReset += HandleOnReset;
			DoUpdate();
		}
コード例 #16
0
ファイル: IkConstraint.cs プロジェクト: ClazzX1/BussStopOCD
		public IkConstraint (IkConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
			this.data = data;
			mix = data.mix;
			bendDirection = data.bendDirection;

			bones = new ExposedList<Bone>(data.bones.Count);
			foreach (BoneData boneData in data.bones)
				bones.Add(skeleton.FindBone(boneData.name));
			target = skeleton.FindBone(data.target.name);
		}
コード例 #17
0
 public static Vector3 GetSkeletonBonePosition(SkeletonAnimation skeletonAnimation, string name)
 {
     if (skeletonAnimation != null)
     {
         Spine.Bone bone = skeletonAnimation.skeleton.FindBone(name);
         if (bone != null)
         {
             return(new Vector3(bone.WorldX, bone.WorldY, 0));
         }
     }
     return(Vector3.zero);
 }
コード例 #18
0
 public static Vector3 GetskeletonGraphicBonePosition(SkeletonGraphic skeletonGraphic, string name)
 {
     if (skeletonGraphic != null && skeletonGraphic.Skeleton != null)
     {
         Spine.Bone bone = skeletonGraphic.Skeleton.FindBone(name);
         if (bone != null)
         {
             return(new Vector3(bone.WorldX, bone.WorldY, 0));
         }
     }
     return(Vector3.zero);
 }
コード例 #19
0
    void Start()
    {
        if (speedReference == null)
        {
            speedReference = transform;
        }

        skeletonAnimation = GetComponent <SkeletonAnimation>();
        bone = SpineBone.GetBone(boneName, skeletonAnimation);
        skeletonAnimation.UpdateLocal += UpdateLocal;
        lastPosition = speedReference.position;
    }
コード例 #20
0
		/// <summary>Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified
		/// in the world coordinate system.</summary>
		static public void Apply (Bone bone, float targetX, float targetY, float alpha) {
			Bone pp = bone.parent;
			float id = 1 / (pp.a * pp.d - pp.b * pp.c);
			float x = targetX - pp.worldX, y = targetY - pp.worldY;
			float tx = (x * pp.d - y * pp.b) * id - bone.x, ty = (y * pp.a - x * pp.c) * id - bone.y;
			float rotationIK = MathUtils.Atan2(ty, tx) * MathUtils.radDeg - bone.shearX - bone.rotation;
			if (bone.scaleX < 0) rotationIK += 180;
			if (rotationIK > 180)
				rotationIK -= 360;
			else if (rotationIK < -180) rotationIK += 360;
			bone.UpdateWorldTransform(bone.x, bone.y, bone.rotation + rotationIK * alpha, bone.scaleX, bone.scaleY,
				bone.shearX, bone.shearY);
		}
コード例 #21
0
ファイル: Clock.cs プロジェクト: harayoki/m_clock
 void Start()
 {
     clock = GetComponent<SkeletonAnimation>();
     clockState = clock.state;
     clockState.TimeScale = 1.0f;
     clockState.SetAnimation(0, "loop", true);
     armLong = clock.skeleton.FindBone ("arm-long");
     armShort = clock.skeleton.FindBone ("arm-short");
     needle = clock.skeleton.FindBone ("needle");
     Debug.Log (armLong);
     Debug.Log (armShort);
     Debug.Log (needle);
 }
コード例 #22
0
    public Vector3 GetTileCenter(int index)
    {
        if (index >= 0)
        {
            string     name = GetTileName(index);
            Spine.Bone bone = _skeletonAnim.Skeleton.FindBone(name);

            Vector3 center = SpineHelper.GetBoneCenter(_skeletonAnim.transform, bone);
            return(center);
        }

        return(Vector3.zero);
    }
コード例 #23
0
		/// <param name="worldVertices">Must have at least the same length as this attachment's vertices.</param>
		public void ComputeWorldVertices (Bone bone, float[] worldVertices) {
			float x = bone.skeleton.x + bone.worldX, y = bone.skeleton.y + bone.worldY;
			float m00 = bone.m00;
			float m01 = bone.m01;
			float m10 = bone.m10;
			float m11 = bone.m11;
			float[] vertices = this.vertices;
			for (int i = 0, n = vertices.Length; i < n; i += 2) {
				float px = vertices[i];
				float py = vertices[i + 1];
				worldVertices[i] = px * m00 + py * m01 + x;
				worldVertices[i + 1] = px * m10 + py * m11 + y;
			}
		}
コード例 #24
0
    void Follow()
    {
        if (target == null)
        {
            return;
        }
        SkeletonGraphic skeletonGraphic = target.GetComponent <SkeletonGraphic> ();

        if (skeletonGraphic != null && skeletonGraphic.Skeleton != null && boneName != "")
        {
            Spine.Bone _bone = skeletonGraphic.Skeleton.FindBone(boneName);
            if (_bone == null)
            {
                Debug.LogFormat("skeletonGraphic bone {0} of object {1} no found", boneName, target.name);
                return;
            }
            Vector3 _pos = new Vector3(_bone.WorldX, _bone.WorldY, 0) * 100;
            x = _bone.WorldX;
            y = _bone.WorldY;
            gameObject.transform.localPosition = _pos;            //target.transform.TransformPoint(_pos);
            return;
        }

        SkeletonAnimation skeletonAnimation = target.GetComponent <SkeletonAnimation>();

        if (skeletonAnimation == null || skeletonAnimation.skeleton == null)
        {
            return;
        }
        if (boneName != "")
        {
            Spine.Bone bone = skeletonAnimation.skeleton.FindBone(boneName);
            if (bone == null)
            {
#if UNITY_EDITOR
                string key = boneName + "@" + skeletonAnimation.skeletonDataAsset.name;
                if (!errorBone.ContainsKey(key))
                {
                    Debug.LogErrorFormat("skeletonAnimation bone {0} of {1} no found", boneName, skeletonAnimation.skeletonDataAsset.name);
                    errorBone[key] = true;
                }
#endif
                return;
            }

            Vector3 pos = new Vector3(bone.WorldX, bone.WorldY, 0);
            gameObject.transform.position = target.transform.TransformPoint(pos + localOffset);
        }
    }
コード例 #25
0
ファイル: BoundingBoxAttachment.cs プロジェクト: D021/ink
		/// <param name="worldVertices">Must have at least the same length as this attachment's vertices.</param>
		public void ComputeWorldVertices (float x, float y, Bone bone, float[] worldVertices) {
			x += bone.worldX;
			y += bone.worldY;
			float m00 = bone.m00;
			float m01 = bone.m01;
			float m10 = bone.m10;
			float m11 = bone.m11;
			float[] vertices = Vertices;
			for (int i = 0, n = vertices.Length; i < n; i += 2) {
				float px = vertices[i];
				float py = vertices[i + 1];
				worldVertices[i] = px * m00 + py * m01 + x;
				worldVertices[i + 1] = px * m10 + py * m11 + y;
			}
		}
コード例 #26
0
		public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
			this.data = data;
			rotateMix = data.rotateMix;
			translateMix = data.translateMix;
			scaleMix = data.scaleMix;
			shearMix = data.shearMix;

			bones = new ExposedList<Bone>();
			foreach (BoneData boneData in data.bones)
				bones.Add (skeleton.FindBone (boneData.name));
			
			target = skeleton.FindBone(data.target.name);
		}
コード例 #27
0
    public Spine.Bone GetBoneMouse()
    {
        string boneName = "mouse_";

        if (_unit.unit.dataUnit.bodyType == DataConfig.BODY_TYPE.CAR)
        {
            boneName += _bodyStatus.displayLevel;
        }
        else if (_unit.unit.dataUnit.bodyType == DataConfig.BODY_TYPE.CAR_WITH_CANNON)
        {
            boneName += _cannonStatus.displayLevel;
        }

        Spine.Bone bone = GetBone(boneName);
        return(bone);
    }
コード例 #28
0
 static int FindBone(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Spine.Skeleton obj  = (Spine.Skeleton)ToLua.CheckObject <Spine.Skeleton>(L, 1);
         string         arg0 = ToLua.CheckString(L, 2);
         Spine.Bone     o    = obj.FindBone(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #29
0
    private void AdjustMouse()
    {
        string boneName = "mouse_" + cannonLevel;

        Spine.Bone boneMouse = _skeletonAnim.Skeleton.FindBone(boneName);

        Vector3 bPoint = new Vector3(boneMouse.WorldX, boneMouse.WorldY, 0);
        Vector3 wPoint = transform.TransformPoint(bPoint);

        float height = 2.4f;

        CameraControl cameraControl = GameObject.Find("Main Camera").GetComponent <CameraControl> ();
        Vector3       position      = GeometryHelper.ProjectPointToPlane(wPoint, height, cameraControl.orientation);

        GameObject.Find("Mouse").transform.position = wPoint;
    }
コード例 #30
0
    private ArrowScript SpawnSingleArrow()
    {
        Spine.Bone bone = skeletonAnimation.skeleton.FindBone("arrow 1");

        if (bone != null)
        {
            Vector3    spawnPosition = new Vector2(bone.WorldX, bone.WorldY);
            GameObject arrow         = new GameObject("Arrow");
            arrow.transform.position = transform.position + spawnPosition;
            ArrowScript arrowScript = arrow.AddComponent <ArrowScript>();
            return(arrowScript);
        }
        else
        {
            return(null);
        }
    }
コード例 #31
0
    void FireProjectile()
    {
        Vector3 ProjectileDirection = Vector3.zero;

        if (playerMovementComponent)
        {
            // Debug.Log("Im shooting in the direction " + playerMovementComponent.PlayerDirection);
            switch (playerMovementComponent.PlayerDirection)
            {
            case PlayerMovementScript.EnumPlayerDirection.Up:
                ProjectileDirection.y = 1;
                break;

            case PlayerMovementScript.EnumPlayerDirection.Left:
                ProjectileDirection.x = -1;
                break;

            case PlayerMovementScript.EnumPlayerDirection.Right:
                ProjectileDirection.x = 1;
                break;

            case PlayerMovementScript.EnumPlayerDirection.Down:
                ProjectileDirection.y = -1;
                break;
            }
        }

        SkeletonAnimation skeletonAnimation = playerMovementComponent.GetSkeleton();

        Spine.Bone bone = skeletonAnimation.skeleton.FindBone("Prcs_arm_back_empty5");
        Vector3    weaponSlotPosition      = skeletonAnimation.transform.TransformPoint(new Vector3(bone.WorldX, bone.WorldY, 0f));
        Vector2    ProjectileSpawnLocation = weaponSlotPosition;



        GameObject         CreatedProjectile  = Instantiate(ProjectilePrefab, ProjectileSpawnLocation, Quaternion.identity, null);
        ProjectileMovement projectileMovement = CreatedProjectile.GetComponent <ProjectileMovement>();

        if (projectileMovement)
        {
            // Debug.Log(ProjectileDirection);
            projectileMovement.SetLaunchDirection(ProjectileDirection);
        }

        SpawnedProjectile = CreatedProjectile;
    }
コード例 #32
0
    static int get_RootBone(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Spine.Skeleton obj = (Spine.Skeleton)o;
            Spine.Bone     ret = obj.RootBone;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index RootBone on a nil value"));
        }
    }
コード例 #33
0
		public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
			this.data = data;
			translateMix = data.translateMix;
			rotateMix = data.rotateMix;
			scaleMix = data.scaleMix;
			shearMix = data.shearMix;
			offsetRotation = data.offsetRotation;
			offsetX = data.offsetX;
			offsetY = data.offsetY;
			offsetScaleX = data.offsetScaleX;
			offsetScaleY = data.offsetScaleY;
			offsetShearY = data.offsetShearY;

			bone = skeleton.FindBone(data.bone.name);
			target = skeleton.FindBone(data.target.name);
		}
コード例 #34
0
ファイル: Unit.cs プロジェクト: fchsg/UnityBattleTank
    public bool GetFireMousePosition(out Vector3 position)
    {
        TankSpineAttach spineAttach = GetComponent <TankSpineAttach> ();

        Spine.Bone boneMouse = spineAttach.GetBoneMouse();
        if (boneMouse != null)
        {
            Vector3 bPoint = new Vector3(boneMouse.WorldX, boneMouse.WorldY, 0);
            Vector3 wPoint = spineAttach.spine.transform.TransformPoint(bPoint);

//			float height = 2.4f * unit.dataUnit.length / 10;
//			position = GeometryHelper.ProjectPointToPlane(wPoint, height, _game.mapCamera.cameraControl.orientation);

            position = wPoint;
            return(true);
        }

        position = transform.position;
        return(false);
    }
コード例 #35
0
 public virtual Vector3 GetBoneScale(string name)
 {
     if (skeletonAnimation != null)
     {
         // TODO: check range
         Spine.Bone bone = skeletonAnimation.skeleton.FindBone(name);
         if (bone != null)
         {
             if (bone.ScaleX == bone.ScaleY)
             {
                 return(new Vector3(bone.ScaleX, bone.ScaleY, bone.ScaleX));
             }
             else
             {
                 return(new Vector3(bone.ScaleX, bone.ScaleY, 1));
             }
         }
     }
     return(Vector3.one);
 }
コード例 #36
0
    public void SpawnChar(int id)
    {
        Spine.TrackEntry trc        = null;
        string           curAnim    = "idle";
        float            normalTime = 0;
        bool             initiated  = anim != null;

        if (initiated)
        {
            trc        = anim.skeleton.state.GetCurrent(0);
            curAnim    = trc.Animation.name;
            normalTime = trc.TrackTime / trc.Animation.duration;

            Destroy(anim.gameObject);
        }

        curChar = charStorage.GetCharacter(id);
        GameObject go = Instantiate(curChar.prefab, transform.position, curChar.prefab.transform.rotation);

        go.transform.parent = transform;
        Init(go);
        anim.skeleton.state.SetAnimation(0, curAnim, curAnim == "idle");

        if (initiated)
        {
            trc = anim.skeleton.state.GetCurrent(0);


            trc.TrackTime   = normalTime * trc.Animation.duration;
            trc.mixDuration = 0;
        }
        root = anim.skeleton.skeleton.FindBone("body");

        //Recolor!
        RecolorManager rc = RecolorManager.Get();

        if (rc != null)
        {
            rc.Recolor(id);
        }
    }
コード例 #37
0
        public virtual Vector3 GetPosition(string name)
        {
            if (skeletonAnimation != null)
            {
                // TODO: check range
                Spine.Bone bone = skeletonAnimation.skeleton.FindBone(name);
                if (bone != null)
                {
                    Vector3 pos = new Vector3(bone.WorldX, bone.WorldY, 0);
                    return(spineObject.transform.TransformPoint(pos));
                }
            }

            Vector3 spos;

            if (GetSpecialPosition(name, out spos))
            {
                return(spos);
            }

            return(gameObject.transform.TransformPoint(new Vector3(0, 1, 0)));
        }
コード例 #38
0
ファイル: Player.cs プロジェクト: Myfi/Barnyard_Splosion
    void Start () {
		game = GameObject.Find ("Gui").GetComponent<GameHandler> ();
		boxCollider = GetComponent<BoxCollider2D> ();
		character = GetComponent<MeshRenderer> ();
		controller = GetComponent<Controller2D> ();
		anim = GetComponent<SkeletonAnimation> ();
		skeleton = anim.skeleton;
		arm = skeleton.FindBone ("RShoulder");
		backArm = skeleton.FindBone ("LShoulder");

		weap = skeleton.FindBone ("Weapon");
		skelRend = GetComponent<SkeletonRenderer> ();
		skeleton.FindSlot ("WeaponImage").Attachment = null;
		anim.state.ClearTrack(1);
		controller.CatchPlayer (this);
		crouchTap = new TapInfo (.6f, int.MaxValue);
		dashTap = new TapInfo (.6f, int.MaxValue);

        //Initiate the width of the HP bar, this may need to be placed in the Update portion if window scaling is changed.
        width = healthbar.GetComponent<RectTransform>().rect.width;
		startMaxXPos = healthbar.GetComponent<RectTransform>().offsetMax.x;

        UpdateGravity();
	}
コード例 #39
0
		private void SortPathConstraintAttachment (Attachment attachment, Bone slotBone) {
			if (!(attachment is PathAttachment)) return;
			int[] pathBones = ((PathAttachment)attachment).bones;
			if (pathBones == null)
				SortBone(slotBone);
			else {
				var bones = this.bones;
				for (int i = 0, n = pathBones.Length; i < n;) {
					int nn = pathBones[i++];
					nn += i;
					while (i < nn)
						SortBone(bones.Items[pathBones[i++]]);
				}
			}
		}
コード例 #40
0
		private void SortPathConstraintAttachment (Skin skin, int slotIndex, Bone slotBone) {
			foreach (var entry in skin.Attachments)
				if (entry.Key.slotIndex == slotIndex) SortPathConstraintAttachment(entry.Value, slotBone);
		}
コード例 #41
0
    void Update()
    {
        armBone  = skeletonAnimation.skeleton.FindBone("Arm-Left");
        headBone = skeletonAnimation.skeleton.FindBone("Mouth");

        Vector3 armBoneTransform = transform.TransformPoint(
            new Vector3(armBone.WorldX, armBone.WorldY, 0));
        Vector3 headBoneTransform = transform.TransformPoint(
            new Vector3(headBone.WorldX, headBone.WorldY, 0));

        bool slapping = false;
        bool wobbling = false;

        //control inputs
        float x = Input.GetAxis(XAxis);
        float y = Input.GetAxis(YAxis);

        if (Input.GetButton(SlapButton))
        {
            slapping = true;
        }
        if (Input.GetButton(WobbleHatButton))
        {
            wobbling = true;
        }

        velocity.x = 0;

        if (Input.GetButtonDown(JumpButton) && controller.isGrounded)
        {
            //jump
            playerAudioSource.Stop();
            playerAudioSource.clip  = jumpAudioClip;
            playerAudioSource.pitch = GetRandomPitch(0.2f);
            playerAudioSource.Play();
            velocity.y  = jumpSpeed;
            jumpEndTime = Time.time + jumpDuration;
        }
        else if (Time.time < jumpEndTime && Input.GetButtonUp(JumpButton))
        {
            jumpInterrupt = true;
        }


        if (x != 0)
        {
            //walk or run
            velocity.x  = Mathf.Abs(x) > 0.6f ? runSpeed : walkSpeed;
            velocity.x *= Mathf.Sign(x);
        }

        if (jumpInterrupt)
        {
            //interrupt jump and smoothly cut Y velocity
            if (velocity.y > 0)
            {
                velocity.y = Mathf.MoveTowards(velocity.y, 0, Time.deltaTime * 100);
            }
            else
            {
                jumpInterrupt = false;
            }
        }

        //apply gravity F = mA (Learn it, love it, live it)
        velocity.y -= gravity * Time.deltaTime;

        //move
        controller.Move(new Vector3(velocity.x, velocity.y, 0) * Time.deltaTime);

        if (controller.isGrounded)
        {
            //cancel out Y velocity if on ground
            velocity.y    = -gravity * Time.deltaTime;
            jumpInterrupt = false;
        }

        //graphics updates
        // slapping
        if (slapping && _timeElapsed > idleTime)
        {
            // slap
            playerAudioSource.Stop();
            playerAudioSource.clip  = GetRandomSlap();
            playerAudioSource.pitch = GetRandomPitch(0.2f);
            playerAudioSource.Play();

            skeletonAnimation.loop          = false;
            skeletonAnimation.AnimationName = slapName;

            shootProjectile.Fire(facingRight, armBoneTransform);

            _timeElapsed = 0;
        }
        // wobbling hat
        else if (wobbling && _timeElapsed > idleTime)
        {
            // wobble
            playerAudioSource.Stop();
            playerAudioSource.clip  = GetRandomWobble();
            playerAudioSource.pitch = GetRandomPitch(0.2f);
            playerAudioSource.Play();

            skeletonAnimation.loop          = false;
            skeletonAnimation.AnimationName = hatWobbleName;

            _timeElapsed = 0;
        }
        // idle
        else
        {
            _timeElapsed += Time.deltaTime;

            if (controller.isGrounded && _timeElapsed > idleTime)
            {
                skeletonAnimation.loop = true;
                if (x == 0) //idle
                {
                    skeletonAnimation.AnimationName = idleName;
                }
                else //move
                {
                    skeletonAnimation.AnimationName = Mathf.Abs(x) > 0.6f ? runName : walkName;
                }
            }
        }

        if (!controller.isGrounded)
        {
            skeletonAnimation.loop = false;
            if (velocity.y > 0) //jump
            {
                skeletonAnimation.AnimationName = jumpName;
            }
            else //fall
            {
                skeletonAnimation.AnimationName = jumpName;
            }
        }

        //flip left or right
        if (x > 0)
        {
            facingRight = true;
            skeletonAnimation.skeleton.FlipX = false;
        }
        else if (x < 0)
        {
            facingRight = false;
            skeletonAnimation.skeleton.FlipX = true;
        }

        //store previous state
        lastVelocity = velocity;
        lastGrounded = controller.isGrounded;
    }
コード例 #42
0
 virtual protected void SetFlip(Bone bone, bool flip)
 {
     bone.flipX = flip;
 }
コード例 #43
0
		public void ComputeWorldVertices (float x, float y, Bone bone, float[] worldVertices) {
			x += bone.worldX;
			y += bone.worldY;
			float m00 = bone.m00, m01 = bone.m01, m10 = bone.m10, m11 = bone.m11;
			float[] offset = this.offset;
			worldVertices[X1] = offset[X1] * m00 + offset[Y1] * m01 + x;
			worldVertices[Y1] = offset[X1] * m10 + offset[Y1] * m11 + y;
			worldVertices[X2] = offset[X2] * m00 + offset[Y2] * m01 + x;
			worldVertices[Y2] = offset[X2] * m10 + offset[Y2] * m11 + y;
			worldVertices[X3] = offset[X3] * m00 + offset[Y3] * m01 + x;
			worldVertices[Y3] = offset[X3] * m10 + offset[Y3] * m11 + y;
			worldVertices[X4] = offset[X4] * m00 + offset[Y4] * m01 + x;
			worldVertices[Y4] = offset[X4] * m10 + offset[Y4] * m11 + y;
		}
コード例 #44
0
ファイル: IkConstraint.cs プロジェクト: nalone/spine-runtimes
 /// <summary>Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as
 /// possible. The target is specified in the world coordinate system.</summary>
 /// <param name="child">Any descendant bone of the parent.</param>
 public static void apply(Bone parent, Bone child, float targetX, float targetY, int bendDirection, float alpha)
 {
     float childRotation = child.rotation, parentRotation = parent.rotation;
     if (alpha == 0) {
         child.rotationIK = childRotation;
         parent.rotationIK = parentRotation;
         return;
     }
     float positionX, positionY;
     Bone parentParent = parent.parent;
     if (parentParent != null) {
         parentParent.worldToLocal(targetX, targetY, out positionX, out positionY);
         targetX = (positionX - parent.x) * parentParent.worldScaleX;
         targetY = (positionY - parent.y) * parentParent.worldScaleY;
     } else {
         targetX -= parent.x;
         targetY -= parent.y;
     }
     if (child.parent == parent) {
         positionX = child.x;
         positionY = child.y;
     } else {
         child.parent.localToWorld(child.x, child.y, out positionX, out positionY);
         parent.worldToLocal(positionX, positionY, out positionX, out positionY);
     }
     float childX = positionX * parent.worldScaleX, childY = positionY * parent.worldScaleY;
     float offset = (float)Math.Atan2(childY, childX);
     float len1 = (float)Math.Sqrt(childX * childX + childY * childY), len2 = child.data.length * child.worldScaleX;
     // Based on code by Ryan Juckett with permission: Copyright (c) 2008-2009 Ryan Juckett, http://www.ryanjuckett.com/
     float cosDenom = 2 * len1 * len2;
     if (cosDenom < 0.0001f) {
         child.rotationIK = childRotation + ((float)Math.Atan2(targetY, targetX) * radDeg - parentRotation - childRotation)
             * alpha;
         return;
     }
     float cos = (targetX * targetX + targetY * targetY - len1 * len1 - len2 * len2) / cosDenom;
     if (cos < -1)
         cos = -1;
     else if (cos > 1)
         cos = 1;
     float childAngle = (float)Math.Acos(cos) * bendDirection;
     float adjacent = len1 + len2 * cos, opposite = len2 * (float)Math.Sin(childAngle);
     float parentAngle = (float)Math.Atan2(targetY * adjacent - targetX * opposite, targetX * adjacent + targetY * opposite);
     float rotation = (parentAngle - offset) * radDeg - parentRotation;
     if (rotation > 180)
         rotation -= 360;
     else if (rotation < -180) //
         rotation += 360;
     parent.rotationIK = parentRotation + rotation * alpha;
     rotation = (childAngle + offset) * radDeg - childRotation;
     if (rotation > 180)
         rotation -= 360;
     else if (rotation < -180) //
         rotation += 360;
     child.rotationIK = childRotation + (rotation + parent.worldRotation - child.parent.worldRotation) * alpha;
 }
コード例 #45
0
ファイル: Bone.cs プロジェクト: czlc/spine-runtimes
		/// <summary>Computes the world SRT using the parent bone and the specified local SRT.</summary>
		public void UpdateWorldTransform (float x, float y, float rotation, float scaleX, float scaleY) {
			appliedRotation = rotation;
			appliedScaleX = scaleX;
			appliedScaleY = scaleY;

			float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation);
			float la = cos * scaleX, lb = -sin * scaleY, lc = sin * scaleX, ld = cos * scaleY;
			Bone parent = this.parent;
			if (parent == null) { // Root bone.
				Skeleton skeleton = this.skeleton;
				if (skeleton.flipX) {
					x = -x;
					la = -la;
					lb = -lb;
				}
				if (skeleton.flipY != yDown) {
					y = -y;
					lc = -lc;
					ld = -ld;
				}
				a = la;
				b = lb;
				c = lc;
				d = ld;
				worldX = x;
				worldY = y;
				worldSignX = Math.Sign(scaleX);
				worldSignY = Math.Sign(scaleY);
				return;
			}

			float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
			worldX = pa * x + pb * y + parent.worldX;
			worldY = pc * x + pd * y + parent.worldY;
			worldSignX = parent.worldSignX * Math.Sign(scaleX);
			worldSignY = parent.worldSignY * Math.Sign(scaleY);

			if (data.inheritRotation && data.inheritScale) {
				a = pa * la + pb * lc;
				b = pa * lb + pb * ld;
				c = pc * la + pd * lc;
				d = pc * lb + pd * ld;
			} else if (data.inheritRotation) { // No scale inheritance.
				pa = 1;
				pb = 0;
				pc = 0;
				pd = 1;
				do {
					cos = MathUtils.CosDeg(parent.appliedRotation);
					sin = MathUtils.SinDeg(parent.appliedRotation);
					float temp = pa * cos + pb * sin;
					pb = pa * -sin + pb * cos;
					pa = temp;
					temp = pc * cos + pd * sin;
					pd = pc * -sin + pd * cos;
					pc = temp;

					if (!parent.data.inheritRotation) break;
					parent = parent.parent;
				} while (parent != null);
				a = pa * la + pb * lc;
				b = pa * lb + pb * ld;
				c = pc * la + pd * lc;
				d = pc * lb + pd * ld;
				if (skeleton.flipX) {
					a = -a;
					b = -b;
				}
				if (skeleton.flipY != yDown) {
					c = -c;
					d = -d;
				}
			} else if (data.inheritScale) { // No rotation inheritance.
				pa = 1;
				pb = 0;
				pc = 0;
				pd = 1;
				do {
					float r = parent.rotation;
					cos = MathUtils.CosDeg(r);
					sin = MathUtils.SinDeg(r);
					float psx = parent.appliedScaleX, psy = parent.appliedScaleY;
					float za = cos * psx, zb = -sin * psy, zc = sin * psx, zd = cos * psy;
					float temp = pa * za + pb * zc;
					pb = pa * zb + pb * zd;
					pa = temp;
					temp = pc * za + pd * zc;
					pd = pc * zb + pd * zd;
					pc = temp;

					if (psx < 0) r = -r;
					cos = MathUtils.CosDeg(-r);
					sin = MathUtils.SinDeg(-r);
					temp = pa * cos + pb * sin;
					pb = pa * -sin + pb * cos;
					pa = temp;
					temp = pc * cos + pd * sin;
					pd = pc * -sin + pd * cos;
					pc = temp;

					if (!parent.data.inheritScale) break;
					parent = parent.parent;
				} while (parent != null);
				a = pa * la + pb * lc;
				b = pa * lb + pb * ld;
				c = pc * la + pd * lc;
				d = pc * lb + pd * ld;
				if (skeleton.flipX) {
					a = -a;
					b = -b;
				}
				if (skeleton.flipY != yDown) {
					c = -c;
					d = -d;
				}
			} else {
				a = la;
				b = lb;
				c = lc;
				d = ld;
			}
		}
コード例 #46
0
    void UpdateGunAimingAndShooting(Spine.Bone gunBone)
    {
        const float LowerRotationBound = -90.0f;
        const float UpperRotationBound = 90.0f;

        // temp variables
        float   tempRot;
        Vector3 tempVec;

        // gun bone rotation
        tempVec = Camera.main.WorldToScreenPoint(new Vector3(gunBone.WorldX + player.transform.position.x, gunBone.WorldY + (player.transform.position.y), 0));
        tempVec = Input.mousePosition - tempVec;
        Vector3 direction = tempVec;

        // if (shotReady)
        //{
        direction.Normalize();
        tempRot          = Mathf.Atan2(tempVec.y, tempVec.x * player.transform.localScale.x) * Mathf.Rad2Deg;
        gunBone.Rotation = Mathf.Clamp(tempRot, LowerRotationBound, UpperRotationBound) - gunBone.parent.LocalToWorldRotation(gunBone.parent.rotation);
        //}

        Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        mousePos.z = gunTarget.transform.position.z;
        gunTarget.transform.position = mousePos;

        if (mousePos.x >= player.transform.position.x)
        {
            playerAnim.aimDirection = 1.0f;
        }
        else
        {
            playerAnim.aimDirection = -1.0f;
        }

        if (shotReady && !playedCockedSfx && Input.GetMouseButton(0))
        {
            playedCockedSfx = true;
            shotgunCockSource.Stop();
            shotgunCockSource.pitch = CharacterMovement.GetRandomPitch(0.2f) * TimeManager.GetInstance().GetCurrentTimescale();
            shotgunCockSource.Play();
        }

        if (Input.GetMouseButtonUp(0) && shotReady)
        {
            lastTimeFired   = 0.0f;
            shotReady       = false;
            playedCockedSfx = false;
            playedReload    = false;

            // shotgun sfx
            {
                shotgunSource.Stop();
                shotgunSource.pitch = CharacterMovement.GetRandomPitch(0.2f) * TimeManager.GetInstance().GetCurrentTimescale();
                shotgunSource.Play();
            }

            var playerCollider = player.GetComponent <CapsuleCollider2D>();
            if (playerCollider)
            {
                playerCollider.enabled = false;
            }
            RaycastHit2D hit = Physics2D.Raycast(new Vector2(gunBone.WorldX + player.transform.position.x,
                                                             gunBone.WorldY + (player.transform.position.y)),
                                                 direction);

            bool personHit = false;
            if (hit.collider != null)
            {
                CharacterHealth characterHealth = hit.collider.gameObject.GetComponent <CharacterHealth>();

                if (characterHealth)
                {
                    personHit = true;

                    characterHealth.ChangeHealth(-100.0f);

                    var bloodBurst = characterHealth.bloodBurst;

                    if (bloodBurst)
                    {
                        bloodBurst.Stop();
                        bloodBurst.transform.position = new Vector3(hit.point.x, hit.point.y, bloodBurst.transform.position.z);
                        bloodBurst.Play();
                    }

                    bloodSplashSource.Stop();
                    bloodSplashSource.pitch = CharacterMovement.GetRandomPitch(0.2f) * TimeManager.GetInstance().GetCurrentTimescale();
                    bloodSplashSource.PlayDelayed(0.05f);
                }
                else if (hit.collider.gameObject.tag == "Ground")
                {
                    groundSplash.Stop();
                    groundSplash.transform.position = new Vector3(hit.point.x, hit.point.y, groundSplash.transform.position.z);
                    groundSplash.Play();

                    ricochetAudioSource.Stop();
                    ricochetAudioSource.pitch = CharacterMovement.GetRandomPitch(0.2f) * TimeManager.GetInstance().GetCurrentTimescale();
                    ricochetAudioSource.Play();
                }
            }
            if (playerCollider)
            {
                playerCollider.enabled = true;
            }

            // camera shake
            cameraShake.originalPos = Camera.main.transform.localPosition;
            if (personHit)
            {
                cameraShake.shakeAmount   = 0.5f;
                cameraShake.shakeDuration = 0.12f;
            }
            else
            {
                cameraShake.shakeAmount   = 0.2f;
                cameraShake.shakeDuration = 0.1f;
            }
        }
    }
コード例 #47
0
 override protected void SetFlip(Bone bone, bool flip)
 {
     bone.flipY = flip;
 }
コード例 #48
0
ファイル: Animation.cs プロジェクト: xinwei2016/test
 protected override void SetFlip(Bone bone, bool flip)
 {
     bone.flipY = flip;
 }
コード例 #49
0
 public void FollowXBone(Spine.Bone bone, FormationUnit unit)
 {
     followBone = true;
     targetBone = bone;
     targetUnit = unit;
 }
コード例 #50
0
		private void SortBone (Bone bone) {
			if (bone.sorted) return;
			Bone parent = bone.parent;
			if (parent != null) SortBone(parent);
			bone.sorted = true;
			updateCache.Add(bone);
		}
コード例 #51
0
ファイル: IkConstraint.cs プロジェクト: nalone/spine-runtimes
 /// <summary>Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified
 /// in the world coordinate system.</summary>
 public static void apply(Bone bone, float targetX, float targetY, float alpha)
 {
     float parentRotation = (!bone.data.inheritRotation || bone.parent == null) ? 0 : bone.parent.worldRotation;
     float rotation = bone.rotation;
     float rotationIK = (float)Math.Atan2(targetY - bone.worldY, targetX - bone.worldX) * radDeg - parentRotation;
     bone.rotationIK = rotation + (rotationIK - rotation) * alpha;
 }
コード例 #52
0
    public void TakeDamage(Vector3 ImpactPoint, Collider2D collider)
    {
        if (!GameRule.get.IsGameActive())
        {
            return;
        }
        DoDamageFlash();


        bool    bWeakSpot     = false;
        Vector2 ImpactPoint2D = ImpactPoint;


        Spine.Bone bone = skeletonAnimation.skeleton.FindBone("drag_navel");
        Vector3    weaponSlotPosition   = skeletonAnimation.transform.TransformPoint(new Vector3(bone.WorldX, bone.WorldY, 0f));
        Vector2    weaponSpotPosition2D = weaponSlotPosition;
        Vector2    direction            = (ImpactPoint - transform.position).normalized;

        if (skeletonAnimation.Skeleton.ScaleX > 0)
        {
            if (direction.x < 0)
            {
                DebugLastHitPosition       = ImpactPoint2D;
                DebugLastWeakPointPosition = weaponSlotPosition;
                if ((weaponSpotPosition2D - ImpactPoint2D).sqrMagnitude < WeakPointRadius * WeakPointRadius)
                {
                    bWeakSpot = true;
                }
            }
        }
        else
        {
            if (direction.x > 0)
            {
                DebugLastHitPosition       = ImpactPoint2D;
                DebugLastWeakPointPosition = weaponSlotPosition;
                if ((weaponSpotPosition2D - ImpactPoint2D).sqrMagnitude < WeakPointRadius * WeakPointRadius)
                {
                    bWeakSpot = true;
                }
            }
        }

        if (bWeakSpot)
        {
            Health -= WeakSpotDamage;
        }
        else
        {
            Health -= 1.0f;
        }
        if (Health > 0.0f)
        {
            GameObject VFXprefab;
            if (bWeakSpot)
            {
                VFXprefab = WeakPointHitVFX;
                if (WeakPointHitSound.Length > 0)
                {
                    audioSource.PlayOneShot(WeakPointHitSound[UnityEngine.Random.Range(0, WeakPointHitSound.Length)]);
                }
            }
            else
            {
                VFXprefab = HitVFX;
                if (HitSound.Length > 0)
                {
                    audioSource.PlayOneShot(HitSound[UnityEngine.Random.Range(0, HitSound.Length)]);
                }
            }

            GameObject go = Instantiate <GameObject>(VFXprefab, ImpactPoint - Vector3.forward, Quaternion.identity);
            if (go)
            {
                Destroy(go, 5.0f);
            }
            if (bWeakSpot && (bAllowMovement || bShouldInterruptAttack))
            {
                Animator.Play("HitReaction");
            }
        }
        else
        {
            GameRule.get.DragonDead();
        }
    }
コード例 #53
0
    public static Vector3 GetBoneCenter(Transform transform, Spine.Bone bone)
    {
        Vector3 wPoint = transform.TransformPoint(bone.WorldX, bone.WorldY, 0);

        return(wPoint);
    }
コード例 #54
0
 private void OnEnable()
 {
     KeyboardInput.OnLeftMouseButton += Shoot;
     _pistolBone = GetComponent <PlayAnimations>()._rightArmSkeleton.skeleton.FindBone("Pistol");
 }
コード例 #55
0
        public void Update()
        {
            float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
            Bone  target = this.target;
            float ta = target.a, tb = target.b, tc = target.c, td = target.d;
            ExposedList <Bone> bones = this.bones;

            for (int i = 0, n = bones.Count; i < n; i++)
            {
                Bone bone = bones.Items[i];

                if (rotateMix > 0)
                {
                    float a = bone.a, b = bone.b, c = bone.c, d = bone.d;
                    float r = (float)Math.Atan2(tc, ta) - (float)Math.Atan2(c, a) + data.offsetRotation * MathUtils.degRad;
                    if (r > MathUtils.PI)
                    {
                        r -= MathUtils.PI2;
                    }
                    else if (r < -MathUtils.PI)
                    {
                        r += MathUtils.PI2;
                    }
                    r *= rotateMix;
                    float cos = MathUtils.Cos(r), sin = MathUtils.Sin(r);
                    bone.a = cos * a - sin * c;
                    bone.b = cos * b - sin * d;
                    bone.c = sin * a + cos * c;
                    bone.d = sin * b + cos * d;
                }

                if (translateMix > 0)
                {
                    float tempx, tempy;
                    target.LocalToWorld(data.offsetX, data.offsetY, out tempx, out tempy);
                    bone.worldX += (tempx - bone.worldX) * translateMix;
                    bone.worldY += (tempy - bone.worldY) * translateMix;
                }

                if (scaleMix > 0)
                {
                    float bs = (float)Math.Sqrt(bone.a * bone.a + bone.c * bone.c);
                    float ts = (float)Math.Sqrt(ta * ta + tc * tc);
                    float s  = bs > 0.00001f ? (bs + (ts - bs + data.offsetScaleX) * scaleMix) / bs : 0;
                    bone.a *= s;
                    bone.c *= s;
                    bs      = (float)Math.Sqrt(bone.b * bone.b + bone.d * bone.d);
                    ts      = (float)Math.Sqrt(tb * tb + td * td);
                    s       = bs > 0.00001f ? (bs + (ts - bs + data.offsetScaleY) * scaleMix) / bs : 0;
                    bone.b *= s;
                    bone.d *= s;
                }

                if (shearMix > 0)
                {
                    float b = bone.b, d = bone.d;
                    float by = MathUtils.Atan2(d, b);
                    float r  = MathUtils.Atan2(td, tb) - MathUtils.Atan2(tc, ta) - (by - MathUtils.Atan2(bone.c, bone.a));
                    if (r > MathUtils.PI)
                    {
                        r -= MathUtils.PI2;
                    }
                    else if (r < -MathUtils.PI)
                    {
                        r += MathUtils.PI2;
                    }
                    r = by + (r + data.offsetShearY * MathUtils.degRad) * shearMix;
                    float s = (float)Math.Sqrt(b * b + d * d);
                    bone.b = MathUtils.Cos(r) * s;
                    bone.d = MathUtils.Sin(r) * s;
                }
            }
        }
コード例 #56
0
		public void ComputeWorldVertices (Bone bone, float[] worldVertices) {
			float x = bone.skeleton.x + bone.worldX, y = bone.skeleton.y + bone.worldY;
			float m00 = bone.a, m01 = bone.b, m10 = bone.c, m11 = bone.d;
			float[] offset = this.offset;
			worldVertices[X1] = offset[X1] * m00 + offset[Y1] * m01 + x;
			worldVertices[Y1] = offset[X1] * m10 + offset[Y1] * m11 + y;
			worldVertices[X2] = offset[X2] * m00 + offset[Y2] * m01 + x;
			worldVertices[Y2] = offset[X2] * m10 + offset[Y2] * m11 + y;
			worldVertices[X3] = offset[X3] * m00 + offset[Y3] * m01 + x;
			worldVertices[Y3] = offset[X3] * m10 + offset[Y3] * m11 + y;
			worldVertices[X4] = offset[X4] * m00 + offset[Y4] * m01 + x;
			worldVertices[Y4] = offset[X4] * m10 + offset[Y4] * m11 + y;
		}
コード例 #57
0
ファイル: Animation.cs プロジェクト: xinwei2016/test
 protected virtual void SetFlip(Bone bone, bool flip)
 {
     bone.flipX = flip;
 }
コード例 #58
0
 // Use this for initialization
 void Start()
 {
     _skeletonAnimation = GetComponent <SkeletonAnimation>();
     _rootBone          = _skeletonAnimation.skeleton.FindBone("root");
 }
コード例 #59
0
    public void ShowPopupMessage(FormationUnit unit, PopupMessageType type, string parameter = "", float ripOffset = 0)
    {
        PopupMessage popupMessage = Instantiate(popupText.gameObject).GetComponent<PopupMessage>();
        popupMessage.RectTransform.SetParent(eventRect, false);
        Spine.Bone bone = unit.CurrentState.Skeleton.FindBone("fxhead") ?? unit.CurrentState.Skeleton.FindBone("fxskill");

        switch(type)
        {
            case PopupMessageType.DeathBlow:
                popupMessage.SetColor(PopupColors["pop_text_deathblow"], PopupColors["pop_text_outline_deathblow"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_deathblow"));
                popupMessage.SetRotation(new Vector3(0, 0, 8));
                break;
            case PopupMessageType.DeathsDoor:
                bone = unit.CurrentState.Skeleton.FindBone("fxchest");
                popupMessage.SetColor(PopupColors["pop_text_death_avoided"], PopupColors["pop_text_outline_death_avoided"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_death_avoided"));
                popupMessage.SetIcon("poptext_death_avoided");
                popupMessage.SetRotation(new Vector3(0, 0, 8));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/combat/deaths_door");
                break;
            case PopupMessageType.HeartAttack:
                popupMessage.SetColor(PopupColors["pop_text_heart_attack"], PopupColors["pop_text_outline_heart_attack"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_heart_attack"));
                popupMessage.SetOffset(new Vector3(0, ripOffset, 0));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/char/heart_attack");
                break;
            case PopupMessageType.RetreatFailed:
                popupMessage.SetColor(PopupColors["pop_text_heart_attack"], PopupColors["pop_text_outline_heart_attack"]);
                popupMessage.SetMessage(LocalizationManager.GetString("retreat_fail_announcement"));
                popupMessage.SetOffset(new Vector3(0, ripOffset, 0));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/combat/retreat_fail");
                break;
            case PopupMessageType.Miss:
                popupMessage.SetColor(PopupColors["pop_text_miss"], PopupColors["pop_text_outline_miss"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_miss"));
                popupMessage.SetOffset(new Vector3(0, ripOffset, 0));
                break;
            case PopupMessageType.Dodge:
                popupMessage.SetColor(PopupColors["pop_text_miss"], PopupColors["pop_text_outline_miss"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_dodge"));
                popupMessage.SetRotation(new Vector3(0, 0, 4));
                popupMessage.SetOffset(new Vector3(0, ripOffset, 0));
                break;
            case PopupMessageType.ZeroDamage:
                popupMessage.SetColor(PopupColors["pop_text_no_damage"], PopupColors["pop_text_outline_no_damage"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_no_damage"));
                popupMessage.SetOffset(new Vector3(0, ripOffset, 0));
                break;
            case PopupMessageType.Damage:
                popupMessage.SetColor(PopupColors["pop_text_damage"], PopupColors["pop_text_outline_damage"]);
                popupMessage.SetMessage(parameter);
                popupMessage.SetOffset(new Vector3(0, ripOffset, 0));
                popupMessage.SkillMessage.fontSize = 70;
                break;
            case PopupMessageType.CritDamage:
                popupMessage.SetColor(PopupColors["pop_text_crit_damage"], PopupColors["pop_text_outline_crit_damage"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_crittxt") + "\n" + parameter);
                popupMessage.SetOffset(new Vector3(0, ripOffset, 0));
                popupMessage.SkillMessage.fontSize = 72;
                break;
            case PopupMessageType.Stress:
                popupMessage.SetColor(PopupColors["pop_text_stress_damage"], PopupColors["pop_text_outline_stress_damage"]);
                popupMessage.SetMessage(parameter);
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/stress_up");
                popupMessage.SkillMessage.fontSize = 70;
                break;
            case PopupMessageType.StressHeal:
                popupMessage.SetColor(PopupColors["pop_text_stress_reduce"], PopupColors["pop_text_outline_stress_reduce"]);
                popupMessage.SetMessage(parameter);
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/stress_down");
                popupMessage.SkillMessage.fontSize = 70;
                break;
            case PopupMessageType.Heal:
                popupMessage.SetColor(PopupColors["pop_text_heal"], PopupColors["pop_text_outline_heal"]);
                popupMessage.SetMessage(parameter);
                popupMessage.SkillMessage.fontSize = 70;
                break;
            case PopupMessageType.CritHeal:
                popupMessage.SetColor(PopupColors["pop_text_heal_crit"], PopupColors["pop_text_outline_heal_crit"]);
                popupMessage.SetMessage(parameter);
                popupMessage.SkillMessage.fontSize = 72;
                break;
            case PopupMessageType.Pass:
                popupMessage.SetColor(PopupColors["pop_text_pass"], PopupColors["pop_text_outline_pass"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_pass"));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/char/pass");
                break;
            case PopupMessageType.Tagged:
                popupMessage.SetColor(PopupColors["pop_text_tagged"], PopupColors["pop_text_outline_tagged"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_tagged"));
                popupMessage.SetIcon("poptext_tagged");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/marked");
                break;
            case PopupMessageType.Untagged:
                popupMessage.SetColor(PopupColors["pop_text_tagged"], PopupColors["pop_text_outline_tagged"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_untagged"));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/marked");
                popupMessage.SetRotation(new Vector3(0, 0, 6));
                break;
            case PopupMessageType.Bleed:
                popupMessage.SetColor(PopupColors["pop_text_bleed"], PopupColors["pop_text_outline_bleed"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_bleed"));
                popupMessage.SetIcon("poptext_bleed");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/bleed_onset");
                break;
            case PopupMessageType.Poison:
                popupMessage.SetColor(PopupColors["pop_text_poison"], PopupColors["pop_text_outline_poison"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_poison"));
                popupMessage.SetIcon("poptext_poison");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/poison_onset");
                break;
            case PopupMessageType.Buff:
                popupMessage.SetColor(PopupColors["pop_text_buff"], PopupColors["pop_text_outline_buff"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_buff"));
                popupMessage.SetIcon("poptext_buff");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/buff");
                break;
            case PopupMessageType.Debuff:
                popupMessage.SetColor(PopupColors["pop_text_debuff"], PopupColors["pop_text_outline_debuff"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_debuff"));
                popupMessage.SetIcon("poptext_debuff");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/debuff");
                break;
            case PopupMessageType.Stunned:
                popupMessage.SetColor(PopupColors["pop_text_stun"], PopupColors["pop_text_outline_stun"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_stun"));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/stun_onset");
                break;
            case PopupMessageType.Unstun:
                popupMessage.SetColor(PopupColors["pop_text_stun_clear"], PopupColors["pop_text_outline_stun_clear"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_stun"));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/stun_off");
                break;
            case PopupMessageType.Cured:
                popupMessage.SetColor(PopupColors["pop_text_cured"], PopupColors["pop_text_outline_cured"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_cured"));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/cured");
                break;
            case PopupMessageType.BleedResist:
                if(unit.Character.DisplayModifier != null && unit.Character.DisplayModifier.DisabledPopups.Contains("resist"))
                {
                    Destroy(popupMessage.gameObject);
                    return;
                }
                popupMessage.SetColor(PopupColors["pop_text_bleed_resist"], PopupColors["pop_text_outline_bleed_resist"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_bleed_resist"));
                popupMessage.SetIcon("poptext_bleed_resist");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/resist");
                break;
            case PopupMessageType.PoisonResist:
                if (unit.Character.DisplayModifier != null && unit.Character.DisplayModifier.DisabledPopups.Contains("resist"))
                {
                    Destroy(popupMessage.gameObject);
                    return;
                }
                popupMessage.SetColor(PopupColors["pop_text_poison_resist"], PopupColors["pop_text_outline_poison_resist"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_blight_resist"));
                popupMessage.SetIcon("poptext_poison_resist");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/resist");
                break;
            case PopupMessageType.StunResist:
                if (unit.Character.DisplayModifier != null && unit.Character.DisplayModifier.DisabledPopups.Contains("resist"))
                {
                    Destroy(popupMessage.gameObject);
                    return;
                }
                popupMessage.SetColor(PopupColors["pop_text_stun_resist"], PopupColors["pop_text_outline_stun_resist"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_stun_resist"));
                popupMessage.SetIcon("poptext_stun_resist");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/resist");
                break;
            case PopupMessageType.MoveResist:
                if (unit.Character.DisplayModifier != null && unit.Character.DisplayModifier.DisabledPopups.Contains("resist"))
                {
                    Destroy(popupMessage.gameObject);
                    return;
                }
                popupMessage.SetColor(PopupColors["pop_text_move_resist"], PopupColors["pop_text_outline_move_resist"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_move_resist"));
                popupMessage.SetIcon("poptext_move_resist");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/resist");
                break;
            case PopupMessageType.DebuffResist:
                if (unit.Character.DisplayModifier != null && unit.Character.DisplayModifier.DisabledPopups.Contains("resist"))
                {
                    Destroy(popupMessage.gameObject);
                    return;
                }
                popupMessage.SetColor(PopupColors["pop_text_debuff_resist"], PopupColors["pop_text_outline_debuff_resist"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_debuff_resist"));
                popupMessage.SetIcon("poptext_debuff_resist");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/resist");
                break;
            case PopupMessageType.DiseaseResist:
                if (unit.Character.DisplayModifier != null && unit.Character.DisplayModifier.DisabledPopups.Contains("resist"))
                {
                    Destroy(popupMessage.gameObject);
                    return;
                }
                popupMessage.SetColor(PopupColors["pop_text_disease_resist"], PopupColors["pop_text_outline_disease_resist"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_disease_resist"));
                popupMessage.SetIcon("poptext_disease_resist");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/resist");
                break;
            case PopupMessageType.Disease:
                popupMessage.SetColor(PopupColors["pop_text_disease_resist"], PopupColors["pop_text_outline_disease_resist"]);
                popupMessage.SetMessage(parameter);
                popupMessage.SetOffset(new Vector3(0, 70, 0));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/char/quirk_neg");
                break;
            case PopupMessageType.PositiveQuirk:
                popupMessage.SetColor(PopupColors["notable"], Color.black);
                popupMessage.SetMessage(parameter);
                popupMessage.SetOffset(new Vector3(0, 70, 0));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/char/quirk_pos");
                break;
            case PopupMessageType.NegativeQuirk:
                popupMessage.SetColor(PopupColors["harmful"], Color.black);
                popupMessage.SetMessage(parameter);
                popupMessage.SetOffset(new Vector3(0, 70, 0));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/char/quirk_neg");
                break;
            case PopupMessageType.QuirkRemoved:
                popupMessage.SetColor(PopupColors["notable"], Color.black);
                popupMessage.SetMessage(parameter + LocalizationManager.GetString("curio_announcement_purge_format"));
                popupMessage.SetOffset(new Vector3(0, 70, 0));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/char/quirk_pos");
                break;
            case PopupMessageType.DiseaseCured:
                popupMessage.SetMessage(string.Format(LocalizationManager.GetString("str_ui_disease_cured"), parameter));
                popupMessage.SetColor(PopupColors["pop_text_disease_resist"], PopupColors["pop_text_outline_disease_resist"]);
                popupMessage.SetIcon("poptext_disease_resist");
                popupMessage.SetOffset(new Vector3(0, 30, 0));
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/cured");
                break;
            case PopupMessageType.Guard:
                popupMessage.SetColor(PopupColors["pop_text_guard"], PopupColors["pop_text_outline_guard"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_guard"));
                popupMessage.SetIcon("poptext_guard");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/guard");
                break;
            case PopupMessageType.Riposte:
                popupMessage.SetColor(PopupColors["pop_text_riposte"], PopupColors["pop_text_outline_riposte"]);
                popupMessage.SetMessage(LocalizationManager.GetString("str_ui_riposte"));
                popupMessage.SetIcon("poptext_riposte");
                FMODUnity.RuntimeManager.PlayOneShot("event:/general/status/riposte_enabled");
                break;
        }

        Vector3 screenPosition = RaidSceneManager.DungeonPositionToScreen(
            unit.RectTransform.TransformPoint(bone.WorldX, bone.WorldY, 0));
        popupMessage.RectTransform.position = new Vector3(screenPosition.x, screenPosition.y, 0);
        popupMessage.FollowXBone(bone, unit);
        popupMessage.gameObject.SetActive(true);
    }
コード例 #60
0
 public Spine.Bone GetBone(string boneName)
 {
     Spine.Bone bone = _skeletonAnim.Skeleton.FindBone(boneName);
     return(bone);
 }