示例#1
0
 public ComponentController(Startup.DeleteByIdResolver deleteAccesor, IComponentReadOnlyRepository readComponent, ICreate <Component> createComponent, IUpdate <Component> updateComponent)
 {
     delete = new DeleteComponent(deleteAccesor(WebApi.DeletesID.Component), readComponent);
     create = new CreateComponent(createComponent, readComponent);
     update = new UpdateComponent(updateComponent, readComponent);
     read   = new ReadComponent(readComponent);
 }
示例#2
0
文件: Entity.cs 项目: Shien007/Season
 public void RegisterComponent(UpdateComponent comp)
 {
     TaskManager.AddTask(comp);
     componentList.Add(comp);
     comp.Register(this);
     comp.Active();
 }
示例#3
0
        public Entity Clone()
        {
            Entity entity = new Entity();

            foreach (Entity child in Children)
            {
                entity.AddChild(child.Clone());
            }
            entity.X       = X;
            entity.Y       = Y;
            entity.Active  = Active;
            entity.Visible = Visible;

            if (UpdateComponent != null)
            {
                entity.AddUpdateComponent((IUpdateComponent)UpdateComponent.Clone());
            }
            if (RenderComponent != null)
            {
                entity.AddRenderComponent((IRenderComponent)RenderComponent.Clone());
            }
            foreach (KeyValuePair <Type, Component> entry in ComponentList)
            {
                entity.AddComponent(entry.Value.Clone());
            }
            foreach (KeyValuePair <string, UpdateChain> chain in UpdateChains)
            {
                foreach (IUpdateComponent component in chain.Value)
                {
                    entity.AddChainComponent(chain.Key, (IUpdateComponent)component.Clone());
                }
            }

            return(entity);
        }
示例#4
0
 protected LightNode(Entity entity)
 {
     this.entity = entity;
     cPosition   = entity.GetComponent <PositionComponent>();
     cUpdate     = entity.GetComponent <UpdateComponent>();
     cTransform  = entity.GetComponent <TransformComponent>();
 }
示例#5
0
        public void InitLogic(Dictionary <byte, NetworkPlayer> players)
        {
            PlayerCount     = players.Count;
            Mediator        = MainForm.Instance.Mediator;
            DoAfterGameLoop = new List <Action>();
            PlayerPaddles   = new Dictionary <byte, Paddle>();
            ArenaBalls      = new Dictionary <byte, IBall>();
            ArenaObjects    = new Dictionary <byte, ArenaObject>();

            float deltaAngle = SharedUtilities.PI * 2 / PlayerCount;
            float angle      = (-SharedUtilities.PI + deltaAngle) / 2f;

            foreach (var player in players.Values)
            {
                PaddleType pType  = player.PaddleType;
                Paddle     paddle = PaddleFactory.CreatePaddle(pType, player.Id);
                paddle.SetPosition(SharedUtilities.RadToDeg(angle));
                PlayerPaddles.Add(player.Id, paddle);
                player.SetLife(paddle.Life);
                if (Mediator.GetBool("IdMatches", player.Id))
                {
                    LocalPaddle = paddle;
                }
                paddle.AddClampAngles(SharedUtilities.RadToDeg(angle - deltaAngle / 2), SharedUtilities.RadToDeg(angle + deltaAngle / 2));
                angle += deltaAngle;
            }
            AlivePaddleCount         = PlayerPaddles.Count;
            StartingAlivePaddleCount = AlivePaddleCount;



            UpdatableRoot = new UpdateComposite();
            UpdatableRoot.Add(LocalPaddle.Id, LocalPaddle);

            UpdateComponent spawnerBranch = new UpdateComposite();

            spawnerBranch.Add(spawnerBranch.GetNextId(), new ObstacleSpawner(GameData.ObstacleSpawnerParams, ArenaObjectFactories.Values.ToArray()));
            spawnerBranch.Add(spawnerBranch.GetNextId(), new PowerUpSpawner(GameData.PowerUpSpawnerParams, ArenaObjectFactories.Values.ToArray()));
            UpdatableRoot.Add(UpdatableRoot.GetNextId(), spawnerBranch);

            UpdateComponent objectBranch = new UpdateComposite();

            ObjectBranchId = UpdatableRoot.GetNextId();
            UpdatableRoot.Add(ObjectBranchId, objectBranch);

            UpdateComponent ballBranch = new UpdateComposite();

            BallBranchId = UpdatableRoot.GetNextId();
            UpdatableRoot.Add(BallBranchId, ballBranch);

            BallType bType = RoomSettings.Instance.BallType;
            Ball     ball  = Ball.CreateBall(0, bType, ArenaDimensions.Center, GameData.DefaultBallSpeed, Vector2.RandomInUnitCircle(), GameData.DefaultBallSize);

            ArenaBalls.Add(0, ball);
            ballBranch.Add(0, ball);

            IsInitted = true;
            PauseGame(false);
        }
示例#6
0
        private static void UseComposableLogic()
        {
            var fac = new UoWFac();
            ComposableOperatorLogic logic = new ComposableOperatorLogic(fac);

            var getComp = new GetComponent(logic);
            var updComp = new UpdateComponent(logic);

            var oper = getComp.Execute(16);

            var rnd = new Random().Next(800, 1000);

            oper.FirstName = $"jp cito {rnd}";
            oper.Document  = rnd.ToString();

            updComp.Execute(oper);
        }
示例#7
0
 public void InitComponent(Transform componentRoot)
 {
     this.ComponentRoot    = componentRoot;
     DataNodeComponent     = FindAndRegisterComponent <DataNodeComponent>();
     DataTableComponent    = FindAndRegisterComponent <DataTableComponent>();
     DownloadComponent     = FindAndRegisterComponent <DownloadComponent>();
     FsmComponent          = FindAndRegisterComponent <FSMComponent>();
     ResourceComponent     = FindAndRegisterComponent <ResourceComponent>();
     SettingComponent      = FindAndRegisterComponent <SettingComponent>();
     SoundComponent        = FindAndRegisterComponent <SoundComponent>();
     TimerComponent        = FindAndRegisterComponent <TimerComponent>();
     WebComponent          = FindAndRegisterComponent <WebComponent>();
     UpdateComponent       = FindAndRegisterComponent <UpdateComponent>();
     LocalizationComponent = FindAndRegisterComponent <LocalizationComponent>();
     VideoComponent        = FindAndRegisterComponent <VideoComponent>();
     InputComponent        = FindAndRegisterComponent <InputComponent>();
     SceneComponent        = FindAndRegisterComponent <SceneComponent>();
 }
        /// <summary>
        /// Routes to a dynamically generated "Component Update" Page. Gathers information from the database.
        /// </summary>
        /// <param name="id">Id of the Component</param>
        /// <returns>A dynamic "Module Show" webpage which provides a form to input new component information.</returns>
        /// <example>GET : /Component/Update/5</example>
        public ActionResult Update(int id)
        {
            UpdateComponent ViewModel = new UpdateComponent();

            string url = "componentdata/findComponent/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                ComponentDto SelectedComponent = response.Content.ReadAsAsync <ComponentDto>().Result;
                ViewModel.component = SelectedComponent;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
示例#9
0
 public void Update(string chain = null)
 {
     if (!Active)
     {
         return;
     }
     if (Parent != null)
     {
         inheritedVisibility = Parent.InheritedVisibility;
     }
     else
     {
         inheritedVisibility = Visible;
     }
     if (chain == null)
     {
         if (UpdateComponent != null)
         {
             UpdateComponent.Update();
         }
     }
     else
     {
         if (UpdateChains != null && UpdateChains.ContainsKey(chain))
         {
             foreach (IUpdateComponent component in UpdateChains[chain])
             {
                 component.Update();
             }
         }
     }
     if (Children.Count != 0)
     {
         LinkedListNode <Entity> child = Children.First;
         while (child != null)
         {
             child.Value.Update(chain);
             child = child.Next;
         }
     }
 }
示例#10
0
 public static void RemoveTask(UpdateComponent comp)
 {
     comp.DeActive();
     UpdateContainer.Remove(comp);
 }
示例#11
0
 public static void AddTask(UpdateComponent comp)
 {
     UpdateContainer.Add(comp);
 }
示例#12
0
文件: Entity.cs 项目: Shien007/Season
 public void RemoveComponent(UpdateComponent comp)
 {
     componentList.Remove(comp);
     TaskManager.RemoveTask(comp);
 }
示例#13
0
        public static void Update(string FormName, string Id, string Attribute, string Value)
        {
            try
            {
                Form form = Application.OpenForms[FormName];

                if (form == null)
                {
                    logger.Error("FormName:" + FormName + " not exist!");
                    return;
                }


                object cpt = form.Controls.Find(Id, true).FirstOrDefault();
                if (cpt == null)
                {
                    logger.Error("FormName:" + FormName + " Id:" + Id + " not exist!");
                    return;
                }
                string Type = cpt.GetType().Name;
                switch (Type)
                {
                case "CheckBox":
                    CheckBox ckb = cpt as CheckBox;
                    if (ckb.InvokeRequired)
                    {
                        UpdateComponent ph = new UpdateComponent(Update);

                        ckb.BeginInvoke(ph, FormName, Id, Attribute, Value);
                    }
                    else
                    {
                        switch (Attribute)
                        {
                        case UIAttribute.Enabled:
                            switch (Value)
                            {
                            case SetValue.True:
                                ckb.Enabled = true;
                                break;

                            case SetValue.False:
                                ckb.Enabled = false;
                                break;
                            }
                            break;

                        case UIAttribute.Checked:
                            switch (Value)
                            {
                            case SetValue.True:
                                ckb.Checked = true;
                                break;

                            case SetValue.False:
                                ckb.Checked = false;
                                break;
                            }
                            break;

                        default:
                            logger.Error("Attribute is not supported");
                            break;
                        }
                    }
                    break;

                case "Label":
                    Label lb = cpt as Label;
                    if (lb.InvokeRequired)
                    {
                        UpdateComponent ph = new UpdateComponent(Update);

                        lb.BeginInvoke(ph, FormName, Id, Type, Attribute, Value);
                    }
                    else
                    {
                        switch (Attribute)
                        {
                        case UIAttribute.Enabled:
                            switch (Value)
                            {
                            case SetValue.True:
                                lb.Enabled = true;
                                break;

                            case SetValue.False:
                                lb.Enabled = false;
                                break;
                            }
                            break;

                        case UIAttribute.Text:
                            lb.Text = Value;
                            break;

                        case UIAttribute.BackColor:
                            lb.BackColor = Color.FromName(Value);
                            break;

                        default:
                            logger.Error("Attribute is not supported");
                            break;
                        }
                    }
                    break;

                case "RichTextBox":
                    RichTextBox rtb = cpt as RichTextBox;
                    if (rtb.InvokeRequired)
                    {
                        UpdateComponent ph = new UpdateComponent(Update);

                        rtb.BeginInvoke(ph, FormName, Id, Type, Attribute, Value);
                    }
                    else
                    {
                        switch (Attribute)
                        {
                        case UIAttribute.Enabled:
                            switch (Value)
                            {
                            case SetValue.True:
                                rtb.Enabled = true;
                                break;

                            case SetValue.False:
                                rtb.Enabled = false;
                                break;
                            }
                            break;

                        case UIAttribute.Text:
                            rtb.Text = Value;
                            break;

                        default:
                            logger.Error("Attribute is not supported");
                            break;
                        }
                    }
                    break;

                case "TextBox":
                    TextBox tb = cpt as TextBox;
                    if (tb.InvokeRequired)
                    {
                        UpdateComponent ph = new UpdateComponent(Update);

                        tb.BeginInvoke(ph, FormName, Id, Type, Attribute, Value);
                    }
                    else
                    {
                        switch (Attribute)
                        {
                        case UIAttribute.Enabled:
                            switch (Value)
                            {
                            case SetValue.True:
                                tb.Enabled = true;
                                break;

                            case SetValue.False:
                                tb.Enabled = false;
                                break;
                            }
                            break;

                        case UIAttribute.Text:
                            tb.Text = Value;
                            break;

                        default:
                            logger.Error("Attribute is not supported");
                            break;
                        }
                    }
                    break;

                default:
                    logger.Error("Type is not supported");
                    break;
                }
            }
            catch (Exception e)
            {
                logger.Error(e.StackTrace);
            }
        }
示例#14
0
 void Start()
 {
     movementComp = GetComponent <MovementComponent>();
     updateComp   = GetComponent <UpdateComponent>();
     yPosition    = transform.position.y;
 }