当前位置: 首页 > news >正文

网站建设与管理的内容南庄营销网站建设

网站建设与管理的内容,南庄营销网站建设,joomla与wordpress学哪个好,网站的修改Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释#xff0c;可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Entity.cs using System.Collections; using System.Collections.Generic;…Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Entity.cs using System.Collections; using System.Collections.Generic; using UnityEngine;public class Entity : MonoBehaviour {[Header(Knockback info)][SerializeField] protected Vector2 knockbackDirection;//被击打后的速度信息[SerializeField] protected float knockbackDuration;//被击打的时间protected bool isKnocked;//此值通过卡住SetVelocity函数的方式用来阻止当一个角色被攻击时会乱动的情况[Header(Collision Info)]public Transform attackCheck;//transform类代表的时物体的位置,用来控制攻击检测的位置public float attackCheckRadius;//检测半径[SerializeField] protected Transform groundCheck;//transform类代表的时物体的位置,后面会来定位子组件的位置 [SerializeField] protected float groundCheckDistance;[SerializeField] protected Transform wallCheck;//transform类代表的时物体的位置,后面会来定位子组件的位置 [SerializeField] protected float wallCheckDistance;[SerializeField] protected LayerMask whatIsGround;//LayerMask类与Raycast配合https://docs.unity3d.com/cn/current/ScriptReference/Physics.Raycast.html#region 定义Unity组件public Animator anim { get; private set; }//这样才能配合着拿到自己身上的animator的控制权public Rigidbody2D rb { get; private set; }//配合拿到身上的Rigidbody2D组件控制权public EntityFX fx { get; private set; }//拿到EntityFX#endregionpublic int facingDir { get; private set; } 1;protected bool facingRight true;//判断是否朝右protected virtual void Awake(){fx GetComponentEntityFX();拿到的组件上的EntityFX控制权anim GetComponentInChildrenAnimator();//拿到自己子组件身上的animator的控制权rb GetComponentRigidbody2D();}protected virtual void Start(){}protected virtual void Update(){}public virtual void Damage(){fx.StartCoroutine(FlashFX);//IEnumertor本质就是将一个函数分块执行只有满足某些条件才能执行下一段代码此函数有StartCoroutine调用//https://www.zhihu.com/tardis/bd/art/504607545?source_id1001StartCoroutine(HitKnockback);//调用被击打后产生后退效果的函数Debug.Log(gameObject.namewas damaged);}protected virtual IEnumerator HitKnockback(){isKnocked true;//此值通过卡住SetVelocity函数的方式用来阻止当一个角色被攻击时会乱动的情况rb.velocity new Vector2(knockbackDirection.x * -facingDir, knockbackDirection.y);yield return new WaitForSeconds(knockbackDuration);isKnocked false;}//被击打后产生后退效果的函数#region 速度函数Velocitypublic virtual void SetZeroVelocity(){if(isKnocked){return;}rb.velocity new Vector2(0, 0);}//设置速度为0函数public virtual void SetVelocity(float _xVelocity, float _yVelocity){if(isKnocked)return;此值通过卡住SetVelocity函数的方式用来阻止当一个角色被攻击时会乱动的情况rb.velocity new Vector2(_xVelocity, _yVelocity);//将rb的velocity属性设置为对应的想要的二维向量。因为2D游戏的速度就是二维向量FlipController(_xVelocity);//在其他设置速度的时候调用翻转控制器}//控制速度的函数此函数在其他State中可能会使用但仅能通过player.SeVelocity调用#endregion#region 翻转函数Flippublic virtual void Flip(){facingDir facingDir * -1;facingRight !facingRight;transform.Rotate(0, 180, 0);//旋转函数,transform不需要额外定义因为他是自带的}//翻转函数public virtual void FlipController(float _x)//目前设置x目的时能在空中时也能转身{if (_x 0 !facingRight)//当速度大于0且没有朝右时翻转{Flip();}else if (_x 0 facingRight){Flip();}}#endregion#region 碰撞函数Collisionpublic virtual bool IsGroundDetected(){return Physics2D.Raycast(groundCheck.position, Vector2.down, groundCheckDistance, whatIsGround);}//通过RayCast检测是否挨着地面,https://docs.unity3d.com/cn/current/ScriptReference/Physics2D.Raycast.html//xxxxxxxx() xxxxxxxx xxxxxxxxxx() return xxxxxxxxx;public virtual bool IsWallDetected(){return Physics2D.Raycast(wallCheck.position, Vector2.right * facingDir, wallCheckDistance, whatIsGround);}//通过RayCast检测是否挨着地面,https://docs.unity3d.com/cn/current/ScriptReference/Physics2D.Raycast.html//xxxxxxxx() xxxxxxxx xxxxxxxxxx() return xxxxxxxxx;protected virtual void OnDrawGizmos(){Gizmos.DrawLine(groundCheck.position, new Vector3(groundCheck.position.x, groundCheck.position.y - groundCheckDistance));//绘制一条从 from(前面的) 开始到 to后面的 的线。Gizmos.DrawLine(wallCheck.position, new Vector3(wallCheck.position.x wallCheckDistance, wallCheck.position.y));//绘制一条从 from(前面的) 开始到 to后面的 的线。Gizmos.DrawWireSphere(attackCheck.position, attackCheckRadius);//https://docs.unity3d.com/2022.3/Documentation/ScriptReference/Gizmos.DrawWireSphere.html//绘制具有中心和半径的线框球体。}//画图函数#endregion }PlayerPrimaryAttack.cs using System.Collections; using System.Collections.Generic; using UnityEngine;public class PlayerPrimaryAttackState : PlayerState {//p38 2.从ground进入private int comboCounter;private float lastTimeAttacked;//距离上一次攻击的时间private float comboWindow 2;//可以间隔的时间public PlayerPrimaryAttackState(Player _player, PlayerStateMachine _stateMachine, string _animBoolName) : base(_player, _stateMachine, _animBoolName){}public override void Enter(){base.Enter();xInput 0;//修复攻击乱转的问题if(comboCounter 2||Time.timecomboWindowlastTimeAttacked)//当计数器超过2和间隔时间大于window时进入第一个攻击动作{comboCounter 0;}Debug.Log(comboCounter);player.anim.SetInteger(ComboCounter, comboCounter);//设置animtor里的comboCounter#region 选择攻击方向float attackDir player.facingDir;if(xInput ! 0){attackDir xInput;}#endregion//使其能改变攻击方向player.SetVelocity(player.attackMovement[comboCounter].x * attackDir, player.attackMovement[comboCounter].y);//给角色初速度让角色在攻击触发时移动一点stateTimer .1f;}public override void Exit(){base.Exit();player.StartCoroutine(BusyFor, .15f);comboCounter;lastTimeAttacked Time.time;}public override void Update(){base.Update();if(stateTimer0){player.SetZeroVelocity();}//1.修改移动时攻击时后可以移动的BUG//2.但给了点时间模拟惯性可以动一点if (triggerCalled){stateMachine.ChangeState(player.idleState);}} }
http://www.pierceye.com/news/796671/

相关文章:

  • 网站还能赚钱吗logo公司商标设计
  • 数字校园建设专题网站wordpress游览器标签页
  • 企业网站分析报告途牛网站大数据建设
  • 免费创建论坛网站wordpress sql插件
  • 有移动端网站 怎么做app做网站的困难
  • 金种子酒业网站建设苏州专业的网站建设公司
  • 住房与住房建设部网站首页给网站做收录较好的软件
  • 课程网站的设计网站开发遇到的难题
  • 学网站建设要什么iis 二级网站 发布
  • 怎么仿做网站wordpress文章进不去
  • 网站建设费算办公费吗html5商城网站模板
  • 188旅游网站源码下载做个爬架网站如何做
  • 中国做的比较好的网站设计公司有哪些可以做翻译兼职的网站吗
  • 深圳做网站建设公司dw学生个人网页制作视频
  • html网页设计代码作业网站衡水武邑县建设局网站
  • 网站后台登陆验证码wordpress 前台加载慢
  • 网站推广去哪家比较好专门做网站的公司叫什么
  • 前端做项目的网站资源公司做网站的步骤
  • 资源分享网站怎么建设网站建设百度云
  • 宣讲家网站官德修养与作风建设短视频seo关键词
  • 更新网站怎么弄建设工程合同范本工程施工合同范本
  • 外贸网站建设有什么需要注意的吗白山网站设计
  • 哪家做网站性价比高宁波seo网络优化哪家好
  • 望京做网站微信订阅号怎么做网站
  • 分销系统网站建设网站建设 51下拉平台
  • 怎么才能自己做网站怎么自己制作app
  • 爱看视频的网站政务公开既网站信息化建设会议
  • 做外单什么网站好网站模板下载之后怎么做
  • 网站维护细则微博同步wordpress
  • 网站微商城的建设新网域名备案