void RebuildActionList(MT_Combatant who) { if (Dbg.Assert(who != null)) { return; } if (Dbg.Assert(who.Base != null)) { return; } if (Dbg.Assert(who.Base.Actions != null)) { return; } for (int i = 0; i < who.Base.Actions.Count; i++) { GameObject obj = AddElement(); if (Dbg.Assert(obj != null)) { return; } UI_ActionListPanelEntry entry = obj.GetComponent <UI_ActionListPanelEntry>(); if (Dbg.Assert(entry != null)) { return; } entry.Set(who, who.Base.Actions[i], i); UN.SetActive(obj, true); } }
public override Status GetStatus(MT_Combatant c) { if (c.IsOut) { return(Status.Unavailable); } return(_curStatus); //### TODO FIX }
/// <summary> /// Called when a combatant has selected an action to run. /// For now, we assume we only allow one action at a time to run. /// </summary> /// <param name="ndx"></param> public void StartAction(BS_Action action, MT_Combatant comb) { if (IsRunningAction) { return; } _currentAction = action; _currentActionIt = action.Execute(comb); }
// ------------------------------------------------------------------------- public override void OnEnable() // ------------------------------------------------------------------------- { _path = new UnityEngine.AI.NavMeshPath(); _who = _params[0] as MT_Combatant; if (!Dbg.Assert(_who != null)) { _nma = _who.Pawn.GetComponent <UnityEngine.AI.NavMeshAgent>(); } _done = false; base.OnEnable(); }
public void Set(MT_Combatant who, BS_Action act, int ndx) { _who = who; _action = act; _ndx = ndx; _number.text = (_ndx + 1).ToString(); if (_image != null) { _image.sprite = act.Icon; } // ### TODO : add icons! }
// --------------------------------------------------------------------------------------- /// <summary> /// Called when we're preparing to go into the match. I.e. still in League, about to go to Match. /// Creates list of MatchCombatant structures /// </summary> /// <param name="ndx"></param> /// <param name="team"></param> /// <param name="matchParams"></param> public void Initialize(int ndx, BS_Team team, BS_MatchParams matchParams) // --------------------------------------------------------------------------------------- { Combatants = new List <MT_Combatant>(); Score = 0; TeamNdx = ndx; Team = team; foreach (var v in team.GetCombatantsForMatch(matchParams)) { MT_Combatant cmbt = new MT_Combatant(); cmbt.Initialize(v, this); Combatants.Add(cmbt); } }
public void Update() { MT_Combatant me = PT_Game.UI.Match.SelectedPCCombatant; bool active = me != null; UN.SetActive(_actionList, active); UN.SetActive(_apAvail, active); UN.SetActive(_apCost, active); if (active) { UN.SetText(_apAvail, ((int)Math.Round(me.Base.ActionPoints)).ToString()); UN.SetActive(_apCost, active); //### TODO: Add logic to compute cost of current action } }
// ### TODO : move this into an instance, so we're sure it gets cleaned up public override IEnumerator Execute(MT_Combatant c) { //Events.AddGlobalListener<> // Step #1 get target point. Dbg.Assert(_targetSet == false); // TODO : Fix & remove target function. Unless for NPCs int markerId = -1; if (_targetSet == false) { EventWaitSet ews = new EventWaitSet(-1.0f); // param is timeout ews.Add <MT_SelectedPathEvent>(); ews.Add <MT_InputModeCanceledEvent>(); PT_Game.Match.InputMgr.QueueInputMode <MT_InputModeSelectPath>(c); IEnumerator it = ews.WaitForEvent(); while (it.MoveNext()) { yield return(null); } PT_Game.Match.InputMgr.QueueInputMode <MT_InputModeNone>(); MT_SelectedPathEvent ev = ews.GetEvent() as MT_SelectedPathEvent; if (ev == null) { PT_Game.Match.InputMgr.QueueInputMode <MT_InputModeBase>(); yield break; } markerId = PT_Game.Match.Widgets.ShowDestinationPoint(ev.Where, -1); SetTarget(ev.Where); } c.Pawn.SetDestination(_destinationPt); while (IsMovingToDestination(c, _destinationPt)) { _lastPt = c.Pawn.transform.position; yield return(null); } PT_Game.Match.Widgets.HideDestinationPoint(markerId); PT_Game.Match.InputMgr.QueueInputMode <MT_InputModeBase>(); yield return(null); }
public void OnSelectionChanged(SM_SelectionChangedEvent ev) { MT_Combatant comb = null; SM_Pawn pawn = ev.Get <SM_Pawn>(); if (pawn != null) { comb = pawn.GameParent as MT_Combatant; if (comb.Team.Team.IsAI) // TODO: change this to compare against current UI player { comb = null; } } SetCombatant(comb); }
bool IsMovingToDestination(MT_Combatant c, Vector3 destination) { if (Time.deltaTime < float.Epsilon) // we're effectively paused, so don't do anything { return(true); } float distMovedLastTime = ((_lastPt - c.Pawn.transform.position).sqrMagnitude) / Time.deltaTime; _totalDistanceCovered += distMovedLastTime; if ((c.Pawn.transform.position - _destinationPt).sqrMagnitude < 0.2f) { return(false); } return(true); }
public void SetCombatant(MT_Combatant c) { _who = c; if (c == null) { UN.SetActive(_visualBase, false); } else { UN.SetActive(_visualBase, true); UN.SetText(_nameText, c.Base.FullName); UN.SetFill(_healthBar, c.Base.GetPropertyRatio(BS_PropertyId.Health)); UN.SetFill(_apBar, c.Base.GetPropertyRatio(BS_PropertyId.ActionPoints)); UN.SetEnabled(_selectBtn, !c.Base.Team.IsAI); _icon.sprite = PT_Game.Data.Icons.GetIcon(c.Base.IconImageName); } }
void OnSelectionChanged(SM_SelectionChangedEvent ev) { if (Dbg.Assert(ev.NewWho != null)) { return; } MT_Combatant commandable = null; for (int i = 0; commandable == null && i < ev.NewWho.Count; i++) { SM_Pawn t = ev.NewWho[i] as SM_Pawn; if (t != null) { MT_Combatant matchComb = t.GameParent as MT_Combatant; if (matchComb != null) { if (matchComb.Team.Team.IsAI == false) { commandable = matchComb; } } } } if (commandable == _lastCombatant) { return; } _lastCombatant = commandable; ClearAll(); if (commandable != null) { RebuildActionList(commandable); } }
//protected override void OnSelectionChanged(SM_SelectionChangedEvent ev) //{ // //### TODO check to see if this is someone that the local player can muck with // //bool isHumanTeam = false; // //// if we are de-selecting, or selecting non-human team then we don't care // //if (ev.NewWho.Count == 0 && isHumanTeam == false) // //{ // // _inputMgr.QueueInputMode<MT_InputModeBase>(); // //} //} public override bool Update() { // returns true if we're done with update this frame if (base.Update()) { return(true); } UpdateHilight(PT_Game.Match.MainCamera); if (Input.GetMouseButtonDown(0)) { SM_ISelectable sel = CheckForObjectUnderMouse(PT_Game.Match.MainCamera); if (sel != null) { } } MT_Combatant c = PT_Game.UI.Match.SelectedPCCombatant; Dbg.Assert(c != null); if (c.IsOut == false) { int numKeyDown = GetNumberKeyDown(); if (numKeyDown >= 0) { if (c.Base.Actions != null && numKeyDown <= c.Base.Actions.Count) { PT_Game.Match.StartAction(c.Base.Actions[numKeyDown - 1], c); // TODO : replace with event? return(true); } } } return(false); }
public void OnEnable() { _lastCombatant = null; ClearAll(); Events.AddGlobalListener <SM_SelectionChangedEvent>(OnSelectionChanged); }
public abstract IEnumerator Execute(MT_Combatant c);
public abstract Status GetStatus(MT_Combatant c);