public void setHangar()
    {
        Debug.Log(mount1Set + " " + mount2Set);
        int hangarCapacity = shipTypes.Count;

        if (hangarslots.Count != hangarCapacity)
        {
            for (int i = hangarslots.Count; i < hangarCapacity; i++)
            {
                GameObject newObj = (GameObject)Object.Instantiate(Resources.Load(shipTypes[i]));
                newObj.SetActive(false);
                Spaceship_Player script = newObj.GetComponent <Spaceship_Player>();
                script.IsActive = false;
                if (shipUpgrade1.Count != shipTypes.Count)
                {
                    addToShipUpgrades();
                }
                script.setUpStates(shipUpgrade1[i], shipUpgrade2[i], shipUpgrade3[i]);
                script.shipInitialization();
                hangarslots.Add(newObj);

                gunMountManagement(canonTypes[mount1Set], i, 0);
                if (script.CanonMountCapacity > 2)
                {
                    gunMountManagement(canonTypes[mount2Set], i, 1);
                }
            }
        }
    }
    public void gunMountManagement(string gunType, int ship, int m)
    {
        Spaceship_Player script = hangarslots[ship].GetComponent <Spaceship_Player>();

        script.removeCanon(m);
        script.gunSetting(gunType, m);
        script.mountCanon(m);
    }
    public void setNewUpgradesHangar(int slotPos)
    {
        Spaceship_Player script = hangarslots[slotPos].GetComponent <Spaceship_Player>();

        script.setUpStates(shipUpgrade1[slotPos], shipUpgrade2[slotPos], shipUpgrade3[slotPos]);
        gunMountManagement(script.canonTypes[mount1Set], slotPos, 0);
        if (script.CanonMountCapacity > 2)
        {
            gunMountManagement(script.canonTypes[mount2Set], slotPos, 1);
        }
    }
    public override void updateLevel()
    {
        //Debug.Log(canonLimit);

        if (completed)
        {
        }
        else
        {
            script.hangar.hangarslots[script.shipChoise].SetActive(false);
            script.shipChoise = swipeControl.SwipeCounter;
            shipScript        = script.hangar.hangarslots[script.shipChoise].GetComponent <Spaceship_Player>();
            canonLimit        = shipScript.CanonMountCapacity;
            script.hangar.hangarslots[script.shipChoise].SetActive(true);
            script.hangar.hangarslots[script.shipChoise].transform.Rotate(new Vector3(0, 1, 0) * Time.deltaTime * 45);
        }
    }
示例#5
0
    protected void createPlayerSpaceship(GameObject gameProp, Vector3 scale, Vector3 pos, Vector3 turnRotation, Transform cameraTransform, bool active, bool onStage)
    {
        gameProp.transform.localScale = scale;
        Vector3 newPos = cameraTransform.position;

        newPos.x += pos.x;
        newPos.y += pos.y;
        newPos.z += pos.z;
        gameProp.transform.position = newPos;
        gameProp.transform.rotation = cameraTransform.rotation;
        gameProp.transform.Rotate(new Vector3(1, 0, 0) * turnRotation.x);
        gameProp.transform.Rotate(new Vector3(0, 1, 0) * turnRotation.y);
        gameProp.transform.Rotate(new Vector3(0, 0, 1) * turnRotation.z);
        gameProp.SetActive(onStage);
        Spaceship_Player shipScript = gameProp.GetComponent <Spaceship_Player>();

        shipScript.IsActive = active;
    }
    public void setSpaceshipGuns(int ps)
    {
        int shipC = GameObject.Find("ARCamera").GetComponent <Player_Charactor>().shipChoise;
        Spaceship_Player script = hangarslots[shipC].GetComponent <Spaceship_Player>();

        script.removeCanon(0);
        string _cannon = canonTypes[ps];

        script.gunSetting(_cannon, 0);
        script.mountCanon(0);
        mount1Set = ps;
        if (script.CanonMountCapacity > 2)
        {
            script.removeCanon(1);
            script.gunSetting(_cannon, 1);
            script.mountCanon(1);
            mount2Set = ps;
        }
    }
    protected void setClassTargets()
    {
        fireButton[0] = Resources.Load("Interface/firebutton_vest_up") as Texture;
        fireButton[1] = Resources.Load("Interface/Button_Gui_Fire") as Texture;

        fireButtonDown[0] = Resources.Load("Interface/firebutton_vest_down") as Texture;
        fireButtonDown[1] = Resources.Load("Interface/Button_Gui_Fire_down") as Texture;

        setMainVars();

        player  = GameObject.Find(cameraName);
        script  = player.GetComponent <Player_Charactor>();
        shipScr = script.hangar.hangarslots[script.shipChoise].GetComponent <Spaceship_Player>();
        shipScr.copyInitialization();
        shipHealth          = shipScr.shipHealth();
        shipShield          = shipScr.shipShield();
        shipAmmunition1     = shipScr.mountMagasinCapacity1;
        shipAmmunitionLoss1 = shipScr.mountMagasinCapacity1;

        if (shipScr.CanonMountCapacity > 2)
        {
            shipAmmunition2     = shipScr.mountMagasinCapacity2;
            shipAmmunitionLoss2 = shipScr.mountMagasinCapacity2;
        }


        lifeRemainingTexture       = Resources.Load("Interface/ammobar") as Texture;
        lifeRemainingBehindTexture = Resources.Load("healthb") as Texture;
        _unLoadTimer = 5f;

        completed = false;

        background = GameObject.Find("ImageTarget");

        if (startTime == "")
        {
            startTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Debug.Log(startTime);
        }
    }
    public override void loadLevel()
    {
        swipeControl = gameObject.AddComponent("newSwipe_Levels") as newSwipe_Levels;
        // finds the texture for the buttons
        setMainVars();
        countMountOne = GameObject.Find("ARCamera").GetComponent <Player_Charactor>().hangar.mount1Set;
        countMountTwo = GameObject.Find("ARCamera").GetComponent <Player_Charactor>().hangar.mount2Set;
        swipeControl.setUpSwipeLimits(script.hangar.hangarslots.Count, true);

        completed = false;

        string  newProp;
        Vector3 newScale;
        Vector3 newPosition;
        Vector3 newRotation;

        if (script.gameSetting == 1)
        {
            buildingProps = "Buildings/SpaceHangar";
            newProp       = buildingProps;
            newScale      = new Vector3(5, 10, 5);
            newPosition   = new Vector3(0, 0, -125);
            newRotation   = new Vector3(90, 180, 0);
            createScaleSceneObject(newProp, newScale, newPosition, newRotation, background.transform);
        }
        else
        {
            buildingProps = "Buildings/Planetarium";
            newProp       = buildingProps;
            newScale      = new Vector3(2.9f, 4.2f, 2.9f);
            newPosition   = new Vector3(0, 0, -125);
            newRotation   = new Vector3(90, 180, 0);
            createScaleSceneObject(newProp, newScale, newPosition, newRotation, background.transform);
        }



        newScale    = new Vector3(10, 10, 10);
        newPosition = new Vector3(-23, 0, 50);
        newRotation = new Vector3(0, 0, 0);


        for (int i = 0; i < script.hangar.hangarslots.Count; i++)
        {
            if (i == script.shipChoise)
            {
                createPlayerSpaceship(script.hangar.hangarslots[i], newScale, newPosition, newRotation, props[0].transform.FindChild("buyableObjectSpawn").transform, false, true);
            }
            else
            {
                createPlayerSpaceship(script.hangar.hangarslots[i], newScale, newPosition, newRotation, props[0].transform.FindChild("buyableObjectSpawn").transform, false, false);
            }
        }


        newProp     = "SunLight";
        newScale    = new Vector3(1, 1, 1);
        newPosition = new Vector3(0, 15, -15);
        newRotation = new Vector3(125, 0, 0);
        createDirectionalLightInScene(newProp, newScale, newPosition, newRotation,
                                      background.transform, Color.white);

        shipScript = script.hangar.hangarslots[script.shipChoise].GetComponent <Spaceship_Player>();
        swipeControl.resetSwipe(script.shipChoise);
    }
    public override void levelGUI()
    {
        //
        int buttonHeight = Screen.height / 7, buttonWidth = Screen.width / 4, placementX = 0, placementY = 0, scaleFont = buttonHeight / 3;

        if (canonLimit >= 2)
        {
            placementX = Screen.width - Screen.width / 4;
            placementY = Screen.height / 10;

            GUI.BeginGroup(new Rect(placementX, placementY, buttonWidth, buttonHeight));
            if (GUI.Button(new Rect(0, 0, buttonWidth, buttonHeight), buttonTexture, GUIStyle.none))
            {
                selectedGun = 0;
                countMountOne++;

                if (countMountOne > script.hangar.canonTypes.Count - 1)
                {
                    countMountOne = 0;
                }
                script.hangar.mount1Set = countMountOne;

                shipScript.removeCanon(selectedGun);

                string newarr = script.hangar.canonTypes[countMountOne];
                shipScript.gunSetting(newarr, selectedGun);
                shipScript.mountCanon(selectedGun);
            }
            scaleFont           = buttonHeight / 4;
            myGUIStyle.fontSize = scaleFont;
            string[] getLine  = script.hangar.canonTypes[countMountOne].ToString().Split('/');
            string[] getLine2 = getLine[1].ToString().Split('_');
            GUI.Box(new Rect(0, -buttonHeight / 3, buttonWidth, buttonHeight), "Change Weapon", myGUIStyle);
            GUI.Box(new Rect(0, 0, buttonWidth, buttonHeight), getLine2[0], myGUIStyle);
            GUI.EndGroup();
        }
        if (canonLimit >= 4)
        {
            placementX = Screen.width - Screen.width / 4;
            placementY = Screen.height / 10 + buttonHeight;

            GUI.BeginGroup(new Rect(placementX, placementY, buttonWidth, buttonHeight));
            if (GUI.Button(new Rect(0, 0, buttonWidth, buttonHeight), buttonTexture, GUIStyle.none))
            {
                selectedGun = 1;
                countMountTwo++;
                if (countMountTwo > script.hangar.canonTypes.Count - 1)
                {
                    countMountTwo = 0;
                }

                script.hangar.mount2Set = countMountTwo;

                shipScript.removeCanon(selectedGun);
                string newarr = script.hangar.canonTypes[countMountTwo];
                shipScript.gunSetting(newarr, selectedGun);
                shipScript.mountCanon(selectedGun);
            }
            scaleFont           = buttonHeight / 4;
            myGUIStyle.fontSize = scaleFont;
            string[] getLine  = script.hangar.canonTypes[countMountTwo].ToString().Split('/');
            string[] getLine2 = getLine[1].ToString().Split('_');
            GUI.Box(new Rect(0, -buttonHeight / 3, buttonWidth, buttonHeight), "Change Weapon", myGUIStyle);
            GUI.Box(new Rect(0, 0, buttonWidth, buttonHeight), getLine2[0], myGUIStyle);
            GUI.EndGroup();
        }

        placementX = 0;
        placementY = 0;

        GUI.BeginGroup(new Rect(placementX, placementY, buttonWidth, buttonHeight));
        if (GUI.Button(new Rect(0, 0, buttonWidth, buttonHeight), buttonTexture, GUIStyle.none))
        {
            completed = true;
            for (int i = 0; i < script.hangar.hangarslots.Count; i++)
            {
                Spaceship_Player ship = script.hangar.hangarslots[i].GetComponent <Spaceship_Player>();
                ship.IsActive = false;
                ship.gameObject.SetActive(false);
            }
            deleteAllProps();
        }
        scaleFont           = buttonHeight / 3;
        myGUIStyle.fontSize = scaleFont;
        GUI.Box(new Rect(0, -buttonHeight / 6, buttonWidth, buttonHeight), "Back", myGUIStyle);
        GUI.EndGroup();

        placementX = 0;
        placementY = Screen.height - buttonHeight * 2;

        GUI.BeginGroup(new Rect(placementX, placementY, buttonWidth, buttonHeight * 2));
        GUI.Box(new Rect(0, 0, buttonWidth * 1.5f, buttonHeight * 2), buttonTexture, GUIStyle.none);
        scaleFont           = buttonHeight / 4;
        myGUIStyle.fontSize = scaleFont;
        GUI.Box(new Rect(0, 0, buttonWidth, buttonHeight), shipScript.getGunOne(), myGUIStyle);

        GUI.EndGroup();


        placementX = 0;
        placementY = Screen.height - buttonHeight * 1;

        GUI.BeginGroup(new Rect(placementX, placementY, buttonWidth, buttonHeight * 2));
        GUI.Box(new Rect(0, 0, buttonWidth * 1.5f, buttonHeight * 2), buttonTexture, GUIStyle.none);
        scaleFont           = buttonHeight / 4;
        myGUIStyle.fontSize = scaleFont;
        GUI.Box(new Rect(0, 0, buttonWidth, buttonHeight), shipScript.getShipStats(), myGUIStyle);

        GUI.EndGroup();
    }
    public override void updateLevel()
    {
        shipDamageHealth    = shipScr.shipInGameHealth;
        shipDamageShield    = shipScr.shipInGameShield;
        shipAmmunitionLoss1 = shipScr.mountMagasinCapacity1;
        if (shipScr.CanonMountCapacity > 2)
        {
            shipAmmunitionLoss2 = shipScr.mountMagasinCapacity2;
        }
        enemySpawnScr    = props[0].GetComponent <SpawnControl_Enemy>();
        enemiesDestroyed = enemySpawnScr.EnemyDead;

        //	Debug.Log(levelCompleted);

        if (useAxisInput)
        {
            // assigns the position of the joystick to h and v
            joystickInput = joystick.position.x;
        }
        else
        {
            joystickInput = Input.GetAxis("Horizontal");
        }



        if (spwnScr.spawnEmpty)
        {
            if ((float)enemiesDestroyed / howManyEnemies > 0.6f)
            {
                endGame = "Complete";
                gain    = priceCreditsTotal();
            }
            else
            {
                endGame = "Fail";
                gain    = 0;
            }

            levelCompleted = true;
            _unLoadTimer  -= Time.deltaTime * 1f;

            if (_unLoadTimer < 0)
            {
                if ((float)enemiesDestroyed / howManyEnemies > 0.6f)
                {
                    script.credits += priceCreditsTotal();
                    if (script.levelsCompleted < levelNumber)
                    {
                        script.levelsCompleted = levelNumber;
                    }
                }

                unloadButtons();
                closeLevel();
                Spaceship_Player shipScript = script.hangar.hangarslots[script.shipChoise].GetComponent <Spaceship_Player>();
                shipScript.gameObject.SetActive(false);
                shipScript.IsActive = false;
                completed           = true;
                script.profileMan.gameSave();
                script.databaseConnect.AddScore(script.userDatabaseID.ToString(), script.levelsCompleted.ToString(), startTime, script.credits.ToString(), levelNumber.ToString());
                startTime = "";
                System.GC.Collect();
                Resources.UnloadUnusedAssets();
            }
        }
        else if (shipDamageHealth < 1)
        {
            levelCompleted = true;
            _unLoadTimer  -= Time.deltaTime * 1f;
            Spaceship_Player shipScript = script.hangar.hangarslots[script.shipChoise].GetComponent <Spaceship_Player>();
            shipScript.gameObject.SetActive(false);


            endGame = "Fail";
            gain    = 0;

            if (_unLoadTimer < 0)
            {
                unloadButtons();
                closeLevel();
                resetLevel();
                shipScript.IsActive = false;
                completed           = true;
                script.profileMan.gameSave();
                script.databaseConnect.AddScore(script.userDatabaseID.ToString(), script.levelsCompleted.ToString(), startTime, script.credits.ToString(), levelNumber.ToString());
                startTime = "";
                System.GC.Collect();
                Resources.UnloadUnusedAssets();
            }
        }
        else
        {
            sentButtonInput();
        }
    }