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

网站建好以后每年都续费么广州网站设计建设

网站建好以后每年都续费么,广州网站设计建设,武汉个人做网站,广州网站建设公司怎么挑选【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili 教程源地址:https://www.udemy.com/course/2d-rpg-alexdev/ 本章节添加了更多的音效细节 音频管理器 AudioManager.cs 使得多个音效可以同时播放,注释掉以下代码 public void PlaySFX(in…

【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili

教程源地址:https://www.udemy.com/course/2d-rpg-alexdev/

本章节添加了更多的音效细节

音频管理器

AudioManager.cs

使得多个音效可以同时播放,注释掉以下代码

 public void PlaySFX(int _sfxIndex,Transform _source)//播放音效{//if(sfx[_sfxIndex].isPlaying)//如果音效正在播放//    return;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class AudioManager : MonoBehaviour
{public static AudioManager instance;[SerializeField] private float sfxMinimumDistance;//音效最小距离[SerializeField] private AudioSource[] sfx;//音效[SerializeField] private AudioSource[] bgm;//背景音乐public bool playBgm;private int bgmIndex;private void Awake(){if(instance != null)Destroy(instance.gameObject);elseinstance = this;}private void Update(){if (!playBgm)StopAllBGM();else{if(!bgm[bgmIndex].isPlaying)//如果背景音乐没有播放PlayBGM(bgmIndex);}}public void PlaySFX(int _sfxIndex,Transform _source)//播放音效{//if(sfx[_sfxIndex].isPlaying)//如果音效正在播放//    return;if(_source!=null && Vector2.Distance(PlayerManager.instance.player.transform.position, _source.position) > sfxMinimumDistance)//距离过远不播放return;if (_sfxIndex < sfx.Length){sfx[_sfxIndex].pitch = Random.Range(.85f, 1.15f);//设置音效的音调sfx[_sfxIndex].Play();}}public void StopSFX(int _index) => sfx[_index].Stop();//停止音效public void PlayRandomBGM()//播放随机背景音乐{bgmIndex = Random.Range(0, bgm.Length);PlayBGM(bgmIndex);}public void PlayBGM(int _bgmIndex)//播放背景音乐{bgmIndex = _bgmIndex;StopAllBGM();bgm[bgmIndex].Play();}public void StopAllBGM(){for (int i = 0; i < bgm.Length; i++){bgm[i].Stop();}}}

Blackhole_Skill.cs

加上了释放技能的玩家语音和技能音效

        AudioManager.instance.PlaySFX(3, player.transform);AudioManager.instance.PlaySFX(6, player.transform);
using UnityEngine;
using UnityEngine.UI;public class Blackhole_Skill : Skill
{[SerializeField] private UI_SkillTreeSlot blackHoleUnlockButton;public bool blackHoleUnlocked { get; private set; }[SerializeField] private int amountOfAttacks;[SerializeField] private float cloneCooldown;[SerializeField] private float blackholeDuration;[Space][SerializeField] private GameObject blackHolePrefab;[SerializeField] private float maxSize;[SerializeField] private float growSpeed;[SerializeField] private float shrinkSpeed;BlackHole_Skill_Controller currentBlackhole;//当前的黑洞private void UnlockBlackHole(){if (blackHoleUnlockButton.unlocked)blackHoleUnlocked =true;}public override bool CanUseSkill(){return base.CanUseSkill();}public override void UseSkill(){base.UseSkill();//调用了基类 Skill中的 UseSkill 方法GameObject newBlackHole = Instantiate(blackHolePrefab, player.transform.position, Quaternion.identity); //这行代码使用 Instantiate 方法在玩家当前位置生成一个新的黑洞对象currentBlackhole = newBlackHole.GetComponent<BlackHole_Skill_Controller>();currentBlackhole.SetupBlackhole(maxSize, growSpeed, shrinkSpeed, amountOfAttacks, cloneCooldown,blackholeDuration);//调用SetupBlackhole,传递一系列参数来配置黑洞的行为,包括最大尺寸、增长速度、缩小速度、攻击次数和克隆冷却时间AudioManager.instance.PlaySFX(3, player.transform);AudioManager.instance.PlaySFX(6, player.transform);}protected override void Start(){base.Start();blackHoleUnlockButton.GetComponent<Button>().onClick.AddListener(UnlockBlackHole);}protected override void Update(){base.Update();}public bool SkillCompeleted(){if(!currentBlackhole){return false;}if (currentBlackhole.playerCanExitState){currentBlackhole = null;return true;}return false;}public float GetBlackholeRadius()//解决水晶黑洞的攻击范围问题{return maxSize / 2;}protected override void CheckUnlock(){base.CheckUnlock();UnlockBlackHole();  }
}

ItemObject.cs

添加了拾取物品的音效

public void PickupItem()//将物品添加到背包,然后销毁
{//11月12日改if (!Inventory.instance.CanAddItem() && itemData.itemType == ItemType.Equipment)//如果不能添加物品并且物品类型是装备{rb.velocity = new Vector2(0, 7);return;}AudioManager.instance.PlaySFX(18, transform);Inventory.instance.AddItem(itemData);Destroy(gameObject);
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;//创建一个物体,放入这个脚本
public class ItemObject : MonoBehaviour
{[SerializeField] private Rigidbody2D rb;[SerializeField] private ItemData itemData;//就是你放入的图标private void SetupVisuals()//设置物品的图标和名称{if (itemData == null)return;SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();if (spriteRenderer == null){Debug.LogError("SpriteRenderer component is missing");return;}GetComponent<SpriteRenderer>().sprite = itemData.icon;//在编辑器中显示图标gameObject.name = "Item object - " + itemData.itemName;//直接在编辑器中显示名字}public void SetupItem(ItemData _itemData,Vector2 _velocity)//配置物品的数据和掉落的初始速度{itemData = _itemData;rb.velocity = _velocity;SetupVisuals();}public void PickupItem()//将物品添加到背包,然后销毁{//11月12日改if (!Inventory.instance.CanAddItem() && itemData.itemType == ItemType.Equipment)//如果不能添加物品并且物品类型是装备{rb.velocity = new Vector2(0, 7);return;}AudioManager.instance.PlaySFX(18, transform);Inventory.instance.AddItem(itemData);Destroy(gameObject);}
}

Checkpoint.cs

到检查点如果火堆未启动过,加个点亮火堆的音效

        if(activationStatus==false)AudioManager.instance.PlaySFX(5, transform);
using System.Collections;
using System.Collections.Generic;
using UnityEngine;//2024.11.28 19:38 疑似有点生病
//
public class Checkpoint : MonoBehaviour
{private Animator anim;public string id;public bool activationStatus;private void Awake(){anim = GetComponent<Animator>();}[ContextMenu("产生检查点ID")]//在编辑器中生成一个按钮private void GenerateId(){id = System.Guid.NewGuid().ToString();}private void OnTriggerEnter2D(Collider2D collision)//检测到碰撞{if (collision.GetComponent<Player>()!=null)//检测到玩家{ActivateCheckPoint();//激活检查点}}public void ActivateCheckPoint()//激活检查点{if(activationStatus==false)AudioManager.instance.PlaySFX(5, transform);activationStatus = true;anim.SetBool("active", true);}
}

PlayerMoveState.cs

移动会产生脚步声

    public override void Enter(){base.Enter();AudioManager.instance.PlaySFX(14,null);}public override void Exit(){base.Exit();AudioManager.instance.StopSFX(14);}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class PlayerMoveState : PlayerGroundedState
{public PlayerMoveState(Player _player, PlayerStateMachine _stateMachine, string _animBoolName) : base(_player, _stateMachine, _animBoolName){}public override void Enter(){base.Enter();AudioManager.instance.PlaySFX(14,null);}public override void Exit(){base.Exit();AudioManager.instance.StopSFX(14);}public override void Update(){base.Update();player.SetVelocity(xInput * player.moveSpeed, rb.velocity.y);if (xInput == 0  || player.IsWallDetected())stateMachine.ChangeState(player.idleState);//如果玩家没有按下左箭头键或右箭头键,我们将切换到Idle状态}
}

http://www.wooajung.com/news/22251.html

相关文章:

  • 网站开发背景网络稿件投稿平台
  • 无锡网站建设f7wlb站是哪个网站
  • 不忘初心 继续前进网站怎么做苏州关键词排名提升
  • 东莞做网站费用seo基础知识
  • 仪征 网站建设北京百度推广官网首页
  • 没内涵网站源码品牌营销策划公司哪家好
  • 专业做邯郸网站优化信息流广告公司排名
  • 电大企业网站建设论文范文个人网页设计作品欣赏
  • 电商网站建设新闻优网营销
  • 怎么创建一个网站卖东西注册网站的免费网址
  • 长春网站建设外包seo外包是什么意思
  • 手机做图纸app下载网站怎样做网络推广
  • 做网站开发 甲方提供资料seo的工作内容主要包括
  • 详情页设计思路怎么写seo推广培训学费
  • asp网站助手seo网站推广的主要目的是什么
  • 门户型网站模板seo是什么级别
  • 深圳龙岗网站建设公司哪家好微商软文范例
  • 佛山做网站公司有哪些北京seo优化服务
  • 武汉网站建设企业网页分析报告案例
  • 西安市网站建设谷歌网站推广优化
  • 长春企业网站如何建设百度问一问官网
  • vue做网站首页上海企业seo
  • 网站上传ftp什么搜索引擎搜索最全
  • 网站推广工具大全上海最新政策
  • 企业信息系统应用seo门户网站建设方案
  • 百度总部在哪里班级优化大师怎么用
  • 政府网站监管怎么做sem运营是什么意思
  • 学校做网站难吗百度识图在线识别
  • 如果是自已建设的网站_那你在数据库想改成什么时间都可以.目前搜索引擎排名
  • 营销型网站设计思路网络营销案例题