Inheritance: IComponent
Example #1
0
    private void OnMouseUpAsButton()
    {
        if (selected == null)
        {
            selected = this;
            gameObject.GetComponent <MeshRenderer>().material.color = Color.red;
            detailCamera.transform.position = linkedComponent.transform.position + new Vector3(0, 0, -60);
            detailCamera.enabled            = true;
        }
        else if (selected == this)
        {
            selected = null;
            gameObject.GetComponent <MeshRenderer>().material.color = Color.yellow;
            detailCamera.enabled = false;
        }
        else
        {
            selected.GetComponent <MeshRenderer>().material.color = selected.getColorStart();
            selected = this;
            gameObject.GetComponent <MeshRenderer>().material.color = Color.red;
            detailCamera.transform.position = linkedComponent.transform.position + new Vector3(0, 0, -60);
        }

        // load tracking scene
        SceneManager.LoadScene("SimpleModelTrackerExample");
    }
Example #2
0
        public static void UpdateUnitList(this Trigger self)
        {
            ListComponent <long> deleteList = ListComponent <long> .Create();

            DUnitComponent dUnitComponent = self.Domain.GetComponent <DUnitComponent>();

            for (int i = 0; i < self.UnitList.List.Count; i++)
            {
                DUnit unit = dUnitComponent.Get(self.UnitList.List[i]);
                if (unit == null)
                {
                    deleteList.List.Add(unit.Id);
                    continue;
                }

                if (unit.GetComponent <UnitStateComponent>().UnitState == (int)UnitState.Death)
                {
                    deleteList.List.Add(unit.Id);
                }
            }

            for (int i = 0; i < deleteList.List.Count; i++)
            {
                self.UnitList.List.Remove(deleteList.List[i]);
            }
            deleteList.List.Clear();
        }
 protected void ibtnEdit_Click(object sender, EventArgs e)
 {
     if (IsChallengeFiles)
     {
         LinkButton ee         = (LinkButton)sender;
         string     documentId = (string)ee.CommandArgument;
         DocumentId                 = new Guid(documentId);
         challengeFileComponent     = new ChallengeFileComponent(new Guid(documentId));
         WizardFile.ActiveStepIndex = 1;
         txtFileName.Text           = challengeFileComponent.ChallengeFile.ObjectName;
         lblExtension.Text          = challengeFileComponent.ChallengeFile.ObjectExtension;
         var list = ListComponent.GetListPerCategory("ChallengeFile", Thread.CurrentThread.CurrentCulture.Name).FirstOrDefault(a => a.Label == challengeFileComponent.ChallengeFile.ObjectType);
         ddCategory.SelectedValue = list.Key;
     }
     else
     {
         LinkButton ee         = (LinkButton)sender;
         string     documentId = (string)ee.CommandArgument;
         DocumentId                 = new Guid(documentId);
         documentComponent          = new DocumentComponent(new Guid(documentId));
         WizardFile.ActiveStepIndex = 1;
         ddCategory.SelectedValue   = documentComponent.Document.Category;
         txtTitle.Text              = documentComponent.Document.Title;
         txtFileName.Text           = documentComponent.Document.Name;
         lblExtension.Text          = documentComponent.Document.FileType;
         txtDescription.Text        = documentComponent.Document.Description;
         rdbScope.SelectedValue     = documentComponent.Document.Scope;
     }
     UpdateFile.Visible = true;
     CreateFile.Visible = false;
 }
        public ActionResult RegisterNewBuyer(BuyerRegistrationViewModel postModel)
        {
            if (ModelState.IsValid)
            {
                Mapper.CreateMap <BuyerRegistrationViewModel, Buyer>();
                Mapper.CreateMap <BuyerRegistrationViewModel, User>();
                Buyer buyer = Mapper.Map <BuyerRegistrationViewModel, Buyer>(postModel);
                User  user  = Mapper.Map <BuyerRegistrationViewModel, User>(postModel);

                UserComponent     userComponent = new UserComponent();
                ValidationResults vResult       = userComponent.CreateUser(user);
                postModel.ValidationResult = vResult;
                if (vResult.Success == true)
                {
                    BuyerComponent buyerComponent = new BuyerComponent();
                    vResult = buyerComponent.RegisterNewBuyer(buyer);
                    postModel.ValidationResult = vResult;
                }
            }
            else
            {
                ListComponent lstComponent = new ListComponent();
                postModel.Countries = lstComponent.GetListItemsById("Country");
                postModel.Cities    = lstComponent.GetListItemsById("City");
                postModel.AreBothAddressSameOptions = lstComponent.GetListItemsById("YesOrNo");
            }
            return(View("RegisterNewBuyer", postModel));
        }
Example #5
0
        // 场景切换协程
        public static async ETTask SceneChangeTo(Scene zoneScene, string sceneName, long sceneInstanceId)
        {
            // zoneScene.RemoveComponent<AIComponent>();
            zoneScene.AddComponent <KeyCodeComponent>();
            CurrentScenesComponent currentScenesComponent = zoneScene.GetComponent <CurrentScenesComponent>();

            currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
            Scene currentScene = SceneFactory.CreateCurrentScene(sceneInstanceId, zoneScene.Zone, sceneName, currentScenesComponent);

            currentScene.AddComponent <UnitComponent>();
            currentScene.AddComponent <AOISceneComponent, int>(6);
            // 可以订阅这个事件中创建Loading界面
            using (ListComponent <ETTask> tasks = ListComponent <ETTask> .Create())
            {
                tasks.Add(WaitChangeScene(zoneScene, sceneName)); //等收到消息并且地图创建完成
                tasks.Add(WaitCreateMyUnit(zoneScene));           // 等待CreateMyUnit的消息
                await ETTaskHelper.WaitAll(tasks);
            }
            M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;

            UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);
            // zoneScene.AddComponent<AIComponent,int>(1);

            await Game.EventSystem.PublishAsync(new EventType.SceneChangeFinish()
            {
                ZoneScene = zoneScene, CurrentScene = currentScene
            });

            // 通知等待场景切换的协程
            zoneScene.GetComponent <ObjectWait>().Notify(new WaitType.Wait_SceneChangeFinish());
        }
Example #6
0
        public Entity AddList(System.Collections.Generic.List <string> newList)
        {
            var component = new ListComponent();

            component.list = newList;
            return(AddList(component));
        }
        private JsonResult GetCityList(string Country)
        {
            ListComponent lstComponent = new ListComponent();
            var           cities       = lstComponent.GetListItemsById(Country);

            return(Json(cities, JsonRequestBehavior.AllowGet));
        }
Example #8
0
 public void changeSelection(ListComponent selected)
 {
     if (activeComponent != null)
     {
         activeComponent.SetState(false);
     }
     activeComponent = selected;
     activeComponent.SetState(true);
 }
Example #9
0
            public static ListComponent Read(BinaryReader br)
            {
                ListComponent ret = new ListComponent();

                ret.Data        = br.ReadStructures <UInt32>(5).ToArray();
                ret.Wrap        = br.ReadByte();
                ret.Orientation = br.ReadByte();
                ret.Padding     = br.ReadBytes(2);
                return(ret);
            }
Example #10
0
        public ListComponent GetListObject(int Id)
        {
            ListComponent listComponent = null;

            if (objects.ContainsKey(Id))
            {
                listComponent = objects[Id];
            }
            return(listComponent);
        }
        public ActionResult RegisterNewBuyerGet()
        {
            var           viewModel    = new BuyerRegistrationViewModel();
            ListComponent lstComponent = new ListComponent();

            viewModel.Countries = lstComponent.GetListItemsById("Country");
            viewModel.Cities    = lstComponent.GetListItemsById("City");
            viewModel.AreBothAddressSameOptions = lstComponent.GetListItemsById("YesOrNo");
            return(View("RegisterNewBuyer", viewModel));
        }
Example #12
0
 //---------------------------------------------------------------------
 public void _releaseAllComponent()
 {
     ListComponent.Reverse();
     foreach (var i in ListComponent)
     {
         i.release();
         i.Entity    = null;
         i.EntityMgr = null;
     }
     ListComponent.Reverse();
 }
Example #13
0
 protected string GetTextCategory(string key)
 {
     if (IsChallengeFiles)
     {
         return(ListComponent.GetLabelFromListKey("ChallengeFile", System.Threading.Thread.CurrentThread.CurrentCulture.Name, key));
     }
     else
     {
         return(ListComponent.GetLabelFromListKey("FileCategory", System.Threading.Thread.CurrentThread.CurrentCulture.Name, key));
     }
 }
 private void DestroyActComponent(bool onlyDestory = false)
 {
     for (int i = 0; i < ListComponent.Count; ++i)
     {
         ListComponent[i].OnDestroy();
     }
     if (!onlyDestory)
     {
         ListComponent.Clear();
     }
 }
Example #15
0
 public void changeSelection(TrackingAssembly selected)
 {
     if (activeComponent != null)
     {
         activeComponent.SetState(false);
     }
     activeComponent = null;
     selected.gameObject.SetActive(true);
     selected.transform.rotation = Quaternion.identity;
     selected.GetComponent <VLModelTrackableBehaviour>().UpdateTransformation(true);
 }
 public Entity ReplaceList(System.Collections.Generic.List<string> newList)
 {
     ListComponent component;
     if (hasList) {
         WillRemoveComponent(ComponentIds.List);
         component = list;
     } else {
         component = new ListComponent();
     }
     component.list = newList;
     return ReplaceComponent(ComponentIds.List, component);
 }
Example #17
0
        /// <summary>
        /// 异步加载assetbundle, 加载ab包分两部分,第一部分是从硬盘加载,第二部分加载all assets。两者不能同时并发
        /// </summary>
        public static async ETTask LoadBundleAsync(this ResourcesComponent self, string assetBundleName)
        {
            assetBundleName = assetBundleName.BundleNameToLower();

            string[] dependencies = self.GetSortedDependencies(assetBundleName);
            //Log.Debug($"-----------dep load async start {assetBundleName} dep: {dependencies.ToList().ListToString()}");

            using (ListComponent <ABInfo> abInfos = ListComponent <ABInfo> .Create())
            {
                async ETTask LoadDependency(string dependency, List <ABInfo> abInfosList)
                {
                    CoroutineLock coroutineLock = null;

                    try
                    {
                        coroutineLock = await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Resources, dependency.GetHashCode());

                        ABInfo abInfo = await self.LoadOneBundleAsync(dependency);

                        if (abInfo == null || abInfo.RefCount > 1)
                        {
                            return;
                        }

                        abInfosList.Add(abInfo);
                    }
                    finally
                    {
                        coroutineLock?.Dispose();
                    }
                }

                // LoadFromFileAsync部分可以并发加载
                using (ListComponent <ETTask> tasks = ListComponent <ETTask> .Create())
                {
                    foreach (string dependency in dependencies)
                    {
                        tasks.Add(LoadDependency(dependency, abInfos));
                    }
                    await ETTaskHelper.WaitAll(tasks);

                    // ab包从硬盘加载完成,可以再并发加载all assets
                    tasks.Clear();
                    foreach (ABInfo abInfo in abInfos)
                    {
                        tasks.Add(self.LoadOneBundleAllAssets(abInfo));
                    }
                    await ETTaskHelper.WaitAll(tasks);
                }
            }
        }
Example #18
0
    /// <summary>
    /// Load text to labels and load the all categories of user preferences
    /// </summary>
    private void PopulateControls()
    {
        var list          = ListComponent.GetListPerCategory("AvailableResource", Thread.CurrentThread.CurrentCulture.Name).ToList();
        var listEmptyItem = new NexsoProDAL.List();

        listEmptyItem.Value = "0";
        listEmptyItem.Label = Localization.GetString("SelectItem", LocalResourceFile);
        list = ListComponent.GetListPerCategory("Theme", Thread.CurrentThread.CurrentCulture.Name).ToList();
        chkTheme.DataSource = list;
        chkTheme.DataBind();
        list = ListComponent.GetListPerCategory("Beneficiaries", Thread.CurrentThread.CurrentCulture.Name).ToList();
        chkBeneficiaries.DataSource = list;
        chkBeneficiaries.DataBind();
        list = ListComponent.GetListPerCategory("Sector", Thread.CurrentThread.CurrentCulture.Name).ToList();
        chkSector.DataSource = list;
        chkSector.DataBind();
        list = ListComponent.GetListPerCategory("WhoAreYou", Thread.CurrentThread.CurrentCulture.Name).ToList();
        list.Insert(0, listEmptyItem);
        ddlWhoareYou.DataSource = list;
        ddlWhoareYou.DataBind();
        list = ListComponent.GetListPerCategory("Source", Thread.CurrentThread.CurrentCulture.Name).ToList();
        list.Insert(0, listEmptyItem);
        ddlSource.DataSource = list;
        ddlSource.DataBind();
        list = ListComponent.GetListPerCategory("Language", Thread.CurrentThread.CurrentCulture.Name).ToList();
        list.Insert(0, listEmptyItem);
        ddlLanguage.DataSource = list;
        ddlLanguage.DataBind();
        if (userId > 0)
        {
            txtEmail.Text    = currentUser.Email;
            lblEmailTxt.Text = txtEmail.Text;
            foreach (ProfilePropertyDefinition property in currentUser.Profile.ProfileProperties)
            {
                MapPropToPage(property.PropertyName, property.PropertyValue);
            }
            MapPropToPage(userId);
        }

        var    returnUrl = Globals.UserProfileURL(userId);
        string url       = NexsoHelper.GetCulturedUrlByTabName("Change Password") + "?returnurl=" + returnUrl;

        passwordLink.NavigateUrl = url;
        if (PortalSettings.EnablePopUps)
        {
            passwordLink.Attributes.Add("onclick", "return " + UrlUtils.PopUpUrl(url, this, PortalSettings, true, false, 300, 650));
        }
    }
Example #19
0
    public void ShowData()
    {
        objTabController = new TabController();
        if (solutionId != Guid.Empty)
        {
            SolutionComponent solutionComponent = new SolutionComponent(solutionId);
            lnkSolutionName.Text        = solutionComponent.Solution.Title;
            lnkSolutionName.NavigateUrl = NexsoHelper.GetCulturedUrlByTabName("solprofile") + "/sl/" + solutionId.ToString();
            OrganizationComponent organizationComponent = new OrganizationComponent(solutionComponent.Solution.OrganizationId);
            lnkInstitutionName.Text        = organizationComponent.Organization.Name;
            lnkInstitutionName.NavigateUrl = NexsoHelper.GetCulturedUrlByTabName("insprofile") + "/in/" + organizationComponent.Organization.OrganizationID;

            lblSolutionshortDescription.Text = solutionComponent.Solution.TagLine;


            lblduration.Text = ListComponent.GetLabelFromListValue("ProjectDuration", Thread.CurrentThread.CurrentCulture.Name, solutionComponent.Solution.Duration.ToString());
            // lblFormat.Text = ListComponent.GetLabelFromListValue("DeliveryFormat", Thread.CurrentThread.CurrentCulture.Name, solutionComponent.Solution.DeliveryFormat.ToString());
            FillBeneficiaries();
            FillThemes();
            FillFormat();
            LocationList1.SolutionId = solutionComponent.Solution.SolutionId;
            LocationList1.EditMode   = false;
            mainPanel.Visible        = true;
            EmptyPanel.Visible       = false;
            LocationList1.LoadData();

            if (!string.IsNullOrEmpty(organizationComponent.Organization.Logo))
            {
                imgOrganizationLogo.ImageUrl = PortalSettings.HomeDirectory + "ModIma/Images/" +
                                               organizationComponent.Organization.Logo;
            }
            else
            {
                imgOrganizationLogo.ImageUrl = PortalSettings.HomeDirectory + "ModIma/Images/noImage.png";
            }

            imgThemeIcon.ImageUrl = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "") + ControlPath +
                                    "images/theme.png";
            imgBeneficiariesIcon.ImageUrl = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "") + ControlPath +
                                            "images/beneficiaries.png";
            btnView.CommandArgument = solutionId.ToString();
        }
        else
        {
            mainPanel.Visible  = false;
            EmptyPanel.Visible = true;
        }
    }
Example #20
0
        protected override async ETTask Run(Session session, M2C_PathfindingResult message)
        {
            Unit unit = session.DomainScene().CurrentScene().GetComponent <UnitComponent>().Get(message.Id);

            float speed = unit.GetComponent <NumericComponent>().GetAsFloat(NumericType.Speed);

            using (ListComponent <Vector3> list = ListComponent <Vector3> .Create())
            {
                for (int i = 0; i < message.Xs.Count; ++i)
                {
                    list.Add(new Vector3(message.Xs[i], message.Ys[i], message.Zs[i]));
                }

                await unit.GetComponent <MoveComponent>().MoveToAsync(list, speed);
            }
        }
Example #21
0
        public Entity ReplaceList(System.Collections.Generic.List <string> newList)
        {
            ListComponent component;

            if (hasList)
            {
                WillRemoveComponent(ComponentIds.List);
                component = list;
            }
            else
            {
                component = new ListComponent();
            }
            component.list = newList;
            return(ReplaceComponent(ComponentIds.List, component));
        }
Example #22
0
        public void RegisterListObject(ListComponent listComponent)
        {
            int ID = GetNextID();

            objects.Add(ID, listComponent);
            listComponent.SetId(ID);
            if (listComponent.GetType() == typeof(Row))
            {
                ((Row)listComponent).SetId(ID);
                //Debug.Log("Row: " + ((Row)listComponent).Get(0).Data.GetLabel());
            }
            else if (listComponent.GetType() == typeof(SubList))
            {
                ((SubList)listComponent).SetId(ID);
            }
            //Debug.Log("Current Id: " + ID + "("+listComponent.GetId()+")"+ " Total objects: " + objects.Count);
        }
Example #23
0
        public async ETTask Run(ModeContex contex, string content)
        {
            switch (content)
            {
            case ConsoleMode.CreateRobot:
                Log.Console("CreateRobot args error!");
                break;

            default:
                CreateRobotArgs options = null;
                Parser.Default.ParseArguments <CreateRobotArgs>(content.Split(' '))
                .WithNotParsed(error => throw new Exception($"CreateRobotArgs error!"))
                .WithParsed(o => { options = o; });

                // 获取当前进程的RobotScene
                using (ListComponent <StartSceneConfig> thisProcessRobotScenes = ListComponent <StartSceneConfig> .Create())
                {
                    List <StartSceneConfig> robotSceneConfigs = StartSceneConfigCategory.Instance.Robots;
                    foreach (StartSceneConfig robotSceneConfig in robotSceneConfigs)
                    {
                        if (robotSceneConfig.Process != Game.Options.Process)
                        {
                            continue;
                        }
                        thisProcessRobotScenes.Add(robotSceneConfig);
                    }

                    // 创建机器人
                    for (int i = 0; i < options.Num; ++i)
                    {
                        int index = i % thisProcessRobotScenes.Count;
                        StartSceneConfig      robotSceneConfig      = thisProcessRobotScenes[index];
                        Scene                 robotScene            = Game.Scene.Get(robotSceneConfig.Id);
                        RobotManagerComponent robotManagerComponent = robotScene.GetComponent <RobotManagerComponent>();
                        Scene                 robot = await robotManagerComponent.NewRobot(Game.Options.Process * 10000 + i);

                        robot.AddComponent <AIComponent, int>(1);
                        Log.Console($"create robot {robot.Zone}");
                        await TimerComponent.Instance.WaitAsync(2000);
                    }
                }
                break;
            }
            contex.Parent.RemoveComponent <ModeContex>();
            await ETTask.CompletedTask;
        }
Example #24
0
    /// <summary>
    /// Load information to the controls (textbox and dropdownlist)
    /// </summary>
    public void BindData()
    {
        var listEmptyItem = new NexsoProDAL.List();

        listEmptyItem.Key   = "0";
        listEmptyItem.Label = Localization.GetString("SelectItem", LocalResourceFile);
        var list = ListComponent.GetListPerCategory("FileCategory", Thread.CurrentThread.CurrentCulture.Name).ToList();

        if (IsChallengeFiles)
        {
            list = ListComponent.GetListPerCategory("ChallengeFile", Thread.CurrentThread.CurrentCulture.Name).ToList();
            list.Insert(0, listEmptyItem);
            ddCategory.DataSource = list;
            ddCategory.DataBind();
            txtTitle.Visible              = true;
            lblTitle.Visible              = true;
            lblDescription.Visible        = false;
            txtDescription.Visible        = false;
            RadButton1.ValidationGroup    = "ChallengeFiles";
            btnBackUpdate.ValidationGroup = "ChallengeFiles";
            btnBackUpdate.ValidationGroup = "ChallengeFiles";
            if (string.IsNullOrEmpty(ChallengeReference))
            {
                aUploadFile.Enabled = false;
                rdProgressAreaUploadFile.Visible = false;
            }
            else
            {
                aUploadFile.Enabled = true;
                rdProgressAreaUploadFile.Visible = true;
            }
        }
        else
        {
            list.Insert(0, listEmptyItem);
            ddCategory.DataSource = list;
            ddCategory.DataBind();
        }
        FillDataRepeater();
        list = ListComponent.GetListPerCategory("FileScope", Thread.CurrentThread.CurrentCulture.Name).ToList();
        rdbScope.DataSource = list;
        rdbScope.DataBind();
        lblTitle.Text    = TextTitle;
        rfvtxtTitle.Text = TextTitleValidator;
    }
Example #25
0
        public static Unit Create(Scene currentScene, UnitInfo unitInfo)
        {
            UnitComponent unitComponent = currentScene.GetComponent <UnitComponent>();
            Unit          unit          = unitComponent.AddChildWithId <Unit, int>(unitInfo.UnitId, unitInfo.ConfigId);

            unitComponent.Add(unit);

            unit.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z);
            unit.Forward  = new Vector3(unitInfo.ForwardX, unitInfo.ForwardY, unitInfo.ForwardZ);

            NumericComponent numericComponent = unit.AddComponent <NumericComponent>();

            for (int i = 0; i < unitInfo.Ks.Count; ++i)
            {
                numericComponent.Set(unitInfo.Ks[i], unitInfo.Vs[i]);
            }

            unit.AddComponent <MoveComponent>();
            if (unitInfo.MoveInfo != null)
            {
                if (unitInfo.MoveInfo.X.Count > 0)
                {
                    using (ListComponent <Vector3> list = ListComponent <Vector3> .Create())
                    {
                        list.Add(unit.Position);
                        for (int i = 0; i < unitInfo.MoveInfo.X.Count; ++i)
                        {
                            list.Add(new Vector3(unitInfo.MoveInfo.X[i], unitInfo.MoveInfo.Y[i], unitInfo.MoveInfo.Z[i]));
                        }

                        unit.MoveToAsync(list).Coroutine();
                    }
                }
            }

            unit.AddComponent <ObjectWait>();

            unit.AddComponent <XunLuoPathComponent>();

            Game.EventSystem.Publish(unit.DomainScene(), new EventType.AfterUnitCreate()
            {
                Unit = unit
            });
            return(unit);
        }
Example #26
0
            protected override void Destroy(ResourcesLoaderComponent self)
            {
                async ETTask UnLoadAsync()
                {
                    using (ListComponent <string> list = ListComponent <string> .Create())
                    {
                        list.AddRange(self.LoadedResource);
                        self.LoadedResource = null;

                        if (TimerComponent.Instance == null)
                        {
                            return;
                        }

                        // 延迟5秒卸载包,因为包卸载是引用计数,5秒之内假如重新有逻辑加载了这个包,那么可以避免一次卸载跟加载
                        await TimerComponent.Instance.WaitAsync(5000);

                        foreach (string abName in list)
                        {
                            CoroutineLock coroutineLock = null;
                            try
                            {
                                coroutineLock =
                                    await CoroutineLockComponent.Instance.Wait(CoroutineLockType.ResourcesLoader, abName.GetHashCode(), 0);

                                {
                                    if (ResourcesComponent.Instance == null)
                                    {
                                        return;
                                    }

                                    await ResourcesComponent.Instance.UnloadBundleAsync(abName);
                                }
                            }
                            finally
                            {
                                coroutineLock?.Dispose();
                            }
                        }
                    }
                }

                UnLoadAsync().Coroutine();
            }
Example #27
0
        // 可以多次调用,多次调用的话会取消上一次的协程
        public static async ETTask FindPathMoveToAsync(this Unit unit, Vector3 target, ETCancellationToken cancellationToken = null)
        {
            float speed = unit.GetComponent <NumericComponent>().GetAsFloat(NumericType.Speed);

            if (speed < 0.01)
            {
                unit.SendStop(-1);
                return;
            }

            using var list = ListComponent <Vector3> .Create();

            unit.GetComponent <PathfindingComponent>().Find(unit.Position, target, list);

            List <Vector3> path = list;

            if (path.Count < 2)
            {
                unit.SendStop(0);
                return;
            }

            // 广播寻路路径
            M2C_PathfindingResult m2CPathfindingResult = new M2C_PathfindingResult();

            m2CPathfindingResult.Id = unit.Id;
            for (int i = 0; i < list.Count; ++i)
            {
                Vector3 vector3 = list[i];
                m2CPathfindingResult.Xs.Add(vector3.x);
                m2CPathfindingResult.Ys.Add(vector3.y);
                m2CPathfindingResult.Zs.Add(vector3.z);
            }
            MessageHelper.Broadcast(unit, m2CPathfindingResult);

            bool ret = await unit.GetComponent <MoveComponent>().MoveToAsync(path, speed);

            if (ret) // 如果返回false,说明被其它移动取消了,这时候不需要通知客户端stop
            {
                unit.SendStop(0);
            }
        }
Example #28
0
        private static void CheckConnectTimeout(this RouterComponent self, long timeNow)
        {
            // 检查连接过程超时
            using (ListComponent <long> listComponent = ListComponent <long> .Create())
            {
                foreach (var kv in self.ConnectIdNodes)
                {
                    if (timeNow < kv.Value.LastRecvOuterTime + 10 * 1000)
                    {
                        continue;
                    }

                    listComponent.Add(kv.Value.Id);
                }

                foreach (long id in listComponent)
                {
                    self.OnError(id, ErrorCore.ERR_KcpRouterConnectFail);
                }
            }

            // 外网消息超时就断开,内网因为会一直重发,没有重连之前内网连接一直存在,会导致router一直收到内网消息
            using (ListComponent <long> listComponent = ListComponent <long> .Create())
            {
                foreach (var kv in self.OuterNodes)
                {
                    // 比session超时应该多10秒钟
                    if (timeNow < kv.Value.LastRecvOuterTime + ConstValue.SessionTimeoutTime + 10 * 1000)
                    {
                        continue;
                    }

                    listComponent.Add(kv.Value.Id);
                }

                foreach (long id in listComponent)
                {
                    self.OnError(id, ErrorCore.ERR_KcpRouterTimeout);
                }
            }
        }
Example #29
0
        public static List <ListItemModel> GetListsFromCategory(string category, CultureInfo culture)
        {
            List <ListItemModel> _return = new List <ListItemModel>();
            var list = ListComponent.GetListPerCategory(category, culture.Name).ToList();

            foreach (var item in list)
            {
                _return.Add(new ListItemModel()
                {
                    Category = item.Category,
                    Key      = item.Key,
                    Culture  = item.Culture,
                    Order    = item.Order,
                    Value    = item.Value
                }
                            );
            }


            return(_return);
        }
Example #30
0
        public async ETTask Run(RobotCase robotCase)
        {
            using ListComponent <Scene> robots = ListComponent <Scene> .Create();

            // 创建了两个机器人,生命周期是RobotCase,RobotCase_FirstCase.Run执行结束,机器人就会删除
            await robotCase.NewRobot(2, robots);

            foreach (Scene robotScene in robots)
            {
                M2C_TestRobotCase response = await robotScene.GetComponent <Client.SessionComponent>().Session.Call(new C2M_TestRobotCase()
                {
                    N = robotScene.Zone
                }) as M2C_TestRobotCase;

                if (response.N != robotScene.Zone)
                {
                    // 跟预期不一致就抛异常,外层会catch住在控制台上打印
                    throw new Exception($"robot case: {RobotCaseType.FirstCase} run fail!");
                }
            }
        }
        public static void Check(this ActorLocationSenderComponent self)
        {
            using (ListComponent <long> list = ListComponent <long> .Create())
            {
                long timeNow = TimeHelper.ServerNow();
                foreach ((long key, Entity value) in self.Children)
                {
                    ActorLocationSender actorLocationMessageSender = (ActorLocationSender)value;

                    if (timeNow > actorLocationMessageSender.LastSendOrRecvTime + ActorLocationSenderComponent.TIMEOUT_TIME)
                    {
                        list.Add(key);
                    }
                }

                foreach (long id in list)
                {
                    self.Remove(id);
                }
            }
        }
Example #32
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            pixel = new Texture2D(GraphicsDevice, 1, 1);
            pixel.SetData<Color>(new Color[] { Color.White });
            font = Content.Load<SpriteFont>(@"fonts/font");

            cam = new Camera2D(new Vector2(1280, 720) / 2f);
            cam.speed = 0.2f;

            map.Load(Content);

            layerList = new ListComponent<MapLayer>(16, 46, "Layers", map.layers).Load(Content, GraphicsDevice);
            layerList.OnClickedEvent += new ListComponent<MapLayer>.OnClicked(layerList_OnClickedEvent);

            texContainer = new TextureContainer(500, 200, @"gfx/map").Load(Content, GraphicsDevice);
            texContainer.OnNewSource += new TextureContainer.OnNewSourceDelegate(texContainer_OnNewSource);

            layerCompo = new LayerComponent().Load(Content, GraphicsDevice);

            collisionCompo = new CollisionComponent().Load(Content, GraphicsDevice);
            collisionCompo.Set(map.ledges, map.grid);

            buttons = new List<Button>();

            Button btnNewLayer = new Button(16, 16, "New layer").Load(Content, GraphicsDevice);
            btnNewLayer.OnClickedEvent += new Button.OnClicked(btnNewLayer_OnClickedEvent);
            buttons.Add(btnNewLayer);

            Button btnRmLayer = new Button(100, 16, "Delete layer").Load(Content, GraphicsDevice);
            btnRmLayer.OnClickedEvent += new Button.OnClicked(btnRmLayer_OnClickedEvent);
            buttons.Add(btnRmLayer);

            Button btnSave = new Button(1280 - 300, 16, "Save").Load(Content, GraphicsDevice);
            btnSave.OnClickedEvent += new Button.OnClicked(btnSave_OnClickedEvent);
            buttons.Add(btnSave);

            Button btnLoad = new Button(1280 - 150, 16, "Load").Load(Content, GraphicsDevice);
            btnLoad.OnClickedEvent += new Button.OnClicked(btnLoad_OnClickedEvent);
            buttons.Add(btnLoad);
        }
 public Entity AddList(System.Collections.Generic.List<string> newList)
 {
     var component = new ListComponent();
     component.list = newList;
     return AddList(component);
 }
 public Entity AddList(ListComponent component)
 {
     return AddComponent(ComponentIds.List, component);
 }
Example #35
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            animList = new ListComponent<Animation>(16, 50, "Animations", collection.animations).Load(Content, GraphicsDevice);
            animList.OnDoubleClickedEvent += new ListComponent<Animation>.OnClicked(animList_OnDoubleClickedEvent);
            animList.OnClickedEvent += new ListComponent<Animation>.OnClicked(animList_OnClickedEvent);

            frameList = new ListComponent<Frame>(286, 50, "Frames", collection.frames).Load(Content, GraphicsDevice);
            frameList.OnClickedEvent += new ListComponent<Frame>.OnClicked(frameList_OnClickedEvent);
            frameList.OnDoubleClickedEvent += new ListComponent<Frame>.OnClicked(frameList_OnDoubleClickedEvent);

            kfList = new ListComponent<KeyFrame>(16, 200, "Keyframes", new List<KeyFrame>()).Load(Content, GraphicsDevice);
            kfList.OnClickedEvent += new ListComponent<KeyFrame>.OnClicked(kfList_OnClickedEvent);

            buttons = new List<Button>();

            Button btnNewAnim = new Button(16, 16, "New Animation").Load(Content, GraphicsDevice);
            btnNewAnim.OnClickedEvent += new Button.OnClicked(btnNewAnimClicked);
            buttons.Add(btnNewAnim);

            Button btnDeleteAnim = new Button(136, 16, "Delete Animation").Load(Content, GraphicsDevice);
            btnDeleteAnim.OnClickedEvent += new Button.OnClicked(btnDeleteAnim_OnClickedEvent);
            buttons.Add(btnDeleteAnim);

            Button btnNewFrame = new Button(286, 16, "New Frame").Load(Content, GraphicsDevice);
            btnNewFrame.OnClickedEvent += new Button.OnClicked(btnNewFrame_OnClickedEvent);
            buttons.Add(btnNewFrame);

            Button btnDeleteFrame = new Button(286 + 126, 16, "Delete Frame").Load(Content, GraphicsDevice);
            btnDeleteFrame.OnClickedEvent += new Button.OnClicked(btnDeleteFrame_OnClickedEvent);
            buttons.Add(btnDeleteFrame);

            Button btnKeyFrame = new Button(286 + 286, 16, "KeyFrame").Load(Content, GraphicsDevice);
            btnKeyFrame.OnClickedEvent += new Button.OnClicked(btnKeyFrame_OnClickedEvent);
            buttons.Add(btnKeyFrame);

            Button btnDeleteKeyFrame = new Button(286 + 386, 16, "Del KF").Load(Content, GraphicsDevice);
            btnDeleteKeyFrame.OnClickedEvent += new Button.OnClicked(btnDeleteKeyFrame_OnClickedEvent);
            buttons.Add(btnDeleteKeyFrame);

            Button btnSave = new Button(1280 - 100, 16, "Save").Load(Content, GraphicsDevice);
            btnSave.OnClickedEvent += new Button.OnClicked(btnSave_OnClickedEvent);
            buttons.Add(btnSave);

            Button btnLoad = new Button(1280, 16, "Load").Load(Content, GraphicsDevice);
            btnLoad.OnClickedEvent += new Button.OnClicked(btnLoad_OnClickedEvent);
            buttons.Add(btnLoad);

            texContainer = new TextureContainer(16, 400, @"gfx/tex").Load(Content, GraphicsDevice);
            texContainer.OnNewSource += new TextureContainer.OnNewSourceDelegate(texContainer_OnNewSource);

            frameContainer = new FrameContainer(600, 200).Load(Content, GraphicsDevice);
            kfContainer = new KeyFrameContainer(16, 400).Load(Content, GraphicsDevice);

            textBox = new TextBox().LoadContent(Content, GraphicsDevice);

            animCompo = new AnimationComponent(900, 50).Load(Content, GraphicsDevice);

            pixel = new Texture2D(GraphicsDevice, 1, 1);
            pixel.SetData<Color>(new Color[] { Color.White });
        }