• 从暗黑3D火炬之光技能系统说到-Laya非入门教学一~资源管理


    我不知道那些喷Laya没有浏览器,嘲笑别人编辑器做不好,是什么水平?

    首先目前国内除了WPS和飞书,就没有第三家公司能把编辑器做好。

    要是一般的游戏开发者,如我,有一点点引擎代码(某项目),用VsCode或者甚至很多人用.txt+终端命令就能完成一个游戏开发;但我需要游戏“漂亮”一点,除了代码,我还有一点点“素材”,那我首选Unity 作为图片素材的浏览和管理工具,不是很合理的么?

    -------- 后面会补充,Unity Editor的各种入门细节操作(为什么是世一编辑器

    《插播一段Unity 代码,实际这个文章是说图片素材的日常管理》

    火炬之光操控人物逻辑

    操作后发现鼠标左键,是射击;右键,是范围爆炸

    全局搜索:mousebutton,找到以下代码

    1. //mainUIControl.cs
    2. //void Update()方法的代码
    3. //fire
    4. bool continousFire=player.ContinousFire() & (Input.GetMouseButton(0) || Input.GetButton("Fire1"));
    5. if(Input.GetMouseButtonDown(0) || Input.GetButtonDown("Fire1") || continousFire) player.FireWeapon();
    6. //alt fire, could fire weapon alt-mode to launch selected ability
    7. if(Input.GetMouseButtonDown(1) || Input.GetButtonDown("Fire2")) player.FireAbility();
    8. //launch ability
    9. if(Input.GetMouseButtonDown(2) || Input.GetButtonDown("Fire3")) player.FireAbilityAlt();

    攻击(直线):FireAbilityA

    我们只需要范围攻击,所以直接看:.FireAbilityA

    1. public static void LaunchAbility(Ability ability, bool useCostNCD=true){
    2. bool teleport=ability.type==_AbilityType.Movement & ability.moveType==_MoveType.Teleport;
    3. if(ability.type==_AbilityType.AOE || ability.type==_AbilityType.Shoot || teleport){
    4. //get the hit point and activate the ability on that particular spot
    5. Ray ray = CameraControl.GetMainCamera().ScreenPointToRay(Input.mousePosition);
    6. RaycastHit hit;
    7. if(Physics.Raycast(ray, out hit, Mathf.Infinity)) ability.Activate(hit.point);
    8. else ability.Activate(GameControl.GetPlayer().thisT.position); //use player position if there's no valid position
    9. }
    10. else{
    11. //activate the ability on the player position
    12. ability.Activate(GameControl.GetPlayer().thisT.position);
    13. }
    14. }

    逻辑也很简单:就是在一个位置做一些范围的物理处理:

    ability.Active(position)

    当然实际上,是有一个 if else 的判断(在自身范围附近爆,还是抛出一个火箭筒在敌人阵地附近爆)

    攻击(爆炸型):Activate

    1. //Ability.cs
    2. //launch the ability, at the position given
    3. public void Activate(Vector3 pos=default(Vector3), bool useCostNCD=true){
    4. //技能cd
    5. if(useCostNCD){
    6. }
    7. //范围音效
    8. AudioManager.PlaySound(launchSFX);
    9. //爆炸的实体对象(光圈)
    10. //instantiate the launch object, if there's any
    11. if(launchObj!=null){
    12. GameObject obj=(GameObject)MonoBehaviour.Instantiate(launchObj, pos, Quaternion.identity);
    13. if(autoDestroyLaunchObj) MonoBehaviour.Destroy(obj, launchObjActiveDuration);
    14. }
    15. //物理攻击
    16. //for aoe ability
    17. if(type==_AbilityType.AOE || type==_AbilityType.AOESelf){
    18. // unitInstance.ApplyAttack(aInstance);
    19. //apply explosion force
    20. // TDSPhysics.ApplyExplosionForce(pos, aStats);
    21. }
    22. //for ability that affects all hostile unit in game
    23. else if(type==_AbilityType.All){
    24. //get all hostile unit for unit tracker
    25. //List unitList=new List( UnitTracker.GetAllUnitList() );
    26. // unitList[i].ApplyAttack(aInstance);
    27. }
    28. //for ability that meant to be cast on player unit(跟踪??东风导弹)
    29. else if(type==_AbilityType.Self){
    30. //apply the attack on player
    31. AttackInstance aInstance=new AttackInstance(GameControl.GetPlayer(), GetRuntimeAttackStats());
    32. GameControl.GetPlayer().ApplyAttack(aInstance);
    33. }
    34. //for ability that fires a shoot object(射击)
    35. else if(type==_AbilityType.Shoot){
    36. //
    37. }
    38. else if(type==_AbilityType.Movement){//(强制移动,闪现)
    39. //
    40. }
    41. }

    技能朝向+旋转问题

    (Unity-粒子是不能旋转的)

    能医不自医,还是碰到了需要粒子旋转的问题,这个我曾经教了很多人解决

    接受伤害

    (待补充)

    关于Laya资源管理

    复习了一下Unity之后,我们很快就进入Laya的环节

    在火炬之光3D项目内(或者你选一个空项目亦可),就是创建一个"AnotherCat"目录

    把你认为可能是素材的目录,拖到Unity Project面板目录“AnotherCat”内

    然后就可以愉快地选择Texture【分类】(搜索输入框右边的下拉按钮),

            -- 当然,也可以如图,只搜索刚才创建的“AnotherCat”目录内的所有Textures

    Unity Editor的基础操作

    预览大小调整

    双击打开图片(外部:windows 图片工具)

    多目录浏览

  • 相关阅读:
    GIT学习之路
    项目会议如何开
    spring-boot-starter和spring-boot-starter-web的关联
    Postman知识汇总
    私域流量时代来临,电商企业如何布局?
    性能测试-度量指标及选择(6)
    Python3,9分钟撸完一个电脑录屏神器,女神说今晚要给我加鸡腿。
    完整版在xcode打测试专用ipa包流程​
    linux内核工作延迟机制
    根视图切换动画
  • 原文地址:https://blog.csdn.net/avi9111/article/details/133824030