public void Enter(BurinkeruInputManager inputManager, BurinkeruCharacterController parent, CharacterComponents components) { this.inputManager = inputManager; this.components = components; base.Enter(parent); }
private void ChangeTo(CharacterComponents comps) { //If there is no current character controller installed => first time initializing one if (controlledCharacterComponents != null) { Rigidbody rBody = controlledCharacterComponents.characterMotor.GetComponent <Rigidbody>(); Animator anim = controlledCharacterComponents.characterMotor.GetComponent <Animator>(); controlledCharacterComponents.characterMotor.enabled = false; controlledCharacterComponents.characterController.enabled = false; //To assure that nothing can influence the inactive character, we destroy its rigidbody component Destroy(rBody); //To assure that no leftover animation blending value remains on the inactive character, we manually nullify them anim.SetFloat("Forward", 0f); anim.SetFloat("Turn", 0f); } //Change the camera behaviour to the specified target and its focus boom.IdealPosition = comps.idealCameraPosition; boom.Target = comps.cameraFocus; //Enable the controller components comps.characterMotor.enabled = true; comps.characterController.enabled = true; //Remove or add a rigidbody component comps.characterMotor.gameObject.AddComponent <Rigidbody>(); comps.characterMotor.ReassignRigidbody(); //Lastly we assign our new component container to our currently controlled one and invoke our event controlledCharacterComponents = comps; Switched(comps); }
private void ReassignRigidbody(CharacterComponents entity) { if (entity.identification == Entity.Human) { playerBody = this.gameObject.GetComponentInParent <Rigidbody>(); } }
public PlayerComponents(CharacterComponents character, InputConfiguration bindings, int playerID, Vector2 characterVisualsVector) { this.character = character; this.bindings = bindings; this.playerID = playerID; this.characterVisualsVector = characterVisualsVector; }
public void SenseNewThreat(CharacterComponents character) { if (character == null) { return; } if (character is EnemyComponents enemyAI) { if (team == enemyAI.enemyControl.team) { //same team, friendly fire, dont retaliate... //or maybe do retaliate depending on the team type and ai return; } } if (currentTargetAlive) { //is the attacker closer? if ((transform.position - character.transform.position).sqrMagnitude < (transform.position - currentTarget.transform.position).sqrMagnitude) { currentTarget = character.fighter; } } else { currentTarget = character.fighter; } }
public override void InitEffect(Power data, CharacterComponents attacker) { this.InitCompoenents(); this.attackPower = data.attackPower; this.attacker = attacker; this.ownCollider.enabled = false; this.destroyDelay = new WaitForSeconds(this.aliveTime); this.StartToEffect(); }
private void DemarkTarget(CharacterComponents disregard) { //Note: We do not need Entity => disregard if (nearestObject) { nearestObject.GetComponent <MeshRenderer>().material.shader = Shader.Find("Standard"); nearestObject = null; } }
/// <summary> /// The source could be an item or another object in the scene. /// This function returns a copy of itself so it can start affect characters. /// </summary> public virtual Effect Instantiate(CharacterComponents character, object source, string sourceName) { Effect copy = Instantiate(this); copy.GetCharacter = character; copy.GetSource = source; copy.sourceName = sourceName; copy.description = GenerateDescription(); return(copy); }
/// <summary> /// Equips item if not equipped already. /// Otherwise unequips. /// </summary> public void ToggleEquip(CharacterComponents character, AskLeftOrRight askLeftOrRight) { if (IsEquipped) { character.inventory.UnequipItem(slot); } else { character.inventory.EquipItem(this, askLeftOrRight); } }
private void ChangeHuman(CharacterComponents ent) { if (ent.identification == Entity.Human) { isHuman = true; } else { isHuman = false; } }
private void Init() { if (!this.isInit) { this.isInit = true; this.TakeRandomData(); this.m_Components = this.gameObject.GetComponent <CharacterComponents>(); this.rigidbody = this.gameObject.GetComponent <Rigidbody>(); this.collider = this.gameObject.GetComponent <Collider>(); this.states = this.gameObject.GetComponent <EnemyStatesController>(); } }
public void Setup(CharacterComponents characterComponents, Armament armsScriptable, Slot[] usedSlots, HoldMethod holdMethod) { this.characterComponents = characterComponents; this.armsScriptable = armsScriptable; this.usedSlots = usedSlots; this.holdMethod = holdMethod; foreach (Ability ability in abilitySet) { ability.Setup(characterComponents, holdMethod == HoldMethod.rightHand); } }
public override void OnEnable() { base.OnEnable(); lockInput = false; if (player == null) { player = PlayerController.Current.character; } player.inventory.OnInventoryChange += UpdateAll; UpdateAll(); }
/// <summary> /// Don't use this function, use Inventory.EquipItem /// </summary> public void Equip(CharacterComponents character, EquipmentSlot slot) { if (GetItemType == ItemType.armour) { character.characterSheet.health.OnDecreased += OnHealthDecrease; } this.character = character; this.slot = slot; character.characterSheet.AddEffect(equippedEffect, this, displayName); UpdateEquipped(); }
private void OnTriggerEnter(Collider other) { CharacterComponents components = other.GetComponent <CharacterComponents>(); if (components != null) { if (components != this.attacker) { this.victim = components; this.TriggerPowerEffect(); } } }
protected virtual void Awake() { InitStatusEffects(); components = GetComponent <CharacterComponents>(); components.Init(); abnormalComponents = GetComponent <AbnormalComponents>(); //animationHandler = Components.AnimationHandler; rgbody = components.Rigidbody2D; bodyTransform = GetComponent <Transform>(); statsEffectsManager = GetComponent <CharacterStatsEffectsManager>(); statsEffectsManager.SetOwner(this); }
public void ReportDead(CharacterComponents character) { if (character is EnemyComponents enemy) { deadEnemies.Add(enemy); Console.Current.AddLog("enemy died!"); } else if (character is PlayerComponents player) { //The player died! Console.Current.AddLog("you died!"); } }
public void ToggleInventoryVisibility(CharacterComponents entity) { switch (entity.identification) { case Entity.Human: GameInstance.GetInstance().UI_Components.inventory.alpha = 1; break; case Entity.Dog: GameInstance.GetInstance().UI_Components.inventory.alpha = 0; break; } }
private void OnTriggerEnter(Collider other) { CharacterComponents component = other.GetComponent <CharacterComponents>(); if (component != null) { if (component != this.attacker && component.character != this.characterThrew) { this.Collided(other); } } else { this.Destroy(); } }
/// <summary> /// Don't use this function, use Inventory.UnequipItem /// </summary> public void Unequip() { if (character == null) { Debug.LogWarning("Was never equipped, cannot unequip.", this); return; } if (GetItemType == ItemType.armour) { character.characterSheet.health.OnDecreased -= OnHealthDecrease; } character.characterSheet.RemoveEffect(this); character = null; UpdateEquipped(); }
private void MovementCollision(Collision collision) { var rigidbody = collision.rigidbody; if (rigidbody == null) { return; } CharacterComponents character = rigidbody.GetComponent <CharacterComponents>(); if (character == null) { return; } SenseNewThreat(character); }
public void InitStates(CharacterComponents components, EnemyData data) { this.Init(); this.data = data; this.moveState.m_Components = components; this.attackState.m_Components = components; this.distanceMovingAttack = data.distanceMovingAttack; this.distanceStaticAttack = data.distanceStaticAttack; this.moveState.movementSpeed = data.moveSpeed; this.attackState.m_Components.Attack.attackPower = data.attackPower; this.ChangeMoveTarget(this.currentTarget); this.ChangeAttackTarget(this.currentTarget); this.moveState.ChangeOwnTransform(this.ownTransform); this.attackState.ChangeOwnTransform(this.ownTransform); }
public void LandAttack(int damage, Vector3 origin, CharacterComponents attacker, int heft, out int ricochet) { ricochet = 0; if (enabled == false) { return; } int reduction = 0; int poise = 0; //we can use a base poise attribute bool canRicochet = false; foreach (var listener in attackListeners) { listener.OnAttacked(damage, origin, attacker, out DefenceFeedback feedback); ricochet += feedback.ricochet; reduction += feedback.reduction; poise += feedback.poise; canRicochet = canRicochet || feedback.landedOnWeapon; } damage -= reduction; //play soundfx/vfx for hit confirmation if (poise < heft) { if (canRicochet) { fighter.RicochetStagger(); } else if (0 < damage) { fighter.DamagedStagger(); } } if (0 < damage) { IncreaseResource(Resource.health, -damage); } }
private IEnumerator SwitchControlRoutine(CharacterComponents comps) { Color newColor = fadeTexture.color; //Mark the gameState as 'switching' to prevent changing controls while already changing controls currentlySwitching = true; //The farther the two bodies are away from each other, the longer it takes for the texture to fade to black. This is limited to one second. fadeTime = Mathf.Min(Vector3.Distance(controlledCharacterComponents.characterMotor.transform.position, comps.characterMotor.transform.position) * 0.1f, 1f); boom.IdealPosition = null; float counter = 0f; //While the overlay texture (most likely completely black) is not complete blocking the view, increase its opaqueness while (counter < 1f) { counter += Time.deltaTime * (1 / fadeTime); newColor.a = Mathf.SmoothStep(0f, 1f, counter); fadeTexture.color = newColor; yield return(null); } //Now we disable the current body and enable to body that we will possess after the change switch (comps.identification) { case Entity.Human: ChangeTo(human); break; case Entity.Dog: ChangeTo(dog); break; } //Finally we wait for one second before the overlay texture starts to fade out again yield return(new WaitForSeconds(1f)); StartCoroutine(RegainControl()); }
private IEnumerator AttackAnimation(Vector3 direction, CharacterComponents other) { Tweener hitTweener = null; attackStart = transform.position; var getCurve = attackAnimation.curve; float finalTime = getCurve.keys[getCurve.length - 1].time; float currentTime = 0; bool impacted = false; damageDealt = false; do { float curveValue = getCurve.Evaluate(currentTime); transform.position = attackStart + curveValue * direction; if (impacted == false && .8f <= curveValue) { impacted = true; //decrease other health other.characterSheet.health.Decrease( //with my attack character.characterSheet.attributes.attack.GetTotal); damageDealt = true; //play onhit animation other.combatant.PlayHitAnimation(out hitTweener); } yield return(null); currentTime += Time.deltaTime; }while (currentTime < finalTime); yield return(new WaitUntil(() => hitTweener.IsEnded)); }
private void ReassignRigidbody(CharacterComponents entity) { if (entity.identification == Entity.Human) playerBody = this.gameObject.GetComponentInParent<Rigidbody>(); }
//Edited part private void ChangeFocus(CharacterComponents entity) { focalTransform = entity.mainObject.transform; }
public void OnAttacked(int damage, Vector3 contactPoint, CharacterComponents character, out DefenceFeedback feedback) { BlockAbility.BlockAttack(characterComponents.attackIndicator, blockConfig, damage, contactPoint, out feedback); }
public PlayerComponents(CharacterComponents character, InputConfiguration bindings, int playerID) { this.character = character; this.bindings = bindings; this.playerID = playerID; }
private IEnumerator SwitchControlRoutine(CharacterComponents comps) { Color newColor = fadeTexture.color; //Mark the gameState as 'switching' to prevent changing controls while already changing controls currentlySwitching = true; //The farther the two bodies are away from each other, the longer it takes for the texture to fade to black. This is limited to one second. fadeTime = Mathf.Min(Vector3.Distance(controlledCharacterComponents.characterMotor.transform.position, comps.characterMotor.transform.position) * 0.1f, 1f); boom.IdealPosition = null; float counter = 0f; //While the overlay texture (most likely completely black) is not complete blocking the view, increase its opaqueness while (counter < 1f) { counter += Time.deltaTime * (1 / fadeTime); newColor.a = Mathf.SmoothStep(0f, 1f, counter); fadeTexture.color = newColor; yield return null; } //Now we disable the current body and enable to body that we will possess after the change switch (comps.identification) { case Entity.Human: ChangeTo(human); break; case Entity.Dog: ChangeTo(dog); break; } //Finally we wait for one second before the overlay texture starts to fade out again yield return new WaitForSeconds(1f); StartCoroutine(RegainControl()); }
private void ChangeTo(CharacterComponents comps) { //If there is no current character controller installed => first time initializing one if (controlledCharacterComponents != null) { Rigidbody rBody = controlledCharacterComponents.characterMotor.GetComponent<Rigidbody>(); Animator anim = controlledCharacterComponents.characterMotor.GetComponent<Animator>(); controlledCharacterComponents.characterMotor.enabled = false; controlledCharacterComponents.characterController.enabled = false; //To assure that nothing can influence the inactive character, we destroy its rigidbody component Destroy(rBody); //To assure that no leftover animation blending value remains on the inactive character, we manually nullify them anim.SetFloat("Forward", 0f); anim.SetFloat("Turn", 0f); } //Change the camera behaviour to the specified target and its focus boom.IdealPosition = comps.idealCameraPosition; boom.Target = comps.cameraFocus; //Enable the controller components comps.characterMotor.enabled = true; comps.characterController.enabled = true; //Remove or add a rigidbody component comps.characterMotor.gameObject.AddComponent<Rigidbody>(); comps.characterMotor.ReassignRigidbody(); //Lastly we assign our new component container to our currently controlled one and invoke our event controlledCharacterComponents = comps; Switched(comps); }
public abstract void InitEffect(Power data, CharacterComponents attacker);
public void Enter(CharacterComponents components) { this.components = components; IsActive = true; onEnter(); }
public void SetPower(PowerType powerType, CharacterComponents attacker) { this.powerType = powerType; this.attacker = attacker; }
public override void Setup(CharacterComponents characterComponents, bool mirror) { base.Setup(characterComponents, mirror); holdToChain?.Setup(characterComponents, mirror); }