public ObjRetinue CreateRetinue(Scene _this, int dataId, ObjCharacter owner, Vector2 pos, Vector2 dir, int camp, int level = -1) { if (Table.GetNpcBase(dataId) == null) { Logger.Error("CreateRetinue retinue = {0},objId={1}", dataId, owner.ObjId); return(null); } var npc = new ObjRetinue(); npc.Init(_this.GenerateNextId(), dataId, owner); npc.SetPosition(pos.X, pos.Y); npc.SetDirection(dir); if (level > 0) { npc.SetLevel(level); npc.InitData(level); } else { npc.InitData(level); } npc.SetCamp(camp); _this.EnterScene(npc); return(npc); }
public void Tick(ObjRetinue _this, float delta) { ObjCharacter.GetImpl().Tick(_this, delta); if (0 == _this.mLogicTickCount % 10) { if (_this.Owner == null) { _this.Scene.LeaveScene(_this); return; } var rePos = _this.GetPosition(); var ownerPos = _this.Owner.GetPosition(); var distance = (ownerPos - rePos).LengthSquared(); if (distance > 64) { _this.EnterState(BehaviorState.Idle); _this.SetPosition(ownerPos); _this.SyncCharacterPostion(); } } }