Exemplo n.º 1
0
        public override bool DoBeforeRouteCheck()
        {
            // Check if obj close
            if (LookForGameObjClose(_obj))
            {
                // We already at destination
                return(false);
            }

            // Check if obj has coordinates
            Parent.BaseCoord = NpcHelper.GetGameObjCoord(_obj, Parent.Lfs);
            if (Parent.BaseCoord == null)
            {
                throw new GameObjectCoordNotFound(_obj.Name);
            }

            // Check for other coordinates
            if (_obj.GetType().IsSubclassOf(typeof(NPC)))
            {
                NPC npc = (NPC)_obj;

                // Use current zone as a key
                if (npc.Coordinates.Count > 0)
                {
                    ZoneWp zwp = npc.Coordinates[Parent.Player.ZoneText];
                    if (zwp != null)
                    {
                        Parent.Vlist = zwp.List;
                    }
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        private void bwRouteNavigation_DoWork(object sender, DoWorkEventArgs e)
        {
            Waypoints wp = (Waypoints)e.Argument;

            NpcHelper.StartNavState(new NavigationState(wp, "test_run", wp.Name),
                                    ProcessManager.Player, "test_run");
        }
Exemplo n.º 3
0
    /// <summary>
    /// 获得场景中所有npc
    /// </summary>
    /// <returns></returns>
    public static List <MiniMapPointInfo> GetInstanceAllNpc(uint instance_id)
    {
        List <MiniMapPointInfo> map_point_infos = new List <MiniMapPointInfo>();
        var nep_data = xc.Dungeon.LevelManager.Instance.LoadLevelFileTemporary(SceneHelp.GetFirstStageId(instance_id));

        if (nep_data == null)
        {
            GameDebug.LogError("get nep_data failed,instance id: " + instance_id);
            return(map_point_infos);
        }

        Dictionary <int, Neptune.BaseGenericNode> monstersData = nep_data.GetData <Neptune.NPC>().Data;

        foreach (var item in monstersData)
        {
            if (item.Value is Neptune.NPC)
            {
                Neptune.NPC npc = item.Value as Neptune.NPC;
                //if (npc.SpawnDirectly)
                {
                    MiniMapPointInfo info = new MiniMapPointInfo();
                    info.Id        = npc.Id;
                    info.MapId     = instance_id;
                    info.ActorId   = NpcHelper.GetNpcActorId(npc.ExcelId);
                    info.Name      = RoleHelp.GetActorName(info.ActorId);
                    info.BlackName = info.Name;
                    info.Position  = npc.Position;
                    info.PointType = MiniMapPointType.Npc;
                    map_point_infos.Add(info);
                }
            }
        }
        return(map_point_infos);
    }
Exemplo n.º 4
0
        public bool Delete(IDbConnection connection, AllianceDataModel alliance)
        {
            if (alliance == null)
            {
                throw new NullReferenceException();
            }
            var confederation = NpcHelper.GetNpcByName(Npc.ConfederationName);

            if (alliance.Id == confederation.NpcAlliance.Id)
            {
                throw new NotImplementedException(nameof(confederation.NpcAlliance.Id));
            }
            var skagry = NpcHelper.GetNpcByName(Npc.SkagyName);

            if (alliance.Id == skagry.NpcAlliance.Id)
            {
                throw new NotImplementedException(nameof(skagry.NpcAlliance.Id));
            }


            var allianceId = alliance.Id;

            DisbandAlliance(connection, alliance.CreatorId, allianceId);
            _aRepo.Delete(connection, allianceId);

            return(_channelService.DeleteAllianceChannel(null, allianceId));
        }
Exemplo n.º 5
0
        private void LearnNpcSkills(NPC npc)
        {
            // Learn all skills
            string skill = cbServiceList.SelectedItem.ToString();

            NpcHelper.LearnSkills(npc, skill, "npc");
        }
        public void Init(IDbConnection connection)
        {
            var npces = NpcHelper.GetAllNpc();

            foreach (var npc in npces)
            {
                CreateNpc(connection, npc.Value);
            }
        }
        public void CreateMotherNpces(IDbConnection connection)
        {
            var npces = NpcHelper.GetAllNpc();

            foreach (var npc in npces.Select(i => i.Value.NpcMother))
            {
                CreateMotherNpc(connection, npc);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 家泳那边没有单个更新
 /// </summary>
 public void UpdateNpcState(CEventBaseArgs args)
 {
     if (IsEnable == false)
     {
         return;
     }
     foreach (var kv in mNpcListPointObjs)
     {
         uint state = NpcHelper.GetNpcTaskState(kv.Key);//npcId
         UpdateOneNpc(state, kv.Value);
     }
 }
Exemplo n.º 9
0
 private void BindTo(object sender, DoWorkEventArgs e)
 {
     try
     {
         GameObject obj = NpcHelper.FindGameObjByName(GetCurrentRow().NAME);
         NpcHelper.MoveToGameObj(obj, "test_bind");
         NpcHelper.BindToInn((NPC)obj, "test_bind");
     }
     catch (Exception ex)
     {
         ShowErrorMessage(ex);
     }
 }
Exemplo n.º 10
0
        private void btnMoveToNearest_Click(object sender, EventArgs e)
        {
            if ((int)btnMoveToNearest.Tag == 0)
            {
                if (!CheckInGame())
                {
                    return;
                }

                if (cbServiceList.SelectedItem == null)
                {
                    ShowErrorMessage("No services selected");
                    return;
                }

                // Find nearest class trainer
                try
                {
                    BotDataSet.ServiceTypesRow srv_row = (BotDataSet.ServiceTypesRow)
                                                             ((DataRowView)cbServiceList.SelectedItem).Row;

                    // Change button state
                    btnMoveToNearest.Tag  = 1;
                    btnMoveToNearest.Text = "Stop Moving";

                    NPC npc = NpcHelper.MoveInteractService(srv_row.NAME, "npc");

                    // Select found npc
                    if (npc != null)
                    {
                        SelectGameObj(npc);
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage(ex);
                }
                finally
                {
                    btnMoveToNearest.Enabled = true;
                }
            }
            else if ((int)btnMoveToNearest.Tag == 1)
            {
                ProcessManager.Player.StateMachine.GlobalState.Exit(ProcessManager.Player);

                // Change button state
                btnMoveToNearest.Text = "Move to Nearest";
                btnMoveToNearest.Tag  = 0;
            }
        }
Exemplo n.º 11
0
        internal void btnAddNPC_Click(object sender, EventArgs e)
        {
#if DEBUG
            //\\ TEST
            if (ProcessManager.Config.IsTest)
            {
                if ((ProcessManager.Config.Test == 1) &&
                    !ProcessManager.Player.HasTarget)
                {
                    // Target NPC
                    // string name = "Melithar Staghelm";
                    // string name = "Conservator Ilthalaine";
                    // string name = "Gilshalan Windwalker";
                    // string name = "Dellylah";
                    string name = "Innkeeper Keldamyr";
                    LuaHelper.TargetUnitByName(name);
                }
            }
#endif

            if (!CheckBeforeNpcTest())
            {
                return;
            }


            try
            {
                GameObject npc = NpcHelper.AddNpc("npc");
                if (npc != null)
                {
                    // Check for duplication
                    int idx = bsGameObjects.Find("NAME", npc.Name);
                    if (idx >= 0)
                    {
                        ((DataView)((DataRowView)bsGameObjects.Current).DataView).Delete(idx);
                    }
                    DataManager.AddGameObject(npc);
                    SelectGameObj(npc);
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Can't add current NPC. " + ex.Message);
            }
        }
Exemplo n.º 12
0
    public bool FireTouchEvent()
    {
        if (!mIsTouching)
        {
            return(false);
        }

        Actor localPlayer = Game.GetInstance().GetLocalPlayer();

        if (localPlayer != null && localPlayer.IsAttacking() == false)// 在释放技能时不能停止
        {
            localPlayer.Stop();
            localPlayer.MoveCtrl.TryWalkAlongStop();
        }

        if (TaskHelper.ProcessTouchTasksNpc(this) == false)      // 任务npc逻辑
        {
            if (MarryHelper.ProcessTouchMarryNpc(this) == false) // 结婚npc逻辑
            {
                NpcHelper.ProcessNpcFunction(this);
            }
        }

        TargetPathManager.Instance.StopPlayerAndReset(true, false);

        SetSelectEffect(true);
        //TurnToOriginalDir();

        bool isTurnToLocalPlayer = true;

        if (mDefine.Function == NpcDefine.EFunction.INTERACTION)
        {
            if (mDefine.FunctionParams[2] == "0")
            {
                isTurnToLocalPlayer = false;
            }
        }
        if (isTurnToLocalPlayer == true)
        {
            TurnToLocalPlayer();
        }

        return(true);
    }
Exemplo n.º 13
0
        public bool Delete(IDbConnection connection, int allianceId)
        {
            var confederation = NpcHelper.GetNpcByName(Npc.ConfederationName);

            if (allianceId == confederation.NpcAlliance.Id)
            {
                throw new NotImplementedException(nameof(confederation.NpcAlliance.Id));
            }
            var skagry = NpcHelper.GetNpcByName(Npc.SkagyName);

            if (allianceId == skagry.NpcAlliance.Id)
            {
                throw new NotImplementedException(nameof(skagry.NpcAlliance.Id));
            }

            var allaicne = GetAllianceById(connection, allianceId, true);

            return(Delete(connection, allaicne));
        }
Exemplo n.º 14
0
        private void MoveTo(object sender, DoWorkEventArgs e)
        {
            // For some bizzard reason executes multiple times
            if (e.Result != null)
            {
                Console.WriteLine("MoveTo again");
                return;
            }

            try
            {
                NpcHelper.MoveToGameObjByName(GetCurrentRow().NAME, "npc");
                e.Result = true;
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
                e.Result = false;
            }
        }
Exemplo n.º 15
0
        private void goToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Get selection
            DataGridViewSelectedRowCollection rows = dgWaypoints.SelectedRows;

            string err = null;

            if (rows.Count != 1)
            {
                err = "Impossible move to dest - ";
                if (rows.Count == 0)
                {
                    err += "Nothing selected";
                }
                else
                {
                    err += "Single selection required";
                }
            }

            DataGridViewRow row = rows[0];

            // Last record always empty
            if (row.IsNewRow)
            {
                err = "Destination is empty";
            }

            if (err != null)
            {
                ShowErrorMessage(err + " !!!");
                return;
            }


#if DEBUG
            if (ProcessManager.Player != null)
#endif
            // Move To
            NpcHelper.MoveToDest(MakeVector(row), "record");
        }
        /// <summary>
        ///  Не делает проверки планеты на текущее состояние.
        ///  Если планета уже имеет установленного владельца, проверку нужно делать перед методом
        /// В любом слае  отправляет запрос на обновление планеты, и извлечение альянса
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="planet"></param>
        /// <param name="newOwner"></param>
        /// <param name="allianceService"></param>
        public void UpdatePlanetOwner(IDbConnection connection, GDetailPlanetDataModel planet, int newOwner, IAllianceService allianceService)
        {
            var npc = NpcHelper.GetNpcByName(Npc.SkagyName);

            if (newOwner == npc.NpcUser.Id)
            {
                planet.AllianceId = npc.NpcAlliance.Id;
                planet.UserId     = newOwner;
                AddOrUpdate(connection, planet);
                return;
            }

            var allianceUser = allianceService.GetAllianceUserByUserId(connection, newOwner);

            if (planet.AllianceId != allianceUser.AllianceId)
            {
                planet.AllianceId = allianceUser.AllianceId;
            }
            planet.UserId = newOwner;
            AddOrUpdate(connection, planet);
        }
Exemplo n.º 17
0
        public void CreateNpcPoint()
        {
            var List = MiniMapHelp.GetInstanceAllNpc(m_CurSceneId);

            for (int i = 0; i < List.Count; i++)
            {
                var  info  = List[i];
                uint state = NpcHelper.GetNpcTaskState((uint)info.Id, m_CurSceneId);//npcId
                if (IsDisplayNpcByTaskState(state))
                {
                    var rect = GetItem(m_NpcPoint);
                    UpdateOneNpc(state, rect.gameObject);
                    Vector3 vect = new Vector3((info.Position.x - minX) / uiScalex, (info.Position.z - minY) / uiScaley, 0);
                    rect.localPosition = vect;
                    Text nameText = UIHelper.FindChild(rect.gameObject, "NameText").GetComponent <Text>();
                    nameText.text = info.BlackName;
                    Button btn = rect.GetComponent <Button>();
                    btn.onClick.RemoveAllListeners();
                    btn.onClick.AddListener(() => { OnClickNpcPoint(info); });
                    mNpcListPointObjs.Add((uint)info.Id, rect.gameObject);
                }
            }
        }
Exemplo n.º 18
0
    public void InitNPCData(Neptune.NPC data)
    {
        mNpcData         = data;
        gameObject.layer = LayerMask.NameToLayer("Npc");
        CanClickNPC      = true;

#if UNITY_EDITOR
        if (IsEscortNPC)
        {
            gameObject.name = "Npc_Escort_" + data.Id + "_" + data.ExcelId + "_" + ActorId + "_" + UID.obj_idx;
        }
        else
        {
            gameObject.name = "Npc_" + data.Id + "_" + data.ExcelId + "_" + ActorId + "_" + UID.obj_idx;
        }
#endif

        Stand();

        float radius = NpcHelper.MakeNpcDefine((uint)NpcData.ExcelId).Radius;
        mTouchSqrRadius = radius * radius;

        mOriginalDir = Trans.forward;
    }
Exemplo n.º 19
0
        public StarInfoOut GetStarInfo(IDbConnection connection, int starId)
        {
            var system = _systemService.GetSystem(connection, starId, i => i);

            if (system == null)
            {
                return(null);
            }

            var galaxyName = _galaxyService.GetGalaxyById(connection, system.GalaxyId, i => i.NativeName);

            if (galaxyName == null)
            {
                return(null);
            }

            var sectorName = _gSectorsService.GetById(connection, system.SectorId, i => i.NativeName);

            if (sectorName == null)
            {
                return(null);
            }

            var geometryStar = _systemService.GetGeometryStarById(connection, starId, i => i);

            if (geometryStar == null)
            {
                return(null);
            }

            var detailSystem = _systemService.GetDetailSystemBySystemId(connection, starId);

            if (detailSystem == null)
            {
                return(null);
            }

            var planetCountsInSystem = _gDetailPlanetService.GetPlanetCountInSystem(connection, starId);

            if (planetCountsInSystem == 0)
            {
                return(null);
            }


            var npcSkagry       = NpcHelper.GetNpcByName(Npc.SkagyName);
            var npcConfederaion = NpcHelper.GetNpcByName(Npc.ConfederationName);

            var owner        = npcSkagry.NpcUser.Nickname;
            var allianceName = npcSkagry.NpcAlliance.Name;


            if (detailSystem.AllianceId == npcConfederaion.NpcAlliance.Id)
            {
                owner        = npcConfederaion.NpcUser.Nickname;
                allianceName = npcConfederaion.NpcAlliance.Name;
            }
            if (detailSystem.UserName != null && detailSystem.UserName != npcSkagry.NpcUser.Nickname)
            {
                owner = detailSystem.UserName;
                if (detailSystem.AllianceId == npcConfederaion.NpcAlliance.Id)
                {
                    allianceName = npcConfederaion.NpcAlliance.Name;
                }
                else
                {
                    allianceName = _allianceService.GetAllianceById(connection, detailSystem.AllianceId, i => i.Name);
                }
            }

            var systemType = _gameTypeService.GetGGameType(connection, geometryStar.TypeId);
            var starInfo   = new StarInfoOut
            {
                GalaxyId             = system.GalaxyId,
                GalaxyName           = galaxyName,
                SectorId             = system.SectorId,
                SectorName           = sectorName,
                SystemId             = system.Id,
                SystemName           = detailSystem.Name,
                Id                   = system.Id,
                NativeName           = detailSystem.Name,
                TextureTypeId        = geometryStar.TextureTypeId,
                Owner                = owner,
                Bonus                = detailSystem.EnergyBonus,
                TypeNativeName       = systemType.Type,
                SubtypeNativeName    = systemType.SubType,
                SubtypeTranslateName = systemType.SubType,
                Description          =
                    L10N.ExecuteTranslateNameOrDescr(detailSystem.Description, false, L10N.GetCurrentCulture()),
                AllianceName = allianceName,
                ChildCount   = planetCountsInSystem,
                SpriteImages = new SpriteImages().StarImages(systemType.SubType, geometryStar.TextureTypeId)
            };

            starInfo.SetComplexButtonView();

            return(starInfo);
        }
        private bool CreatePlanetDetails(IDbConnection connection)
        {
            var planets       = _getPlanetCollection(connection);
            var npc           = NpcHelper.GetNpcByName(Npc.SkagyName);
            var detailPlanets = new List <GDetailPlanetDataModel>();

            foreach (var planet in planets)
            {
                var translate = new L10N();
                translate.InitializeField();

                var type          = _gameTypeService.GetGGameType(connection, planet.GameTypeId);
                var typeTranslate = type.Description;
                translate.En.Description = "Unique Description En " + planet.NativeName + " " + " TypeDescription: " +
                                           typeTranslate.En.Description;

                translate.Es.Description = "Unique Description Es " + planet.NativeName + " " + " TypeDescription: " +
                                           typeTranslate.Es.Description;
                translate.Ru.Description = "Unique Description Ru " + planet.NativeName + " " + " TypeDescription: " +
                                           typeTranslate.Ru.Description;
                translate.En.Name = translate.Es.Name = translate.Ru.Name = planet.NativeName;


                var detailPlanet = new GDetailPlanetDataModel
                {
                    Id           = planet.Id,
                    UserId       = npc.NpcUser.Id,
                    AllianceId   = npc.NpcAlliance.Id,
                    Name         = planet.NativeName,
                    Description  = translate,
                    DangerLevel  = 1,
                    LastActive   = DateTime.UtcNow,
                    MoonCount    = GetMoonCount(planet.SystemPosition),
                    UnitProgress = new Dictionary <UnitType, TurnedUnit>()
                };

                _iOwnProgressInitializer.SetInitialPlanetBuilds(detailPlanet, npc.NpcUser.Id);
                _iOwnProgressInitializer.SetInitialHangarAndResource(connection, detailPlanet);

                detailPlanets.Add(detailPlanet);
            }

            #region for  Delete

            //for (int p = 0; p < planets.Count; p++)
            //{

            //    var planet = planets[p];
            //    var system = detailSystems.First(i => i.Id == planet.SystemId);
            //    var systemName = system.Name;
            //    //var planetName = systemName + "-"+ planet.SystemPosition;


            //    var translate = new L10N();
            //    translate.InitializeField();

            //    var type = await _gameTypeService.GetGGameTypeAsync(planet.GameTypeId);
            //    var typeTranslate = type.Description;
            //    translate.En.Description = "Unique Description En " + planet.NativeName + " " + " TypeDescription: " +
            //                               typeTranslate.En.Description;

            //    translate.Es.Description = "Unique Description Es " + planet.NativeName + " " + " TypeDescription: " +
            //                               typeTranslate.Es.Description;
            //    translate.Ru.Description = "Unique Description Ru " + planet.NativeName + " " + " TypeDescription: " +
            //                               typeTranslate.Ru.Description;
            //    translate.En.Name = translate.Es.Name = translate.Ru.Name = planet.NativeName;


            //    var detailPlanet = new GDetailPlanetDataModel
            //    {
            //        Id = planet.Id,
            //        UserId = npc.NpcUser.Id,
            //        AllianceId = npc.NpcAlliance.Id,
            //        Name = planet.NativeName,
            //        Description = translate,
            //        DangerLevel = (byte)Rand.Next(0, 10),
            //        LastActive = DateTime.UtcNow,
            //        MoonCount = GetMoonCount(planet.SystemPosition)

            //    };

            //    _iOwnProgressInitializer.SetInitialPlanetBuilds(detailPlanet, npc.NpcUser.Id);
            //    _iOwnProgressInitializer.SetInitialHangarAndResource(detailPlanet);

            //    detailPlanets.Add(detailPlanet);
            //}

            #endregion

            var suc = _gDetailPlanetService.AddOrUpdateDetailPlanetList(connection, detailPlanets).Any();
            return(true);
        }
Exemplo n.º 21
0
        protected override void DoExecute(WowPlayer player)
        {
            try
            {
                if (q.State == _start_state)
                {
                    obj = QuestHelper.FindQuestGameObj(req, q, lfs);
                }
                else if (q.State == _end_state)
                {
                    Finish(player);
                }
                else
                {
                    switch (q.State)
                    {
                    case QuestStates.OBJ_FOUND:
                        Vector3D dest = NpcHelper.GetGameObjCoord(obj, lfs);

                        // Switch to Travel State
                        string msg = "Moving to quest " +
                                     req.NpcDestText + " " + obj.Name;
                        Log(lfs, msg + " ...");
                        NavigationState ns = new NavigationState(dest, lfs, msg);

                        ns.Finished += SetQuestStateReached;
                        CallChangeStateEvent(player, ns, true, false);

                        q.State = QuestStates.MOVING_TO_OBJ;
                        break;

                    case QuestStates.MOVING_TO_OBJ:
                        // Do nothing
                        break;

                    // Keep it for now but works for NPC only
                    case QuestStates.OBJ_REACHED:
                        // Target game object
                        NpcHelper.TargetGameObj(obj, lfs);
                        q.State = QuestStates.OBJ_TARGETED;
                        break;

                    case QuestStates.OBJ_TARGETED:
                        QuestHelper.SelectGameObjQuest(req, obj, q, lfs);
                        break;

                    case QuestStates.SELECTED:
                        QuestHelper.DoActionEx(req, q, lfs);
                        break;

                    default:
                        throw new QuestSkipException("Unknown quest state: " +
                                                     Enum.GetName(typeof(QuestStates), q.State));
                    }
                }
            }
            catch // For now skip quest on any exception
            {
                SkipQuest(player);
            }
        }
Exemplo n.º 22
0
        public void RunTaskItem(IDbConnection connection, int taskId)
        {
            if (taskId == 0)
            {
                return;
            }
            var taskItem = _uTaskService.GetByTaskId(connection, taskId, true);

            if (taskItem == null)
            {
                _demonLog.CrateAndSave("UserTaskDataModel", "TaskRunner.RunTaskItem.taskItemIsNull", new { TaskId = taskId }, taskId);

                return;
            }

            if (taskItem.TaskEnd)
            {
                return;
            }
            lock (_runTaskItemLocker)
            {
                var currUtcTime = DateTime.UtcNow;
                var curTime     = UnixTime.ToTimestamp(currUtcTime);
                var endTime     = taskItem.DateActivate + taskItem.Duration;
                var timers      = TimerExecutor.GetTaskTimersByTaskId(taskItem.Id);
                if (timers.Count > 1)
                {
                    _demonLog.CrateAndSave("UserTaskDataModel", "TaskRunner.RunTaskItem.multipleTimers_", new { TaskId = taskId }, taskId);
                    return;
                }
                var timer = timers.FirstOrDefault();
                if (timer == null)
                {
                    var delay = endTime - curTime;
                    if (delay > 0)
                    {
                        _onUserTaskCreated(delay, taskItem.Id, taskItem.SourceUserId, taskItem.TargetPlanetId);
                        return;
                    }
                }
                else if (!timer.InProgress || timer.IsDisposed)
                {
                    return;
                }

                taskItem = _uTaskService.SetUpdateInProgress(connection, taskItem);

                #region Body

                try
                {
                    var targetPlanetId  = taskItem.TargetPlanetId;
                    var targetPlanetSrc = _gDetailPlanetService.GetPlanet(connection, targetPlanetId);

                    var defenderUser    = _gameUserService.GetGameUser(connection, targetPlanetSrc.UserId);
                    var defendorPremium = _storeService.GetPremiumWorkModel(connection, defenderUser.Id);
                    var defendorPlanet  = _planetRunner.RunSinglePlanet(connection, targetPlanetSrc, defendorPremium, _gDetailPlanetService);


                    //result.TimeOver = true;
                    //var user = taskItem.user;
                    UserDataModel sourceUser = null;
                    var           npc        = NpcHelper.GetNpcByName(Npc.SkagyName);
                    if (taskItem.SourceUserId == defenderUser.Id)
                    {
                        taskItem.IsAtack    = false;
                        taskItem.IsTransfer = true;
                        sourceUser          = defenderUser;
                    }
                    else
                    {
                        taskItem.IsAtack    = true;
                        taskItem.IsTransfer = false;
                        if (taskItem.SourceUserId == npc.NpcUser.Id)
                        {
                            sourceUser = npc.NpcUser;
                        }
                        else
                        {
                            sourceUser = _gameUserService.GetGameUser(connection, taskItem.SourceUserId);
                        }
                    }

                    #region IsAtack

                    if (taskItem.IsAtack)
                    {
                        var atackModel = new TmpAtackModel
                        {
                            TaskItem   = taskItem,
                            SourceUser = new TmpAtackItem
                            {
                                User = sourceUser
                            },
                            DefendorUser = new TmpAtackItem
                            {
                                User    = defenderUser,
                                Premium = defendorPremium
                            },
                            DefendorPlanet = defendorPlanet,
                            Npc            = npc,
                            BattleTime     = curTime,
                            BattleDtTime   = currUtcTime
                        };
                        _atack(connection, atackModel);
                        var ti     = atackModel.TaskItem.CloneDeep();
                        var report = atackModel.ReportDataModel.CloneDeep();
                        int?newTotalWinnerUserCc = atackModel.NewTotalWinnerUserCc;

                        Task.Factory.StartNew(() => { _uTaskService.NotyfyTaskFinished(ti, report, newTotalWinnerUserCc); });

                        return;
                    }

                    #endregion

                    #region IsTransfer

                    defendorPlanet.Hangar = UnitList.CalculateNewUnits(taskItem.SourceFleet, defendorPlanet.Hangar, true);
                    _gDetailPlanetService.AddOrUpdate(connection, defendorPlanet);
                    taskItem.TaskEnd = true;
                    _uTaskService.UnlockUpdateInProgress(connection, taskItem.Id);
                    var updatedTask = _uTaskService.AddOrUpdate(connection, taskItem);

                    Task.Factory.StartNew(() => { _uTaskService.NotyfyTaskFinished(updatedTask); });



                    #endregion
                }
                catch (Exception e)
                {
                    _demonLog.CrateAndSave("UserTaskDataModel", "TaskRunner.RunTaskItem.ExceptionTaskItemData", taskItem, taskItem.Id);
                    _demonLog.CrateAndSave("Exception", "TaskRunner.RunTaskItem.ExceptionData", e, taskItem.Id);
                    _uTaskService.UnlockUpdateInProgress(connection, taskItem.Id);
                    throw;
                }
            }

            #endregion
        }
Exemplo n.º 23
0
        public PlanetInfoOut GetPlanetInfo(IDbConnection connection, int planetId, int currentUserId)
        {
            var planetGeometry = _geometryPlanetService.GetGeometryPlanetById(connection, planetId);

            if (planetGeometry == null)
            {
                return(null);
            }

            var planetType = _gameTypeService.GetGGameType(connection, planetGeometry.TypeId);

            if (planetType == null)
            {
                return(null);
            }


            var galaxyName = _galaxyService.GetGalaxyById(connection, planetGeometry.GalaxyId, i => i.NativeName);

            if (galaxyName == null)
            {
                return(null);
            }

            var sectorName = _gSectorsService.GetById(connection, planetGeometry.SectorId, i => i.NativeName);

            if (sectorName == null)
            {
                return(null);
            }

            var systemName = _systemService.GetDetailSystemBySystemId(connection, planetGeometry.SystemId, i => i.Name);

            if (systemName == null)
            {
                return(null);
            }


            var planetDetail = _gDetailPlanetService.GetPlanet(connection, planetId);

            if (planetDetail == null)
            {
                return(null);
            }


            var skagry             = NpcHelper.GetNpcByName(Npc.SkagyName);
            var userName           = skagry.NpcUser.Nickname;
            var planetAllianceName = skagry.NpcAlliance.Name;

            if (planetDetail.UserId != skagry.NpcUser.Id)
            {
                userName           = _gameUserService.GetGameUser(connection, planetDetail.UserId, i => i.Nickname);
                planetAllianceName = _allianceService.GetAllianceById(connection, planetDetail.AllianceId, i => i.Name);
            }
            var isCurrentUser = currentUserId == planetDetail.UserId;


            var planetInfo = new PlanetInfoOut
            {
                GalaxyId                 = planetGeometry.GalaxyId,
                GalaxyName               = galaxyName,
                SectorId                 = planetGeometry.SectorId,
                SectorName               = sectorName,
                SystemId                 = planetGeometry.SystemId,
                SystemName               = systemName,
                Id                       = planetGeometry.Id,
                NativeName               = planetDetail.Name,
                TextureTypeId            = planetGeometry.TextureTypeId,
                Owner                    = userName,
                LastActive               = planetDetail.LastActive,
                PlanetReferToCurrentUser = isCurrentUser,
                TypeNativeName           = planetType.Type,
                SubtypeNativeName        = planetType.SubType,
                Description              =
                    L10N.ExecuteTranslateNameOrDescr(planetDetail.Description, false, L10N.GetCurrentCulture()),
                AllianceName = planetAllianceName,
                ChildCount   = planetDetail.MoonCount,
                SpriteImages = new SpriteImages().PlanetImages(planetType.SubType, planetGeometry.TextureTypeId)
            };


            if (string.Equals(planetInfo.SubtypeNativeName, PlanetoidSubTypes.Earth.ToString(),
                              StringComparison.CurrentCultureIgnoreCase))
            {
                planetInfo.SubtypeTranslateName = "translate Earth";
            }
            else if (string.Equals(planetInfo.SubtypeNativeName, PlanetoidSubTypes.Gas.ToString(),
                                   StringComparison.CurrentCultureIgnoreCase))
            {
                planetInfo.SubtypeTranslateName = "translate Gas Gigant";
            }
            else if (string.Equals(planetInfo.SubtypeNativeName, PlanetoidSubTypes.IceGas.ToString(),
                                   StringComparison.CurrentCultureIgnoreCase))
            {
                planetInfo.SubtypeTranslateName = "translate Ice";
            }
            planetInfo.SetComplexButtonView();
            return(planetInfo);
        }