コード例 #1
0
ファイル: Planet.cs プロジェクト: ryry6/Planet-war
 void Awake()
 {
     planetHealth = GetComponent <PlanetHealth>();
     planetShield = GetComponent <PlanetShield>();
     stockPile    = GetComponent <StockPile>();
     planetStats  = GetComponent <PlanetStats>();
 }
コード例 #2
0
    // Use this for initialization
    void Update()
    {
        planetStats = GetComponentInParent <Planet>().planetStats;
        float scale = planetStats.size * planetStats.gravityRadiusMultiplier;

        transform.localScale = new Vector3(scale, scale, scale);
    }
コード例 #3
0
    public IEnumerator MovePlanetToScreen(Planet planet, PlanetStats curStats)
    {
        statsPanel.water.fillAmount = 0f;
        statsPanel.green.fillAmount = 0f;
        statsPanel.earth.fillAmount = 0f;
        statsPanel.hot.fillAmount   = 0f;
        statsPanel.name.text        = "";
        planetMoved                 = false;
        curPlanet                   = planet.gameObject;
        curPlanetStats.water        = curStats.water / 100f;
        curPlanetStats.green        = curStats.green / 100f;
        curPlanetStats.earth        = curStats.earth / 100f;
        curPlanetStats.hot          = curStats.hot / 100f;
        curPlanetStats.name         = curStats.name;
        planet.transform.localScale = startPlanet.localScale;


        for (float i = 0f; i <= 1; i += 0.01f * speed)
        {
            planet.transform.localScale = Vector3.Lerp(startPlanet.localScale, endPlanet.localScale, i);
            yield return(null);
        }


        statsPanel.water.fillAmount = curPlanetStats.water;
        statsPanel.green.fillAmount = curPlanetStats.green;
        statsPanel.earth.fillAmount = curPlanetStats.earth;
        statsPanel.hot.fillAmount   = curPlanetStats.hot;
        statsPanel.name.text        = curPlanetStats.name;
        planetMoved = true;
    }
コード例 #4
0
 void Start()
 {
     if (photonView.isMine)
     {
         health = maxHealth;
     }
     planetStats = GetComponent <PlanetStats>();
 }
コード例 #5
0
ファイル: UpgradesMenu.cs プロジェクト: ryry6/Planet-war
    private void Start()
    {
        missileStats = planet.GetComponent <MissileStats>();
        planetStats  = planet.GetComponent <PlanetStats>();
        stats        = planet.GetComponent <PlanetStats>().stats;

        foreach (Stat stat in stats)
        {
            SetCostText(stat);
        }
    }
コード例 #6
0
    public void ReCentre()
    {
        // Assign the planetStats variable the values for the planetStats component on the current planet:
        planetStats = planet.GetComponent <Planet>().planetStats;
        // Set the orbit center to be the transform of the current planet:
        center = planet.transform;
        // Call CheckOrbit()
        // CheckOrbit();
        // Set the force variable according to the speed of the current planet:
        force = force * planetStats.orbitSpeed;

        // Set the isOrbiting variable to true so that Orbit() will be called:
        isOrbiting = true;
    }
コード例 #7
0
    private void Start()
    {
        aiCurrency = GetComponent <Currency>();
        aiPlanet   = GetComponent <Planet>();
        GetComponent <WorldUI>().SetPlayerName("AI Planet");
        ps = GetComponent <PlanetStats>();

        upgrades     = null;
        purchasables = GetComponents <IPurchasable>();


        StartCoroutine("attackTarget");
        StartCoroutine("BuyWeapon");
        StartCoroutine(BuyUpgrade());
    }
コード例 #8
0
    void Start()
    {
        if (!photonView.isMine)
        {
            enabled = false;
            //this isn't the local player so disable the canvas
            localCanvas.SetActive(false);
            currencyTxt.enabled = false;
            return;
        }

        stockPile.OnMissileChange += UpdateStockPileUI;

        playerCurrency = GetComponent<Currency>();
        stats = GetComponent<PlanetStats>();

        UpdateStockPileUI();
    }
コード例 #9
0
ファイル: Ball.cs プロジェクト: christophergale/SkyAceScripts
    public void ReCentre()
    {
        // Get a reference to the Planet component of the planet, so that we can access its planetStats
        planetClass = planet.GetComponent <Planet>();
        // Assign the planetStats variable the values for the planetStats component on the current planet:
        planetStats = planetClass.planetStats;
        // Set the orbit center to be the transform of the current planet:
        center = planet.transform;

        //if (planet.GetComponent<Quest>() != null)
        //{
        //    GameManager.instance.activeQuest = planet.GetComponent<Quest>();
        //    GameManager.instance.questLog.text = "Liberate " + planetStats.name;
        //}

        if (planet.GetComponent <QuestRace>())
        {
            planet.GetComponent <QuestRace>().StartRace();
        }

        // Set the force variable according to the speed of the current planet:
        force = force * planetStats.orbitSpeed;

        // Change the planetAudio for the new planet
        AudioManager.instance.CheckPlanetAudio();

        // Set the isOrbiting variable to true so that Orbit() will be called:
        isOrbiting = true;

        // If the planet has not yet been visited, add it to the visited index of the GameManager so as to keep track of which planets the player has visited
        if (planetClass.visited != true && planetStats.isPlanet)
        {
            // visitedIndex defaults to 0, so the first planet visited is stored at visited[0]
            GameManager.instance.visited[visitedIndex] = planetClass;
            // We then change this planet's visited bool to true, so that it cannot be added to the array a second time
            planetClass.visited = true;
            // Then we add 1 to visitedIndex so that the next planet that the player visits will be stored at the next index of the array
            visitedIndex += 1;
        }

        AudioManager.instance.UpdateSoundtrack();
    }
コード例 #10
0
    [SerializeField] public static float descriptScale = 2f; //0.9f

    // Use this for initialization
    void Awake()
    {
        // This is a persistent object
        DontDestroyOnLoad(this.gameObject);

        if (SystemInfo.deviceType == DeviceType.Handheld)
        {
            Application.targetFrameRate = 60;
        }

        // Set the current Solar System Viewing Mode (should always start with Scale Mode)
        currentMode = "ScaleMode";
        // Load the viewing mode
        SceneManager.LoadScene(currentMode);

        // Populate the planetstats dictionary
        planetstats = new Dictionary <string, PlanetStats>();

        PlanetStats mercuryStats = new PlanetStats("Mercury", "Mercury has very little atmosphere.", 4879, 167, 3.7f, 0, 57.9d);
        PlanetStats venusStats   = new PlanetStats("Venus", "Venus spins backwards compared to other planets.", 12104, 464, 8.9f, 0, 108.2d);
        PlanetStats earthStats   = new PlanetStats("Earth", "Our home planet.", 12756, 15, 9.8f, 1, 149.6d);
        PlanetStats marsStats    = new PlanetStats("Mars", "Mars is the closest planet to our home.", 6792, -65, 3.7f, 2, 227.9d);
        PlanetStats jupiterStats = new PlanetStats("Jupiter", "Jupiter is the biggest planet in our solar system.", 142984, -110, 23.1f, 79, 778.6d);
        PlanetStats saturnStats  = new PlanetStats("Saturn", "Saturn has winds that reach up to 500 meters per second.", 120536, -140, 9.0f, 62, 1433d);
        PlanetStats uranusStats  = new PlanetStats("Uranus", "Uranus is a gas giant that spins backwards like Venus.", 51118, -195, 8.7f, 27, 2872d);
        PlanetStats neptuneStats = new PlanetStats("Neptune", "Neptune has the second largest gravity - second only to Jupiter.", 49528, -200, 11f, 14, 4495d);

        planetstats.Add("Mercury", mercuryStats);
        planetstats.Add("Venus", venusStats);
        planetstats.Add("Earth", earthStats);
        planetstats.Add("Mars", marsStats);
        planetstats.Add("Jupiter", jupiterStats);
        planetstats.Add("Saturn", saturnStats);
        planetstats.Add("Uranus", uranusStats);
        planetstats.Add("Neptune", neptuneStats);

        // The maximum diameter of a planet in pixels
        float maxDiameterPixels = internalHeight * maxHeightUsed;

        // Divide maxDiameter by biggest planet = num pixels per km
        pixelsPerKm = maxDiameterPixels / planetstats["Jupiter"].diameter;
    }
コード例 #11
0
    public void ImportThisPlanet()
    {
        // Set the UI Name's text to the scriptable planet's name
        nameText.text = planet.name;
        // Set the UI image to the scriptable planet's sprite
        graphicSprite.sprite = planet.graphic;

        // Use the scriptable planet's name to look up the corresponding stats
        thisPlanet = GameController.planetstats[planet.name];

        // Set the rest of this planet's child objects to the planet's stats
        descriptionText.text = thisPlanet.description;
        diameterText.text    = "Diameter: " + thisPlanet.diameter.ToString() + " km";
        temperatureText.text = "Average Temperature: " + thisPlanet.temperature.ToString() + " °C";
        gravityText.text     = "Gravity: " + thisPlanet.gravity.ToString() + " m/s²";
        numMoonsText.text    = "Number of Moons: " + thisPlanet.numMoons.ToString();

        // Set the extra stats
        kmFromSun = thisPlanet.kmFromSun;

        // Setup the planet
        GetComponent <PlanetController>().PlanetSetup(thisPlanet);
    }
コード例 #12
0
ファイル: LayerStats.cs プロジェクト: mystakin/CoreCollector
    // Use this for initialization
    void Start()
    {
        rend        = GetComponentInChildren <SpriteRenderer>();
        planetStats = transform.parent.gameObject.GetComponent <PlanetStats>();

        if (tag == Tags.finalLayer)
        {
            health              = planetStats.finalLayerHealth;
            halfHealthSprite    = planetStats.damagedFinalSprites[0];
            quarterHealthSprite = planetStats.damagedFinalSprites[1];
            scoreGiven          = 100;

            if (rubber)
            {
                rend.sprite = planetStats.rubberSprites[0];
                tag         = Tags.rubber;
            }
            else if (iron)
            {
                rend.sprite = planetStats.ironSprites[0];
                tag         = Tags.iron;
            }
        }

        if (tag == Tags.middleLayer)
        {
            health              = planetStats.middleLayerHealth;
            halfHealthSprite    = planetStats.damagedMiddleSprites[0];
            quarterHealthSprite = planetStats.damagedMiddleSprites[1];
            scoreGiven          = 50;

            if (rubber)
            {
                rend.sprite = planetStats.rubberSprites[1];
                tag         = Tags.rubber;
            }
            else if (iron)
            {
                rend.sprite = planetStats.ironSprites[1];
                tag         = Tags.iron;
            }
        }

        if (tag == Tags.outerLayer)
        {
            health              = planetStats.outerLayerHealth;
            halfHealthSprite    = planetStats.damagedOuterSprites[0];
            quarterHealthSprite = planetStats.damagedOuterSprites[1];
            scoreGiven          = 10;

            if (rubber)
            {
                rend.sprite = planetStats.rubberSprites[2];
                tag         = Tags.rubber;
            }
            else if (iron)
            {
                rend.sprite = planetStats.ironSprites[2];
                tag         = Tags.iron;
            }
        }

        maxHealth = health;
    }
コード例 #13
0
    // SETUP PLANET
    public void PlanetSetup(PlanetStats thisPlanet)
    {
        // Initialize Variables

        // Set a reference to the child objects, Name and Image;
        planetNameObject  = gameObject.transform.Find("Name").gameObject;
        planetImageObject = gameObject.transform.Find("Image").gameObject;

        // Get the RectTransform of this planet and it's name object.
        planetRectTransform = GetComponent <RectTransform>();
        nameRectTransform   = planetNameObject.GetComponent <RectTransform>();

        // Get the starting versions of this Mode's co-ords and scale
        thisModeX = planetRectTransform.anchoredPosition.x;
        thisModeY = planetRectTransform.anchoredPosition.y;

        // Get the pixels per unit of the sprite being used
        ppu = planetImageObject.GetComponent <Image>().sprite.pixelsPerUnit;

        // Get reference to this planet's button
        planetButtonScript = gameObject.GetComponent <ButtonSwitch>();

        // Initialize audio controller reference
        audioObj = AudioController.Instance;

        // Setup the objects in accordance with the current mode
        currentMode = GameController.currentMode;
        if (currentMode == "ScaleMode")
        {
            // Set the scale of the planet relative to it's diameter
            diameterInPixels = thisPlanet.diameter * GameController.pixelsPerKm;
            thisModeScale    = diameterInPixels / ppu;
            planetImageObject.transform.localScale = new Vector2(thisModeScale, thisModeScale);

            // Keep the name above the scaled planet
            nameRectTransform = planetNameObject.GetComponent <RectTransform>();
            thisModeNameX     = nameRectTransform.anchoredPosition.x;
            thisModeNameY     = nameRectTransform.anchoredPosition.y;
            nameRectTransform.anchoredPosition = new Vector2(thisModeNameX, thisModeNameY + GameController.textScalar * diameterInPixels);
        }
        // Setup the distance mode planet to be standard size
        else if (gameObject.name == "Distance Planet")
        {
            // Reset planetIsMoving bool
            GameController.planetIsMoving = false;

            // Set this planet's name text position to the Planet Info version
            var nameX = nameRectTransform.anchoredPosition.x;
            nameRectTransform.anchoredPosition = new Vector2(nameX, GameController.infoNameY);

            // Set this planet's position and scale to the default version
            planetRectTransform.anchoredPosition   = new Vector2(GameController.defaultX, GameController.kmPlanetY);
            planetImageObject.transform.localScale = new Vector2(GameController.defaultScale, GameController.defaultScale);
        }
        else if (currentMode == "DistanceMode")
        {
            // Get the reference to the Distance Planet and it's import script
            distanceObj          = DistanceController.distanceObj;
            distanceImportScript = distanceObj.GetComponent <PlanetImport>();

            // Disable the button if this mini planet is the same as Distance Planet
            if (gameObject.name == distanceImportScript.planet.name)
            {
                planetButtonScript.ButtonDisable();
            }
        }

        // Save vector to variable for future use
        thisModeNameVector = nameRectTransform.anchoredPosition;
    }
コード例 #14
0
 void Start()
 {
     curPlanetStats = new PlanetStats();
     SpawnPlanet();
     //StartCoroutine(MovePlanetToScreen(planets[0], stats[0]));
 }