public List <int> tileAmounts;                                                                       //index = tile type, value = amount in inventory

    // Use this for initialization
    void Start()
    {
        SI = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ShipInventory>();

        for (int i = 0; i < 4; i++)
        {
            tileAmounts.Add(0);
        }
        fuelAmount = 0;
        ironAmount = 0;
        // oxygenAmount = 0;
        SI.shipOxygenAmount -= oxygenAmount;
        if (!System.IO.File.Exists(Application.streamingAssetsPath + "/saves/player.save"))             //Si le fichier n'existe pas on le crée
        {
            System.IO.File.Create(Application.streamingAssetsPath + "/saves/player.save").Close();
            string[] baseQuantity = new string[3];
            baseQuantity[0] = "0;0;0";                                                                  //fuel, iron , playeroxygen
            baseQuantity[1] = "0;0;0;0";                                                                //tiles (not useful for this script)
            baseQuantity[2] = "0;100;100;100";                                                          //shipoxygen, engine fuel tank and oxygen tank State
            System.IO.File.WriteAllLines(Application.streamingAssetsPath + "/saves/player.save", baseQuantity);
        }
        else
        {                                                                                               //Sinon on le lis
            string[] lines = System.IO.File.ReadAllLines(Application.streamingAssetsPath + "/saves/player.save");

            string[] tmp = lines[0].Split(';');
            fuelAmount   = 0;
            ironAmount   = 0;
            oxygenAmount = int.Parse(tmp[2]);

            string[] tmp2 = lines[1].Split(';');
            for (int i = 0; i < tmp2.Length; i++)
            {
                tileAmounts[i] = int.Parse(tmp2[i]);
            }
        }
        GameObject ui = GameObject.Find("Canvas");                                                      //On affiche le nombre de tiles que le joueur possède à l'initialisation de la scène de la planète

        if (ui)
        {
            UIScript canvas = ui.GetComponent <UIScript>();
            canvas.UpdateNbTiles(0, tileAmounts[0]);
            canvas.UpdateNbTiles(1, fuelAmount);
            canvas.UpdateNbTiles(2, ironAmount);
        }
        else
        {
            Debug.LogError("Aucun canvas trouvé dans la scène de la planète - PlayerInventory line 44");
        }
        OxygenIntake();
    }
    // Use this for initialization
    void Awake()
    {
        GameObject gameManager = GameObject.FindGameObjectWithTag("GameManager");

        if (gameManager != null)
        {
            param = gameManager.GetComponent <Parameters>();
            if (param != null)
            {
                seedPlanets = param.getAllSeedsSystem();                                                        //Recupere les seeds des planetes du systèmes
                for (int i = 0; i < seedPlanets.Count; i++)                                                     //Positionne chaque planètes sur le tableau de bord
                {
                    Vector3    pos  = new Vector3(xMin + (i / (float)seedPlanets.Count) * (xMax - xMin), y, 0);
                    GameObject temp = Instantiate(planetPrefab, pos, Quaternion.identity);
                    temp.GetComponent <Spaceship_Planet>().setIndexPlanet(i);                                    //Pour que chaque planète connaise son index au sein du système
                    temp.GetComponent <Spaceship_Planet>().setSeed(seedPlanets[i]);
                    if (param.planetSpritesIndexes[param.currentSystem][i] == -1)
                    {
                        var index = Random.Range(0, allSprites.Count);
                        param.planetSpritesIndexes[param.currentSystem][i] = index;
                        temp.GetComponent <SpriteRenderer>().sprite        = allSprites[index];
                    }
                    else
                    {
                        temp.GetComponent <SpriteRenderer>().sprite = allSprites[param.planetSpritesIndexes[param.currentSystem][i]];
                    }
                }
            }
            if (param.comeFromGazeuse)
            {
                param.comeFromGazeuse = false;
                gazeuseWindows.SetActive(true);
                ShipInventory s  = param.gameObject.GetComponent <ShipInventory>();
                var           de = param.getRandomInt(0, 3);
                if (de == 0 && s.GetScannerState() == 1)
                {
                    s.SetScannerState(0);
                }
                else if (de == 1 && s.GetFuelTankState() == 1)
                {
                    s.SetFuelTankState(0);
                }
                else if (de == 2 && s.GetOxygenTankState() == 1)
                {
                    s.SetOxygenTankState(0);
                }
            }
        }
        refreshLeds.Refresh();
    }
Esempio n. 3
0
    void Awake()
    {
        param     = GameObject.FindGameObjectWithTag("GameManager").GetComponent <Parameters>();
        info      = GameObject.FindGameObjectWithTag("planettype").GetComponent <Text>();
        temp      = GameObject.FindGameObjectWithTag("planettemperature").GetComponent <Text>();
        mass      = GameObject.FindGameObjectWithTag("planetemasse").GetComponent <Text>();
        csvReader = GameObject.Find("CSVReader").GetComponent <CSVReader>();
        bar       = GameObject.FindGameObjectWithTag("loadingimage").GetComponent <Image>();
        inv       = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ShipInventory>();
        loadtxt   = GameObject.FindGameObjectWithTag("loadingtext").GetComponent <Text>();

        if (info == null)
        {
            Debug.LogError("Texte non trouvé");
        }
    }
 public void SetupPortScreen()
 {
     shipInventory = GameObject.FindWithTag("Player").GetComponent <ShipInventory>();
 }
 // Use this for initialization
 void Awake()
 {
     s = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ShipInventory>();
     r = panel.GetComponent <RefreshShipLeds>();
 }
Esempio n. 6
0
 void Awake()
 {
     SI = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ShipInventory>();
     p  = GameObject.FindGameObjectWithTag("GameManager").GetComponent <Parameters>();
 }
Esempio n. 7
0
 void Awake()
 {
     playerInventory = GameObject.FindWithTag("Player").GetComponent <ShipInventory>();
 }
 void Awake()
 {
     image         = gameObject.transform.Find("ItemGraphic").GetComponent <Image>();
     shipInventory = GameObject.FindWithTag("Player").GetComponent <ShipInventory>();
 }
Esempio n. 9
0
    // Update is called once per frame
    void Update()
    {
        if (!GameEnd)
        {
            iFrames--;
        }

        while (iFrames > 1800)
        {
            iFrames  -= 1800;
            iMinutes += 1;
        }

        if (iFrames == 0 && iMinutes != 0)
        {
            iMinutes  -= 1;
            ShipParent = GameObject.FindGameObjectWithTag("Player1");
            ShipInventory ShipScript = ShipParent.GetComponent <ShipInventory>();
            int           iFood      = ShipScript.GetFood();
            int           iCrew      = ShipScript.GetCrew();
            if (iFood == 0)
            {
                Debug.Log("Half of crew: " + iCrew / 2);
                if ((iCrew / 2) < 1)
                {
                    iCrew--;
                }
                else
                {
                    iCrew = (iCrew / 2);
                }
                ShipScript.SetCrew(iCrew);
            }
            else
            {
                iFood -= iCrew;
                ShipParent.GetComponent <ShipInventory>().SetFood(iFood);
            }
            iFrames += 1800;
        }
        else if (iFrames == 600 || iFrames == 1200)
        {
            ShipParent = GameObject.FindGameObjectWithTag("Player1");
            ShipInventory ShipScript = ShipParent.GetComponent <ShipInventory>();
            int           iFood      = ShipScript.GetFood();
            int           iCrew      = ShipScript.GetCrew();

            if (iFood < iCrew)
            {
                iCrew -= (iCrew - iFood);
            }
            if (iFood == 0)
            {
                Debug.Log("Half of crew: " + iCrew / 2);
                if ((iCrew / 2) < 1)
                {
                    iCrew--;
                }
                else
                {
                    iCrew = (iCrew / 2);
                }
                ShipScript.SetCrew(iCrew);
            }
            else
            {
                iFood -= iCrew;
                ShipScript.SetFood(iFood);
            }
        }
        counterText.text = iMinutes + " : ";
        if (iFrames < 300)
        {
            counterText.text += "0" + iFrames / 30;
        }
        else
        {
            counterText.text += iFrames / 30;
        }
        if (iFrames <= 0 && iMinutes <= 0)
        {
            GC       = GameObject.FindGameObjectWithTag("GameControl");
            GCScript = GC.GetComponent <GameControl>();
            GCScript.SetGold(GameObject.FindGameObjectWithTag("Player1").GetComponent <ShipInventory>().GetGold());
            GCScript.SetEnding(2);
            SceneManager.LoadScene("Ending");
            GameEnd = true;
        }

        /*while (seconds > 0 && minutes > 0)
         * {
         *  minutes = (float)(0 - (Time.time / 60f));
         *  seconds = (float)(10 - (Time.time % 60f));
         *  counterText.text = minutes.ToString("00") + ":" + seconds.ToString("00");
         * }*/


        //if (minutes <= 0)
        //{
        //    if (seconds <= 1)
        //    {
        //        Application.Quit();
        //        //Debug.Log("Exit");
        //    }
        //}
    }
 // Use this for initialization
 void Awake()
 {
     s = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ShipInventory>();
     Refresh();
 }