Ejemplo n.º 1
0
 public void Run()
 {
     foreach (var i in _filter)
     {
         RotatingObject rt = _filter.Get1[i];
         _filter.Get2[i].EulerRotation.x = (_filter.Get2[i].EulerRotation.x + rt.RotatingSpeedX) % 360.0f;
         _filter.Get2[i].EulerRotation.y = (_filter.Get2[i].EulerRotation.y + rt.RotatingSpeedY) % 360.0f;
         _filter.Get2[i].EulerRotation.z = (_filter.Get2[i].EulerRotation.z + rt.RotatingSpeedZ) % 360.0f;
     }
 }
Ejemplo n.º 2
0
        public void ParseWorldNodes(JSONNode node, EcsWorld ecsWorld)
        {
            foreach (var point in node["data"]["points"])
            {
                EcsEntity entity = ecsWorld.NewEntity();
                
                // parse worldpoint entry
                WorldPoint worldPoint = entity.Set<WorldPoint>();
                worldPoint.PointID = int.Parse(point.Key);
                worldPoint.PointType = (WorldPointType) point.Value["loc_type"].AsInt;

                // Set Object rotation
                RotatingObject rObject = entity.Set<RotatingObject>();
                rObject.RotatingSpeedX = Random.Range(-0.2f, 0.2f);
                rObject.RotatingSpeedY = Random.Range(-0.2f, 0.2f);
                rObject.RotatingSpeedZ = Random.Range(-0.2f, 0.2f);

                ObjectOwner objOwner = entity.Set<ObjectOwner>();
                objOwner.OwnerUsername = point.Value["owned_by"];
                objOwner.IsOwned = (objOwner.OwnerUsername) == "" ? false : true;
                
                // parse position
                Positioning.Components.Position pos = entity.Set<Positioning.Components.Position>();
                pos.Point.Set(point.Value["position"]["x"].AsInt, Random.Range(-10.0f, 10.0f), point.Value["position"]["y"].AsInt);
                IDtoPoint.Add(worldPoint.PointID, pos.Point);
                
                // parse point type
                switch (worldPoint.PointType)
                {
                    case WorldPointType.Asteroid:
                        entity.Set<AllocateView>().id = "Asteroid";
                        break;
                    case WorldPointType.Planet:
                        entity.Set<AllocateView>().id = "Planet";
                        break;
                    case WorldPointType.Station:
                        entity.Set<AllocateView>().id = "Station";
                        rObject.RotatingSpeedX = 0.0f;
                        rObject.RotatingSpeedZ = 0.0f;
                        break;
                }

            }

            // Generating lines
            foreach (var point in node["data"]["points"]) {
                int pID = int.Parse(point.Key);

                foreach (var neighbour in point.Value["adjacent"])
                {
                    int nKey = int.Parse(neighbour.Value);
                    if (nKey < pID) {
                        EcsEntity lineEntity = ecsWorld.NewEntity();

                        LineConnection lConnection = lineEntity.Set<LineConnection>();
                        lConnection.PositionA = IDtoPoint[pID];
                        lConnection.PositionB = IDtoPoint[nKey];

                        lineEntity.Set<AllocateView>().id = "Line";
                    }
                    
                }
            }

        }