public static void Init() { if (instance != null) { return; } instance = LoadDB(); }
public static void TriggerAbility(int ID) //for trigger and collectible that activate an ability { if (instance == null) { return; } LaunchAbility(Ability_DB.CloneItem(ID), false); }
public void _AddAbility(int abID, int replaceID = -1) { Ability newAbility = Ability_DB.CloneItem(abID); if (newAbility == null) { return; } int slotID = -1; if (replaceID >= 0) { for (int i = 0; i < abilityList.Count; i++) { if (abilityList[i].ID == replaceID) { slotID = i; break; } } } if (slotID < 0) { slotID = abilityList.Count; abilityList.Add(null); } abilityList[slotID] = newAbility; abilityList[slotID].Init(); if (replaceID < 0 || slotID < 0) { TDS.NewAbility(abilityList[slotID]); } else { TDS.NewAbility(newAbility, slotID); } Select(slotID); }
[HideInInspector] public bool temporary = false; //used for weapon that is collected via collectible, cannot switch weapon and discard when out of ammo void Awake() { //make sure none of the element in shootPointList is null for (int i = 0; i < shootPointList.Count; i++) { if (shootPointList[i] == null) { shootPointList.RemoveAt(i); i -= 1; } } //if no shoot point has been assigned, use the current transform if (shootPointList.Count == 0) { shootPointList.Add(transform); } if (shootObject != null) { InitShootObject(); } aStats.Init(); //initiate the attack stats //create the ability ability = Ability_DB.CloneItem(abilityID); if (ability != null) { ability.Init(); } if (shootObject != null) { ObjectPoolManager.New(shootObject, 3); } else { Debug.LogWarning("shoot object for weapon unassigned", this); } Reset(); }
public void _SetupAbility(List <int> abIDlist, bool enableAll) { abilityList = new List <Ability>(); //cloen the ability from DB list (so they dont get modified in runtime) if (enableAll) { abilityList = Ability_DB.LoadClone(); } else { for (int i = 0; i < abIDlist.Count; i++) { abilityList.Add(Ability_DB.CloneItem(abIDlist[i])); abilityList[i].Init(); } } //select an ability, if there's any Select((abilityList.Count == 0) ? -1 : 0); }
public static void LoadAbility() { abilityDB = Ability_DB.LoadDB(); for (int i = 0; i < abilityDB.abilityList.Count; i++) { if (abilityDB.abilityList[i] != null) { //abilityDB.abilityList[i].ID=i; abilityIDList.Add(abilityDB.abilityList[i].ID); } else { abilityDB.abilityList.RemoveAt(i); i -= 1; } } UpdateLabel_Ability(); TDSEditorWindow.SetAbilityDB(abilityDB, abilityIDList, abilityLabel); TDSEditorInspector.SetAbilityDB(abilityDB, abilityIDList, abilityLabel); }
public static void SetAbilityDB(Ability_DB db, List <int> IDList, string[] label) { abilityDB = db; abilityIDList = IDList; abilityLabel = label; }
public override bool OnGUI() { if (!base.OnGUI()) { return(true); } if (window == null) { Init(); } List <Ability> abilityList = abilityDB.abilityList; Undo.RecordObject(this, "window"); Undo.RecordObject(abilityDB, "AbilityDB"); if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save")) { SetDirtyTDS(); } if (!Ability_DB.UpdatedToPost_2018_3()) { GUI.color = new Color(0, 1f, 1f, 1f); if (GUI.Button(new Rect(Math.Max(260, window.position.width - 230), 5, 100, 25), "Copy Old DB")) { Ability_DB.CopyFromOldDB(); Select(0); } GUI.color = Color.white; } if (GUI.Button(new Rect(5, 5, 120, 25), "Create New")) { Select(NewItem()); } if (abilityList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected")) { Select(NewItem(selectID)); } float startX = 5; float startY = 55; if (minimiseList) { if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>")) { minimiseList = false; } } else { if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<")) { minimiseList = true; } } Vector2 v2 = DrawAbilityList(startX, startY, abilityList); startX = v2.x + 25; if (abilityList.Count == 0) { return(true); } Rect visibleRect = new Rect(startX, startY, window.position.width - startX - 10, window.position.height - startY - 5); Rect contentRect = new Rect(startX, startY, contentWidth - startY, contentHeight); scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect); //float cachedX=startX; v2 = DrawAbilityConfigurator(startX, startY, abilityList[selectID]); contentWidth = v2.x + 35; contentHeight = v2.y - 55; GUI.EndScrollView(); if (GUI.changed) { SetDirtyTDS(); } return(true); }
public void ChangeAbility(int newID) { ability = Ability_DB.CloneItem(abilityID); }