/// <summary>检查unMeltChecker是否在meltCollider内或相交 </summary> private bool CheckMeltStatus(MeltArea meltArea) { bool status = false; //如果同时接触了两个可溶入区域 默认溶第一个 Collider2D meltCollider = meltArea.GetComponent <Collider2D>(); if (View.PlayerView.UnMeltCheckCollider.IsTouching(meltCollider)) { //Debug.Log("刚好相交"); status = true; } else if (meltCollider.OverlapPoint(View.PlayerView.Rigidbody.position)) { //Debug.Log("进入内部"); status = true; } else { status = false; } //Debug.Log("检查溶入状态:" + status); return(status); }
//只有在溶入过程结束后还没进入区域的情况不push /// <summary>设置溶入状态</summary> private void SetMeltStatus(bool meltStatus) { Model.MeltStatus = meltStatus; Model.LastMeltReqTime = float.MinValue; View.PlayerView.NormalEntity.SetActive(!Model.MeltStatus); View.PlayerView.MeltedEntity.SetActive(Model.MeltStatus); Debug.Log("设置溶入状态:" + meltStatus); //修复在ground状态溶入再溶出的问题 if (meltStatus) { Model.StayedGround = null; } if (meltStatus) { Model.LastMeltTime = Time.fixedTime; } else { Model.LastMeltOutTime = Time.fixedTime; } //特效处理 if (meltStatus) { } else { //播放溶出特效 for (int i = 0; i < 2; i++) { GameObject meltOutEffect = GameObject.Instantiate(View.PlayerView.MeltOutEffect, Model.Map.transform); meltOutEffect.transform.position = View.PlayerView.Rigidbody.position; SetMeltEffectRandomEulerAngles(meltOutEffect.transform); SetMeltEffectColor(meltOutEffect.GetComponent <SpriteRenderer>()); meltOutEffect.GetComponent <Animator>().Play("Melt_Out"); AnimKiller killer = meltOutEffect.AddComponent <AnimKiller>(); killer.StateName = "Melt_Out"; } } //音效处理 if (meltStatus) { PlayAudioClip(View.AudioSetting.MeltInAudioClip); } else { PlayAudioClip(View.AudioSetting.MeltOutAudioClip); } //依附处理 if (meltStatus) { foreach (MeltArea meltArea in Model.CurrentStayMeltAreas) { IAttachable attachedObject = meltArea.GetComponentInParent <IAttachable>(); if (attachedObject != null) { Model.AttachedObject = attachedObject; Model.AttachedObject.OnStartAttached(View.PlayerView.Rigidbody); } } } else { Model.AttachedObject = null; } //溶入和溶出时的推力处理 if (meltStatus) { MeltArea targetMeltArea = Model.CurrentStayMeltAreas.First.Value; //已经相交则不需要推力进入溶入区域 if (!CheckMeltStatus(targetMeltArea)) { ColliderDistance2D distance2D = Physics2D.Distance(targetMeltArea.GetComponent <Collider2D>(), View.PlayerView.CenterCollider); Vector2 v0 = GetPushInVelocity(distance2D.normal * distance2D.distance, View.PlayerSetting.MeltInDuration); View.PlayerView.Rigidbody.velocity = View.PlayerSetting.MeltInPushMultiplier * v0; //1.8 } } else { AnimatorStateInfo stateInfo = View.PlayerView.PlayerAnim.GetCurrentAnimatorStateInfo(0); //只有在Melted.Idle状态下才推出 if (stateInfo.fullPathHash == Animator.StringToHash("Base Layer.Melted.Idle")) { Debug.Log("推力推出"); //View.PlayerView.PlayerAnim.SetTrigger("MeltOut"); ColliderDistance2D distance2D = Physics2D.Distance(View.PlayerView.CenterCollider, Model.LastExitMeltArea.GetComponent <Collider2D>()); Vector2 pushForce = GetPushOutForce(distance2D.normal); View.PlayerView.Rigidbody.AddForce(View.PlayerSetting.MeltOutPushMultiplier * pushForce); } } //在溶出操作时插值恢复NormalMoveCollider Transform moveTransform = View.PlayerView.NormalMoveCheckCollider.transform; moveTransform.localScale = Vector3.zero; moveTransform.DOScale(new Vector3(1, 1, 1), View.PlayerSetting.MeltOutDuration); }
public ExitMeltAreaCommand(MeltArea meltArea) { this.MeltArea = meltArea; }
public MeltOutCommand(MeltArea meltArea) { this.MeltArea = meltArea; }
public EnterMeltAreaCommand(MeltArea meltArea) { this.MeltArea = meltArea; }