override public void FixedUpdate() { base.FixedUpdate(); if (paused) { return; } if (activeCharacter == null) { if (pointsRemaining == 0) { EndRound(); } } if (activeCharacter != null) { RoundPointsCharacter ppc = activeCharacter.GetComponent <RoundPointsCharacter>(); if (limitMode == TurnLimitMode.Time) { ppc.Limiter -= Time.deltaTime; } else if (limitMode == TurnLimitMode.AP) { float waitAPCost = ppc.PerSecondAPCost; DecreaseAP(waitAPCost * Time.deltaTime); } if (ppc.Limiter <= 0) { Deactivate(activeCharacter); } } }
public void DecreaseAP(float amt) { if (activeCharacter != null && limitMode == TurnLimitMode.AP) { RoundPointsCharacter ppc = activeCharacter.GetComponent <RoundPointsCharacter>(); ppc.Limiter -= amt; } }
override public void Start() { pointsRemaining = pointsPerRound; foreach (Character c in characters) { RoundPointsCharacter ppc = c.GetComponent <RoundPointsCharacter>(); ppc.UsesThisRound = 0; ppc.Limiter = 0; } }
//NEXT: maybe this is best phrased as a call from the scheduler to the Region letting it know //some relevant information? Or else a call from the Region to the scheduler -- either way, //the Region must be AP-savvy in order to get the correct paths. public float GetMaximumTraversalDistance(Character c = null) { //FIXME: only right for AP-limited scheduler if (c == null) { c = activeCharacter; } if (c == null) { return(0); } RoundPointsCharacter ppc = c.GetComponent <RoundPointsCharacter>(); float moveAPCost = ppc.PerUnitMovementAPCost; return((float)(ppc.Limiter / moveAPCost)); }
override public void Activate(Character c, object ctx = null) { if (c == null) { return; } RoundPointsCharacter ppc = c.GetComponent <RoundPointsCharacter>(); int uses = ppc.UsesThisRound; if (limitMode == TurnLimitMode.AP) { //set C's AP based on uses ppc.Limiter = ppc.MaxTurnAP; } else if (limitMode == TurnLimitMode.Time) { //set timer based on uses ppc.Limiter = ppc.MaxTurnTime; } float downscaleFactor = ppc.TurnDiminishScale; ppc.Limiter *= Mathf.Pow(downscaleFactor, uses); if (limitMode == TurnLimitMode.AP) { //FIXME: It is NOT OKAY for the scheduler to determine the move region's max range? //???: What about characters' intrinsic stats and so on? //???: may be better to pass this through a param instead... // Region ms = c.moveSkill.targetSettings[0].targetRegion; // ms.radiusMaxF = Formula.Constant(GetMaximumTraversalDistance(c)); } //FIXME: can we do something here for time-based traversal distance limitation? //???: What about characters' intrinsic movement stats and so on? Debug.Log("starting AP: " + ppc.Limiter); base.Activate(c, ctx); ppc.UsesThisRound = uses + 1; //(for now): ON `activate`, MOVE // activeCharacter.moveSkill.ActivateSkill(); pointsRemaining--; }
override public void CharacterMoved(Character c, Vector3 from, Vector3 to, PathNode endOfPath) { /* Debug.Log("moved to "+to);*/ RoundPointsCharacter ppc = c.GetComponent <RoundPointsCharacter>(); if (limitMode == TurnLimitMode.AP) { float moveAPCost = ppc.PerUnitMovementAPCost; float distance = 0; if (onlyDrainAPForXYDistance) { distance = endOfPath.xyDistanceFromStart; } else { distance = Mathf.Floor(endOfPath.distance); } Debug.Log("Distance: " + distance + " from " + from + " to " + to); DecreaseAP(moveAPCost * distance); Debug.Log("new AP: " + ppc.Limiter); } }
public void EndRound() { if (activeCharacter != null) { Deactivate(activeCharacter); } map.BroadcastMessage("RoundEnded", currentTeam, SendMessageOptions.DontRequireReceiver); currentTeam++; if (currentTeam >= teamCount) { currentTeam = 0; } pointsRemaining = pointsPerRound; foreach (Character c in characters) { if (c.EffectiveTeamID == currentTeam) { RoundPointsCharacter ppc = c.GetComponent <RoundPointsCharacter>(); ppc.UsesThisRound = 0; } } map.BroadcastMessage("RoundBegan", currentTeam, SendMessageOptions.DontRequireReceiver); }
override public void CharacterMovedIncremental(Character c, Vector3 from, Vector3 to, PathNode endOfPath) { //FIXME: might be broken for certain types of incremental tile-locked moves /* Debug.Log("moved to "+to);*/ RoundPointsCharacter ppc = c.GetComponent <RoundPointsCharacter>(); if (limitMode == TurnLimitMode.AP) { float moveAPCost = ppc.PerUnitMovementAPCost; float distance = 0; if (onlyDrainAPForXYDistance) { distance = Vector2.Distance(new Vector2(to.x, to.y), new Vector2(from.x, from.y)); } else { distance = Vector3.Distance(to, from); } Debug.Log("Inc distance: " + distance + " from " + from + " to " + to); DecreaseAP(moveAPCost * distance); Debug.Log("new AP: " + ppc.Limiter); } }
public void OnGUI() { Scheduler s = GetComponent <Scheduler>(); Arbiter a = GetComponent <Arbiter>(); if (pendingTargetedSkill != null) { if (targetingChoices == null || targetingChoices.Length == 0) { targetingChoices = new string[] { "Tile", "Character", "Cancel" }; } int choice = OnGUIChoices("Target tile or character?", targetingChoices); if (choice != -1) { if (choice == 0) { pendingTargetedSkill.ConfirmDelayedSkillTarget(TargetOption.Path); } else if (choice == 1) { pendingTargetedSkill.ConfirmDelayedSkillTarget(TargetOption.Character); } else if (choice == 2) { pendingTargetedSkill.IncrementalCancel(); } pendingTargetedSkill = null; } return; } bool showAnySchedulerButtons = true; bool showCancelButton = true; Character ac = s.activeCharacter; var skills = ac == null ? new SkillDef[0] : ac.Skills; if (ac != null) { if (map == null) { map = transform.parent.GetComponent <Map>(); } MoveSkillDef ms = ac.moveSkill; if (ms != null && ms.isActive) { if (a.IsLocalTeam(ac.EffectiveTeamID)) { MoveExecutor me = ms.Executor; if (!me.IsMoving) { if (ms.RequireConfirmation && ms.AwaitingConfirmation) { bool yesButton = false, noButton = false; OnGUIConfirmation("Move here?", out yesButton, out noButton); if (yesButton) { ms.ApplyCurrentTarget(); ms.AwaitingConfirmation = false; } if (noButton) { ms.AwaitingConfirmation = false; ms.TemporaryMove(map.InverseTransformPointWorld(me.position)); } showCancelButton = false; } else { showCancelButton = false; } showAnySchedulerButtons = false; } else { showAnySchedulerButtons = false; showCancelButton = false; } } } foreach (SkillDef skill in skills) { if (!skill.isPassive && skill.isActive && skill is ActionSkillDef && !(skill is MoveSkillDef || skill is WaitSkillDef)) { ActionSkillDef ask = skill as ActionSkillDef; if (a.IsLocalTeam(ac.EffectiveTeamID)) { if (ask.RequireConfirmation && ask.AwaitingConfirmation) { bool yesButton = false, noButton = false; OnGUIConfirmation("Confirm?", out yesButton, out noButton); if (yesButton) { ask.ApplyCurrentTarget(); } if (noButton) { ask.AwaitingConfirmation = false; } } showAnySchedulerButtons = false; } } } WaitSkillDef ws = ac.waitSkill; if (ws != null && ws.isActive) { if (a.IsLocalTeam(ac.EffectiveTeamID)) { if (ws.RequireConfirmation && ws.AwaitingConfirmation) { bool yesButton = false, noButton = false; OnGUIConfirmation("Wait here?", out yesButton, out noButton); if (yesButton) { ws.ApplyCurrentTarget(); } if (noButton) { ws.AwaitingConfirmation = false; } } else { showCancelButton = permitMultipleMoves || permitMultipleActions || !(activeCharacterHasMoved && activeCharacterHasActed); } showAnySchedulerButtons = false; } } } if (s is CTScheduler) { if (ac != null && a.IsLocalTeam(ac.EffectiveTeamID)) { GUILayout.BeginArea(new Rect( 8, 8, 128, 240 )); GUILayout.Label("Character:" + ac.gameObject.name); GUILayout.Label("HP: " + Mathf.Ceil(ac.GetStat("health", ac.GetStat("HP")))); GUILayout.Label("CT: " + Mathf.Floor(ac.GetStat((s as CTScheduler).ctStat))); //TODO:0: support skills //show list of skills SkillDef activeSkill = null; foreach (SkillDef sk in skills) { if (sk.isActive) { activeSkill = sk; break; } } if (activeSkill == null) { //root: move, act group, wait var nextSel = OnGUISkillGroup(ac, skills, selectedGroup); selectedGroup = nextSel == null ? null : nextSel.ToList(); } else if (showCancelButton) { if (GUILayout.Button("Cancel " + activeSkill.skillName)) { activeSkill.Cancel(); } } GUILayout.EndArea(); } } else if (s is TeamRoundsPickAnyOnceScheduler) { TeamRoundsPickAnyOnceScheduler tps = s as TeamRoundsPickAnyOnceScheduler; GUILayout.BeginArea(new Rect( 8, 8, 110, 240 )); GUILayout.Label("Current Team:" + tps.currentTeam); if (ac != null) { GUILayout.Label("Character:" + ac.gameObject.name); GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health"))); //show list of skills SkillDef activeSkill = null; foreach (SkillDef sk in skills) { if (sk.isActive) { activeSkill = sk; break; } } if (activeSkill == null) { //root: move, act group, wait var nextSel = OnGUISkillGroup(ac, skills, selectedGroup); selectedGroup = nextSel == null ? null : nextSel.ToList(); } else if (showCancelButton) { if (GUILayout.Button("Cancel " + activeSkill.skillName)) { activeSkill.Cancel(); } } } else { GUILayout.Label("Click any team member"); } if (a.IsLocalTeam(tps.currentTeam)) { if (showAnySchedulerButtons && !(ac != null && ac.moveSkill.Executor.IsMoving) && GUILayout.Button("End Round")) { tps.EndRound(); } } GUILayout.EndArea(); } else if (s is TeamRoundsPointsScheduler) { TeamRoundsPointsScheduler tps = s as TeamRoundsPointsScheduler; if (a.IsLocalTeam(tps.currentTeam)) { GUILayout.BeginArea(new Rect( 8, 8, 110, 240 )); GUILayout.Label("Current Team: " + tps.currentTeam); GUILayout.Label("Points Left: " + tps.pointsRemaining); if (ac != null) { GUILayout.Label("Character:" + ac.gameObject.name); GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health"))); RoundPointsCharacter rpc = ac.GetComponent <RoundPointsCharacter>(); GUILayout.Label("AP: " + Mathf.Floor(rpc.Limiter)); //show list of skills SkillDef activeSkill = null; foreach (SkillDef sk in skills) { if (sk.isActive) { activeSkill = sk; break; } } if (activeSkill == null) { //root: move, act group, wait var nextSel = OnGUISkillGroup(ac, skills, selectedGroup); selectedGroup = nextSel == null ? null : nextSel.ToList(); } else if (showCancelButton) { if (GUILayout.Button("Cancel " + activeSkill.skillName)) { activeSkill.Cancel(); } if (showAnySchedulerButtons && activeSkill is MoveSkillDef && !(activeSkill as MoveSkillDef).Executor.IsMoving) { if (GUILayout.Button("End Move")) { //?? activeSkill.ApplySkill(); } } } } else { if (showAnySchedulerButtons && !(ac != null && ac.moveSkill.Executor.IsMoving) && GUILayout.Button("End Round")) { tps.EndRound(); } } GUILayout.EndArea(); } } else if (s is TeamRoundsInitiativeScheduler || s is RoundsInitiativeScheduler) { GUILayout.BeginArea(new Rect( 8, 8, 110, 240 )); TeamRoundsInitiativeScheduler tis = s as TeamRoundsInitiativeScheduler; if (tis != null) { GUILayout.Label("Current Team:" + tis.currentTeam); } if (ac != null) { GUILayout.Label("Character:" + ac.gameObject.name); GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health"))); //show list of skills SkillDef activeSkill = null; foreach (SkillDef sk in skills) { if (sk.isActive) { activeSkill = sk; break; } } if (activeSkill == null) { //root: move, act group, wait var nextSel = OnGUISkillGroup(ac, skills, selectedGroup); selectedGroup = nextSel == null ? null : nextSel.ToList(); } else if (showCancelButton) { if (GUILayout.Button("Cancel " + activeSkill.skillName)) { activeSkill.Cancel(); } } } GUILayout.EndArea(); } }