zoukankan      html  css  js  c++  java
  • 3:《地牢守卫者》代码分析:PlayerPawn

    玩家具备一个替换武器的功能,基本方法就是销毁前一个武器创建一个预期的新武器。

    function SwapWeaponFor(AntWeapon WeaponTemplate)
    {
    if(Weapon!=none)
    Weapon.LifeSpan=-1;
    Invmanger.RemoveFromInventory(Weapon);

    if(weaponTemplate!=none)
    CreateInventoryFromtemplate(WeaponTemplate);
    }

    将武器的生命周期设为-1,同时从模板中将其清空。

     skelControlLookAt骨骼观察目标。

    ConvertDegreeFloatToRotAxis将float转化为角度

    获取一个目标点的方向

    function GetTargetRotation(vector TargetLocation)

    {

      local rotator TargetRotation;

      TargetRotation=Rotator(TargetLocation-Location);

      DesiredLookAtYaw=Clamp(TargetRotation.Yaw-Rotation.Yaw,ConvertDegreeFloatToRotAxis(-52),ConvertDegreeFloatToRotAxis(52)); //取一个角度范围
    }

    获取了方向后应该在Tick中进行插值运算

    event Tick(float DeltaTime)

    {

      super.Tick(DeltaTime);

      CurrentLookAtYaw+=float(DesiredLookAtYaw-CurrentLookAtYaw)*FMin(DeltaTime*5.0f,1);

      PlayerSkelControlLookAt.BoneRotation.Yaw=CurrentLookAtYaw;
    }

    上面的Tick函数一直执行了一个枚举,遍历场景中的金币ManaToken,CheckForTokens()。其实Tick加枚举是最影响性能的因素,以后有机会我再优化方法。

    var float ManaTokenAttractionRadius;   //吸收的距离,这让我想起了奎爷吸魂;)

    var float ManaTokenCollectRadius; //拾取的距离

    function CheckForTokens()

    {

      local AntManaToken Token; //在使用遍历的时候应该牢记一点,要遍历局部变量是必备的,这应该在以后写的时候构成条件反射

    foreach OverLappingActors(class'AntManaToken',Token,ManaTokenAttractionRadius)

      {

        token.AttrackTo(self); //这将是大名鼎鼎的吸魂魔法  

        if(VSize(location-Token.Location)<ManaTokenCollectRadius)

        AntPlayerController(controller).CollectManaToken(token); //token.Collected(AntManaToken token); AddManaPower(token.ManaPower);

      
    }



     

  • 相关阅读:
    调试php的soapCient
    thinkphp 常见问题
    git使用备忘
    org.apache.catalina.startup.Catalina异常处理
    Java多线程中join方法详解
    WebSphere 安装和配置过程
    数据库错误
    把sql输出成。sql文件
    Oracle 使用命令导入dmp文件
    pl_sql develope连接远程数据库的方法
  • 原文地址:https://www.cnblogs.com/NEOCSL/p/2366785.html
Copyright © 2011-2022 走看看