void Awake(){ instance = (UnitCreepAnimation)target; if(!init) Init(); EditorUtility.SetDirty(instance); }
void Awake() { instance = (UnitCreepAnimation)target; if (!init) { Init(); } EditorUtility.SetDirty(instance); }
public void SetAnimationComponent(UnitCreepAnimation ani) { aniInstance = ani; }
Vector3 DrawUnitConfigurator(float startX, float startY, List <UnitCreep> creepList, bool offense = false) { UnitCreep creep = creepList[selectID]; float maxWidth = 0; //float cachedY=startY; float cachedX = startX; startX += 65; //startY+=20; int type = (int)creep.type; cont = new GUIContent("Creep Type:", "Type of the creep. Different type of creep has different capabilities"); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); contL = new GUIContent[creepTypeLabel.Length]; for (int i = 0; i < contL.Length; i++) { contL[i] = new GUIContent(creepTypeLabel[i], creepTypeTooltip[i]); } type = EditorGUI.Popup(new Rect(startX + 80, startY, width - 40, 15), new GUIContent(""), type, contL); creep.type = (_CreepType)type; startX = cachedX; v3 = DrawIconAndName(creep, startX, startY); startY = v3.y; maxWidth = v3.z; startY += 20; v3 = DrawUnitDefensiveSetting(creep, startX, startY, objHList, objHLabelList); startY = v3.y; if (maxWidth < v3.z) { maxWidth = v3.z; } startY += 20; cont = new GUIContent("Flying:", "Check to mark the creep as flying unit."); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.flying = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), creep.flying); cont = new GUIContent("Move Speed:", "Moving speed of the creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.moveSpeed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), creep.moveSpeed); cont = new GUIContent("Life Cost:", "The amont of life taken from player when this creep reach it's destination"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.lifeCost = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.lifeCost); cont = new GUIContent("Score Value:", "Score gained when destroy this creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.scoreValue = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.scoreValue); cont = new GUIContent("Life Gain:", "Life awarded to the player when player successfully destroy this creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.lifeValue = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.lifeValue); cont = new GUIContent("Energy Gain:", "Energy awarded to the player when player successfully destroy this creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.valueEnergyGain = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.valueEnergyGain); cont = new GUIContent("Resource Gain Upon Destroyed:", "The amont of life taken from player when this creep reach it's destination"); //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); rscGainFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), rscGainFoldout, cont); if (rscGainFoldout) { EditorUtilities.DrawSprite(new Rect(startX + 25, startY += spaceY - 2, 20, 20), EditorDBManager.iconRsc); startY += 2; EditorGUI.LabelField(new Rect(startX, startY, width, height), " - min/max"); creep.valueRscMin = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.valueRscMin); creep.valueRscMax = EditorGUI.IntField(new Rect(startX + spaceX + 40, startY, 40, height), creep.valueRscMax); startY += 5; } string[] creepNameList = EditorDBManager.GetCreepNameList(); cont = new GUIContent("SpawnUponDestroyed:", "Creep prefab to be spawn when an instance of this unit is destroyed. Note that the HP of the spawned unit is inherit from the destroyed unit. Use HP-multiplier to specifiy how much of the HP should be carried forward"); GUI.Label(new Rect(startX, startY += spaceY, width, height), cont); int ID = -1; for (int i = 0; i < creepList.Count; i++) { if (creepList[i].gameObject == creep.spawnUponDestroyed) { ID = i + 1; } } ID = EditorGUI.Popup(new Rect(startX + spaceX + 30, startY, 120, height), ID, creepNameList); if (ID > 0 && creepList[ID - 1] != creep) { creep.spawnUponDestroyed = creepList[ID - 1].gameObject; } else if (ID == 0) { creep.spawnUponDestroyed = null; } if (creep.spawnUponDestroyed != null) { cont = new GUIContent(" - Num to Spawn:", "The amount of creep to spawn when this unit is destroyed"); EditorGUI.LabelField(new Rect(startX + 20, startY += spaceY, width, height), cont); creep.spawnUponDestroyedCount = EditorGUI.IntField(new Rect(startX + spaceX + 30, startY, 40, height), creep.spawnUponDestroyedCount); cont = new GUIContent(" - HP Multiplier:", "The percentage of HP to pass to the next unit. 0.5 being 50% of parent unit's fullHP, 1 being 100% of parent unit's fullHP"); EditorGUI.LabelField(new Rect(startX + 20, startY += spaceY, width, height), cont); creep.spawnUnitHPMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX + 30, startY, 40, height), creep.spawnUnitHPMultiplier); } startY += 20; if (creep.type == _CreepType.Offense) { cont = new GUIContent("Stop To Attack:", "Check to have the creep stop moving when there's target to attack"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.stopToAttack = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), creep.stopToAttack); startY += spaceY; } v3 = DrawUnitOffensiveSetting(creep, startX, startY, objHList, objHLabelList); startY = v3.y + 20; if (maxWidth < v3.z) { maxWidth = v3.z; } if (creep.type == _CreepType.Offense) { startY += 30; } UnitCreepAnimation ani = creep.gameObject.GetComponent <UnitCreepAnimation>(); if (ani == null) { if (GUI.Button(new Rect(startX, startY, width + 50, height + 2), "Add animation component")) { ani = creep.gameObject.AddComponent <UnitCreepAnimation>(); } } if (ani != null) { if (GUI.Button(new Rect(startX, startY, width + 50, height + 2), "Remove animation component")) { DestroyImmediate(ani, true); //creep.gameObject.GetComponent<UnitCreepAnimation>(); return(new Vector3(startX, startY, maxWidth)); } startY += 5; type = (int)ani.type; cont = new GUIContent("Type:", "Type of the animation to use"); contL = new GUIContent[animationTypeLabel.Length]; for (int i = 0; i < contL.Length; i++) { contL[i] = new GUIContent(animationTypeLabel[i], animationTypeTooltip[i]); } EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); type = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), type, contL); ani.type = (UnitCreepAnimation._AniType)type; if (ani.type == UnitCreepAnimation._AniType.Legacy) { int objID = GetObjectIDFromHList(ani.aniRootObj != null ? ani.aniRootObj.transform : null, objHList); cont = new GUIContent("AnimationRootObj:", "The gameObject that contains the Animation component that runs the animation on the unit"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList); ani.aniRootObj = (objHList[objID] == null) ? null : objHList[objID]; cont = new GUIContent("Move Speed Multiplier:", "The multiplier used to match the move animation speed to the unit's move speed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.moveSpeedMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX + 30, startY, 40, height), ani.moveSpeedMultiplier); } else if (ani.type == UnitCreepAnimation._AniType.Mecanim) { int objID = GetObjectIDFromHList(ani.aniRootObj != null ? ani.aniRootObj.transform : null, objHList); cont = new GUIContent("Animator RootObj:", "The gameObject that contains the Animator component that control the animation on the unit"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList); ani.aniRootObj = (objHList[objID] == null) ? null : objHList[objID]; } if (ani.type != UnitCreepAnimation._AniType.None) { cont = new GUIContent("Spawn Clip:", "The animation clip to be played when the creep is destroyed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.clipSpawn = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipSpawn, typeof(AnimationClip), false); cont = new GUIContent("Move Clip:", "The animation clip to be played when the creep is moving"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.clipMove = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipMove, typeof(AnimationClip), false); cont = new GUIContent("Dead Clip:", "The animation clip to be played when the creep is destroyed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.clipDead = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipDead, typeof(AnimationClip), false); cont = new GUIContent("Destination Clip:", "The animation clip to be played when the creep reach its destination"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.clipDestination = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipDestination, typeof(AnimationClip), false); } } return(new Vector3(startX, startY, maxWidth)); }
public void SetAnimationComponent(UnitCreepAnimation ani){ aniInstance=ani; }
Vector3 DrawUnitConfigurator(float startX, float startY, List <UnitCreep> creepList) { UnitCreep creep = creepList[selectID]; float maxWidth = 0; float cachedY = startY; float cachedX = startX; startX += 65; //startY+=20; startX = cachedX; v3 = DrawIconAndName(creep, startX, startY); startY = v3.y; maxWidth = v3.z; cachedY = startY; v3 = DrawUnitDefensiveSetting(creep, startX, startY, objHList, objHLabelList); startY = v3.y; if (maxWidth < v3.z) { maxWidth = v3.z; } startY += 20; cont = new GUIContent("Flying:", "Check to mark the creep as flying unit."); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.flying = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), creep.flying); cont = new GUIContent("Move Speed:", "Moving speed of the creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.moveSpeed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), creep.moveSpeed); cont = new GUIContent("Life Cost:", "The amont of life taken from player when this creep reach it's destination"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.lifeCost = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.lifeCost); cont = new GUIContent("Life Gain:", "Life awarded to the player when player successfully destroy this creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.lifeValue = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.lifeValue); cont = new GUIContent("Energy Gain:", "Energy awarded to the player when player successfully destroy this creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); creep.valueEnergyGain = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.valueEnergyGain); cont = new GUIContent("Resource Gain Upon Destroyed:", "The amont of life taken from player when this creep reach it's destination"); EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width + 150, height), cont); List <Rsc> rscList = EditorDBManager.GetRscList(); for (int i = 0; i < rscList.Count; i++) { EditorUtilities.DrawSprite(new Rect(startX + 25, startY += spaceY - 2, 20, 20), rscList[i].icon); startY += 2; EditorGUI.LabelField(new Rect(startX, startY, width, height), " - min/max"); //+rscList[i].name); creep.valueRscMin[i] = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.valueRscMin[i]); creep.valueRscMax[i] = EditorGUI.IntField(new Rect(startX + spaceX + 40, startY, 40, height), creep.valueRscMax[i]); } startY += 5; startY = cachedY + spaceY; startX += 300; //~ if(creep.type==_CreepType.Offense){ //~ cont=new GUIContent("Stop To Attack:", "Check to have the creep stop moving when there's target to attack"); //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); //~ creep.stopToAttack=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), creep.stopToAttack); //~ startY+=spaceY; //~ } //~ v3=DrawUnitOffensiveSetting(creep, startX, startY, objHList, objHLabelList); startY=v3.y+20; if(maxWidth<v3.z) maxWidth=v3.z; //~ if(creep.type==_CreepType.Offense) startY+=30; UnitCreepAnimation ani = creep.gameObject.GetComponent <UnitCreepAnimation>(); if (ani == null) { if (GUI.Button(new Rect(startX, startY, width + 50, height + 2), "Add animation component")) { ani = creep.gameObject.AddComponent <UnitCreepAnimation>(); } } if (ani != null) { if (GUI.Button(new Rect(startX, startY, width + 50, height + 2), "Remove animation component")) { DestroyImmediate(ani, true); //creep.gameObject.GetComponent<UnitCreepAnimation>(); return(new Vector3(startX, startY, maxWidth)); } startY += 5; int type = (int)ani.type; cont = new GUIContent("Type:", "Type of the animation to use"); contL = new GUIContent[animationTypeLabel.Length]; for (int i = 0; i < contL.Length; i++) { contL[i] = new GUIContent(animationTypeLabel[i], animationTypeTooltip[i]); } //cont=new GUIContent("AnimationRootObj:", "The gameObject that contains the Animation component that runs the animation on the unit"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); type = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), type, contL); ani.type = (UnitCreepAnimation._AniType)type; if (ani.type == UnitCreepAnimation._AniType.Legacy) { int objID = GetObjectIDFromHList(ani.aniRootObj != null ? ani.aniRootObj.transform : null, objHList); cont = new GUIContent("AnimationRootObj:", "The gameObject that contains the Animation component that runs the animation on the unit"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList); ani.aniRootObj = (objHList[objID] == null) ? null : objHList[objID]; cont = new GUIContent("Move Speed Multiplier:", "The multiplier used to match the move animation speed to the unit's move speed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.moveSpeedMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX + 30, startY, 40, height), ani.moveSpeedMultiplier); } else if (ani.type == UnitCreepAnimation._AniType.Mecanim) { int objID = GetObjectIDFromHList(ani.aniRootObj != null ? ani.aniRootObj.transform : null, objHList); cont = new GUIContent("Animator RootObj:", "The gameObject that contains the Animator component that control the animation on the unit"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList); ani.aniRootObj = (objHList[objID] == null) ? null : objHList[objID]; //~ cont=new GUIContent("Dead Clip:", "The animation clip played by the animator when the creep is destroyed. This is required to know the duration of the animation"); //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); //~ ani.clipDead=(AnimationClip)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), ani.clipDead, typeof(AnimationClip), false); //~ cont=new GUIContent("Destination Clip:", "The animation clip played by the animator when the creep reach its destination. This is required to know the duration of the animation"); //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); //~ ani.clipDestination=(AnimationClip)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), ani.clipDestination, typeof(AnimationClip), false); } if (ani.type != UnitCreepAnimation._AniType.None) { cont = new GUIContent("Spawn Clip:", "The animation clip to be played when the creep is destroyed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.clipSpawn = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipSpawn, typeof(AnimationClip), false); cont = new GUIContent("Move Clip:", "The animation clip to be played when the creep is moving"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.clipMove = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipMove, typeof(AnimationClip), false); cont = new GUIContent("Dead Clip:", "The animation clip to be played when the creep is destroyed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.clipDead = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipDead, typeof(AnimationClip), false); cont = new GUIContent("Destination Clip:", "The animation clip to be played when the creep reach its destination"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ani.clipDestination = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipDestination, typeof(AnimationClip), false); } } //GUI.Box(new Rect(cachedX, cachedY, maxWidth, 10), ""); return(new Vector3(startX, startY, maxWidth)); }
public void SetAnimationComponent(UnitCreepAnimation ani) { animCreep = ani; }