void Start() { weapon = GetComponentInChildren <WeaponAttack>(); player = GameObject.FindGameObjectWithTag("Player").transform; agent = GetComponent <NavMeshAgent>(); }
private IEnumerator DelayedAttack(WeaponAttack attk) { if (attk == null) { Debug.LogError("No attack specified. Cooldown will not be applied."); yield return(null); } yield return(new WaitForSeconds(attk.damageDelay)); RaycastHit hit; Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); if (Physics.Raycast(ray, out hit, 7f, attackLayermask)) { if (hit.transform.root.tag == "Enemy") { if (hit.transform.root.GetComponent <EnemyHealth>().isDead) { yield return(null); } //We have hit an enemy. Do damage. int damage = Random.Range(attk.minDamage, attk.maxDamage + 1); hit.transform.root.GetComponent <EnemyHealth>().TakeDamage(damage, this.transform.root.gameObject); Debug.Log("Attack hit. Target: " + hit.transform.root.name + " and dealt " + damage.ToString() + " damage."); } } }
public void setUp(GameObject localPlayer) { if (localPlayer == null) { Debug.LogError("passed null local player"); return; } player = localPlayer; if (player != null && player.GetComponent <Identifier>().typePrefix != Identifier.gunnerType) { Debug.LogError("Displaying incorrect HUD"); return; } health = player.GetComponent <NetHealth>(); resourceManager = player.GetComponent <ResourceManager>(); weapons = player.GetComponent <WeaponAttack>(); weapons.weaponWheel = weaponWheel.GetComponent <WeaponWheel>(); setHealth(1); setShield(1); isPaused = false; }
void killPlayer() { if (this.GetComponent <PlayerAnimate> ().enabled == true) { PlayerAnimate pa = this.GetComponent <PlayerAnimate> (); PlayerMovement pm = this.GetComponent <PlayerMovement> (); RotateToCursor rot = this.GetComponent <RotateToCursor> (); WeaponAttack wa = this.GetComponent <WeaponAttack> (); legDir ld = this.GetComponentInChildren <legDir> (); wa.dropWeapon(); pa.legs.sprite = null; pa.legs.enabled = false; ld.enabled = false; pa.torso.sprite = deadSpr; pa.enabled = false; rot.enabled = false; wa.enabled = false; pm.enabled = false; CircleCollider2D col = this.GetComponent <CircleCollider2D> (); col.enabled = false; } }
public override void OnEnable() { this._explicitMods = new List <RollValue>(); this._implicitMods = new List <RollValue>(); _weaponAttack = null; this._lastHovered = null; }
void revivePlayer() { dead = false; Debug.Log("PlayerHealth - revivePlayer"); PlayerAnimate pa = this.GetComponent <PlayerAnimate> (); PlayerMovement pm = this.GetComponent <PlayerMovement> (); RotateToCursor rot = this.GetComponent <RotateToCursor> (); WeaponAttack wa = this.GetComponent <WeaponAttack> (); dead = false; legDir ld = this.GetComponentInChildren <legDir> (); wa.dropWeapon(); pa.legs.enabled = true; ld.enabled = true; pa.enabled = true; rot.enabled = true; wa.enabled = true; pm.enabled = true; CircleCollider2D col = this.GetComponent <CircleCollider2D> (); col.enabled = true; }
public NodeStates RangeAttack() { tWeapon = GetComponentInChildren <WeaponAttack>(); tWeapon.CreateBullet(); GetComponentInChildren <Animator>().SetTrigger("flash"); return(NodeStates.success); }
public void SetWeapon() // used to set the weapon on the people who are not the owner of this weapon. { if (state.WeaponIndex == "1.1" | state.WeaponIndex == "1.3") { if (state.Weapon != null) { wep_attack = state.Weapon.GetComponent <WeaponAttack>(); // call the turn on attack joint function from this. } } if (entity.IsOwner) { PlayerInventory.ChangeItem(); } if (state.Weapon == null | state.WeaponIndex == "0") { if (entity.IsOwner) { PlayerInventory.DeInitializeInventory(); state.WeaponIndex = "0"; } return; } state.Weapon.transform.SetParent(SetWeaponParent()); if (state.WeaponIndex == "1.3" | state.WeaponIndex == "2.1") // reset chicken to the size of the chicken parent. { state.Weapon.transform.localScale = Vector3.one; } }
// Start is called before the first frame update void Awake() { playerMovement = GetComponent <PlayerMovement>(); WeaponAttack = GetComponent <WeaponAttack>(); weaponManager = GetComponent <WeaponManager>(); mouseLook = GetComponentInChildren <MouseLook>(); playerStats = GetComponent <PlayerStats>(); }
private float dashRange = 0.3f; //How far whirlwind is moving player // Use this for initialization void Start() { myRigidBody = this.GetComponent <Rigidbody>(); Input.multiTouchEnabled = true; myAnimator = GetComponent <Animator>(); weapon = GameObject.FindGameObjectWithTag("Weapon"); weaponAttack = weapon.GetComponent <WeaponAttack>(); }
private void EquipItem(int equipperID, int itemID, GameObject go) { print("Loading weapon"); if (equipperID == playerID) { weapon = go.GetComponentInChildren <WeaponAttack>(); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { //myBoxCollider = animator.transform.FindChild("Sword").GetComponent<BoxCollider>(); myBoxCollider = animator.GetComponent<PlayerController>().mySwordBoxCollider; myWeaponAttack = animator.GetComponent<PlayerController>().mySwordsAttack; myWeaponAttack.damage += 20; myBoxCollider.enabled = true; }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { //myBoxCollider = animator.transform.FindChild("Sword").GetComponent<BoxCollider>(); myBoxCollider = animator.GetComponent <PlayerController>().mySwordBoxCollider; myWeaponAttack = animator.GetComponent <PlayerController>().mySwordsAttack; myWeaponAttack.damage += 20; myBoxCollider.enabled = true; }
void Start() { hitBox = GetComponent <BoxCollider2D>(); weaponIcon = GameObject.Find("Weapon Icon"); icon = weaponIcon.GetComponent <SpriteRenderer>(); anim = GetComponent <Animator>(); //weaponAttack = FindObjectOfType<WeaponAttack>(); weaponAttack = GetComponentInChildren <WeaponAttack>(); }
// Use this for initialization void Start() { pm = this.GetComponent <PlayerMovement> (); sc = GameObject.FindGameObjectWithTag("GameController").GetComponent <SpriteContainer> (); walking = sc.getPlayerUnarmedWalk(); attacking = sc.getPlayerPunch(); legsSpr = sc.getPlayerLegs(); wa = this.GetComponent <WeaponAttack> (); }
/// <summary> /// /// </summary> /// <param name="weaponAttack"></param> /// <returns></returns> private void Attack(WeaponAttack weaponAttack) { var attackTimes = weaponAttack.ActionType == ActionType.Full ? BaseAttackBonus.Length : 1; var weapon = weaponAttack.Weapon; var target = weaponAttack.Target as Entity; //Console.WriteLine($"{Name}: is attacking {attackTimes} times"); // all attacks are calculated Parallel.For(0, attackTimes, (attackIndex, state) => { // break when target is null or dead, no more attacks on dead monsters. if (target == null || target.IsDead) { state.Break(); } var attackRolls = AttackRolls(attackIndex, weapon.CriticalMinRoll); var attack = AttackRoll(attackRolls, target.ArmorClass, out var criticalCounts); Adventure.Enqueue(AdventureLog.Info(this, target, ActivityLog.Create(ActivityLog.ActivityType.Attack, ActivityLog.ActivityState.Init, new int[] { attackIndex, attack, criticalCounts }, weaponAttack))); if (attack > target.ArmorClass || criticalCounts > 0) { var damage = DamageRoll(weapon, Dice); var criticalDamage = 0; if (criticalCounts > 0) { for (var i = 0; i < weapon.CriticalMultiplier - 1; i++) { criticalDamage += DamageRoll(weapon, Dice); } } Adventure.Enqueue(AdventureLog.Info(this, target, ActivityLog.Create(ActivityLog.ActivityType.Attack, ActivityLog.ActivityState.Success, new int[] { attackIndex, attack, criticalCounts, damage, criticalDamage, (int)DamageType.Weapon }, weaponAttack))); target.Damage(damage + criticalDamage, DamageType.Weapon); } else { Adventure.Enqueue(AdventureLog.Info(this, target, ActivityLog.Create(ActivityLog.ActivityType.Attack, ActivityLog.ActivityState.Fail, new int[] { attackIndex, attack, criticalCounts }, weaponAttack))); } Adventure.Enqueue(AdventureLog.Attacked(this, target)); }); }
private void doAttack(int attkIndex) { if (!canAttack) { return; } WeaponAttack attk = null; switch (attkIndex) { default: Debug.LogError("Invalid attack index!"); break; case 0: if (lightAttacks.Count > 0) { Debug.Log("Light Attack"); attk = lightAttacks[Random.Range(0, lightAttacks.Count)]; } else { Debug.LogError("No light attacks assigned! Check the weapon."); } break; case 1: if (heavyAttacks.Count > 0) { Debug.Log("Heavy Attack"); attk = heavyAttacks[Random.Range(0, heavyAttacks.Count)]; } else { Debug.LogError("No heavy attacks assigned! Check the weapon."); } break; } StartCoroutine(AttackCooldown(attk)); if (attk == null) { Debug.LogError("Attack not specified. Routine will now exit."); return; } Debug.Log("Attacking with " + attk.attackName + "."); anim.SetTrigger(attk.triggerName); StartCoroutine(DelayedAttack(attk)); }
public void NoPressRestart() { restartMenu.SetActive(false); WeaponAttack playerScript = GameObject.FindWithTag("Player").GetComponent <WeaponAttack>(); WinManager winScript = GameObject.FindWithTag("Manager").GetComponent <WinManager>(); if (playerScript.hp <= 0 || winScript.wonGame) { SceneManager.LoadScene("MenuScene"); } }
private IEnumerator AttackCooldown(WeaponAttack attack) { if (attack == null) { Debug.LogError("No attack specified. Cooldown will not be applied."); yield return(null); } canAttack = false; yield return(new WaitForSeconds(attack.attackTimeout)); canAttack = true; }
void OnTriggerStay2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { //makes player take damage on contact with mine WeaponAttack waScript = coll.gameObject.GetComponent <WeaponAttack>(); GunScript currWep = waScript.getCurr().GetComponent <GunScript>(); currWep.bulletLeft += (clipNum * currWep.clipSize); currWep.setAmmoCounter(); gameObject.SetActive(false); } }
public void EnableGenericCollider() // enable the weapon's collider { //print("ATTACK PLAYER!!!"); if (wep_attack == null) { wep_attack = state.Weapon.GetComponent <WeaponAttack>(); } if (wep_attack == null) { Debug.LogError("WeaponManager.cs: There is no weapon attack found on the weapon. Please attach this behavior."); return; } wep_attack.Turn_On_Attack_Joint(); }
private void OnTriggerStay2D(Collider2D collision) { if (collision.CompareTag("Weapon")) { // Get WeaponAttack from Weapon Anchor WeaponAttack weaponAttack = collision.GetComponentInParent <WeaponAttack>(); if (weaponAttack.isAttacking) { AudioManager.instance.PlayBigDeathSound(); Destroy(gameObject); } } }
void OnTriggerEnter2D(Collider2D other) { if(other.gameObject.tag == "Weapon") { _weaponattack = other.gameObject.GetComponent<WeaponAttack>(); //call WeaponBurst function from the script. _weaponattack.WeaponBurst(); //play sword explosion audio. _audio.Play(); } }
public NodeStates InRangeAndSight() { if (weaponAttack != null) { if (weaponAttack.IsRange()) { return(NodeStates.success); } } else { weaponAttack = GetComponentInChildren <WeaponAttack>(); } return(NodeStates.fail); }
public NodeStates IsRanged() { if (tWeapon != null) { if (tWeapon.IsRange()) { return(NodeStates.success); } } else { tWeapon = GetComponentInChildren <WeaponAttack>(); } return(NodeStates.fail); }
private WeaponAttack CreateAttack(AttackTypes attackType, IWeapon weapon) { WeaponAttack atk = null; // Figure out to apply damage modifier if (attackType == AttackTypes.Melee) { atk = new MeleeAttack(this, this.Strength, this.Size.Size, weapon); } else if (attackType == AttackTypes.Ranged) { atk = new RangeAttack(this, this.Size.Size, weapon); } return(atk); }
public void revivePlayer() { PlayerAnimate pa = this.GetComponent <PlayerAnimate>(); playermovement pm = this.GetComponent <playermovement>(); rotateToCursor rot = this.GetComponent <rotateToCursor>(); WeaponAttack wa = this.GetComponent <WeaponAttack>(); LegsDirection legDir = this.GetComponentInChildren <LegsDirection>(); wa.dropWeapon(); pa.legs.enabled = true; legDir.enabled = true; pa.enabled = true; rot.enabled = true; wa.enabled = true; pm.enabled = true; dead = false; }
void KillPlayer() { if (this.GetComponent <PlayerAnimate>().enabled == true) { PlayerAnimate pa = this.GetComponent <PlayerAnimate>(); playermovement pm = this.GetComponent <playermovement>(); rotateToCursor rot = this.GetComponent <rotateToCursor>(); WeaponAttack wa = this.GetComponent <WeaponAttack>(); LegsDirection legDir = this.GetComponentInChildren <LegsDirection>(); wa.dropWeapon(); pa.legs.sprite = null; pa.legs.enabled = false; legDir.enabled = false; pa.torso.sprite = deadSpr; pa.enabled = false; rot.enabled = false; wa.enabled = false; pm.enabled = false; BoxCollider2D col = this.GetComponent <BoxCollider2D>(); col.enabled = false; } }
void BeginAttack() { WeaponCollision wc = GetComponentInChildren <WeaponCollision>(); wc.currentCollisions.Clear(); WeaponAttack chainAttack = weaponObject.chainAttack[bufferedAttack]; windupTime = chainAttack.windupTime; backswingTime = chainAttack.backswingTime; foreach (SwingEffect swing in chainAttack.swingEffects) { swing.IsServer = isServer; swing.OnSwing(this); } Animator anim = GetComponentInChildren <Animator>(); if (wc == null || wc.type.Equals("sword")) { anim.Play("SwordSwing_Right"); } else { anim.Play("WeaponStab_Right"); } //Play random swing sound // // // attackStage = 0; //Client and server reset value at same time bufferedAttack = -1; }
public Ally(BattleState battle, int index, int e) : base(battle) { _c = battle.Party[index]; // the (index * 1) is for separation for targeting purposes. _x = (index * 1) + (_c.BackRow ? X_BACK_ROW : X_FRONT_ROW); _y = (index * 1) + y0 + (index * ys); GetMagicSpells(); GetSummons(); if (HP == 0) { Kill(); } V_Timer = new BattleClock(battle.SpeedValue * 2); TurnTimer = new AllyTurnTimer(this, e); PrimaryAttack = new WeaponAttack(this); PrimaryAttackX2 = new WeaponAttack(this, 2); PrimaryAttackX4 = new WeaponAttack(this, 4); }
// Use this for initialization void Start() { myRigidBody = this.GetComponent<Rigidbody>(); Input.multiTouchEnabled = true; myAnimator = GetComponent<Animator>(); weapon = GameObject.FindGameObjectWithTag("Weapon"); weaponAttack = weapon.GetComponent<WeaponAttack>(); }
void Start() { wa = GameObject.FindGameObjectWithTag("Player").GetComponent <WeaponAttack>(); }
// Use this for initialization void Awake () { _weaponattack = Weapon.GetComponent<WeaponAttack>(); }
public void ChangeWeaponAttack(WeaponAttack newWeapon) { Weapon = newWeapon; }