public static void AirState(AbstractFighter actor) { StateTransitions.AirControl(actor); if (actor.KeyBuffered("Shield") && actor.GetIntVar(TussleConstants.FighterVariableNames.AIR_DODGES_REMAINING) >= 1) { //actor.doAction("AirDodge"); } if (actor.KeyBuffered("Attack")) { actor.doAirAttack(); } if (actor.KeyBuffered("Special")) { actor.doAirSpecial(); } if (actor.KeyBuffered("Jump") && actor.GetIntVar(TussleConstants.FighterVariableNames.JUMPS_REMAINING) > 0) { actor.doAction("AirJump"); } actor.SendMessage("CheckForGround"); if (actor.GetBoolVar(TussleConstants.FighterVariableNames.IS_GROUNDED) && actor.ground_elasticity == 0 && actor.GetIntVar("tech_window") == 0) { actor.BroadcastMessage("ChangeXPreferred", 0.0f, SendMessageOptions.RequireReceiver); actor.BroadcastMessage("ChangeYPreferred", actor.GetFloatVar(TussleConstants.FighterAttributes.MAX_FALL_SPEED)); actor.doAction("Land"); } //TODO fastfal }
void OnTriggerExit(Collider other) { if (!other.transform.IsChildOf(this.transform)) { if (contacted_colliders.Contains(other)) { contacted_colliders.Remove(other); } getBattleObject().PrintDebug(this, 3, "Left Collider " + other); } if (other.tag == "Killbox" && !other.bounds.Contains(transform.position)) { GameObject deathBurst = ObjectPooler.current_pooler.GetPooledObject("DeathBurst"); deathBurst.transform.position = transform.position; //TODO change color to that of the player that kill deathBurst.SetActive(true); Color deathCol = Settings.current_settings.player_colors[GetIntVar(TussleConstants.FighterVariableNames.PLAYER_NUM)]; if (hitTagged != null) { deathCol = Settings.current_settings.player_colors[hitTagged.GetIntVar(TussleConstants.FighterVariableNames.PLAYER_NUM)]; } deathBurst.SendMessage("ChangeColor", deathCol); deathBurst.SendMessage("Burst"); SetVar("StopFrames", 60); doAction("Fall"); //TODO respawn Die(); } }
public static void AirControl(AbstractFighter actor) { actor.BroadcastMessage("ChangeXPreferred", actor.GetAxis("Horizontal") * actor.GetFloatVar(TussleConstants.FighterAttributes.MAX_AIR_SPEED)); if (Mathf.Abs(actor.GetFloatVar(TussleConstants.MotionVariableNames.XSPEED)) > actor.GetFloatVar(TussleConstants.FighterAttributes.MAX_AIR_SPEED)) { actor.SendMessage("accel", actor.GetFloatVar(TussleConstants.FighterAttributes.AIR_CONTROL)); } if (Mathf.Abs(actor.GetFloatVar(TussleConstants.MotionVariableNames.YSPEED)) > Mathf.Abs(actor.GetFloatVar(TussleConstants.FighterAttributes.MAX_FALL_SPEED))) { actor.SetVar("landing_lag", actor.GetIntVar(TussleConstants.FighterAttributes.HEAVY_LANDING_LAG)); } }
// Update is called once per frame void Update() { if (fighter == null) { Destroy(this.gameObject); } int damage = Mathf.FloorToInt(fighter.damage_percent); textComponent.text = damage.ToString() + "%"; float r = Mathf.Min(1.0f, damage / 300.0f); textComponent.color = new Color(1.0f, 1.0f - r, 1.0f - r); iconBg.color = Settings.current_settings.player_colors[fighter.GetIntVar(TussleConstants.FighterVariableNames.PLAYER_NUM)]; }
public Hitbox LoadHitbox(AbstractFighter owner, GameAction action, Dictionary <string, string> dict) { Hitbox hbox = Instantiate(hitbox_prefab); hbox.owner = owner.getBattleObject(); hbox.transform.parent = owner.transform; hbox.LoadValuesFromDict(dict); //Flip it if the fighter is flipped if (owner.GetIntVar(TussleConstants.FighterVariableNames.FACING_DIRECTION) == -1) { hbox.trajectory = 180 - hbox.trajectory; } LockHitbox(action, hbox); return(hbox); }
public void FighterDies(AbstractFighter fighter, AbstractFighter killer) { int fighterNum = fighter.GetIntVar(TussleConstants.FighterVariableNames.PLAYER_NUM); FighterResults fighterResults = resultsDict[fighterNum]; if (!BattleLoader.current_loader.stockInfinity) { fighterResults.stocks -= 1; if (fighterResults.stocks <= 0) { UnregisterObject(fighter.getBattleObject()); //If there's one or less players left, end the battle if (fighters.Count <= 1) { EndBattle(); } } else { fighter.Respawn(); } } fighterResults.falls += 1; fighterResults.score -= 1; //If the killer is null, it's a self destruct and we need to adjust the score as such if (killer == null) { fighterResults.score -= 1; fighterResults.selfDestructs += 1; fighterResults.deathsAgainst[fighterNum] += 1; fighterResults.killsAgainst[fighterNum] += 1; } else { int killerNum = killer.GetIntVar(TussleConstants.FighterVariableNames.PLAYER_NUM); FighterResults killerResults = resultsDict[killerNum]; killerResults.score += 1; killerResults.killsAgainst[fighterNum] += 1; fighterResults.deathsAgainst[killerNum] += 1; } }
/// <summary> /// Adds an object to the list of active battle objects /// </summary> /// <param name="obj"></param> public void RegisterObject(BattleObject obj) { objects.Add(obj); AbstractFighter fighter = obj.GetAbstractFighter(); if (fighter != null) { fighters.Add(fighter); int fighterNum = fighter.GetIntVar(TussleConstants.FighterVariableNames.PLAYER_NUM); fighterDict.Add(fighterNum, fighter); resultsDict.Add(fighterNum, new FighterResults(BattleLoader.current_loader.fighters[fighterNum])); //FIXME I think this breaks if you skip a fighter. Check that. //If stocks are infinite, we don't populate the stock dict and will just ignore it whenever a player dies if (!BattleLoader.current_loader.stockInfinity) { resultsDict[fighterNum].stocks = BattleLoader.current_loader.stockCount; } SendMessage("LoadFighterIcons"); //Reload icons when a new fighter is added } }