Ejemplo n.º 1
0
        public List <Sprite> Sprites()
        {
            if (_sprites == null)
            {
                _sprites = new List <Sprite>();
                int    count = 0;
                string path  = Icon;
                while (SpriteHelper.Exist(path))
                {
                    _sprites.Add(SpriteHelper.Load(path));
                    count++;
                    path = Icon.Replace("_0", "_" + count);
                    if (path == Icon)
                    {
                        Debug.LogError(path + " is wrong formed");
                        return(null);
                    }
                }

                //add the sprites on the end
                if (repeat >= 2)
                {
                    var cp = new Sprite[_sprites.Count];
                    _sprites.CopyTo(cp);
                    for (int i = 1; i < repeat; i++)
                    {
                        _sprites.AddRange(cp);
                    }
                }
            }

            return(_sprites);
        }
Ejemplo n.º 2
0
        public bool ExistAnimationSprite(UnitAnimatorType typ)
        {
            if (typ == UnitAnimatorType.Face)
            {
                return(SpriteHelper.Exist(folder + "face"));
            }

            if (typ.ToString().StartsWith("Attack") || typ.ToString().StartsWith("Defend"))
            {
                return(SpriteHelper.Exist(folder + "fight"));
            }

            if (typ == UnitAnimatorType.Yes || typ == UnitAnimatorType.No || typ == UnitAnimatorType.Laugh ||
                typ == UnitAnimatorType.Cast)
            {
                return(SpriteHelper.Exist(folder + "emo"));
            }

            return(false);
        }
Ejemplo n.º 3
0
        public void CreateAnimation()
        {
            var dataBuilding = GetComponent <BuildingInfo>().dataBuilding;

            _anList = null;

            string opath = dataBuilding.Icon;

            //is winter?
            if (GetComponent <BuildingInfo>().isWinter&& !String.IsNullOrEmpty(dataBuilding.winter))
            {
                opath = dataBuilding.winter;
            }

            //has animation?
            if (!opath.Contains("Animation"))
            {
                return;
            }

            List <Sprite> sprites = new List <Sprite>();

            int    count = 0;
            string path  = opath;

            while (SpriteHelper.Exist(path))
            {
                sprites.Add(SpriteHelper.Load(path));
                count++;
                path = opath.Replace("_0", "_" + count);
            }
            // Debug.Log(path+" found animation "+sprites.Count);

            if (sprites.Count == 0)
            {
                throw new MissingMemberException("Building animation " + opath + " has 0 sprites");
            }

            _anList = sprites.ToArray();
        }