Пример #1
0
        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);
        }
Пример #2
0
 public void Destroy(ObjRetinue _this)
 {
     if (null != _this.Owner)
     {
         _this.Owner.mRetinues.Remove(_this);
     }
     ObjNPC.GetImpl().Destroy(_this);
 }
Пример #3
0
 /// <summary>
 ///     消失
 /// </summary>
 public void Disapeare(ObjRetinue _this)
 {
     if (null != _this.Owner)
     {
         _this.Owner.mRetinues.Remove(_this);
     }
     ObjNPC.GetImpl().Disapeare(_this);
 }
Пример #4
0
        /// <summary>
        ///     输出成一个objdata用于客户端创建
        /// </summary>
        /// <returns></returns>
        public ObjData DumpObjData(ObjRetinue _this, ReasonType reason)
        {
            var data = ObjCharacter.GetImpl().DumpObjData(_this, reason);

            data.Owner = new Uint64Array();
            data.Owner.Items.Add(_this.Owner.ObjId);
            return(data);
        }
Пример #5
0
 /// <summary>
 ///     死亡时
 /// </summary>
 /// <param name="_this"></param>
 /// <param name="characterId"></param>
 /// <param name="viewTime"></param>
 /// <param name="damage"></param>
 public void OnDie(ObjRetinue _this, ulong characterId, int viewTime, int damage = 0)
 {
     _this.IsSendDie = true;
     ObjNPC.GetImpl().OnDie(_this, characterId, viewTime, damage);
     if (_this.Buff != null && _this.Owner != null)
     {
         _this.Owner.DeleteBuff(_this.Buff, eCleanBuffType.RetinueDie);
     }
 }
Пример #6
0
 public bool InitSkill(ObjRetinue _this, int level)
 {
     foreach (var skillId in _this.TableCharacter.InitSkill)
     {
         if (-1 != skillId)
         {
             _this.Skill.AddSkill(skillId, level, eAddskillType.InitSkillObjRetinue);
         }
     }
     return(true);
 }
Пример #7
0
        public void AddEnemy(ObjRetinue _this, ulong objId)
        {
            if (objId == _this.ObjId || objId == _this.Owner.ObjId)
            {
                return;
            }

            if (!_this.EnemyList.Contains(objId))
            {
                _this.EnemyList.Add(objId);
            }
        }
Пример #8
0
        public virtual void OnOwnerReceiveDamage(ObjRetinue _this, ObjCharacter enemy, int damage)
        {
            if (null == enemy)
            {
                return;
            }

            if (enemy.ObjId == _this.ObjId || enemy.ObjId == _this.Owner.ObjId)
            {
                return;
            }

            _this.AddEnemy(enemy.ObjId);
            _this.EnterState(BehaviorState.Combat);
        }
Пример #9
0
        public virtual void OnOwnerMakeDamage(ObjRetinue _this, ObjCharacter target, int damage)
        {
            if (null == target)
            {
                return;
            }

            if (target.ObjId == _this.ObjId || target.ObjId == _this.Owner.ObjId)
            {
                return;
            }

            _this.AddEnemy(target.ObjId);
            _this.EnterState(BehaviorState.Combat);
        }
Пример #10
0
 /// <summary>
 ///     初始化
 /// </summary>
 /// <param name="_this"></param>
 /// <param name="id"></param>
 /// <param name="dataId"></param>
 /// <param name="owner"></param>
 public void Init(ObjRetinue _this, ulong id, int dataId, ObjCharacter owner)
 {
     _this.mObjId     = id;
     _this.mTypeId    = dataId;
     _this.Owner      = owner;
     _this.mDirection = new Vector2(1, 0);
     _this.BuffList   = new BuffList();
     _this.BuffList.InitByBase(_this);
     _this.Attr  = new FightAttr(_this);
     _this.Skill = new SkillManager(_this);
     //InitTableData();
     //InitEquip();
     //InitSkill();
     //InitBuff();
     //InitAttr();
     //base.Init(id, dataId);
 }
Пример #11
0
        public void InitData(ObjRetinue _this, int level)
        {
            _this.InitTableData(level);
            _this.InitEquip(level);
            _this.InitSkill(level);
            _this.InitBuff(level);
            _this.InitAttr(level);

            _this.Script = NPCScriptRegister.CreateScriptInstance(_this.TableNpc.AIID);

            //mNextAction = DateTime.Now.AddSeconds(MyRandom.Random(MIN_PATROL_TIME, MAX_PATROL_TIME));

            if (null != _this.TableNpc && _this.TableNpc.HeartRate > 0)
            {
                _this.mAiTickSeconds = Math.Max(ObjNPC.MIN_AI_TICK_SECOND, _this.TableNpc.HeartRate * 0.001f);
                _this.m_AITimer      = SceneServerControl.Timer.CreateTrigger(DateTime.Now.AddSeconds(_this.mAiTickSeconds),
                                                                              () => { _this.Tick_AI(); }, (int)(_this.mAiTickSeconds * 1000));
            }
        }
Пример #12
0
        public ObjCharacter GetEnemyCharacter(ObjRetinue retinue)
        {
            //优先寻找我上次的攻击目标
            var enemy = retinue.Scene.FindCharacter(LastTargetId);
            var pos   = retinue.Owner.GetPosition();

            if (enemy != null && enemy.Active && !enemy.IsDead())
            {
                if ((enemy.GetPosition() - pos).LengthSquared() < 55)
                {
                    return(enemy);
                }
            }
            //优先寻找玩家的当前敌人
            enemy = retinue.Owner.Skill.EnemyTarget;
            if (enemy != null && enemy.Active && !enemy.IsDead())
            {
                if ((enemy.GetPosition() - pos).LengthSquared() < 55)
                {
                    return(enemy);
                }
            }
            //优先攻击攻击玩家的敌人
            enemy = retinue.Scene.FindCharacter(retinue.Owner.LastEnemyId);
            if (enemy != null && enemy.Active && !enemy.IsDead())
            {
                if ((enemy.GetPosition() - pos).LengthSquared() < 55)
                {
                    return(enemy);
                }
            }
            //优先攻击攻击自己的敌人
            enemy = retinue.Scene.FindCharacter(retinue.LastEnemyId);
            if (enemy != null && enemy.Active && !enemy.IsDead())
            {
                if ((enemy.GetPosition() - pos).LengthSquared() < 55)
                {
                    return(enemy);
                }
            }
            return(null);
        }
Пример #13
0
        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();
                }
            }
        }
Пример #14
0
 /// <summary>
 ///     获得等级,NPC不走属性那套,直接用表格的
 /// </summary>
 /// <returns></returns>
 public int GetLevel(ObjRetinue _this)
 {
     return(_this.Attr.GetDataValue(eAttributeType.Level));
 }
Пример #15
0
 /// <summary>
 ///     重新刷出(注意和复活的区别)
 /// </summary>
 public void Respawn(ObjRetinue _this)
 {
     ObjNPC.GetImpl().Respawn(_this);
 }
Пример #16
0
 /// <summary>
 ///     复活
 /// </summary>
 public void Relive(ObjRetinue _this, bool byItem = false)
 {
     ObjNPC.GetImpl().Relive(_this, byItem);
 }
Пример #17
0
 public bool InitAttr(ObjRetinue _this, int level)
 {
     _this.Attr.InitAttributesAll();
     _this.Attr.InitAttributessAllEx(_this.Owner.Attr.mMonsterAttr);
     return(true);
 }