public virtual void Kill(bool respawn) { isDead = true; OnCharacterDeath?.Invoke(respawn); Destroy(gameObject, 2.0f); handleInput = false; body.isKinematic = true; }
/// <summary> /// Called when character dies /// </summary> void Stats_OnDeath() { IsDead = true; anim.SetBool("Dead", true); col.enabled = false; rb.isKinematic = true; OnCharacterDeath?.Invoke(this); }
private void Start() { OnDeath += RemoveCharacter; _turnBackgroundRT = GetComponent <RectTransform>(); _activeCharacters = TurnBasedStateMachine.ActiveCharacters; //Tween Turn order stuff StartCoroutine(SetStartSize()); //insert active character names to turn order //BlinkCurrentCharacter(_turnBoxes[0]); }
public void ChangeHealth(float healthAmount) { Health.ChangeResource(healthAmount); if (healthAmount < 0) { CreateDamageTextPopup(healthAmount.ToString(), transform.position); } if (Health.CurrentValue <= 0) { OnCharacterDeath.Invoke(); } }
/// <summary> /// Actually destroys the object. Should only be called by an animation event /// </summary> protected virtual void Ascend() { // Since this is done, we need to let other character move to where this just was Node myNode = _mAContRef.GetNodeByWorldPosition(this.transform.position); myNode.Occupying = CharacterType.None; // We need to move this character out from the character's parent before we recalculate the visuals, or this will be included in those calculaiton GameObject graveyard = new GameObject("Graveyard"); this.transform.parent = graveyard.transform; // We then need to recreate all the visuals, so that the user can see they can move over the dead body //NEEDTOFIXmAContRef.CreateAllVisualTiles(); // Call the OnCharacterDeath event OnCharacterDeath?.Invoke(); // Remove the ongoing action to signal we are done MoveAttack.RemoveOngoingAction(); //Debug.Log(this.gameObject.name + " has died"); Destroy(graveyard); Destroy(this.gameObject); }
private bool Collision(Fixture chara, Fixture obj, Contact list) { bool returnValue = false; if (model.state == CharacterState.attacking && (obj.CollisionCategories != Category.Cat20 || !((MoveModel)obj.Body.UserData).PlayerIndexes.Contains(model.playerIndex)) && currentMove.Stats.Type == MoveType.Body && (currentMove.Stats.StopAtHit || obj.CollisionCategories != Category.Cat11) && currentMove.attackTimeLeft <= currentMove.Stats.Duration - currentMove.Stats.BodyStart) { moves.EndMove(currentMove); moves.RemoveMove(currentMove); view.Rotation = 0; view.BoundBox.Rotation = 0; model.attackMode = false; if ((obj.CollisionCategories == Category.Cat9 || obj.CollisionCategories == Category.Cat10) && chara.Body.Position.Y + view.size.Y / 2 <= obj.Body.Position.Y - (float)obj.Body.UserData / 2) { model.inAir = false; if (obj.CollisionCategories == Category.Cat10) { model.onSoftBox = true; } model.jumpsLeft = 3; } NaturalState(); returnValue = true; } else if ((obj.CollisionCategories == Category.Cat9 || obj.CollisionCategories == Category.Cat10) && (chara.Body.Position.Y + view.size.Y / 2 <= obj.Body.Position.Y - (float)obj.Body.UserData / 2 && view.VelocityY >= -0.001)) { model.inAir = false; if (obj.CollisionCategories == Category.Cat10) { model.onSoftBox = true; } NaturalState(); model.jumpsLeft = 3; returnValue = true; } else if (obj.CollisionCategories == Category.Cat9) { returnValue = true; } else if (obj.CollisionCategories == Category.Cat20) { MoveModel move = (MoveModel)obj.Body.UserData; if (!move.PlayerIndexes.Contains(model.playerIndex) && !model.invounerable) { move.PlayerIndexes.Add(model.playerIndex); MoveStats stats = move.Stats; float ratio = 0; if (stats.Type == MoveType.Charge && move.chargeTime < stats.MaxWait) { ratio = move.chargeTime / stats.MaxWait; } else { ratio = 1; } Vector2 power = ratio * stats.Power; int damage = (int)ratio * stats.Damage; view.Velocity = move.Xdirection * power * (1 + model.damagePoints / 100) * (100 / model.weight); if (Math.Abs(view.VelocityY) == 0) { view.VelocityY = -1; } model.damagePoints += damage; model.setState(CharacterState.takingHit); if (OnHit != null) { OnHit.Invoke(ConvertUnits.ToDisplayUnits(obj.Body.Position), damage, model.damagePoints, move.PlayerIndexes.First(), model.playerIndex, stats.hitSound); } //if (move.Adjustable && ((AdjustableMove)move).StopAtHit) move.attackTimeLeft = 0; } } else if (obj.CollisionCategories == Category.Cat7 || obj.CollisionCategories == Category.Cat8) { OnCharacterDeath.Invoke(this, obj.CollisionCategories == Category.Cat7); } return(returnValue); }
private void OnDisable() { OnDeath -= RemoveCharacter; }