zoukankan      html  css  js  c++  java
  • Projectile重构

      由于继承了不干净的Projectile,导致iOS上的AntGame运行缓慢,我将会重构这一部分代码。首先应从Projectile方式入手看看这个类中应该填充哪些内容.

      1.首先考虑用脚拇指都能想来的粒子,Bullet粒子,撞到墙壁的粒子。That's all.对于爆炸的子弹,无论人畜,都给他加载爆炸粒子吧。

    var ParticleSystem FlightParticleTemplate;
    var ParticleSystem ExplosionParticleTemplate;

      2.子弹在飞行的时候应该有呼啸的飞行声,爆炸的时候还有爆炸音儿。

    var SoundCue AmbientFlightSoundCue;
    var SoundCue ExplosionSoundCue;

      3.你也知道,飞行的子弹空中是永恒的,飞行的声音同样。

    var ParticleSystemComponent FlightParticleSystemComponent;
    var AudioComponent AmbientAudioComponent;

      4.标志子弹是否爆炸,以及后边是否对其威力来电加强。

    var bool HasExplode;
    var float DamageBoost;

      上边是第一部分的变量声明。我们就需要这么多。

       5.接着是初始化两个Component和template

    if(FlightParticleTemplate!=none)
    {
         FlightParticleSystemComponent= new () class'ParticleSystemComponent';
    
        if(FlightParticleSystemComponent!=none)
      {
            FlightParticleSystemComponent.SetTemplate(FlightParticleSystemTemplate);
       AttachComponent(FlightParticleSystemComponent);
      }
    
    }
    
    if(AmbientFlightSoundCue!=none)
    {
         AmbientAudioComponent=CreateAudioComponent(AmbientFlightSoundCue,true,true);
    }

      两个可选True,第一个是否Play?第二个在Actor销毁的时候是否停止演奏?

      6.处理接触敌人的伤害。

      

    simulated function ProcessTouch(Actor Other,Vector HitLocation,Vector HitNormal)
    {
         local Pawn Pawn;
    
         if(HasExplode)
         return;
       
         Pawn=Pawn(Other);
        if(Pawn!=none)
    { 
    if(pawn!=none&&Other!=Instigator&&!Other.bStatic&&DamageRadius==0.f)
         {           Other.TakeDamage(Damage*DamageBoost,InstigatorController,location,MomentumTransfer*Normal(velocity),MyDamageType,, Self);
          }  
    }
        else if(DamageRadius==0)
    {      Other.TakeDamage(Damage*DamageBoost,InstigatorController,Location,MomentumTransfer*Normal(velocity),MyDamageType,,self);
    }
    
        Explode(HitLocation,HitNormal);
    }
  • 相关阅读:
    2019春季第五周作业
    2019春第四周作业(基础题)计算机
    2019第三周作业
    第二周基础作业
    2019春第九周作业
    2019年春第八周作业
    第七周总结
    第六周作业
    2019春第五周作业
    2019年春季学期第四周作业
  • 原文地址:https://www.cnblogs.com/NEOCSL/p/2798247.html
Copyright © 2011-2022 走看看