Пример #1
0
        public void SetOrientation(Orientation newOrientation)
        {
            Orientation oldOrientation = orientation;

            orientation = newOrientation;

            if (oldOrientation != orientation)
            {
                // All IsometricTransforms should be updated regardless if they have an observer or not.
                IsometricTransform[] transforms = IsometricTransform.GetInstances().ToArray();
                foreach (IsometricTransform t in transforms)
                {
                    if (t.GetLevel().transform == levelTransform)
                    {
                        t.UpdatePosition();
                    }
                }

                OrientableSprite[] orientableSprites = OrientableSprite.GetInstances().ToArray();
                foreach (OrientableSprite os in orientableSprites)
                {
                    if (os.GetLevel().transform == levelTransform)
                    {
                        os.UpdateSprite();
                    }
                }
            }
        }
Пример #2
0
        protected override void Awake()
        {
            base.Awake();

            isoTransform = GetComponent <IsometricTransform>();
            if (isoTransform == null)
            {
                Debug.LogError("Wall Orientable Sprites need an IsometricTransform to find it's neighbors");
            }
        }
Пример #3
0
        private void Start()
        {
            if (instances == null)
            {
                instances = new List <ChessPieceSelector>();
            }

            if (highlightedFloorTiles == null)
            {
                highlightedFloorTiles = new List <Vector2Int>();
            }

            instances.Add(this);
            isoTransform = GetComponent <IsometricTransform>();
            level        = isoTransform.GetLevel();
            pieceType    = (ChessIndex)level.data.GetItem(isoTransform.coords.x, isoTransform.coords.y).x;
        }
Пример #4
0
        public PrefabContainer(GameObject prefab)
        {
            _gameObject = GameObject.Instantiate(prefab);

            _isometricTransform = _gameObject.GetComponent <IsometricTransform>();
            if (_isometricTransform == null)
            {
                _isometricTransform = _gameObject.AddComponent <IsometricTransform>();
            }

            _spriteRenderer = _gameObject.GetComponent <SpriteRenderer>();
            if (_spriteRenderer == null)
            {
                _spriteRenderer = _gameObject.AddComponent <SpriteRenderer>();
            }

            _orientableSprite = _gameObject.GetComponent <OrientableSprite>();
            if (_orientableSprite == null)
            {
                _orientableSprite = _gameObject.AddComponent <SingleOrientableSprite>();
            }
        }
 protected virtual void Awake()
 {
     m_IsometricTransform = GetComponent <IsometricTransform>();
 }