Exemple #1
0
        // Use this for initialization
        protected override void Start()
        {
            base.Start();
            if( Camera2D == null )
            {
                Camera2D = GameObject.FindObjectOfType<Camera2DController>();
            }

            m_camera2DFollowBehaviour = Camera2D.transform.GetComponent<FollowObjectBehaviour>();
            m_camera2DFollowBehaviour.Target = transform;
        }
Exemple #2
0
        // Use this for initialization
        protected override void Start()
        {
            base.Start();
            if (Camera2D == null)
            {
                Camera2D = GameObject.FindObjectOfType <Camera2DController>();
            }

            m_camera2DFollowBehaviour        = Camera2D.transform.GetComponent <FollowObjectBehaviour>();
            m_camera2DFollowBehaviour.Target = transform;
        }
        void Start()
        {
            m_boundingBox        = new Rect();
            m_boundingBox.width  = CreativeSpore.RpgMapEditor.AutoTileMap.Instance.MapTileWidth * CreativeSpore.RpgMapEditor.AutoTileMap.Instance.CellSize.x;
            m_boundingBox.height = CreativeSpore.RpgMapEditor.AutoTileMap.Instance.MapTileHeight * CreativeSpore.RpgMapEditor.AutoTileMap.Instance.CellSize.y;
            m_boundingBox.x      = CreativeSpore.RpgMapEditor.AutoTileMap.Instance.transform.position.x;
            m_boundingBox.y      = CreativeSpore.RpgMapEditor.AutoTileMap.Instance.transform.position.y;
            FollowObjectBehaviour followBhv = GetComponent <FollowObjectBehaviour>();

            if (followBhv && !followBhv.Target)
            {
                PlayerController player = FindObjectOfType <PlayerController>();
                followBhv.Target = player? player.transform : null;
            }
        }
        public void Start()
        {
            Tilemap = GameManager.Instance.LevelInfo.CurrentMap;
            Camera  = GetComponent <Camera>();

            m_boundingBox = new Rect();

            m_boundingBox.width  = Tilemap.SelectedTilemap.GridWidth * Tilemap.SelectedTilemap.CellSize.x;
            m_boundingBox.height = Tilemap.SelectedTilemap.GridHeight * Tilemap.SelectedTilemap.CellSize.y;
            m_boundingBox.x      = Tilemap.SelectedTilemap.transform.position.x;
            m_boundingBox.y      = Tilemap.SelectedTilemap.transform.position.y + m_boundingBox.height;
            FollowObjectBehaviour followBhv = GetComponent <FollowObjectBehaviour>();

            if (followBhv && !followBhv.Target)
            {
                Transform player = GameManager.Instance.Player.transform;
                followBhv.Target = player ? player.transform : null;
            }
        }
Exemple #5
0
        protected override void Start()
        {
            Debug.Log(gameObject.name + " " + gameObject.layer.ToString());

            base.Start();
            weaponH = GetComponent <WeaponHandler>();

            if (Camera2D == null)
            {
                Camera2D = GameObject.FindObjectOfType <Camera2DController>();
            }

            if (PhotonView.isMine)
            {
                m_camera2DFollowBehaviour        = Camera2D.transform.GetComponent <FollowObjectBehaviour> ();
                m_camera2DFollowBehaviour.Target = transform;
            }

            if (!PhotonView.isMine)
            {
                gameObject.transform.GetChild(2).GetComponent <SpriteRenderer> ().enabled = false;
            }
        }
        // Use this for initialization
        public void Init()
        {
            m_autoTileMap = GetComponent <AutoTileMap>();

            if (m_autoTileMap != null && m_autoTileMap.IsInitialized)
            {
                m_isInitialized = true;

                m_tileGroupNames = new string[m_autoTileMap.Tileset.SubTilesets.Count];
                for (int i = 0; i < m_autoTileMap.Tileset.SubTilesets.Count; ++i)
                {
                    m_tileGroupNames[i] = m_autoTileMap.Tileset.SubTilesets[i].Name;
                }

                if (m_autoTileMap.ViewCamera == null)
                {
                    Debug.LogWarning("AutoTileMap has no ViewCamera set. Camera.main will be set as ViewCamera");
                    m_autoTileMap.ViewCamera = Camera.main;
                }
                m_camera2D = m_autoTileMap.ViewCamera.GetComponent <Camera2DController>();

                if (m_camera2D == null)
                {
                    m_camera2D = m_autoTileMap.ViewCamera.gameObject.AddComponent <Camera2DController>();
                }

                m_camera2DFollowBehaviour = m_camera2D.transform.GetComponent <FollowObjectBehaviour>();

                // Generate thumbnail textures
                m_thumbnailTextures = new Texture2D[m_autoTileMap.Tileset.SubTilesets.Count];
                for (int i = 0; i < m_thumbnailTextures.Length; ++i)
                {
                    m_thumbnailTextures[i] = UtilsAutoTileMap.GenerateTilesetTexture(m_autoTileMap.Tileset, m_autoTileMap.Tileset.SubTilesets[i]);
                }

                #region Collision Layer
                m_spriteCollLayer                  = new GameObject();
                m_spriteCollLayer.name             = "CollisionLayer";
                m_spriteCollLayer.transform.parent = transform;
                SpriteRenderer sprRender = m_spriteCollLayer.AddComponent <SpriteRenderer>();
                sprRender.sortingOrder = 50;                 //TODO: +50 temporal? see for a const number later
                _GenerateCollisionTexture();
                #endregion

                #region Layers Combobox
                string[] toolBarNames = m_autoTileMap.MapLayers.Select(x => x.Name).ToArray();
                comboBoxList = new GUIContent[toolBarNames.Length];
                for (int i = 0; i < toolBarNames.Length; ++i)
                {
                    comboBoxList[i] = new GUIContent("Layer: " + toolBarNames[i]);
                }

                listStyle.normal.textColor           = Color.white;
                listStyle.onHover.background         =
                    listStyle.hover.background       = new Texture2D(2, 2);
                listStyle.padding.left               =
                    listStyle.padding.right          =
                        listStyle.padding.top        =
                            listStyle.padding.bottom = 4;

                comboBoxControl = new ComboBox(new Rect(0, 0, 150, 20), comboBoxList[0], comboBoxList, "button", "box", listStyle);
                comboBoxControl.SelectedItemIndex = m_autoTileMap.BrushGizmo.SelectedLayer;
                #endregion
            }
        }
		// Use this for initialization
		public void Init() 
		{
			m_autoTileMap = GetComponent<AutoTileMap>();

			if( m_autoTileMap != null && m_autoTileMap.IsInitialized )
			{
				m_isInitialized = true;

                m_tileGroupNames = new string[m_autoTileMap.Tileset.SubTilesets.Count];
                for (int i = 0; i < m_autoTileMap.Tileset.SubTilesets.Count; ++i)
                {
                    m_tileGroupNames[i] = m_autoTileMap.Tileset.SubTilesets[i].Name;
                }

				if( m_autoTileMap.ViewCamera == null )
				{
					Debug.LogWarning( "AutoTileMap has no ViewCamera set. Camera.main will be set as ViewCamera" );
					m_autoTileMap.ViewCamera = Camera.main;
				}
				m_camera2D = m_autoTileMap.ViewCamera.GetComponent<Camera2DController>();

				if( m_camera2D == null )
				{
					m_camera2D = m_autoTileMap.ViewCamera.gameObject.AddComponent<Camera2DController>();
				}
				
				m_camera2DFollowBehaviour = m_camera2D.transform.GetComponent<FollowObjectBehaviour>();

				// Generate thumbnail textures
				m_thumbnailTextures = new Texture2D[ m_autoTileMap.Tileset.SubTilesets.Count ];
                for (int i = 0; i < m_thumbnailTextures.Length; ++i )
                {
                    m_thumbnailTextures[i] = UtilsAutoTileMap.GenerateTilesetTexture(m_autoTileMap.Tileset, m_autoTileMap.Tileset.SubTilesets[i]);               
                }

				#region Collision Layer
				m_spriteCollLayer = new GameObject();
				m_spriteCollLayer.name = "CollisionLayer";
				m_spriteCollLayer.transform.parent = transform;
				SpriteRenderer sprRender = m_spriteCollLayer.AddComponent<SpriteRenderer>();
				sprRender.sortingOrder = 50; //TODO: +50 temporal? see for a const number later
				_GenerateCollisionTexture();
				#endregion

			}
		}
Exemple #8
0
        // Use this for initialization
        public void Init()
        {
            m_autoTileMap = GetComponent<AutoTileMap>();

            if( m_autoTileMap != null && m_autoTileMap.IsInitialized )
            {
                m_isInitialized = true;

                m_tileGroupNames = new string[m_autoTileMap.Tileset.SubTilesets.Count];
                for (int i = 0; i < m_autoTileMap.Tileset.SubTilesets.Count; ++i)
                {
                    m_tileGroupNames[i] = m_autoTileMap.Tileset.SubTilesets[i].Name;
                }

                if( m_autoTileMap.ViewCamera == null )
                {
                    Debug.LogWarning( "AutoTileMap has no ViewCamera set. Camera.main will be set as ViewCamera" );
                    m_autoTileMap.ViewCamera = Camera.main;
                }
                m_camera2D = m_autoTileMap.ViewCamera.GetComponent<Camera2DController>();

                if( m_camera2D == null )
                {
                    m_camera2D = m_autoTileMap.ViewCamera.gameObject.AddComponent<Camera2DController>();
                }

                m_camera2DFollowBehaviour = m_camera2D.transform.GetComponent<FollowObjectBehaviour>();

                // Generate thumbnail textures
                m_thumbnailTextures = new Texture2D[ m_autoTileMap.Tileset.SubTilesets.Count ];
                for (int i = 0; i < m_thumbnailTextures.Length; ++i )
                {
                    m_thumbnailTextures[i] = UtilsAutoTileMap.GenerateTilesetTexture(m_autoTileMap.Tileset, m_autoTileMap.Tileset.SubTilesets[i]);
                }

                #region Collision Layer
                m_spriteCollLayer = new GameObject();
                m_spriteCollLayer.name = "CollisionLayer";
                m_spriteCollLayer.transform.parent = transform;
                SpriteRenderer sprRender = m_spriteCollLayer.AddComponent<SpriteRenderer>();
                sprRender.sortingOrder = 50; //TODO: +50 temporal? see for a const number later
                _GenerateCollisionTexture();
                #endregion

                #region Layers Combobox
                string[] toolBarNames = m_autoTileMap.MapLayers.Select( x => x.Name ).ToArray();
                comboBoxList = new GUIContent[toolBarNames.Length];
                for (int i = 0; i < toolBarNames.Length; ++i)
                {
                    comboBoxList[i] = new GUIContent("Layer: " + toolBarNames[i]);
                }

                listStyle.normal.textColor = Color.white;
                listStyle.onHover.background =
                listStyle.hover.background = new Texture2D(2, 2);
                listStyle.padding.left =
                listStyle.padding.right =
                listStyle.padding.top =
                listStyle.padding.bottom = 4;

                comboBoxControl = new ComboBox(new Rect(0, 0, 150, 20), comboBoxList[0], comboBoxList, "button", "box", listStyle);
                comboBoxControl.SelectedItemIndex = m_autoTileMap.BrushGizmo.SelectedLayer;
                #endregion

            }
        }