/// <summary>
    /// Only use this when copying existing gameobjects
    /// Use copyInitialization() for copies of
    /// existing gameobjects
    /// </summary>
    public virtual void copyInitialization()
    {
        for (int i = 0; i < canonMountCapacity; i++)
        {
            Weapons_Base     wScript = canonMounted[i].GetComponent <Weapons_Base>();
            Player_Charactor hScript = GameObject.Find("ARCamera").GetComponent <Player_Charactor>();
            wScript.forceStart();

            for (int j = 0; j < hScript.hangar.canonTypes.Count; j++)
            {
                if (hScript.hangar.canonTypes[j] == canonTypes[i])
                {
                    wScript.setUpStates(hScript.hangar.canonUpgrade1[j], hScript.hangar.canonUpgrade2[j], hScript.hangar.canonUpgrade3[j]);
                    wScript.canShoot = true;
                }
            }
        }

        mountMagasinCapacity1 = canonMounted[0].GetComponent <Weapons_Base>().weaponCapacity() * 2;
        if (canonMountCapacity > 2)
        {
            mountMagasinCapacity2 = canonMounted[2].GetComponent <Weapons_Base>().weaponCapacity() * 2;
        }
        shipInGameHealth = shipHealth();
        shipInGameShield = shipShield();
    }
    // Run function to set class specific lists
    public override void shipInitialization()
    {
        renderer.material.shader = Shader.Find("Game/Spaceship_Shader");
        renderer.material.SetColor("_Texture_Blend_Color", Color.white);
        renderer.material.SetColor("_Texture_Override_Color", Color.red);
        renderer.material.SetColor("_Shield_Blend_Color", new Color(0.0f, 0.2f, 0.6f, 0.0f));
        renderer.material.SetFloat("_Shield_Blend", 0f);


        shipValue  = 10000;
        cameraName = "ARCamera";
        player     = GameObject.Find(cameraName);
        // Character Controller used to move the ship
        // and resets it's size, so it will not block
        // shots from canons
        cc        = GetComponent <CharacterController>();
        cc.radius = 4;
        cc.height = 1;

        // Save the initial rotation of ship for reference
        spaceshipRotation = transform.rotation.z;

        canonScale = transform;

        // Ship speed
        maneuverSpeed = 150f;
        // Health of this ship
        health = 500;
        shield = 250;

        // Amount of gun attachments
        canonMountCapacity = 2;

        canonMount   = new Transform[canonMountCapacity];
        canonTypes   = new string[canonMountCapacity];
        canonMounted = new GameObject[canonMountCapacity];

        Player_Charactor script = player.GetComponent <Player_Charactor>();

        for (int i = 0; i < canonMountCapacity; i++)
        {
            canonMount[i] = transform.FindChild("mountT" + i);
            canonTypes[i] = script.hangar.canonTypes[0];
        }
        // Give an intitial value to canon types

        // Find the canon mounts on model
        // Set array for canons


        for (int i = 0; i < canonMountCapacity / 2; i++)
        {
            mountCanon(i);
        }
    }
Example #3
0
    public void setMainVars()
    {
        player     = GameObject.Find("ARCamera");
        script     = player.GetComponent <Player_Charactor>();
        background = GameObject.Find("ImageTarget");
        // finds the texture for the buttons
        versionNum = script.gameSetting;

        swipeSym                    = Resources.Load("Interface/swipeSymbol") as Texture;
        newFont                     = script.newFont;
        buttonTexture               = script.buttonTexture;
        myGUIStyle.font             = newFont;
        myGUIStyle.normal.textColor = script.textColor;
        myGUIStyle.alignment        = TextAnchor.MiddleCenter;
    }
    public override void Start()
    {
        player           = GameObject.Find("ImageTarget");
        script           = GameObject.Find("ARCamera").GetComponent <Player_Charactor>();
        numberOfChildren = 8;
        string  newProp;
        Vector3 newScale;
        Vector3 newPosition;
        Vector3 newRotation;

        levelNumber = 0;
        spacing     = 600;
        for (int i = 0; i < numberOfChildren; i++)
        {
            newProp     = propName[i];
            newScale    = new Vector3(sizes, sizes, sizes);
            newPosition = new Vector3(spacing * i, 0, 0);
            newRotation = new Vector3(0, 0, 0);
            createSceneObject(newProp, newScale, newPosition, newRotation, player.transform);
            moonObjects[i].transform.parent = transform;
            moonObjects[i].GetComponent <Level_ShowEnemy>().showEnemy(script.enemyVersion, enemyTypes[i]);
        }
    }
    public bool filePresent()
    {
        profile       = GameObject.Find("ARCamera");
        profileScript = profile.GetComponent <Player_Charactor>();
        //string path = Application.dataPath + "/SaveGame";
        string path = Application.persistentDataPath + "/SaveGame";

        if (Directory.Exists(path))
        {
            if (!File.Exists(path + "/profileSave.fzf"))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        else
        {
            return(false);
        }
    }
    public override void initializeCanon(Transform scale, int i)
    {
        canonMounted[i] = (GameObject)Object.Instantiate(Resources.Load(canonTypes[i]));
        Transform thisTrans = canonMounted[i].transform;

        //canonMounted[i].transform.localScale = new Vector3(thisTrans.localScale.x * scale.localScale.x ,thisTrans.localScale.y * scale.localScale.y , thisTrans.localScale.z * scale.localScale.z);
        canonMounted[i].transform.position = canonMount[i].position;
        canonMounted[i].transform.rotation = canonMount[i].rotation;
        canonMounted[i].transform.parent   = canonMount[i].transform;

        Weapons_Base     wScript = canonMounted[i].GetComponent <Weapons_Base>();
        Player_Charactor hScript = GameObject.Find("ARCamera").GetComponent <Player_Charactor>();

        wScript.forceStart();

        for (int j = 0; j < hScript.hangar.canonTypes.Count; j++)
        {
            if (hScript.hangar.canonTypes[j] == canonTypes[i])
            {
                wScript.setUpStates(hScript.hangar.canonUpgrade1[j], hScript.hangar.canonUpgrade2[j], hScript.hangar.canonUpgrade3[j]);
            }
        }
    }
    public void gameLoad()
    {
        profile       = GameObject.Find("ARCamera");
        profileScript = profile.GetComponent <Player_Charactor>();
        Debug.Log("x");
        // Find path of folder
        //string path = Application.dataPath + "/SaveGame/";
        string path = Application.persistentDataPath + "/SaveGame";

        Debug.Log(path);
        // If the file exists
        if (File.Exists(path + "/profileSave.fzf"))
        {
            Debug.Log("xxx");
            // Load file
            StreamReader fileLoaded = File.OpenText(path + "/profileSave.fzf");
            string       s          = "";
            // while there is a new line read it
            while ((s = fileLoaded.ReadLine()) != null)
            {
                // Split the line at the '='
                string[] getLine = s.ToString().Split('=');
                // Match title to variable and update game

                if (getLine[0] == "CanonType")
                {
                    profileScript.hangar.addGunToHangar(getLine[1]);
                }
                if (getLine[0] == "CanonUpgrade1")
                {
                    profileScript.hangar.canonUpgrade1.Add(int.Parse(getLine[1]));
                }
                if (getLine[0] == "CanonUpgrade2")
                {
                    profileScript.hangar.canonUpgrade2.Add(int.Parse(getLine[1]));
                }
                if (getLine[0] == "CanonUpgrade3")
                {
                    profileScript.hangar.canonUpgrade3.Add(int.Parse(getLine[1]));
                }

                if (getLine[0] == "ShipType")
                {
                    profileScript.hangar.addSpaceshipToHangar(getLine[1]);
                }
                if (getLine[0] == "ShipUpgrade1")
                {
                    profileScript.hangar.shipUpgrade1.Add(int.Parse(getLine[1]));
                }
                if (getLine[0] == "ShipUpgrade2")
                {
                    profileScript.hangar.shipUpgrade2.Add(int.Parse(getLine[1]));
                }
                if (getLine[0] == "ShipUpgrade3")
                {
                    profileScript.hangar.shipUpgrade3.Add(int.Parse(getLine[1]));
                }
                if (getLine[0] == "GameVersion")
                {
                    profileScript.gameSetting = int.Parse(getLine[1]);
                }
                if (getLine[0] == "LevelCompleted")
                {
                    profileScript.levelsCompleted = int.Parse(getLine[1]);
                }
                if (getLine[0] == "Credit")
                {
                    profileScript.credits = int.Parse(getLine[1]);
                }
                if (getLine[0] == "DatabaseID")
                {
                    profileScript.userDatabaseID = int.Parse(getLine[1]);
                }
                if (getLine[0] == "ShipChoise")
                {
                    profileScript.shipChoise = int.Parse(getLine[1]);
                }
                if (getLine[0] == "CannonChoise1")
                {
                    profileScript.hangar.mount1Set = int.Parse(getLine[1]);
                }
                if (getLine[0] == "CannonChoise2")
                {
                    profileScript.hangar.mount2Set = int.Parse(getLine[1]);
                }
            }
            // Close the file
            fileLoaded.Close();
        }
    }
 // Use this for initialization
 public void Start()
 {
     profile       = GameObject.Find("ARCamera");
     profileScript = profile.GetComponent <Player_Charactor>();
 }