Beispiel #1
0
    /// <summary>
    /// Method used to create a building game object based on the type of building.
    /// Allows one method call to decide which type of building model shall be loaded
    /// </summary>
    /// <param name="penumBuildingType"></param>
    /// <param name="penumGodType"></param>
    /// <returns></returns>
    private GameObject CreateBuildingObject(BUILDING_TYPE penumBuildingType, Faction.GodType penumGodType)
    {
        GameObject uniBuildingGameObject = null;
        string     strResourceKey        = "Buildings/" + penumGodType.ToString() + penumBuildingType.ToString() + UpgradeLevel.ToString();

        // Load the building model from memory
        if (mdictBuildingResources.ContainsKey(strResourceKey) && mdictBuildingResources[strResourceKey] != null)
        {
            uniBuildingGameObject = (GameObject)GameObject.Instantiate(
                mdictBuildingResources[strResourceKey]);
        }
        else
        {
#if DEBUG
            // Model was not found in resources folder, this should not occur as all models have been created now
#endif
        }
        // Check to ensure a game model was found when creating
        if (uniBuildingGameObject != null)
        {
            // Add a linerenderer for outlining, scale based on scene parameters
            // Allows for the outlining of buildings when selected or when building other buildings
            uniBuildingGameObject.AddComponent <LineRenderer>().positionCount = 0;
            uniBuildingGameObject.transform.localScale = new Vector3(ObjectRadius, ObjectRadius, ObjectRadius);
        }
        return(uniBuildingGameObject);
    }