/// <summary>return the 1st avail class that can be chosen by the player (only those marked as "avail at start")</summary> public RPGActorClass GetDefaultPlayerClass(Actor actor) { if (actor != null) { // first check if the class currently on the actor can't be used if (actor.actorClassPrefab != null && UniRPGGlobal.DB.classes.Contains(actor.actorClassPrefab)) { return actor.actorClassPrefab; } } foreach (RPGActorClass c in UniRPGGlobal.DB.classes) { if (c.availAtStart) return c; } return null; }
void OnGUI() { if (!inited) Init(); UniRPGEdGui.UseSkin(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("filter", GUILayout.Width(60)); filter = (UniRPGGlobal.ActorType)EditorGUILayout.EnumPopup(filter); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); scroll = UniRPGEdGui.BeginScrollView(scroll); { if (UniRPGEditorGlobal.Cache.actors.Count > 0) { foreach (Actor actor in UniRPGEditorGlobal.Cache.actors) { if (filter != 0 && (int)actor.GetComponent<Actor>().ActorType != (int)filter) continue; Rect r = EditorGUILayout.BeginHorizontal(); { r.x = 3; r.width = 19; r.height = 19; GUI.DrawTexture(r, (actor.portrait[0] != null ? actor.portrait[0] : UniRPGEdGui.Texture_NoPreview)); GUILayout.Space(21); if (UniRPGEdGui.ToggleButton(selectedActor == actor, actor.screenName, UniRPGEdGui.ButtonRightStyle, UniRPGEdGui.ButtonOnColor, GUILayout.Width(150))) { selectedActor = actor; } } EditorGUILayout.EndHorizontal(); } } else { GUILayout.Label("No Actors are defined\n\nYou might need to Refresh the\ncache if you did define actors.\nDatatabase -> Main -> Actors", UniRPGEdGui.WarningLabelStyle); } } UniRPGEdGui.EndScrollView(); UniRPGEdGui.DrawHorizontalLine(1, UniRPGEdGui.DividerColor, 0, 10); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (selectedActor == null) GUI.enabled = false; if (GUILayout.Button("Accept", UniRPGEdGui.ButtonStyle)) accepted = true; GUI.enabled = true; if (GUILayout.Button("Cancel", UniRPGEdGui.ButtonStyle)) this.Close(); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); }
// ================================================================================================================ #region status panels (attribute bars) private void DrawStatusPanels() { if (gui.showPlayerStatus) { //Debug.Log("gui = " + gui); //Debug.Log("UniRPGGlobal.Player = " + UniRPGGlobal.Player); //Debug.Log("UniRPGGlobal.Player.Actor = " + UniRPGGlobal.Player.Actor); //Debug.Log("UniRPGGlobal.Player.Actor.ActorClass = " + UniRPGGlobal.Player.Actor.ActorClass); DrawStatus(r[9], r[10], gui.showPlayerPortrait, gui.showPlayerLevel, gui.playerStatusShowValue, gui.playerStatusBars, null, UniRPGGlobal.Player.Actor.portrait[0], UniRPGGlobal.Player.Actor.ActorClass.Level); } if (UniRPGGlobal.Player.TargetedCharacter != null) { DefaultGameGUIData.TargetStatusShow d = null; if (UniRPGGlobal.Player.TargetedCharacter.Actor.ActorType == UniRPGGlobal.ActorType.Hostile) d = gui.targetStatus[0]; else if (UniRPGGlobal.Player.TargetedCharacter.Actor.ActorType == UniRPGGlobal.ActorType.Neutral) d = gui.targetStatus[1]; else if (UniRPGGlobal.Player.TargetedCharacter.Actor.ActorType == UniRPGGlobal.ActorType.Friendly) d = gui.targetStatus[2]; if (d == null) return; if (d.show == false) return; if (lastTargetedActor != UniRPGGlobal.Player.TargetedCharacter.Actor) { // init the targetStatusBars var lastTargetedActor = UniRPGGlobal.Player.TargetedCharacter.Actor; for (int i = 0; i < gui.targetStatusBars.Count; i++) { gui.targetStatusBars[i].attrib = lastTargetedActor.ActorClass.GetAttribute(gui.targetStatusBars[i].attribId); } } DrawStatus(r[11], r[12], d.img, d.level, gui.targetStatusShowValue, d.bars ? gui.targetStatusBars : null, d.name ? UniRPGGlobal.Player.TargetedCharacter.Actor.screenName : null, UniRPGGlobal.Player.TargetedCharacter.Actor.portrait[0], UniRPGGlobal.Player.TargetedCharacter.Actor.ActorClass.Level); } else { lastTargetedActor = null; if (gui.targetStatus[3].show && UniRPGGlobal.Player.TargetedItem != null) { DrawStatus(r[11], r[12], gui.targetStatus[3].img, false, 0, null, gui.targetStatus[3].name ? UniRPGGlobal.Player.TargetedItem.screenName : null, UniRPGGlobal.Player.TargetedItem.icon[0], 0); } else if (gui.targetStatus[4].show && UniRPGGlobal.Player.TargetedObject != null) { DrawStatus(r[11], r[12], gui.targetStatus[3].img, false, 0, null, gui.targetStatus[3].name ? UniRPGGlobal.Player.TargetedObject.screenName : null, UniRPGGlobal.Player.TargetedObject.icon[0], 0); } } }
public void ShowShop(GameObject shopKeeperObj) { if (shopKeeperObj == null) { Debug.LogError("Error: Could not show the Shop Interface. The shop keeper object was null."); return; } CharacterBase shopCharacter = shopKeeperObj.GetComponent<CharacterBase>(); shopActor = shopKeeperObj.GetComponent<Actor>(); if (shopCharacter == null || shopActor == null) { Debug.LogError("Error: Could not show the Shop Interface. The object is not a valid character."); return; } // set defaults buyMod = UniRPGGlobal.DB.shopGlobalBuyMod; sellMod = UniRPGGlobal.DB.shopGlobalSellMod; useShopCurrency = UniRPGGlobal.DB.shopGlobalUsesCurrency; shopUnlimited = UniRPGGlobal.DB.shopGlobalUnlimited; shopBuyLabel = "Buy"; shopSellLabel = "Sell"; // now check if character has modifier vars and apply float n = 0f; string s = shopCharacter.GetCustomVariable("buy_mod"); if (!string.IsNullOrEmpty(s)) { if (float.TryParse(s, out n)) buyMod = n; } s = shopCharacter.GetCustomVariable("sell_mod"); if (!string.IsNullOrEmpty(s)) { if (float.TryParse(s, out n)) sellMod = n; } s = shopCharacter.GetCustomVariable("shop_use_currency"); if (!string.IsNullOrEmpty(s)) { if (s == "1") useShopCurrency = true; else if (s == "0") useShopCurrency = false; } s = shopCharacter.GetCustomVariable("shop_unlimited"); if (!string.IsNullOrEmpty(s)) { if (s == "1") shopUnlimited = true; else if (s == "0") shopUnlimited = false; } s = shopCharacter.GetCustomVariable("shop_buy_label"); if (!string.IsNullOrEmpty(s)) shopBuyLabel = s; s = shopCharacter.GetCustomVariable("shop_sell_label"); if (!string.IsNullOrEmpty(s)) shopSellLabel = s; // show shop ShowCenterPanel(DefaultGameGUIData_MenuOption.MenuOption.Shop, false, true); }
private float ApplyValueMod(ValueModifier mod, float value, Actor a1, Actor a2, UniqueMonoBehaviour ub1, UniqueMonoBehaviour ub2, GameObject self, GameObject targeted, GameObject selfTargetedBy, GameObject equipTarget, GameObject helper) { if (mod.param[0] == 0 && mod.param[1] == 0) return value; // nothing to do float v = 0f; float v1 = 0f; float v2 = 0f; if (mod.param[0] > 0) { // get value from param 1; 0: Not Used, 1:Numeric, 2:Value, 3:level(1), 4:attribute(1), 5:CustomVar(1), 6:level(2), 7:attribute(2), 8:CustomVar(2) if (mod.param[0] == 1) v1 = mod.numVal[0].Value(self, targeted, selfTargetedBy, equipTarget, helper); else if (mod.param[0] == 2) v1 = value; else if (mod.param[0] == 3) v1 = a1.ActorClass.Level; else if (mod.param[0] == 4) { RPGAttribute att = a1.ActorClass.GetAttribute(mod.attribId[0]); if (att != null) v1 = att.Value; else Debug.LogError("Attribute Action Error: Modifier Attribute not found on Subject."); } else if (mod.param[0] == 5) { if (ub1 != null) { if (false == float.TryParse(ub1.GetCustomVariable(mod.customVar[0]), out v1)) { Debug.LogError("Attribute Action Error: Modifier Custom Variable not found on Subject or has invalid value."); } } else Debug.LogError("Attribute Action Error: Subject does not support custom variables."); } else { if (mod.param[0] == 6 || mod.param[0] == 7) { if (a2 != null) { if (mod.param[0] == 6) v1 = a2.ActorClass.Level; else if (mod.param[0] == 7) { RPGAttribute att = a2.ActorClass.GetAttribute(mod.attribId[0]); if (att != null) v1 = att.Value; else Debug.LogError("Attribute Action Error: Modifier Attribute not found on Aggressor."); } } else Debug.LogError("Attribute Action Error: Aggressor is not an Actor."); } else if (mod.param[0] == 8) { if (ub2 != null) { if (false == float.TryParse(ub2.GetCustomVariable(mod.customVar[0]), out v1)) { Debug.LogError("Attribute Action Error: Modifier Custom Variable not found on Aggressor or has invalid value."); } } else Debug.LogError("Attribute Action Error: Aggressor does not support custom variables."); } } } if (mod.param[1] > 0) { // get value from param 2; 0: Not Used, 1:Numeric, 2:Value, 3:level(1), 4:attribute(1), 5:CustomVar(1), 6:level(2), 7:attribute(2), 8:CustomVar(2) if (mod.param[1] == 1) v2 = mod.numVal[1].Value(self, targeted, selfTargetedBy, equipTarget, helper); else if (mod.param[1] == 2) v2 = value; else if (mod.param[1] == 3) v2 = a1.ActorClass.Level; else if (mod.param[1] == 4) { RPGAttribute att = a1.ActorClass.GetAttribute(mod.attribId[1]); if (att != null) v2 = att.Value; else Debug.LogError("Attribute Action Error: Modifier Attribute not found on Subject."); } else if (mod.param[1] == 5) { if (ub1 != null) { if (false == float.TryParse(ub1.GetCustomVariable(mod.customVar[0]), out v1)) { Debug.LogError("Attribute Action Error: Modifier Custom Variable not found on Subject or has invalid value."); } } else Debug.LogError("Attribute Action Error: Subject does not support custom variables."); } else { if (mod.param[1] == 6 || mod.param[1] == 7) { if (a2 != null) { if (mod.param[1] == 6) v2 = a2.ActorClass.Level; else if (mod.param[1] == 7) { RPGAttribute att = a2.ActorClass.GetAttribute(mod.attribId[1]); if (att != null) v2 = att.Value; else Debug.LogError("Attribute Action Error: Modifier Attribute not found on Aggressor."); } } else Debug.LogError("Attribute Action Error: Aggressor is not an Actor."); } else if (mod.param[1] == 8) { if (ub2 != null) { if (false == float.TryParse(ub2.GetCustomVariable(mod.customVar[1]), out v2)) { Debug.LogError("Attribute Action Error: Modifier Custom Variable not found on Aggressor or has invalid value."); } } else Debug.LogError("Attribute Action Error: Aggressor does not support custom variables."); } } } if (mod.param[0] == 0) v = v2; if (mod.param[1] == 0) v = v1; if (mod.param[0] > 0 && mod.param[1] > 0) { // apply math to param1 and 2 if applicable; 0:add, 1:sub, 2:div, 3:multiply if (mod.doWhatToParams == 0) v = v1 + v2; else if (mod.doWhatToParams == 1) v = v1 - v2; else if (mod.doWhatToParams == 2) v = v1 / v2; else if (mod.doWhatToParams == 3) v = v1 * v2; else if (mod.doWhatToParams == 4) v = v1 % v2; } // apply to value, // 0:add, 1:sub, 2:div, 3:multiply if (mod.resultToValue == 0) value = value + v; else if (mod.resultToValue == 1) value = value - v; else if (mod.resultToValue == 2) value = value / v; else if (mod.resultToValue == 3) value = value * v; else if (mod.resultToValue == 4) value = value % v; return value; }
/// <summary>check if this skill can be used on the target</summary> private bool IsValidTargetActor(Actor actor) { if (((int)UniRPGGlobal.Target.Player & (int)validTargetsMask) != 0) { // player is always valid target if (actor != null) return actor.Character.canBeTargeted; else return true; } if (actor == null) { if (validTargetsMask == 0) return true; // "Nothing" return false; } else { if (!actor.Character.canBeTargeted) return false; return (((int)actor.ActorType & (int)validTargetsMask) != 0); } }
// ================================================================================================================ public override void Awake() { base.Awake(); _tr = gameObject.transform; _actor = gameObject.GetComponent<Actor>(); initing = true; }