public FatherBuilding(BuilduingTypeInfo info, string type, Vector2 pos) : base(UnitConverter.CreatePolygon(info.Polygon, pos)) { this.Position = polygon.Center; fullHp = info.Health; Defense = new Damage(info.Defense); //SpriteData = ResourceManager.CreateSpData(info.DrawInfo, polygon); this.Type = type; this.wNeed = info.WorkNeeded; wDone = 0; this.SightRange = info.SightRange; IdleAnimation = UnitConverter.CreateAnimation(polygon, info.IdleAnimation); BuildAnimation = UnitConverter.CreateAnimation(polygon, info.BuildAnimation); WorkAnimation = UnitConverter.CreateAnimation(polygon, info.WorkAnimation); SetBaseAnimation(BuildAnimation); BuildAnimation.Stop(); buildMenu = new ActorMenu(this); buildMenu.DisplayBar = true; Health = 1; DrawDepth = Omron.Framework.DrawPriority.BuildingDepth; this.Attacked += new AttackedEventHandler(changeAnim); }
private static string LoadWithFrameDict(PlistDictionary dPlist) { //parse metaData var meta = dPlist["metadata"] as PlistDictionary; PlistMetaData metaData = ParseMetaData(meta); //parse frames List <FrameDataDict> frames = ParseFrames(dPlist["frames"] as PlistDictionary, metaData.format); string name = metaData.realTextureFileName.Substring(0, metaData.realTextureFileName.Length - 4); DirectoryInfo directory = new DirectoryInfo(BuildAnimation.PlistPath + "/png"); Debug.Log("name:" + name); string path = BuildAnimation.DataPathToAssetPath(directory.FullName + "/" + name + ".png"); //load png Texture2D bigTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(path); if (bigTexture == null) { Debug.LogError("LoadTexture2D, failed!" + path); return(null); } List <SpriteMetaData> lstSprite = new List <SpriteMetaData>(); TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter; foreach (FrameDataDict frameDataDict in frames) { frameInfos[frameDataDict.name] = frameDataDict; SpriteMetaData spriteMetaData = SpriteFrame.CreateWithFrameDict(frameDataDict, bigTexture); lstSprite.Add(spriteMetaData); } textureImporter.textureType = TextureImporterType.Sprite; textureImporter.spriteImportMode = SpriteImportMode.Multiple; textureImporter.spritesheet = lstSprite.ToArray(); AssetDatabase.ImportAsset(path); return(path); }
public void OnWorkedOn(float work) { if (IsComplete) { return; } wDone += work; Health += work / wNeed * (fullHp - 1); if (Health > fullHp) { Health = fullHp; } updateMenu(); BuildAnimation.GoToFrameRatio(Completion); if (wDone >= wNeed) {//goes here when construction is done! lolB SetBaseAnimation(IdleAnimation); IdleAnimation.Stop(); wDone = wNeed; OnUpdateMenu(this); return; } }
static void ImageToGo() { instance = EditorWindow.GetWindow <BuildAnimation>(); instance.Show(); }