3 回答
TA贡献1817条经验 获得超6个赞
最好的方法是在顶级类上编写通用的getter方法,SkillEvent然后在special类中重写该方法。由于您似乎需要不同的类型,因此我认为您可以使用执行您在类内部进行参数化的方法的方法
这是您当前代码已发布的示例:
class SkillEvent {
float timestamp;
EventType type ;
public virtual void executeEvent(){ //handles the general case for the execute funciton
execute(timestamp);
}
}
class GrenadeSkillEvent : SkillEvent { //overriden to pass target point into event execution
Vector3 target_point;
public override void executeEvent(){
execute(target_point);
}
}
class BonusEvent : SkillEvent {
int bonus_health;
public override void executeEvent(){/overriden to pass bonus health into event
execute(bonus_health);
}
}
class TerrainEvent : SkillEvent {
GameObject obj;
public override void executeEvent(){//overriden to play animation before event is executed
animation(obj);
execute();
}
}
[ClientRpc]
RpcSendSkillEvent(SkillEvent event){
eventManager.ExecuteEvent(event);
}
ExecuteEvent(SkillEvent event){
event.executeEvent();
}
- 3 回答
- 0 关注
- 136 浏览
添加回答
举报