예제 #1
0
 /// <summary>
 /// Retrieves any tile animation data from the scripted tile.
 /// </summary>
 /// <param name="position">Position of the Tile on the Tilemap.</param>
 /// <param name="tilemap">The Tilemap the tile is present on.</param>
 /// <param name="tileAnimationData">Data to run an animation on the tile.</param>
 /// <returns>Whether the call was successful.</returns>
 public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
 {
     if (m_AnimatedSprites.Length > 0)
     {
         tileAnimationData.animatedSprites    = m_AnimatedSprites;
         tileAnimationData.animationSpeed     = Random.Range(m_MinSpeed, m_MaxSpeed);
         tileAnimationData.animationStartTime = m_AnimationStartTime;
         if (0 < m_AnimationStartFrame && m_AnimationStartFrame <= m_AnimatedSprites.Length)
         {
             var tilemapComponent = tileMap.GetComponent <Tilemap>();
             if (tilemapComponent != null && tilemapComponent.animationFrameRate > 0)
             {
                 tileAnimationData.animationStartTime = (m_AnimationStartFrame - 1) / tilemapComponent.animationFrameRate;
             }
         }
         return(true);
     }
     return(false);
 }
예제 #2
0
 public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
 {
     if (m_AnimatedSprites.Length > 0)
     {
         tileAnimationData.animatedSprites    = m_AnimatedSprites;
         tileAnimationData.animationSpeed     = Random.Range(m_MinSpeed, m_MaxSpeed);
         tileAnimationData.animationStartTime = m_AnimationStartTime;
         return(true);
     }
     return(false);
 }
예제 #3
0
        public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
        {
            if (m_AnimatedSprites.Length > 0)
            {
                Sprite[] animationFrames = m_AnimatedSprites;
                animationFrames = animationFrames.Concat(Enumerable.Repeat(m_defaultSprite, m_delayFrames)).ToArray();

                tileAnimationData.animatedSprites    = animationFrames;
                tileAnimationData.animationSpeed     = m_Speed;
                tileAnimationData.animationStartTime = Random.Range(0, animationFrames.Length * m_Speed);
                return(true);
            }
            return(false);
        }
예제 #4
0
 public override bool GetTileAnimationData(Vector3Int position, ITilemap tilemap, ref TileAnimationData tileAnimationData)
 {
     foreach (TilingRule rule in m_TilingRules)
     {
         Matrix4x4 transform = Matrix4x4.identity;
         if (RuleMatches(rule, position, tilemap, ref transform) && rule.m_Output == TilingRule.OutputSprite.Animation)
         {
             tileAnimationData.animatedSprites = rule.m_Sprites;
             tileAnimationData.animationSpeed  = rule.m_AnimationSpeed;
             return(true);
         }
     }
     return(false);
 }
예제 #5
0
 /// <summary>
 /// Retrieves any tile animation data from the scripted tile.
 /// </summary>
 /// <param name="position">Position of the Tile on the Tilemap.</param>
 /// <param name="tilemap">The Tilemap the tile is present on.</param>
 /// <param name="tileAnimationData">Data to run an animation on the tile.</param>
 /// <returns>Whether the call was successful.</returns>
 public override bool GetTileAnimationData(Vector3Int position, ITilemap tilemap, ref TileAnimationData tileAnimationData)
 {
     if (!m_InstanceTile)
     {
         return(false);
     }
     return(m_InstanceTile.GetTileAnimationData(position, tilemap, ref tileAnimationData));
 }
예제 #6
0
 public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
 {
     if (m_AnimatedSprites.Length > 0)
     {
         tileAnimationData.animatedSprites    = m_AnimatedSprites;
         tileAnimationData.animationSpeed     = Random.Range(m_MinSpeed, m_MaxSpeed);
         tileAnimationData.animationStartTime = m_AnimationStartTime;
         return(true);
     }
     Debug.Log("Duration:" + Duration + Time.deltaTime);
     Duration = Duration + Time.deltaTime;
     if (Duration > MaxDuration)
     {
         Debug.Log("Kill me now");
     }
     return(false);
 }
예제 #7
0
        public override bool GetTileAnimationData(Vec3I gridPos, TM.ITilemap tilemap, ref TM.TileAnimationData tileAnimationData)
        {
            Vec2I   pos     = GridToTile(gridPos);
            Terrain terrain = GetTile(pos).terrain;

            if (!terrain.animated)
            {
                return(false);
            }

            tileAnimationData.animatedSprites    = terrain.GetAnimationSprites(map, pos, GridToSubTile(gridPos));
            tileAnimationData.animationSpeed     = 2;
            tileAnimationData.animationStartTime = 0;

            return(true);
        }
예제 #8
0
 public virtual bool GetTileAnimationData(Vector3Int position, ITilemap tilemap, ref TileAnimationData tileAnimationData)
 {
     return(false);
 }
예제 #9
0
 //base method just returns false; we need to provide information to renderer and return true (success)
 public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
 {
     if (m_AnimatedSprites != null && m_AnimatedSprites.Length > 0)
     {
         tileAnimationData.animatedSprites    = m_AnimatedSprites;
         tileAnimationData.animationSpeed     = m_AnimationSpeed;
         tileAnimationData.animationStartTime = m_AnimationStartTime;
         return(true);
     }
     //else
     return(false);
 }
예제 #10
0
 public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
 {
     return(false);
 }
예제 #11
0
 public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
 {
     if (Animation.Length > 0)
     {
         tileAnimationData.animatedSprites    = Animation;
         tileAnimationData.animationSpeed     = 1;
         tileAnimationData.animationStartTime = 0;
         return(true);
     }
     return(false);
 }
예제 #12
0
 public override bool GetTileAnimationData(Vector3Int position, ITilemap tileMap, ref TileAnimationData tileAnimationData)
 {
     if (AnimatedSprites?.Length == 0)
     {
         return(false);
     }
     tileAnimationData.animatedSprites    = AnimatedSprites;
     tileAnimationData.animationSpeed     = Random.Range(Speed.x, Speed.y);
     tileAnimationData.animationStartTime = RandomStartTime ? Random.value : 0;
     return(true);
 }
예제 #13
0
 /// <summary>
 /// Retrieves any tile animation data from the scripted tile.
 /// </summary>
 /// <param name="position">Position of the Tile on the Tilemap.</param>
 /// <param name="tilemap">The Tilemap the tile is present on.</param>
 /// <param name="tileAnimationData">Data to run an animation on the tile.</param>
 /// <returns>Whether the call was successful.</returns>
 public override bool GetTileAnimationData(Vector3Int position, ITilemap tilemap, ref TileAnimationData tileAnimationData)
 {
     return(runtimeTile.GetTileAnimationData(position, tilemap, ref tileAnimationData));
 }
예제 #14
0
 public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
 {
     if (m_AnimatedSprites.Length > 0)
     {
         var total = m_AnimatedSprites.Length * tileAnimationData.animationSpeed;
         tileAnimationData.animatedSprites    = m_AnimatedSprites;
         tileAnimationData.animationSpeed     = Random.Range(m_MinSpeed, m_MaxSpeed);
         tileAnimationData.animationStartTime = RandomStartTime ? (GetRandomFrame() * tileAnimationData.animationSpeed) / total : 0;
         return(true);
     }
     return(false);
 }
예제 #15
0
 private void GetTileAnimationDataRef(Vector3Int position, ITilemap tilemap, ref TileAnimationData tileAnimationData, ref bool hasAnimation)
 {
     hasAnimation = GetTileAnimationData(position, tilemap, ref tileAnimationData);
 }