コード例 #1
0
ファイル: Border.cs プロジェクト: NathanKr/CSharp
 public Border(BoardInfo info)
 {
     TopLeft     = info.BoardTopLeft;
     BottomRight = info.BoardBottomRight;
     ColorBorder = info.ColorBorder;
     m_graphics  = new GraphicComponent();
 }
コード例 #2
0
    public void Start()
    {
        GameManager.Instance.AddPlayer(id, this);

        if (isLocal)
        {
            moveComponent    = new PlayerMoveComponet();
            graphicComponent = new PlayerGraphicComponent();
            physicsComponent = new PlayerPhysicsComponent();
            componentList.Add(moveComponent);
            componentList.Add(graphicComponent);
            componentList.Add(physicsComponent);
        }
        else
        {
            moveComponent    = new PlayerNetMoveComponent();
            graphicComponent = new PlayerNetGraphicComponent();
            componentList.Add(moveComponent);
            componentList.Add(graphicComponent);
        }

        if (componentList == null)
        {
            return;
        }
        componentAmount = componentList.Count;
        foreach (BaseComponent component in componentList)
        {
            component.OnInit(this);
        }
    }
コード例 #3
0
        // Returns the component with the highest z-order
        public AbstractEntity GetComponentToDraw(int x, int y)
        {
            var entities = this.map[x, y];

            if (entities.Count == 1)
            {
                return(entities[0]);
            }

            Dictionary <GraphicComponent, AbstractEntity> gcs = new Dictionary <GraphicComponent, AbstractEntity>();

            foreach (var e in entities)
            {
                GraphicComponent gc = (GraphicComponent)e.GetComponent(nameof(GraphicComponent));
                if (gc != null)
                {
                    gcs.Add(gc, e);
                }
            }
            return(gcs.OrderByDescending(e2 => e2.Key.zOrder).First().Value);
            //return gcs.First().Value;

            /*entities.OrderBy(e => (GraphicComponent)(e.GetComponent(nameof(GraphicComponent))).zOrder);
             *
             * foreach (var e in entities) {
             *  var mapEnts = entities.Where(ent => ent.GetComponents().ContainsKey(nameof(GraphicComponent)));
             *  return mapEnts.OrderBy(x.)
             *  //return mapEnt.getComponent(nameof(component));
             * }*/
        }
コード例 #4
0
ファイル: GraphicsTurnerForm.cs プロジェクト: slawer/skc
        public GraphicsTurnerForm(GraphicComponent.GraphicManager man)
        {
            InitializeComponent();

            _app = Application.CreateInstance();
            manager = man;
        }
コード例 #5
0
ファイル: Sound.cs プロジェクト: romeguarin/XNAZuneGames
        private void setFrame()
        {
            GraphicComponent frame = new GraphicComponent("Menus/Option Frame", new Rectangle(39, 105, 196, 360));

            frame.setTransitions(new FadeComponent(15, 1), new FadeComponent(15, -1));

            addComponent(frame);
        }
コード例 #6
0
 /// <summary>
 /// ファイルをクリア
 /// </summary>
 public virtual void ClearFile()
 {
     GraphicComponent.RemoveComponentMySelf();
     GraphicComponent = null;
     this.gameObject.RemoveComponent <AssetFileReference>();
     this.File = null;
     this.Loader.Unload();
     this.GraphicInfo = null;
 }
コード例 #7
0
        private void setBackground()
        {
            BackgroundComponent background = new BackgroundComponent("Menus/Standard Menu");

            background.setTransitions(new FadeComponent(15, 1), new FadeComponent(15, -1));

            addComponent(background);

            GraphicComponent bar = new GraphicComponent("Media Player/Media Buttons Frame", new Rectangle(52, 240, 160, 35));

            bar.setTransitions(new MoveComponent(new Vector2(-200, 0), true, 15), new MoveComponent(new Vector2(200, 0), false, 15));
            addComponent(bar);
        }
コード例 #8
0
        public Entity Create(string filepath, Vector3d?position = null, Vector3d?scale = null, string program = "standard", string texture = "Resources/Textures/debug-256.png")
        {
            var g = new GraphicComponent();

            g.ModelName     = filepath;
            g.ProgramName   = program;
            g.TextureName   = texture;
            g.Model         = ResourceManager.Models.Load(filepath);
            g.Model.Program = ResourceManager.Programs[program];
            g.Model.Texture = ResourceManager.Textures[texture];

            var b = new BaseComponent();

            if (null != scale)
            {
                b.Scale = scale.Value;
            }
            if (null != position)
            {
                b.Position = position.Value;
            }

            var bb = g.Model.Mesh().BoundingBox;

            if (null != scale)
            {
                bb.Max = Vector3d.Multiply(bb.Max, scale.Value);
                bb.Min = Vector3d.Multiply(bb.Min, scale.Value);
            }

            var bs = g.Model.Mesh().BoundingSphere;

            if (null != scale)
            {
                bs.Radius *= scale.Value.Length;
            }

            var e = new Entity(filepath, true)
                    .Add(b)
                    .Add(new PhysicComponent()
            {
                BoundingBox = bb, BoundingSphere = bs
            })
                    .Add(g);

            EntityManager.AddEntity(e);

            return(e);
        }
コード例 #9
0
        public Entity CreateGrid()
        {
            var g = new GraphicComponent();

            g.ModelName   = typeof(Grid).FullName;
            g.ProgramName = "normal";

            var e = new Entity("Grid")
                    .Add(new BaseComponent())
                    .Add(g);

            EntityManager.AddEntity(e);

            return(e);
        }
コード例 #10
0
        private void uploadTree()
        {
            EntityManager entityManager = EntityManager.Instance;
            var           entities      = entityManager.Entities;

            if (entityManager.Player != null)
            {
                entities.Add(entityManager.Player);
            }

            Clear();
            foreach (var entity in entities)
            {
                var graphicComponents = entity.GetComponent(typeof(GraphicComponent));

                foreach (var component in graphicComponents)
                {
                    if (component != null)
                    {
                        GraphicComponent graphicComponent = component as GraphicComponent;
                        RenderService.Models.Position    entityPosition  = new Position(entity.Position.X, entity.Position.Y);
                        RenderService.Models.Position    texturePosition = new Position(graphicComponent.Texture.X, graphicComponent.Texture.Y);
                        RenderService.Enums.DrawPriority priority;
                        switch (graphicComponent.RenderType)
                        {
                        case Rendertype.FirstLevel:
                            priority = RenderService.Enums.DrawPriority.High;
                            break;

                        case Rendertype.Background:
                            priority = RenderService.Enums.DrawPriority.Low;
                            break;

                        case Rendertype.Normal:
                            priority = RenderService.Enums.DrawPriority.Normal;
                            break;

                        default:
                            priority = RenderService.Enums.DrawPriority.Normal;
                            break;
                        }

                        GraphicNode node = new GraphicNode(entityPosition, texturePosition, priority);
                        addNode(node);
                    }
                }
            }
        }
コード例 #11
0
        protected UnitEntity buildCube()
        {
            UnitEntity   e            = new UnitEntity();
            UnitServices unitservices = new UnitServices();

            unitservices.AddService(typeof(IUnitEntityType), e);

            GraphicComponent graphic = new GraphicComponent(); // get provided services

            // init each component
            initializeComponent(graphic, unitservices);
            graphic.LoadContent();

            e.Components.Add(graphic);
            return(e);
        }
コード例 #12
0
        //STEP 3: SENSE (COMPONENT) -> EXTRACT FROM COMPONENT:
        // 1) STATION
        // 2) START_VECTOR
        // 3) END_VECTOR
        // 4) RADIUS
        // 5) GLOBAL TRANSFORMATION MATRIX
        // -> USE MATRIX ON START_VECTOR AND END_VECTOR TO MAKE GLOBAL_START_VECTOR & GLOBAL_END_VECTOR
        // MAKE NEW NULL PART
        // MAKE A POINT OBJECT AS ZERO-LENGTH-VECTOR (WHAT'S A ZERO-LENGTH-VECTOR?)
        // MAKE NEW NULL GRAPHICS COMPONENT -> (ASSUMPTION: TRY TO ALLOCATE A GRAPHICS COMPONENT VIA component.GraphicComponents.TryGetGraphicComponent())
        // CHECK FOR LINE INTERSECTION:
        //            IF INTERSECTION -> ALLOCATE PART AND POINT TO COMPONENT -> RETURN 1
        //            ELSE -> ALLOCATE NULL AND ZERO_POINT TO COMPONENT       -> RETURN 0
        protected int Sense(SmartComponent component)
        {
            Station stn = component.ContainingProject as Station;

            if (stn == null)
            {
                return(0);             //??
            }
            Vector3 start  = (Vector3)component.Properties["Start"].Value;
            Vector3 end    = (Vector3)component.Properties["End"].Value;
            double  radius = (double)component.Properties["Radius"].Value;

            // Convert to global (i.e. translate start and end point from component frame coorinates to global coordinates)
            Matrix4 mat = component.Transform.GlobalMatrix;

            start = mat.MultiplyPoint(start);
            end   = mat.MultiplyPoint(end);

            Part    part  = null;
            Vector3 point = Vector3.ZeroVector;

            GraphicComponent gc = null;

            component.GraphicComponents.TryGetGraphicComponent("_sensorPart_", out gc);//<- WHAT'S ALL THIS THEN?!

            int result;

            if (CollisionDetector.CheckLineIntersection(stn, start, end, radius, out part, out point))
            {
                component.Properties["SensedPart"].Value  = part;
                component.Properties["SensedPoint"].Value = point;
                result = 1;
            }
            else
            {
                component.Properties["SensedPart"].Value  = null;
                component.Properties["SensedPoint"].Value = Vector3.ZeroVector;
                result = 0;
            }

            return(result);
        }
コード例 #13
0
        //GRAPHICS STUFF: ?something? -> CreateGraphic()
        protected void RebuildGraphic(SmartComponent component)
        {
            GraphicComponent gc = null;

            if (component.GraphicComponents.TryGetGraphicComponent("_sensorPart_", out gc))
            {
                component.GraphicComponents.Remove(gc);
            }

            Part part = new Part(false);

            part.UIVisible      = false;
            part.PickingEnabled = false;
            part.Detectable     = false;
            part.Name           = "_sensorPart_";
            component.GraphicComponents.Add(part);

            MeshPart mp = new MeshPart();

            CreateGraphic(component, mp);
            part.Mesh[DetailLevels.Medium] = mp;
            part.Mesh.Rebuild();
            part.Color = System.Drawing.Color.FromArgb(64, 255, 255, 0);
        }
コード例 #14
0
 /// <summary>
 /// Used to specify to which <see cref="GraphicComponent"/> is requesting the draw commands.
 /// </summary>
 /// <param name="graphic"></param>
 internal void SetCurrentGraphicComponent(GraphicComponent graphic)
 {
     _currentGraphicComponent = graphic;
 }
コード例 #15
0
ファイル: ChunkCulling.cs プロジェクト: pacojq/Mononoke
 public void RemoveGraphic(GraphicComponent graphic)
 {
     throw new System.NotImplementedException();
 }
コード例 #16
0
 public void RemoveGraphic(GraphicComponent graphic)
 {
     _graphics.Remove(graphic);
 }
コード例 #17
0
 public void AddGraphic(GraphicComponent graphic)
 {
     _graphics.Add(graphic);
 }
コード例 #18
0
 internal void RemoveGraphic(GraphicComponent graphic)
 {
     GraphicsCulling.RemoveGraphic(graphic);
 }
コード例 #19
0
        public void Process(List <AbstractEffect> effects)
        {
            // Draw map
            MapData map_data = this.viewData.GetMapData();

            if (map_data.map != null)
            {
                this.view.mapConsole.Clear();
                for (int y = 0; y < map_data.getHeight(); y++)
                {
                    for (int x = 0; x < map_data.getWidth(); x++)
                    {
                        var           entities = map_data.map[x, y];
                        var           mapEnt   = entities.Single(ent => ent.GetComponents().ContainsKey(nameof(MapsquareData)));
                        MapsquareData msdc     = (MapsquareData)mapEnt.GetComponent(nameof(MapsquareData));
                        if (msdc.visible || Settings.DEBUG_DRAW_ALL)
                        {
                            // Only draw stuff if mapsquare visible
                            AbstractEntity   sq = map_data.GetComponentToDraw(x, y);
                            GraphicComponent gc = (GraphicComponent)sq.GetComponent(nameof(GraphicComponent));
                            RLCell           tc = gc.getVisibleChar();
                            this.view.mapConsole.Set(x, y, tc);
                            if (sq == this.viewData.GetCurrentUnit())
                            {
                                this.view.mapConsole.SetBackColor(x, y, RLColor.Yellow);
                            }
                        }
                        else if (msdc.seen)
                        {
                            AbstractEntity   sq = map_data.GetComponentToDraw(x, y);
                            GraphicComponent gc = (GraphicComponent)sq.GetComponent(nameof(GraphicComponent));
                            this.view.mapConsole.Set(x, y, gc.getSeenChar());
                        }
                        else
                        {
                            this.view.mapConsole.Set(x, y, this.invisible);
                        }
                    }
                }
            }

            // Draw effects
            foreach (var effect in effects)
            {
                effect.draw(this.view.mapConsole);
            }

            // Draw line
            var line2 = this.viewData.GetLine();

            if (line2 != null)
            {
                foreach (var point in line2)
                {
                    this.view.mapConsole.SetBackColor(point.X, point.Y, RLColor.Gray);
                }
            }

            // Draw hover text
            this.view.mapConsole.Print(1, DefaultRLView._mapHeight - 1, this.viewData.GetHoverText(), RLColor.White);

            // Draw crew
            this.view.crewListConsole.Clear();
            int yPos = 0;

            this.view.crewListConsole.Print(0, yPos, "CREW LIST", RLColor.White);
            yPos++;
            int idx = 1;

            foreach (AbstractEntity e in this.viewData.GetUnits())
            {
                RLColor          c   = RLColor.White;
                MobDataComponent mdc = (MobDataComponent)e.GetComponent(nameof(MobDataComponent));
                if (e == this.viewData.GetCurrentUnit())
                {
                    c = RLColor.Yellow; // Highlight selected unit
                }
                else if (mdc.actionPoints <= 0)
                {
                    c = RLColor.Gray;
                }
                MovementDataComponent move = (MovementDataComponent)e.GetComponent(nameof(MovementDataComponent));
                string routeIndicator      = move.route == null || move.route.Count == 0 ? "" : "(R)";
                this.view.crewListConsole.Print(0, yPos, $"{idx}: {e.name} {routeIndicator} ({mdc.actionPoints} APs)", c);
                yPos++;
                idx++;
            }

            // Draw unit stats or menu selection
            this.view.statConsole.Clear();
            yPos = 0;
            Dictionary <int, AbstractEntity> items = this.viewData.GetItemSelectionList();

            if (items != null && items.Count > 0)
            {
                foreach (var idx2 in items.Keys)
                {
                    this.view.statConsole.Print(0, yPos, $"{idx2} : {items[idx2].name}", RLColor.White);
                    yPos++;
                }
            }
            else
            {
                AbstractEntity currentUnit = this.viewData.GetCurrentUnit();
                if (currentUnit != null)
                {
                    foreach (var s in this.viewData.GetStatsFor(currentUnit))
                    {
                        this.view.statConsole.Print(0, yPos, s, RLColor.White);
                        yPos++;
                    }
                }
            }

            // Draw log
            this.view.logConsole.Clear();
            var log = this.viewData.GetLog();
            int pos = 1;

            foreach (var line in log)
            {
                this.view.logConsole.Print(1, pos++, line, RLColor.White);
            }
        }
コード例 #20
0
        // ====================== RENDERING ====================== //

        internal void AddGraphic(GraphicComponent graphic)
        {
            GraphicsCulling.AddGraphic(graphic);
        }