Beispiel #1
0
 public TransportComponent(TransportTypeVO transportType) : base(transportType.AssetName)
 {
     this.TransportType    = transportType;
     this.Spline           = new LinearSpline((float)transportType.MaxSpeed);
     this.GameObj          = null;
     this.ShadowGameObject = null;
     this.ShadowMaterial   = null;
 }
Beispiel #2
0
        private void SpawnTransport(ContractEventData contractData)
        {
            if (!this.CountTransportRequest(contractData))
            {
                return;
            }
            Entity         entity     = contractData.Entity;
            BuildingTypeVO buildingVO = contractData.BuildingVO;
            string         uid;

            if (buildingVO.Faction == FactionType.Empire)
            {
                uid = this.TRANSPORT_SHIP_EMPIRE;
            }
            else
            {
                if (buildingVO.Faction != FactionType.Rebel)
                {
                    return;
                }
                uid = this.TRANSPORT_SHIP_REBEL;
            }
            TransportTypeVO transportType = Service.StaticDataController.Get <TransportTypeVO>(uid);
            Entity          entity2       = this.FindIdleTransport(transportType);

            if (entity2 == null)
            {
                return;
            }
            Entity entity3 = this.FindIdleStarport(contractData);

            if (entity3 == null)
            {
                return;
            }
            TransformComponent transformComponent = entity.Get <TransformComponent>();
            Vector3            vector             = new Vector3(Units.BoardToWorldX(transformComponent.CenterX()), 0f, Units.BoardToWorldZ(transformComponent.CenterZ()));
            GameObject         vehicleLocator     = entity.Get <GameObjectViewComponent>().VehicleLocator;

            if (vehicleLocator != null)
            {
                this.factoryOffset = new Vector3(0f, vehicleLocator.transform.position.y + TransportController.FACTORY_WALL_HEIGHT, 0f);
            }
            else
            {
                this.factoryOffset = new Vector3(0f, TransportController.FACTORY_WALL_HEIGHT, 0f);
            }
            vector            += this.factoryOffset;
            transformComponent = entity3.Get <TransformComponent>();
            Vector3 vector2 = new Vector3(Units.BoardToWorldX(transformComponent.CenterX()), 0f, Units.BoardToWorldZ(transformComponent.CenterZ()));

            vector2 += TransportController.DOCK_OFFSET;
            TransportComponent transportComponent = entity2.Get <TransportComponent>();

            this.BuildSpline(transportComponent.Spline, TransportController.SPAWN_POSITION, vector, vector2, entity3, contractData);
            entity2.Get <StateComponent>().CurState = EntityState.Moving;
        }
Beispiel #3
0
        public Entity CreateTransportEntity(TransportTypeVO transportType)
        {
            Entity        entity    = this.NewEntity();
            SizeComponent component = Units.SizeCompFromGrid(transportType.SizeX, transportType.SizeY);

            entity.Add(component);
            TransportComponent component2 = new TransportComponent(transportType);

            entity.Add(component2);
            Service.Get <EntityViewManager>().LoadEntityAsset(entity);
            return(entity);
        }
Beispiel #4
0
        private Entity FindIdleTransport(TransportTypeVO transportType)
        {
            NodeList <TransportNode> nodeList = this.entityController.GetNodeList <TransportNode>();

            for (TransportNode transportNode = nodeList.Head; transportNode != null; transportNode = transportNode.Next)
            {
                if (transportNode.State.CurState == EntityState.Idle)
                {
                    transportNode.Transport.GameObj.SetActive(true);
                    return(transportNode.Entity);
                }
            }
            Entity entity = Service.EntityFactory.CreateTransportEntity(transportType);

            Service.EntityController.AddEntity(entity);
            return(entity);
        }