AnimalPlayer
实例化
walkingPath
nextPointAry
targetTilePoint
lastPoint
nextPoint
speed
followers
loadBodyComplete里面有很多初始化,其中里面的initBody被复写
frameScript里面调用animalMove
stopWalking==changePath
thingutil.thingMove
changePath(清空数据)_nextPointAry.Clear();walkingPath.Clear();_nextPoint.Set(-1, -1);
walking(arraylist)
animalplayer.walking
isMove为false---clear---addRange---startMove(isMove=true)---nextPathPoint(true)
isMove为true---clear---addRange
nextPathPoint
hasNextPoint(true)->_lastPoint赋值为current,
->_speed.setPoint(lastPoint,_nextPoint)
->把当前像素点转换为格子,然后取出格子的属性值
->isStart->true->walkStart(null)
->isStart->false->walkGridStart(targetTilePoint = nextPoint)
hasNextPoint(false)->walkend
hasNextPoint
_nextPointAry为0 把walkingPath的数据复制给_nextPointAry,然后清空自己
_nextPointAry不为0 删一个值,然后从walking里面取一个值
_nextPoint = _nextPointAry[0]
walkend
setPosition(_nextPoint.x, _nextPoint.y);
_nextPoint.Set(-1, -1);
animalMove
isMove
isArrive->true->判断walkpath 和nextpoint ->walkGridEnd->nextPathPoint->onMove
isArrive->false->(onMove)
isArrive 是为了判断当前速度是否超过了current和next的距离,超过了就死循环找下一个点,找到合适为止
isArrive
return nextPoint==-1
return (_nextPoint - _currentPoint).sqrMagnitude < (_speed.speed * Time.deltaTime) * (_speed.speed * Time.deltaTime);
onMove
setPosition(_currentPoint.x + (float)_speed.xSpeed * Time.deltaTime, _currentPoint.y + (float)_speed.ySpeed * Time.deltaTime);
_speed.update(_currentPoint.x, _currentPoint.y);
walkGridEnd
_currentPoint.Set(_nextPoint.x, _nextPoint.y);
fightUpdate
updateSpeed(msg/100)
updateSpeed
speed.timeSpeed = msg/100
Speed
_speed = value * 3.5 ----- value = msg/100
_xSpeed = _speed * Math.Cos(_radians);
_ySpeed = _speed * Math.Sin(_radians);
speed 为一秒多少像素
算出当前点和下一点的x 和 y 弧度a,然后 每帧执行 sin(a)* speed * Time.deltaTime 的距离
服务端发来数据,打开animalmove循环
把数据存到一个链表里面,取出下一点,计算当前和下一点的弧度,用服务端发来的speed*sin(a)得出应该走的距离,
为了防止超出当前点和下一点的距离
animalmove循环里面寻找出最终合适的点,计算其弧度,得出最终每一帧需要走的距离
iFollower
pet被创建的时候会调用 owner.CallOutPet(pet); 此时pet的owner会被赋值
userplayer会有一个followerlist,每次移动会通知list调用iFollower的方法
onTargetGone--离开视野
onTargetMoved--移动
onTargetDead--死亡
Proto80400201
FightPlay.getInstance().playSkill(attackVO)
playSkill
fillSkillData--对attackVO进行补充
attacker.attack(attackVO);
attack
forupdate--强制播放动作
PlayAttackEffect--播放攻击特效
CheckSkillForwardMove--检查技能突进
OnAttack
doAttacked
doAttacked
EffectManager.getInstance().playAll(vo, SkillConst.ARROW);--远程的会计算怪物到角色距离,然后到达的时候让怪物播受伤
EffectManager.getInstance().playAll(vo, SkillConst.TARGET | SkillConst.TARGET_FOOT);--播普通特效
FrameTimerManager.getInstance().add((int)(vo.effect_attack_timing * 30), 1, onEffectAttacktiming);--对第一个受伤执行playAttacked
playAll
创建技能特效
playAttacked
for循环对所有受伤播放attacked
for循环对所有受伤执行em.playAll(vo, SkillConst.HIT);---受伤特效
attacked
ChangeShaderInHurt--受伤shader
isDead为true-----PlayDeadEffect
isDead为false-----受伤动作或者浮空动作
anData
return data
data
return data as anData
base.data = value
updateLife(anData.hp)
animal创建的时候传入给data的已经是anData
cancelSkill
设置为站立动作
lastFight
LastFightUtil.showLastFightSlowly();--Time.timeScale --Time.fixedDeltaTime
LastFightUtil.AttackAtKeyPoint(animal);--创建最后一击的特效--(thingplayer)
setPerformanceVisible
控制人物是否显示,gameworld每75帧跑一次
CanBeAttacked
return !isDead && data.canSelect && !anData.isInProtect;
IsAttacking
return animationControl != null && (actionState == AnConst.ATTACK || animationControl.CurActionState > 10000 || animationControl.IsTag("1"));
OnExitAnimation
if (nextAttackVO != null)
attack(nextAttackVO);
FrameTimerManager.getInstance().add(6, 1, SetSkillIsAttacking);--设置技能按钮
changeFightState
改变攻击状态