示例#1
0
    public IAssetRequest LoadAudio(string url, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType)
    {
        if (string.IsNullOrEmpty(url))
        {
            Debug.LogError("string.IsNullOrEmpty(url) == true");
            return(null);
        }
        string text = string.Format("{0}/{1}", this.m_strBaseResDir, url);

        try
        {
            if (!Path.HasExtension(text))
            {
                text = Path.ChangeExtension(text, ".mp3");
            }
        }
        catch (Exception ex)
        {
            XLog.Log.Fatal(ex.Message);
        }
        text = GameResourceManager.StandardlizePath(text);
        GameAssetResource assetResource = this.GetAssetResource(text, assetPRIType, true);

        return(new GameAssetRequest(assetResource, callBackFun));
    }
示例#2
0
 protected void SetResourceObject()
 {
     if (m_ResourceScript == null)
     {
         m_ResourceScript = new GameResourceManager();
     }
 }
        public static TileLayer TileLayerFromXml(GameResourceManager gameResourceManager, XElement layerElement)
        {
            var name = layerElement.Attribute("name").Value;
            var mapSize = MathUtil.ParseSize(layerElement.Element("MapSize").Value);
            var tileSize = MathUtil.ParseSize(layerElement.Element("TileSize").Value);
            var tileReferences = GetTileReferences(gameResourceManager, layerElement.Element("TileDefinitionReferences")).ToList();
            var tiles = GetTileRowsFromXml(layerElement.Element("Tiles"));

            var layer = new TileLayer(name, mapSize, tileSize);
            XmlRepository.BaseFromXml(layer, layerElement);

            int x = 0;
            foreach (var row in tiles)
            {
                int y = 0;
                foreach (var element in row)
                {
                    layer[x, y++] = tileReferences.Single(r => r.Id == element).Definition;
                }

                x++;
            }

            return layer;
        }
示例#4
0
 public UiData(FreelancerGame game)
 {
     ResourceManager = game.ResourceManager;
     FileSystem      = game.GameData.VFS;
     Infocards       = game.GameData.Ini.Infocards;
     Fonts           = game.Fonts;
     NavbarIcons     = game.GameData.GetBaseNavbarIcons();
     Sounds          = game.Sound;
     DataPath        = game.GameData.Ini.Freelancer.DataPath;
     if (game.GameData.Ini.Navmap != null)
     {
         NavmapIcons = new IniNavmapIcons(game.GameData.Ini.Navmap);
     }
     else
     {
         NavmapIcons = new NavmapIcons();
     }
     if (!string.IsNullOrWhiteSpace(game.GameData.Ini.Freelancer.XInterfacePath))
     {
         OpenFolder(game.GameData.Ini.Freelancer.XInterfacePath);
     }
     else
     {
         OpenDefault();
     }
 }
        public static HexLayer HexLayerFromXml(GameResourceManager gameResourceManager, XElement layerElement)
        {
            var name = layerElement.Attribute("name").Value;
            var mapSize = MathUtil.ParseSize(layerElement.Element("MapSize").Value);
            var hexSize = MathUtil.ParseSize(layerElement.Element("HexSize").Value);
            var edgeLength = int.Parse(layerElement.Element("EdgeLength").Value);
            var hexReferences = GetHexReferences(gameResourceManager, layerElement.Element("HexDefinitionReferences")).ToList();
            var hexes = GetRowsFromXml(layerElement.Element("Hexes"));

            var layer = new HexLayer(name, mapSize, hexSize, edgeLength);
            XmlRepository.BaseFromXml(layer, layerElement);

            int x = 0;
            foreach (var row in hexes)
            {
                int y = 0;
                foreach (var element in row)
                {
                    layer[x, y++] = hexReferences.Single(r => r.Id == element).Definition;
                }

                x++;
            }

            return layer;
        }
示例#6
0
        public static Scene LoadFrom(GameResourceManager gameResourceManager, string path)
        {
            var document = XDocument.Load(path);

            var sceneElement = document.Element("Scene");
            var scene = new Scene(sceneElement.Attribute("name").Value);

            foreach (var layerElement in sceneElement.Elements())
            {
                switch (layerElement.Name.ToString())
                {
                    case "ImageLayer":
                        scene.Add(ImageXmlRepository.ImageLayerFromXml(gameResourceManager, layerElement));
                        break;
                    case "HexLayer":
                        scene.Add(HexXmlRepository.HexLayerFromXml(gameResourceManager, layerElement));
                        break;
                    case "TileLayer":
                        scene.Add(TileXmlRepository.TileLayerFromXml(gameResourceManager, layerElement));
                        break;
                    case "ColorLayer":
                        scene.Add(ColorXmlRepository.ColorLayerFromXml(layerElement));
                        break;
                    case "SpriteLayer":
                        scene.Add(SpriteXmlRepository.SpriteLayerFromXml(gameResourceManager, layerElement));
                        break;
                    case "DrawingLayer":
                        scene.Add(DrawingXmlRepository.DrawingLayerFromXml(layerElement));
                        break;
                }
            }

            return scene;
        }
示例#7
0
 protected override void Load()
 {
     Title = "Thn Player";
     LibreLancer.Shaders.AllShaders.Compile();
     guiHelper = new ImGuiHelper(this);
     FileDialog.RegisterParent(this);
     Viewport = new ViewportManager(this.RenderState);
     Viewport.Push(0, 0, 800, 600);
     Billboards = new Billboards();
     Nebulae    = new NebulaVertices();
     Resources  = new GameResourceManager(this);
     Renderer2D = new Renderer2D(this.RenderState);
     Audio      = new AudioManager(this);
     Sounds     = new SoundManager(Audio);
     Services.Add(Sounds);
     Services.Add(Billboards);
     Services.Add(Nebulae);
     Services.Add(Resources);
     Services.Add(Renderer2D);
     fontMan = new FontManager();
     fontMan.ConstructDefaultFonts();
     Services.Add(fontMan);
     Services.Add(new GameConfig());
     Typewriter = new Typewriter(this);
     Services.Add(Typewriter);
     Keyboard.KeyDown += KeyboardOnKeyDown;
 }
        public static ImageLayer ImageLayerFromXml(GameResourceManager gameResourceManager, XElement layerElement)
        {
            var name = layerElement.Attribute("name").Value;
            var textureName = layerElement.Element("Texture").Value;
            var rectangleValue = layerElement.Element("Rectangle").Value;

            return new ImageLayer(name, gameResourceManager.GetTexture(textureName), MathUtil.ParseRectangle(rectangleValue));
        }
示例#9
0
    private static string ConvertToAssetBundleName(string ResPath)
    {
        ResPath = GameResourceManager.StandardlizePath(ResPath);
        string text = ResPath.Replace('/', '_');

        text = text.Replace(" ", "");
        return(Path.GetFileNameWithoutExtension(text));
    }
示例#10
0
    void Awake()
    {
        Instance        = this;
        resourceManager = new GameResourceManager();
        resourceManager.Init();

        battleManager = new BattleObjectManager();
        playerManager = new PlayerStateManager();
    }
            protected override void OnCreate()
            {
                base.OnCreate();

                itemManager     = World.GetExistingSystem <ItemManager>();
                dentBank        = World.GetExistingSystem <ItemBank>();
                gameResourceMgr = World.GetExistingSystem <GameResourceManager>();

                connector = World.GetExistingSystem <GameHostConnector>();
            }
示例#12
0
            protected override void OnCreate()
            {
                base.OnCreate();
                Enabled = false;

                m_EquipmentManager = World.GetOrCreateSystem <UnitVisualEquipmentManager>();
                resourceMgr        = World.GetOrCreateSystem <GameResourceManager>();

                GetModule(out attachmentModule);
            }
示例#13
0
    private void DrawActions(string[] actions)
    {
        GUIStyle buttons = new GUIStyle();

        buttons.hover.background  = buttonHover;
        buttons.active.background = buttonClick;
        GUI.skin.button           = buttons;
        int numActions = actions.Length;

        //define the area to draw the actions inside
        GUI.BeginGroup(new Rect(BUILD_IMAGE_WIDTH, 0, ORDERS_BAR_WIDTH, buildAreaHeight));
        //draw scroll bar for the list of actions if need be
        if (numActions >= MaxNumRows(buildAreaHeight))
        {
            DrawSlider(buildAreaHeight, numActions / 2.0f);
        }
        //display possible actions as buttons and handle the button click for each
        for (int i = 0; i < numActions; i++)
        {
            int       column = i % 2;
            int       row    = i / 2;
            Rect      pos    = GetButtonPos(row, column);
            Texture2D action = GameResourceManager.GetBuildImage(actions[i]);

            if (action)
            {
                //create the button and handle the click of that button
                if (GUI.Button(pos, action))
                {
                    RTSAgent agent = Selector.MainSelectedAgent as RTSAgent;
                    if (agent)
                    {
                        PlayClick();

                        if (agent.MyAgentType == AgentType.Unit &&
                            agent.GetAbility <Construct>() &&
                            !ConstructionHandler.IsFindingBuildingLocation())
                        {
                            ConstructionHandler.CreateStructure(actions[i], agent, agent.GetPlayerArea());
                        }
                        else if (agent.MyAgentType == AgentType.Building &&
                                 !agent.GetAbility <Structure>().NeedsConstruction &&
                                 agent.GetAbility <Spawner>())
                        {
                            // send spawn command
                            Command spawnCom = new Command(AbilityDataItem.FindInterfacer("Spawner").ListenInputID);
                            spawnCom.Add <DefaultData>(new DefaultData(DataType.String, actions[i]));
                            UserInputHelper.SendCommand(spawnCom);
                        }
                    }
                }
            }
        }
        GUI.EndGroup();
    }
示例#14
0
    public void SetResource(GameResourceManager ResourceObject, string SlotName)
    {
        if (ResourceObject != null)
        {
            m_imgBoard = ResourceObject.GetResource(string.Format("{0}{1}{2}", "TEXTURE_", SlotName, "Board")).GetComponent <EzGui_Texture>();
            m_imgIcon  = ResourceObject.GetResource(string.Format("{0}{1}{2}", "TEXTURE_", SlotName, "Icon")).GetComponent <EzGui_Texture>();
            m_btnAdd   = ResourceObject.GetResource(string.Format("{0}{1}{2}", "BUTTON_", SlotName, "Add")).GetComponent <EzGui_Button>();
            m_txtNum   = ResourceObject.GetResource(string.Format("{0}{1}{2}", "SPRITE_", SlotName, "Num")).GetComponent <EzGui_SpriteText>();

            SetResources();
        }
    }
示例#15
0
        public static void Init()
        {
            ServerGame.GameDatabase = new CouchbaseDatabase("magic-players", "game");

            GameResourceManager.Init();
            GameMatchmakingManager.Init();
            GameDuelMatchmakingManager.Init();
            GameAvatarManager.Init();
            GameSessionManager.Init();
            LiveReplayManager.Init();
            GameBaseGenerator.Init();
            WordCensorUtil.Init();
        }
示例#16
0
    public IAssetRequest LoadTexture(string url, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType)
    {
        if (string.IsNullOrEmpty(url))
        {
            Debug.LogError("string.IsNullOrEmpty(url) == true");
            return(null);
        }
        string text = string.Format("{0}/{1}.jpg", this.m_strBaseResDir, url);

        text = GameResourceManager.StandardlizePath(text);
        GameAssetResource assetResource = this.GetAssetResource(text, assetPRIType, true);

        return(new GameAssetRequest(assetResource, callBackFun));
    }
示例#17
0
    public IAssetRequest CreateAssetRequest(string assetUrl, List <string> dependes, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType, EnumAssetType eAssetType)
    {
        if (string.IsNullOrEmpty(assetUrl))
        {
            Debug.LogError("string.IsNullOrEmpty(assetUrl) == true");
            return(null);
        }
        assetUrl = string.Format("{0}/{1}", this.m_strBaseResDir, assetUrl);

        assetUrl = GameResourceManager.StandardlizePath(assetUrl);
        GameAssetResource assetResource = this.GetAssetResource(assetUrl, assetPRIType, true);

        return(new GameAssetRequest(assetResource, callBackFun));
    }
    public IAssetRequest LoadAtlas(string url, AssetRequestFinishedEventHandler callBackFun)
    {
        if (string.IsNullOrEmpty(url))
        {
            Debug.LogError("string.IsNullOrEmpty(url) == true");
            return(null);
        }
        string text = string.Format("{0}/{1}", this.m_strBaseResDir, url);

        text = Path.ChangeExtension(text, ".prefab");
        text = GameResourceManager.StandardlizePath(text);
        GameAssetResource assetResource = this.GetAssetResource(text, true);

        return(new GameAssetRequest(assetResource, callBackFun));
    }
示例#19
0
        protected override void OnCreate()
        {
            base.OnCreate();

            definitionHashMap = new NativeHashMap <Entity, EntityVisualDefinition>(32, Allocator.Persistent);

            resourceMgr = World.GetExistingSystem <GameResourceManager>();

            visualMgr         = World.GetExistingSystem <EntityVisualManager>();
            defaultDefinition = visualMgr.Register(AddressBuilder.Client()
                                                   .Folder("Models")
                                                   .Folder("InGame")
                                                   .Folder("Projectiles")
                                                   .Folder("Cannon")
                                                   .GetAsset("CannonProjectile"));
        }
示例#20
0
        private void btnViewMap_Click(object sender, EventArgs e)
        {
            Image iDefaultBackground = GameResourceManager.LoadResource_FullName("EK_SW.KWRendered.png");

            frmImagePreview test = new frmImagePreview();

            test.BackgroundImageLayout = ImageLayout.Stretch;
            test.BackgroundImage       = iDefaultBackground;
            test.ClientSize            = new System.Drawing.Size(iDefaultBackground.Width, iDefaultBackground.Height);
            test.FormBorderStyle       = System.Windows.Forms.FormBorderStyle.None;
            test.Padding     = new Padding(0);
            test.PreviewType = frmImagePreview.PreviewTypes.Other;
            test.Text        = "EK Unleashed :: Kingdom War Reference Map";
            test.Icon        = (Icon)this.Icon.Clone();
            test.Show();
        }
示例#21
0
        private static ITiledFile Load(string filepath, GameResourceManager gameResourceManager, bool scalable)
        {
            var map = new TmxMap(Path.Combine(ContentFolder, filepath));

            var mapSize = new Size(map.Width, map.Height);
            var tilesSize = new Size(map.TileWidth, map.TileHeight);

            var sheets = map.Tilesets.Select(tileset => LoadTileset(tileset, tilesSize, gameResourceManager)).ToList();

            var tileDefinitions = sheets.SelectMany(sheet => sheet.Definitions.Values)
                .ToDictionary(tileDefinition => tileDefinition.Name);

            var tileLayers = map.Layers.Select(l => LoadLayer(l, mapSize, tilesSize, tileDefinitions, scalable)).ToList();
            var objectLayers = map.ObjectGroups.Select(o => LoadObjects(o, tileDefinitions)).ToList();

            return new TiledFile(tileLayers, objectLayers);
        }
示例#22
0
        protected override void Load()
        {
            Title     = "LancerEdit";
            guiHelper = new ImGuiHelper(this);
            guiHelper.PauseWhenUnfocused = Config.PauseWhenUnfocused;
            Audio = new AudioManager(this);
            FileDialog.RegisterParent(this);
            Viewport = new ViewportManager(RenderState);
            InitOptions();
            Resources   = new GameResourceManager(this);
            Commands    = new CommandBuffer();
            Billboards  = new Billboards();
            Polyline    = new PolylineRender(Commands);
            DebugRender = new PhysicsDebugRenderer();
            Viewport.Push(0, 0, 800, 600);
            Keyboard.KeyDown += Keyboard_KeyDown;

            //TODO: Icon-setting code very messy
            int w, h, c;
            var stream = typeof(MainWindow).Assembly.GetManifestResourceStream("LancerEdit.reactor_64.png");
            var bytes  = new byte[stream.Length];

            stream.Read(bytes, 0, (int)stream.Length);
            StbSharp.Stb.stbi_set_flip_vertically_on_load(0);
            var img = StbSharp.Stb.stbi_load_from_memory(bytes, out w, out h, out c, StbSharp.Stb.STBI_rgb_alpha);

            StbSharp.Stb.stbi_set_flip_vertically_on_load(1);
            SetWindowIcon(w, h, img);

            //Open passed in files!
            if (InitOpenFile != null)
            {
                foreach (var f in InitOpenFile)
                {
                    OpenFile(f);
                }
            }

            Renderer2D = new Renderer2D(RenderState);
            RichText   = Renderer2D.CreateRichTextEngine();
            Services.Add(Renderer2D);
            Fonts = new FontManager(this);
            Fonts.ConstructDefaultFonts();
            Services.Add(Fonts);
        }
示例#23
0
 protected override void Load()
 {
     Title = "System Viewer";
     LibreLancer.Shaders.AllShaders.Compile();
     guiHelper = new ImGuiHelper(this, DpiScale);
     FileDialog.RegisterParent(this);
     RenderContext.PushViewport(0, 0, 800, 600);
     Billboards = new Billboards();
     Nebulae    = new NebulaVertices();
     Resources  = new GameResourceManager(this);
     RichText   = RenderContext.Renderer2D.CreateRichTextEngine();
     Services.Add(Billboards);
     Services.Add(Nebulae);
     Services.Add(Resources);
     fontMan = new FontManager();
     fontMan.ConstructDefaultFonts();
     Services.Add(fontMan);
     Services.Add(new GameConfig());
 }
示例#24
0
    public static void CreateStructure(string buildingName, RTSAgent constructingAgent, Rect playingArea)
    {
        Vector2d buildPoint       = new Vector2d(constructingAgent.transform.position.x, constructingAgent.transform.position.z + 10);
        RTSAgent buildingTemplate = GameResourceManager.GetAgentTemplate(buildingName);

        if (buildingTemplate.MyAgentType == AgentType.Building && buildingTemplate.GetComponent <Structure>())
        {
            // check that the Player has the resources available before allowing them to create a new structure
            if (!_cachedCommander.CachedResourceManager.CheckResources(buildingTemplate))
            {
                Debug.Log("Not enough resources!");
            }
            else
            {
                tempObject = Object.Instantiate(buildingTemplate.gameObject, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                if (tempObject)
                {
                    _findingPlacement = true;
                    SetTransparentMaterial(tempObject, GameResourceManager.AllowedMaterial);
                    tempObject.gameObject.name = buildingName;

                    tempStructure = tempObject.GetComponent <Structure>();
                    if (tempStructure.StructureType == StructureType.Wall)
                    {
                        // walls require a little help since they are click and drag
                        _constructingWall       = true;
                        tempStructure.IsOverlay = true;
                        WallPositioningHelper.Setup();
                    }

                    tempStructureBody = tempObject.GetComponent <UnityLSBody>().InternalBody;

                    // structure size is 2 times the size of halfwidth & halfheight
                    tempStructure.BuildSizeLow  = (tempStructureBody.HalfWidth.CeilToInt() * 2);
                    tempStructure.BuildSizeHigh = (tempStructureBody.HalfLength.CeilToInt() * 2);

                    cachedAgent = constructingAgent;

                    tempStructure.gameObject.transform.position = Positioning.GetSnappedPosition(buildPoint.ToVector3());
                }
            }
        }
    }
示例#25
0
 private void DrawBuildQueue(string[] buildQueue, float buildPercentage)
 {
     for (int i = 0; i < buildQueue.Length; i++)
     {
         float topPos   = i * BUILD_IMAGE_HEIGHT - (i + 1) * BUILD_IMAGE_PADDING;
         Rect  buildPos = new Rect(BUILD_IMAGE_PADDING, topPos, BUILD_IMAGE_WIDTH, BUILD_IMAGE_HEIGHT);
         GUI.DrawTexture(buildPos, GameResourceManager.GetBuildImage(buildQueue[i]));
         GUI.DrawTexture(buildPos, buildFrame);
         topPos += BUILD_IMAGE_PADDING;
         float width  = BUILD_IMAGE_WIDTH - 2 * BUILD_IMAGE_PADDING;
         float height = BUILD_IMAGE_HEIGHT - 2 * BUILD_IMAGE_PADDING;
         if (i == 0)
         {
             // shrink the build mask on the item currently being built to give an idea of progress
             topPos += height * buildPercentage;
             height *= (1 - buildPercentage);
         }
         GUI.DrawTexture(new Rect(2 * BUILD_IMAGE_PADDING, topPos, width, height), buildMask);
     }
 }
示例#26
0
 protected override void Load()
 {
     DefaultMaterialMap.Init();
     Title     = "LancerEdit";
     guiHelper = new ImGuiHelper(this, DpiScale * Config.UiScale);
     guiHelper.PauseWhenUnfocused = Config.PauseWhenUnfocused;
     Audio = new AudioManager(this);
     FileDialog.RegisterParent(this);
     options     = new OptionsWindow(this);
     Resources   = new GameResourceManager(this);
     Commands    = new CommandBuffer();
     Polyline    = new PolylineRender(Commands);
     DebugRender = new PhysicsDebugRenderer();
     RenderContext.PushViewport(0, 0, 800, 600);
     Keyboard.KeyDown += Keyboard_KeyDown;
     //TODO: Icon-setting code very messy
     using (var stream = typeof(MainWindow).Assembly.GetManifestResourceStream("LancerEdit.reactor_64.png"))
     {
         var icon = LibreLancer.ImageLib.Generic.BytesFromStream(stream);
         SetWindowIcon(icon.Width, icon.Height, icon.Data);
     }
     using (var stream = typeof(MainWindow).Assembly.GetManifestResourceStream("LancerEdit.reactor_128.png"))
     {
         var icon = (Texture2D)LibreLancer.ImageLib.Generic.FromStream(stream);
         logoTexture = ImGuiHelper.RegisterTexture(icon);
     }
     //Open passed in files!
     if (InitOpenFile != null)
     {
         foreach (var f in InitOpenFile)
         {
             OpenFile(f);
         }
     }
     RichText = RenderContext.Renderer2D.CreateRichTextEngine();
     Fonts    = new FontManager();
     Fonts.ConstructDefaultFonts();
     Services.Add(Fonts);
     Make3dbDlg = new CommodityIconDialog(this);
     LoadScripts();
 }
示例#27
0
 protected override void Load()
 {
     Title     = "System Viewer";
     guiHelper = new ImGuiHelper(this);
     FileDialog.RegisterParent(this);
     Viewport = new ViewportManager(this.RenderState);
     Viewport.Push(0, 0, 800, 600);
     Billboards = new Billboards();
     Nebulae    = new NebulaVertices();
     Resources  = new GameResourceManager(this);
     Renderer2D = new Renderer2D(this.RenderState);
     RichText   = Renderer2D.CreateRichTextEngine();
     Services.Add(Billboards);
     Services.Add(Nebulae);
     Services.Add(Resources);
     Services.Add(Renderer2D);
     fontMan = new FontManager(this);
     fontMan.ConstructDefaultFonts();
     Services.Add(fontMan);
     Services.Add(new GameConfig());
 }
        public static SpriteLayer SpriteLayerFromXml(GameResourceManager gameResourceManager, XElement layerElement)
        {
            var layerName = layerElement.Attribute("name").Value;
            var layer = new SpriteLayer(layerName);
            XmlRepository.BaseFromXml(layer, layerElement);

            foreach (var element in layerElement.Element("Sprites").Elements())
            {
                var sheetName = element.Attribute("sheetName").Value;
                var name = element.Attribute("name").Value;
                var position = element.Attribute("position").Value;

                var sprite = new Sprite(gameResourceManager.GetSpriteSheet(sheetName), name)
                {
                    Position = MathUtil.ParseVector(position)
                };

                layer.AddSprite(sprite);
            }

            return layer;
        }
 public UiContext(FreelancerGame game)
 {
     Renderer2D      = game.Renderer2D;
     RenderState     = game.RenderState;
     ResourceManager = game.ResourceManager;
     FileSystem      = game.GameData.VFS;
     Infocards       = game.GameData.Ini.Infocards;
     Fonts           = game.Fonts;
     NavbarIcons     = game.GameData.GetBaseNavbarIcons();
     Sounds          = game.Sound;
     DataPath        = game.GameData.Ini.Freelancer.DataPath;
     if (!string.IsNullOrWhiteSpace(game.GameData.Ini.Freelancer.XInterfacePath))
     {
         OpenFolder(game.GameData.Ini.Freelancer.XInterfacePath);
     }
     else
     {
         OpenDefault();
     }
     this.game             = game;
     game.Mouse.MouseDown += MouseOnMouseDown;
     game.Mouse.MouseUp   += MouseOnMouseUp;
 }
示例#30
0
    private void Start()
    {
        avatars = GameResourceManager.GetAvatars();
        if (avatars.Length > 0)
        {
            avatarIndex = 0;
        }
        SelectionList.LoadEntries(RTSLockstep.PlayerManager.GetPlayerNames());
        if (clickVolume < 0.0f)
        {
            clickVolume = 0.0f;
        }
        if (clickVolume > 1.0f)
        {
            clickVolume = 1.0f;
        }
        List <AudioClip> sounds  = new List <AudioClip>();
        List <float>     volumes = new List <float>();

        sounds.Add(clickSound);
        volumes.Add(clickVolume);
        audioElement = new AudioElement(sounds, volumes, "SelectPlayerMenu", null);
    }
    //this should be in the controller...
    private void LoadRTSAgents(JsonTextReader reader)
    {
        if (reader == null)
        {
            return;
        }
        RTSAgents agents = GetComponentInChildren <RTSAgents>();
        string    currValue = "", type = "";

        while (reader.Read())
        {
            if (reader.Value != null)
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    currValue = (string)reader.Value;
                }
                else if (currValue == "Type")
                {
                    type = (string)reader.Value;
                    // need to create unit via commander controller...
                    GameObject newObject = Instantiate(GameResourceManager.GetAgentTemplate(type).gameObject);
                    RTSAgent   agent     = newObject.GetComponent <RTSAgent>();
                    agent.name = agent.name.Replace("(Clone)", "").Trim();
                    agent.LoadDetails(reader);
                    agent.transform.parent = agents.transform;
                    agent.SetCommander(this);
                    agent.SetTeamColor();
                }
            }
            else if (reader.TokenType == JsonToken.EndArray)
            {
                return;
            }
        }
    }
 private static IEnumerable<TileReference> GetTileReferences(GameResourceManager gameResourceManager, XElement tileReferencesElement)
 {
     return tileReferencesElement.Elements()
         .Select(x => new TileReference
         {
             Id = int.Parse(x.Attribute("id").Value),
             Definition = gameResourceManager
                 .GetTileSheet(x.Attribute("sheetName").Value)
                 .Definitions[x.Attribute("name").Value]
         });
 }
示例#33
0
 private void OnDisable()
 {
     _instance = null;
 }
 void IScreen.LoadContent(GameResourceManager gameResourceManager)
 {
     this.ResourceManager = gameResourceManager;
     this.Scene = this.CreateScene();
 }
示例#35
0
        private static TileSheet LoadTileset(TmxTileset tileset, Size tilesSize, GameResourceManager gameResourceManager)
        {
            var texturePath = Path.Combine(Path.GetDirectoryName(tileset.Image.Source), Path.GetFileNameWithoutExtension(tileset.Image.Source))
                .Remove(0, ContentFolder.Length + 1);
            //var texture = gameResourceManager.GetTexture(@"Tiled\tmw_desert_spacing");
            var texture = gameResourceManager.GetTexture(texturePath);
            //var sheet = new TileSheet(texture, "Desert", new Size(tmxMap.TileWidth, tmxMap.TileHeight));

            var sheet = gameResourceManager.GetTileSheet(tileset.Name);
            if (sheet == null)
            {
                sheet = new TileSheet(texture, tileset.Name, tilesSize);

                var margin = tileset.Margin;
                var spacing = tileset.Spacing;
                var numTileWidth = (tileset.Image.Width - (2 * margin) + spacing) / (tileset.TileWidth + spacing);
                var numTileHeight = (tileset.Image.Height - (2 * margin) + spacing) / (tileset.TileHeight + spacing);

                for (var j = 0; j < numTileHeight; j++)
                    for (var i = 0; i < numTileWidth; i++)
                        sheet.CreateTileDefinition((tileset.FirstGid + i + numTileWidth * j).ToString(),
                            new Point(margin + i * (tileset.TileWidth + spacing), margin + j * (tileset.TileHeight + spacing)));

                gameResourceManager.AddTileSheet(sheet);
            }

            return sheet;
        }
示例#36
0
 public static ITiledFile Load(string filepath, GameResourceManager gameResourceManager)
 {
     return Load(filepath, gameResourceManager, false);
 }
示例#37
0
 private void Awake()
 {
     GameResourceManager.s_instance = this;
 }
示例#38
0
 public static ITiledFile LoadScalable(string filepath, GameResourceManager gameResourceManager)
 {
     return Load(filepath, gameResourceManager, true);
 }
示例#39
0
 private void OnEnable()
 {
     _instance = this;
 }
示例#40
0
    // Use this for initialization
    public void Setup()
    {
        cachedCommander = GetComponentInParent <AgentCommander>();
        if (cachedCommander && cachedCommander.human)
        {
            resourceValues = new Dictionary <ResourceType, long>();
            resourceLimits = new Dictionary <ResourceType, long>();
            resourceImages = new Dictionary <ResourceType, Texture2D>();
            for (int i = 0; i < resources.Length; i++)
            {
                switch (resources[i].name)
                {
                case "Gold":
                    resourceImages.Add(ResourceType.Gold, resources[i]);
                    resourceValues.Add(ResourceType.Gold, 0);
                    resourceLimits.Add(ResourceType.Gold, 0);
                    break;

                case "Ore":
                    resourceImages.Add(ResourceType.Ore, resources[i]);
                    resourceValues.Add(ResourceType.Ore, 0);
                    resourceLimits.Add(ResourceType.Ore, 0);
                    break;

                case "Stone":
                    resourceImages.Add(ResourceType.Stone, resources[i]);
                    resourceValues.Add(ResourceType.Stone, 0);
                    resourceLimits.Add(ResourceType.Stone, 0);
                    break;

                case "Wood":
                    resourceImages.Add(ResourceType.Wood, resources[i]);
                    resourceValues.Add(ResourceType.Wood, 0);
                    resourceLimits.Add(ResourceType.Wood, 0);
                    break;

                case "Crystal":
                    resourceImages.Add(ResourceType.Crystal, resources[i]);
                    resourceValues.Add(ResourceType.Crystal, 0);
                    resourceLimits.Add(ResourceType.Crystal, 0);
                    break;

                case "Food":
                    resourceImages.Add(ResourceType.Food, resources[i]);
                    resourceValues.Add(ResourceType.Food, 0);
                    resourceLimits.Add(ResourceType.Food, 0);
                    break;

                case "Army":
                    resourceImages.Add(ResourceType.Provision, resources[i]);
                    resourceValues.Add(ResourceType.Provision, 0);
                    resourceLimits.Add(ResourceType.Provision, 0);
                    break;

                default: break;
                }
            }

            Dictionary <ResourceType, Texture2D> resourceHealthBarTextures = new Dictionary <ResourceType, Texture2D>();
            for (int i = 0; i < resourceHealthBars.Length; i++)
            {
                switch (resourceHealthBars[i].name)
                {
                case "ore":
                    resourceHealthBarTextures.Add(ResourceType.Ore, resourceHealthBars[i]);
                    break;

                case "stone":
                    resourceHealthBarTextures.Add(ResourceType.Stone, resourceHealthBars[i]);
                    break;

                case "gold":
                    resourceHealthBarTextures.Add(ResourceType.Gold, resourceHealthBars[i]);
                    break;

                case "crystal":
                    resourceHealthBarTextures.Add(ResourceType.Crystal, resourceHealthBars[i]);
                    break;

                case "food":
                    resourceHealthBarTextures.Add(ResourceType.Food, resourceHealthBars[i]);
                    break;

                case "wood":
                    resourceHealthBarTextures.Add(ResourceType.Wood, resourceHealthBars[i]);
                    break;

                default: break;
                }
            }
            GameResourceManager.SetResourceHealthBarTextures(resourceHealthBarTextures);
            GameResourceManager.StoreSelectBoxItems(selectBoxSkin, healthy, damaged, critical);
            GameResourceManager.StoreConstructionMaterials(allowedMaterial, notAllowedMaterial);
            buildAreaHeight = Screen.height - RESOURCE_BAR_HEIGHT - SELECTION_NAME_HEIGHT - 2 * BUTTON_SPACING;
            SetCursorState(CursorState.Select);

            List <AudioClip> sounds  = new List <AudioClip>();
            List <float>     volumes = new List <float>();
            sounds.Add(clickSound);
            volumes.Add(clickVolume);
            audioElement = new AudioElement(sounds, volumes, "HUD", null);
        }
    }