Пример #1
0
        private void TryToCallPartner(ObjNPC npc, ObjCharacter enemy, float distSqr = 100)
        {
            try
            {
                if (enemy != null)
                {
                    foreach (ObjBase o in npc.Zone.EnumAllVisibleObj())
                    {
                        try
                        {
                            if (!(o is ObjNPC))
                            {
                                continue;
                            }

                            var obj = o as ObjNPC;

                            if (!obj.Active)
                            {
                                continue;
                            }

                            if (obj.CurrentState != BehaviorState.Idle)
                            {
                                continue;
                            }

                            if (obj.GetObjType() != ObjType.NPC)
                            {
                                continue;
                            }

                            if (!obj.IsVisibleTo(enemy))
                            {
                                continue;
                            }

                            if (obj.tbSceneNpc == null || npc.tbSceneNpc == null)
                            {
                                continue;
                            }

                            if (obj.tbSceneNpc.ChouHenGroupId != npc.tbSceneNpc.ChouHenGroupId)
                            {
                                continue;
                            }

                            if (obj.mCamp != npc.mCamp)
                            {
                                continue;
                            }

                            if ((obj.GetPosition() - enemy.GetPosition()).LengthSquared() > distSqr)
                            {
                                continue;
                            }

                            obj.EnterState(BehaviorState.Combat);
                            obj.PushHatre(enemy, 1);
                            obj.AddEnemy(enemy.ObjId);
                            enemy.AddEnemy(obj.ObjId);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch { }
        }