예제 #1
0
        /// <summary>
        /// Initializes base stats and members for the ability
        /// </summary>
        /// <param name="newOwner">The user of the ability</param>
        public virtual void Init(GameObject newOwner)
        {
            owner                   = newOwner;
            abilityData             = (ScriptableObjects.AbilityData)(Resources.Load("AbilityData/" + GetType().Name + "_Data"));
            currentActivationAmount = 0;
            _ownerMoveScript        = newOwner.GetComponent <Movement.GridMovementBehaviour>();
            ownerMoveset            = newOwner.GetComponent <MovesetBehaviour>();
            _ownerKnockBackScript   = newOwner.GetComponent <KnockbackBehaviour>();

            _canPlayAnimation = !abilityData.playAnimationManually;
        }
예제 #2
0
    void Start()
    {
        health     = GetComponent <HealthController>();
        KnockBehav = GetComponent <KnockbackBehaviour>();
        body       = GetComponent <Rigidbody2D>();

        moveInput           = true;
        DmgBehav            = new DamageBehaviour(this);
        BaseStats           = new Stats(5, 5);
        BaseStats.maxhealth = health.MaxHealth;
        TotalStats          = new Stats(BaseStats);

        init();
    }
예제 #3
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            _owner = (KnockbackBehaviour)target;

            _damage         = EditorGUILayout.FloatField("Damage", _damage);
            _knockbackScale = EditorGUILayout.FloatField("Knockback Scale", _knockbackScale);
            _hitAngle       = EditorGUILayout.FloatField("Hit Angle", _hitAngle);
            _hitStun        = EditorGUILayout.FloatField("Hit Stun", _hitStun);

            if (GUILayout.Button("Test Attack"))
            {
                _owner.TakeDamage(name, _damage, _knockbackScale, _hitAngle, DamageType.KNOCKBACK, _hitStun);
            }
        }
예제 #4
0
    void Shoot()
    {
        //Vector2 spread = new Vector2(0, randSpread);
        Vector2      mousePosition     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2      firePointPosition = new Vector2(firePoint.position.x, firePoint.position.y);
        RaycastHit2D hit = Physics2D.Raycast(firePointPosition, mousePosition - firePointPosition, 100, WhatToHit);


        Debug.DrawLine(firePointPosition, (mousePosition - firePointPosition) * 100, Color.cyan);
        if (hit)
        {
            Debug.DrawLine(firePointPosition, hit.point, Color.red);
            Health hp = hit.transform.GetComponent <Health>();
            if (hp)
            {
                hp.Subtract(damage);
                Debug.Log("You hit " + hit.collider.name + " and did " + damage + " damage.");
            }

            KnockbackBehaviour knockback = hit.transform.GetComponent <KnockbackBehaviour>();
            if (knockback)
            {
                knockback.Knockback((mousePosition - firePointPosition).normalized * damage * 8);
            }
        }
        shootSound.Play();

        if (Time.time >= timeToSpawnEffect)
        {
            Vector3 hitPos;
            Vector3 hitNormal; // An effect that will shoot out perpendicular to what it collides with
            if (hit.collider == null)
            {
                hitPos    = (mousePosition - firePointPosition) * 50; // Bullet Effect continues off screen
                hitNormal = new Vector3(9999, 9999, 9999);
            }
            else
            {
                hitPos    = hit.point; // Bullet Effect stops when it hits something
                hitNormal = hit.normal;
            }
            Effect(hitPos, hitNormal, hit);
            timeToSpawnEffect = Time.time + 1 / effectSpawnRate;
        }
    }
예제 #5
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        // Subtract health

        Health health = other.GetComponent <Health>();

        if (health)
        {
            health.Subtract(damage);
        }

        // Knockback

        KnockbackBehaviour knockback = other.GetComponent <KnockbackBehaviour>();

        if (knockback)
        {
            knockback.Knockback((other.transform.position - transform.position).normalized);
        }
    }