private Animator anim; //Animator component void Start() { //assuming player can move canMove = true; //Get a reference to the required components input = GetComponent <PlayerInput_custom>(); rigidBody = GetComponent <Rigidbody2D>(); bodyCollider = GetComponent <BoxCollider2D>(); hitbox_Collider = GetComponentInChildren <WeaponCollider>(); anim = GetComponent <Animator>(); //Record the original x scale of the player originalXScale = transform.localScale.x; //Record the player's height from the collider playerHeight = bodyCollider.size.y; //Record initial collider size and offset colliderStandSize = bodyCollider.size; colliderStandOffset = bodyCollider.offset; //Calculate crouching collider size and offset colliderCrouchSize = new Vector2(bodyCollider.size.x, bodyCollider.size.y / 2f); colliderCrouchOffset = new Vector2(bodyCollider.offset.x, bodyCollider.offset.y / 2f); }
public void SetUpLayer(int layer) { gameObject.layer = layer; WeaponCollider weaponCollider = GetComponentInChildren <WeaponCollider>();; weaponCollider.SetUpLayer(layer); weaponCollider.Active = true; }
private void OnTriggerStay(Collider other) { if (buying) { if (other.tag == "PlayerBody") { PlayerController pcont = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); PlayerCombat pcomb = GameObject.FindGameObjectWithTag("Weapon").GetComponent <PlayerCombat>(); WeaponCollider weapColl = GameObject.FindGameObjectWithTag("Bic").GetComponent <WeaponCollider>(); if (pcont.GetCash() >= 10) { if (machineType == "BlueVendingMachine") //Blue - ammo { pcont.AlterCash(-10); pcomb.SetMaxAmmo(10); weapColl.baseAmmoGain += 0.1f; print("Change"); UIElement.GetComponent <Text>().text = "Ink Ammo Increased"; StartCoroutine(ShowText()); } if (machineType == "OrangeVendingMachine") //Orange - dash CD { pcont.AlterCash(-10); pcont.SetDashCooldown(-0.15f); UIElement.GetComponent <Text>().text = "Dodge Cooldown Decreased"; StartCoroutine(ShowText()); } if (machineType == "GreenVendingMachine") //Green - Health { if (pcont.GetHealth() < pcont.GetMaxHealth()) { pcont.AlterCash(-10); pcont.AlterHealth(10, false); } UIElement.GetComponent <Text>().text = "Health Replenished"; StartCoroutine(ShowText()); } if (machineType == "PurpleVendingMachine") //Purple - Attack Speed { pcont.AlterCash(-10); weapColl.baseDamage += 0.2f; pcomb.SetSwingSpeed(0.98f); UIElement.GetComponent <Text>().text = "Attack Increased"; StartCoroutine(ShowText()); } buying = false; } } } }
public override void Use() { if (_weaponPlace == null) { _weaponPlace = GameObject.FindGameObjectWithTag("WeaponPlace"); } _weapon = Instantiate(prefab, _weaponPlace.transform); PlayerController player = PlayerController.instance; WeaponCollider _weaponCollider = _weapon.AddComponent <WeaponCollider>(); player.SetWeaponCollider(_weapon.GetComponent <Collider>()); Elements outputDamagae = new Elements(damage); outputDamagae.Add(player.GetBaseDamage()); _weaponCollider.SetDamage(outputDamagae); }
void Start() { wasHit = false; isDashing = false; onGround = true; isFalling = false; isDead = false; isBlocking = false; dashTime = startDashTime; if (maxHealth < health) { maxHealth = health; }//adjusts health to max at start of game m_Animator = GetComponent <Animator>(); m_Rigidbody = GetComponentInChildren <Rigidbody>(); weaponCollider = GetComponentInChildren <WeaponCollider>(); }//initializes values and components
protected virtual float SetAttackRange() { if (weapon == null) { weapon = GetComponentInChildren <WeaponCollider>(); } Vector3 size; if (weapon.GetComponent <Collider>() != null) { size = weapon.GetComponent <Collider>().bounds.size; } else { size = weapon.GetComponentInParent <Collider>().bounds.size; } float[] s = new float[] { size.x, size.y, size.z }; return(s.Max() / 2 + GetComponent <CharacterController>().radius); }
public void EnableCurrentWeaponCollider() { WeaponCollider wCollider = currentWeaponModel.GetComponent <WeaponCollider>(); wCollider.EnableCollider(); }