Esempio n. 1
0
        public void AttachDeco(CTile tile, EDeco deco)
        {
            var decoParam = DecoTable.Instance.Table[deco];
            var data      = this.GetDecoData(decoParam);
            var sprite    = this._sprites[ListUtil <int> .GetRandomElement(decoParam.Sprites)];

            FTile.SetEnvironmentFlagTrue(tile.GetFlags());
            var handle = new GameObject();
            var model  = new MDeco(deco);

            model.SetData(data);
            var view       = new VDeco(deco);
            var controller = new CDeco();

            controller.SetGameHandle(handle);
            controller.SetModel(model);
            controller.SetView(view);
            var renderer = handle.AddComponent <SpriteRenderer>();

            tile.SetCurrent(controller);
            renderer.sprite = sprite;
            renderer.transform.SetParent(tile.Handle.transform);
            renderer.transform.position = tile.Handle.transform.position;
            var tileRenderer = tile.Handle.GetComponent <SpriteRenderer>();

            renderer.sortingLayerName = tileRenderer.sortingLayerName;
            renderer.sortingOrder     = tileRenderer.sortingOrder + 1;
        }
Esempio n. 2
0
        private void RenderChar(CChar character, CTile tile)
        {
            var sprite = character.View.Sprites[character.View.Torso];
            var render = character.GameHandle.AddComponent <SpriteRenderer>();

            character.GameHandle.transform.position = tile.Handle.transform.position;
            character.GameHandle.transform.SetParent(this._container);
            character.GameHandle.name = character.View.Type.ToString() + " " + character.View.Race.ToString();
            render.sprite             = sprite;
            render.sortingLayerName   = SortingLayers.CHAR_TORSO;
            this.TryAttachHead(character, SortingLayers.CHAR_HEAD, character.View.Head, tile);
            this.TryAttachDeco(character, tile);
            this.TryAttachEquipment(character, tile);
            this.TryAttachMount(character, tile);
            character.SubComponents.Add(SortingLayers.CHAR_TORSO, character.GameHandle);
            character.SubComponents.Add(SortingLayers.CHAR_MAIN, character.GameHandle);

            if (!character.Proxy.LParty)
            {
                character.GameHandle.transform.localRotation = Quaternion.Euler(0, 180, 0);
            }

            // TODO: This really should be elsewhere, but it works for now.
            tile.SetCurrent(character);
            character.SetTile(tile);
            character.ProcessEnterNewTile(tile);
        }