Example #1
0
    public Planet CreatePlanet(Vector3 v, Planet.PlanetType pt, string planetName, int index, float scale, int pno)
    {
        // 1. Instantiate GameObject and Assign its Sprite
        GameObject go       = new GameObject();
        Sprite     selected = Molten;

        switch (pt)
        {
        case Planet.PlanetType.molten:
            go = Instantiate(MoltenPlanet, v, Quaternion.identity);
            break;

        case Planet.PlanetType.temperate:
            go       = Instantiate(TemperatePlanet, v, Quaternion.identity);
            selected = Temperate;
            break;

        case Planet.PlanetType.water:
            go       = Instantiate(WaterPlanet, v, Quaternion.identity);
            selected = Water;
            break;
        }

        // 2. Scale the gameobject accordingly
        go.transform.localScale = new Vector2(scale, scale);

        // 3. Create new planet instance to return
        return(new Planet(planetName, index, selected, pt, go, scale, pno));
    }
Example #2
0
    public void Initialize(Planet target, Planet.PlanetType type, int count, GameController controller)
    {
        m_target     = target;
        m_type       = type;
        m_count      = count;
        m_controller = controller;

        GameSettings.GameMode gameMode = m_controller.GetGameMode();
        switch (gameMode)
        {
        case GameSettings.GameMode.Easy:
            m_velocity = m_velocityEasy;
            break;

        case GameSettings.GameMode.Normal:
            m_velocity = m_velocityNormal;
            break;

        case GameSettings.GameMode.Hard:
            if (type == Planet.PlanetType.Enemy)
            {
                m_velocity = m_velocityHard;
            }
            else
            {
                m_velocity = m_velocityNormal;
            }
            break;
        }
    }
Example #3
0
    //petal petalcolor stem stemcolor leaf leafcolor pistil pistilcolor
    /// <summary>
    /// Returns a uint ID for a generated flower for the given planet ID (home-0, hot-1, cold-2, neon-3)
    /// </summary>
    /// <param name="planetID"></param>
    /// <returns></returns>
    public uint getRandomFlowerIDForPlanet(Planet.PlanetType planet)
    {
        uint returnValue          = 0;
        int  maxElementsPerPlanet = 4;

        int planetID = (int)planet;

        //Get random petal
        int addValue = availablePlanetPetals[planetID, Random.Range(0, maxElementsPerPlanet)];

        returnValue += (uint)addValue;
        returnValue *= 16;

        //Get random petal color
        addValue     = availablePlanetPetalColors[planetID, Random.Range(0, maxElementsPerPlanet)];
        returnValue += (uint)addValue;
        returnValue *= 16;

        //Get random stem
        addValue     = availablePlanetStems[planetID, Random.Range(0, maxElementsPerPlanet)];
        returnValue += (uint)addValue;
        returnValue *= 16;

        //Get random stem color
        addValue     = availablePlanetStemColors[planetID, Random.Range(0, maxElementsPerPlanet)];
        returnValue += (uint)addValue;
        returnValue *= 16;

        //Get random leaf
        addValue     = availablePlanetLeafs[planetID, Random.Range(0, maxElementsPerPlanet)];
        returnValue += (uint)addValue;
        returnValue *= 16;

        //Get random leaf color
        addValue     = availablePlanetLeafColors[planetID, Random.Range(0, maxElementsPerPlanet)];
        returnValue += (uint)addValue;
        returnValue *= 16;

        //Get random pistil
        addValue     = availablePlanetPistils[planetID, Random.Range(0, maxElementsPerPlanet)];
        returnValue += (uint)addValue;
        returnValue *= 16;

        //Get random pistil color
        addValue     = availablePlanetPistilColors[planetID, Random.Range(0, maxElementsPerPlanet)];
        returnValue += (uint)addValue;

        return(returnValue);
    }
Example #4
0
    public string getRandomFlowerStringForPlanet(Planet.PlanetType planet)
    {
        StringBuilder result = new StringBuilder();
        int           maxElementsPerPlanet = 4;

        int planetID = (int)planet;

        result.Append(availablePlanetPetals[planetID, Random.Range(0, maxElementsPerPlanet)].ToString("X"));
        result.Append(availablePlanetPetalColors[planetID, Random.Range(0, maxElementsPerPlanet)].ToString("X"));
        result.Append(availablePlanetStems[planetID, Random.Range(0, maxElementsPerPlanet)].ToString("X"));
        result.Append(availablePlanetStemColors[planetID, Random.Range(0, maxElementsPerPlanet)].ToString("X"));
        result.Append(availablePlanetLeafs[planetID, Random.Range(0, maxElementsPerPlanet)].ToString("X"));
        result.Append(availablePlanetLeafColors[planetID, Random.Range(0, maxElementsPerPlanet)].ToString("X"));
        result.Append(availablePlanetPistils[planetID, Random.Range(0, maxElementsPerPlanet)].ToString("X"));
        result.Append(availablePlanetPistilColors[planetID, Random.Range(0, maxElementsPerPlanet)].ToString("X"));

        return(result.ToString());
    }
Example #5
0
    public Planet CreatePlanet(float x, float y, SolarSystem solarSystem, float theta, float distFromSun, Planet.PlanetType type = Planet.PlanetType.Earth)
    {
        int    id = CreateUniquePlanetID();
        Planet p  = new Planet(x, y, id, solarSystem, theta, distFromSun, type);

        planets.Add(id, p);
        return(p);
    }