// Use this for initialization
    void Start()
    {
        if (levelProperties == null) {
            levelProperties = GameObject.Find ("GameManager").GetComponent<LevelProperties> ();
        }

        ShipAssembler shipAssembler = gameObject.AddComponent<ShipAssembler> ();
        shipMotor = shipAssembler.AssembleShip (shipName, shipName);
        ship = shipMotor.gameObject;

        ship.transform.Rotate (0, 0, 180);

        view = transform.Find ("View").gameObject;

        /*
        foreach (WeaponSlot slot in shipMotor.properties.equipmentList.weaponSlots) {
            ((WeaponSlot)levelProperties.equipmentCellMap.AddEquipmentCell (slot).linkToSlot).MountWeapon ((TypicalWeapon)levelProperties.availableEquipmentList.weaponsList[0]);
        }
        */
        foreach (WeaponSlot slot in shipMotor.properties.equipmentList.weaponSlots) {
            slot.MountEquipment (levelProperties.availableEquipmentList.weaponsList[0]);
        }
        shipMotor.properties.equipmentList.hullSlots[0].MountEquipment (levelProperties.availableEquipmentList.hullsList[1]);
        shipMotor.properties.equipmentList.engineSlots[0].MountEquipment (levelProperties.availableEquipmentList.enginesList[0]);
        shipMotor.properties.equipmentList.miscSlots[0].MountEquipment (levelProperties.availableEquipmentList.miscList[0]);
        shipMotor.properties.equipmentList.miscSlots[1].MountEquipment (levelProperties.availableEquipmentList.miscList[1]);

        levelProperties.equipmentCellMap.ToggleEquipmentWindowVisibility ();
        levelProperties.equipmentCellMap.ToggleEquipmentWindowVisibility ();
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        // Generate game objects
        if (currentNumOfObjects < levelProperties.objectsInGameMax && Time.time > lastGeneratedObjectTime + levelProperties.objectsGenerationFrequency && CurrentGameState == GameState.Game) {
            string newShipName = ((SpaceObject)levelProperties.spaceObjects.GetValue (Random.Range (0, levelProperties.spaceObjects.Length - 1))).gameObject.name;

            currentShip = new GameObject (newShipName + " Container", typeof(ShipAssembler), typeof(AIController));
            ShipAssembler shipAssembler = currentShip.GetComponent<ShipAssembler> ();
            currentShipMotor = shipAssembler.AssembleShip (newShipName, newShipName);

        //			currentShip.GetComponent<AIController> ().shipMotor = currentShipMotor;

            nmbrOfGeneratedObjects++;
            currentNumOfObjects++;
            lastGeneratedObjectTime = Time.time;
        }
    }