Esempio n. 1
0
    public CosmicPortLandLaunchManager(MonoBehaviour mono, ShipPrefab shipPrefab, Transform launchShipContainer, Transform landShipContainer)
    {
        shipsQueue = new Queue <CosmicPortQueueElement>();

        this.mono                = mono;
        this.shipPrefab          = shipPrefab;
        this.launchShipContainer = launchShipContainer;
        this.landShipContainer   = landShipContainer;
    }
Esempio n. 2
0
    public void LandShip(Trip trip)
    {
        if (isLandingOrLaunching)
        {
            AddToQueue(LandOrLaunch.Land, trip);
            return;
        }

        spawnedShipPrefab = Object.Instantiate(shipPrefab, landShipContainer);
        spawnedShipPrefab.Land(trip, launchShipContainer.position.y);
        spawnedShipPrefab.onLanded += OnLanded;

        SetToBusy();

        mono.StartCoroutine(HandleNextQueueElementCo());
    }
Esempio n. 3
0
        private void readPrefabs()
        {
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(ResourcesManager.xmlPath + "rocketInfo.xml");

            XmlNode rocketsNode = xmldoc.SelectSingleNode("/rockets");
            int     count       = rocketsNode.ChildNodes.Count;
            XmlNode currRocketNode;
            XmlNode currStatNode;

            ShipPrefabs = new ShipPrefab[count];
            string name;
            string path;
            int    defaultHealth;
            int    defaultSpeed;
            int    price;

            for (int i = 0; i < count; i++)
            {
                int[] maxUpgrades = new int[5];
                currRocketNode = rocketsNode.SelectSingleNode(string.Format("r{0}", i));
                name           = currRocketNode.SelectSingleNode("name").InnerText;
                path           = currRocketNode.SelectSingleNode("texture").InnerText;
                for (int j = 0; j < 5; j++)
                {
                    currStatNode = currRocketNode.SelectSingleNode(string.Format("s{0}", j));
                    Int32.TryParse(currStatNode.InnerText, out maxUpgrades[j]);
                }
                Int32.TryParse(currRocketNode.SelectSingleNode("price").InnerText, out price);
                Int32.TryParse(currRocketNode.SelectSingleNode("health").InnerText, out defaultHealth);
                Int32.TryParse(currRocketNode.SelectSingleNode("speed").InnerText, out defaultSpeed);
                ShipPrefabs[i] = new ShipPrefab
                {
                    ShipName      = name,
                    Price         = price,
                    TexturePath   = path,
                    MaxUpgrades   = maxUpgrades,
                    DefaultHealth = defaultHealth,
                    DefaultSpeed  = defaultSpeed
                };
            }
        }
Esempio n. 4
0
    public void LaunchShip(SendShipData sendShipData, int level)
    {
        if (isLandingOrLaunching)
        {
            AddToQueue(LandOrLaunch.Launch, sendShipData);
            return;
        }

        ShipPrefab ship = Object.Instantiate(shipPrefab, launchShipContainer);

        ship.Launch(sendShipData.launchingDock.Ship.shipType, level, landShipContainer.position.y);

        SetToBusy();

        TripsManager.Instance.StartNewTrip(Settlement.Instance.Planet, sendShipData.destination, GetTimeToDestination(sendShipData.destination), sendShipData.launchingDock.Ship, sendShipData.destinationDock);

        sendShipData.launchingDock.RemoveShip();

        mono.StartCoroutine(HandleNextQueueElementCo());
    }