//Function for when the enemy is hit
    private void ObjectHit(AttackInfoContainer obj)
    {
        Debug.Log("SLIME HIT");
        healthComponent.TakeDamage(obj.damage);

        this.state = EnemyState.Hurt;
        this.timer = hurtTime;

        spriteRenderer.material.SetFloat("_FlashAmount", 0.60f);

        //If already in attack state, don't interrupt it

        /*
         * if (this.state != EnemyState.Attack)
         * {
         *
         *  //Change to hurt state
         *  //flinchTimer = flinchTime;
         *
         *  //If already in hurt state, don't update previous state
         *  if (enemyState != EnemyBaseState.Hurt)
         *  {
         *      previousState = enemyState;
         *  }
         *  enemyState = EnemyBaseState.Hurt;
         *
         * }
         */
        //this.rb.velocity = Vector2.zero;
        this.rb.AddForce(obj.direction * obj.force);
    }
Example #2
0
 //Updates variables of this container
 public void UpdateHurtInfo(AttackInfoContainer enemyAttack)
 {
     AttackID   = enemyAttack.AttackID;
     attackType = enemyAttack.attackType;
     force      = enemyAttack.force;
     direction  = enemyAttack.direction;
 }
Example #3
0
 void takeAttack(AttackInfoContainer theContainer)
 {
     if (theContainer != null && theContainer.DidHit)
     {
         myHealth.GetComponent <PlayerHealth>().UpdateLifeTotal(theContainer.DamageNum);
         Debug.Log("Player hit for " + theContainer.DamageNum);
     }
 }
Example #4
0
 /// <summary>
 /// Function to make enemy take this attack based on theAttack container
 /// info and if it hit or not
 /// </summary>
 /// <param name="theAttack">The attack.</param>
 public void takeAttack(AttackInfoContainer theAttack)
 {
     if (theAttack != null && theAttack.DidHit) {
         anim.SetTrigger ("Hit");
         isDead = myHealth.GetComponent<EnemyHealth>().UpdateLifeTotal(theAttack.DamageNum);
         Debug.Log(theAttack.DamageNum);
     }
 }
    //Pass in an object AttackInfo that contains attack direction and attack force
    void ObjectHit(AttackInfoContainer obj)
    {
        Debug.Log("PUNCHING bag HIT");
        isHit = true;
        anim.SetBool("Hit", isHit);

        body.AddForce(obj.direction * obj.force);
    }
Example #6
0
 /// <summary>
 /// Function to make enemy take this attack based on theAttack container
 /// info and if it hit or not
 /// </summary>
 /// <param name="theAttack">The attack.</param>
 public void takeAttack(AttackInfoContainer theAttack)
 {
     if (theAttack != null && theAttack.DidHit)
     {
         anim.SetTrigger("Hit");
         isDead = myHealth.GetComponent <EnemyHealth>().UpdateLifeTotal(theAttack.DamageNum);
         Debug.Log(theAttack.DamageNum);
     }
 }
Example #7
0
    //@obj: contains attack direction and attack force
    void ObjectHit(AttackInfoContainer obj)
    {
        Debug.Log("ENEMY HIT");
        healthComponent.TakeDamage(obj.damage);

        //Change state to hurt
        hurtTimer   = flinchTime;
        spiderState = SpiderState.Hurt;

        rb.AddForce(obj.direction * obj.force);
    }
Example #8
0
 // Use this for initialization
 void Start()
 {
     playerBody           = GetComponent <Rigidbody2D> ();
     playerAnimator       = GetComponent <Animator> ();
     grabCollider         = GameObject.Find("Grab Collider Up").GetComponent <CircleCollider2D> ();
     grabCollider.enabled = false;
     grabState            = GrabState.Setup;
     enemyGrabbed         = false;
     playerAttackInfo     = GetComponent <AttackInfoContainer> ();
     orientationSystem    = GetComponent <OrientationSystem> ();
     moveInfo             = GetComponent <AbilityBasicMovement> ();
 }
 // Use this for initialization
 void Start()
 {
     this.timer            = 0f;
     this.playerBody       = GetComponent <Rigidbody2D>();
     this.playerCollider   = GetComponent <BoxCollider2D>();
     this.chargedAttack    = GetComponent <AbilityChargedAttack>();
     this.DirectionHandler = new FourDirectionSystem();
     this.playerAttackInfo = GetComponent <AttackInfoContainer>();
     this.spriteRenderer   = GetComponent <SpriteRenderer>();
     this.playerAnim       = GetComponent <Animator>();
     this.warpState        = WarpState.Setup;
 }
 // Use this for initialization
 void Start()
 {
     //playerInfo = GetComponent<PlayerInfoContainer> ();
     movementInfo       = GetComponent <AbilityBasicMovement> ();
     playerAttackInfo   = GetComponent <AttackInfoContainer> ();
     swordCollider      = GameObject.Find("Sword Collider Down").GetComponent <SwordCollider> ();    //Down
     swordColliderUp    = GameObject.Find("Sword Collider Up").GetComponent <SwordCollider> ();
     swordColliderLeft  = GameObject.Find("Sword Collider Left").GetComponent <SwordCollider> ();
     swordColliderRight = GameObject.Find("Sword Collider Right").GetComponent <SwordCollider> ();
     playerBody         = GetComponent <Rigidbody2D> ();
     DirectionHandler   = new FourDirectionSystem();
     playerAnimator     = GetComponent <Animator> ();
 }
    // Use this for initialization
    void Start()
    {
        firePoint = transform.Find("FirePoint");
        if (firePoint == null)
        {
            Debug.LogError("No Firepoint!");
        }

        attackInfo            = GetComponent <AttackInfoContainer> ();
        attackInfo.attackType = AttackType.MeleeWeakAttack;
        attackInfo.direction  = -transform.up.normalized;
        attackInfo.force      = baseAttackForce;
    }
Example #12
0
    // Update is called once per frame
    void Update()
    {
        //Check for and take hits that were recieved this frame (or are in queue to be recieved)
        AttackInfoContainer thisFramesAttackInfo = null;

        if (hitsToMe.Count > 0)
        {
            thisFramesAttackInfo = (AttackInfoContainer)hitsToMe.Dequeue();
            takeAttack(thisFramesAttackInfo);
        }

        if (movementScript.isInMeleeRangeOf(movementScript.thePlayer))
        {
            if (AttackTimer <= 0)
            {
                //TODO: PH Test combat damage and crit ideas
                float damageNum = Random.Range(basAtkMin, basAtkMax);

                if (CriticalStrike(5))
                {
                    damageNum = damageNum * 2.0f;
                    Debug.Log("Crit!");
                }

                //Basic Attack Animation
                BasicAttack(new AttackInfoContainer(damageNum, true));

                AttackTimer = basicAttackSpeed;
            }
        }
        //Count Down till next attack
        AttackTimer -= Time.deltaTime;

        //If this enemy is dead do the following
        //TODO: Make it stop looking at the player in the "BasicEnemyMove" script
        //when dead
        if (isDead)
        {
            gameObject.GetComponent <NavMeshAgent>().Stop();
            gameObject.GetComponent <NavMeshAgent>().velocity = new Vector3(0, 0, 0);

            anim.speed = 1;
            anim.SetTrigger("Die");

            Destroy(transform.parent.gameObject, 2.02f);
        }
    }
Example #13
0
    // Update is called once per frame
    void Update()
    {
        AttackInfoContainer thisFramesAttackInfo = null;

        if (hitsToMe.Count > 0)
        {
            thisFramesAttackInfo = (AttackInfoContainer)hitsToMe.Dequeue();
            takeAttack(thisFramesAttackInfo);
        }

        GameObject currentTargetEnemy = getTargetEnemy();

        if (IsInMeleeRangeSC() && currentTargetEnemy != null)
        {
            //Get the script for the enemy we are attacking
            MeleeEnemyCombat enemyScript = currentTargetEnemy.GetComponent <MeleeEnemyCombat>();
            if (Input.GetMouseButton(0) || Input.GetMouseButton(0))
            {
                //If it's time to attack perform an attack
                //TODO: THIS IS WHERE MELEE ABILITY INFO WILL GO, IT WILL BE CARRIED BY the AttackInfoContainer to
                //the enemycombat script
                if (AttackTimer <= 0)
                {
                    //TODO: PH Test combat damage and crit ideas
                    float damageNum = Random.Range(25, 50);

                    if (CriticalStrike(20))
                    {
                        damageNum = damageNum * 2.0f;
                        Debug.Log("Crit!");
                    }

                    enemyScript.queueHit(new AttackInfoContainer(damageNum, true));

                    //Basic Attack Animation
                    BasicAttack();

                    AttackTimer = attackSpeed;
                }
            }
        }

        //Count Down till next attack
        AttackTimer -= Time.deltaTime;
    }
Example #14
0
 // Use this for initialization
 void Start()
 {
     //swordCollider = GetComponent<Collider2D> ();
     attachedCollider = GetComponent <PolygonCollider2D> ();
     if (attachedCollider == null)
     {
         Debug.Log("MISSING COLLIDER REF");
     }
     Debug.Log("GOT COLLIDER REF");
     targetsHit       = new List <int> ();
     moveInfo         = GetComponentInParent <AbilityBasicMovement> ();
     playerAttackInfo = GetComponentInParent <AttackInfoContainer> ();
     SPManager        = GetComponentInParent <PlayerSPComponent>();
     SPValues         = new PlayerSPValues();
     timeManager      = GameObject.Find("Time Manager").GetComponent <TimeFunctions> ();
     hitParticles     = GameObject.Find("HitParticles");
     DisableCollider();
 }
Example #15
0
    // Use this for initialization
    void Start()
    {
        attackInfo            = GetComponent <AttackInfoContainer> ();
        attackInfo.attackType = AttackType.MeleeWeakAttack;
        attackInfo.direction  = -transform.up.normalized;
        attackInfo.force      = baseAttackForce;

        //Get reference of player
        player = GameObject.Find("Player");
        rb     = GetComponent <Rigidbody2D> ();

        //Starting state
        spiderState     = SpiderState.Roaming;
        pState          = PursuitState.Chasing;
        waitTimer       = startWaitTime;
        projectileTimer = 0f;
        //targetSpot = Random.Range (0, moveSpots.Length);
        targetSpot = 0;         //first spot
    }
    //Function for when the enemy is hit
    protected virtual void ObjectHit(AttackInfoContainer obj)
    {
        Debug.Log("DASH ENEMY HIT");
        healthComponent.TakeDamage(obj.damage);

        //If already in attack state, don't interrupt it
        if (enemyState != EnemyBaseState.Attacking)
        {
            //Change to hurt state
            flinchTimer = flinchTime;

            //If already in hurt state, don't update previous state
            if (enemyState != EnemyBaseState.Hurt)
            {
                previousState = enemyState;
            }
            enemyState = EnemyBaseState.Hurt;
        }

        rb.AddForce(obj.direction * obj.force);
    }
    //NOTE: Will need to add additional collider references for sprint attacks
    // and for the chain attacks if they end up being different

    void Start()
    {
        playerAttackInfo = GetComponent <AttackInfoContainer>();
        swordCollider    = GameObject.Find("Sword Collider Down").GetComponent <SwordCollider>(); //Down
        swordColliderUp  = GameObject.Find("Sword Collider Up").GetComponent <SwordCollider>();
        if (swordColliderUp == null)
        {
            Debug.Log("NULL UP ");
        }
        swordColliderLeft  = GameObject.Find("Sword Collider Left").GetComponent <SwordCollider>();
        swordColliderRight = GameObject.Find("Sword Collider Right").GetComponent <SwordCollider>();

        playerBody = GetComponent <Rigidbody2D>();
        //orientationSystem = GetComponent<OrientationSystem>();
        DirectionHandler = new FourDirectionSystem();
        playerAnimator   = GetComponent <Animator>();
        movementInfo     = GetComponent <AbilityBasicMovement>();
        comboCount       = 0;
        bufferInput      = false;
        chargeAttack     = false;
    }
Example #18
0
    // Use this for initialization
    void Start()
    {
        playerAttackInfo = GetComponent <AttackInfoContainer> ();
        //playerOrientation = GetComponent<PlayerOrientation> ();
        movementInfo   = GetComponent <AbilityBasicMovement> ();
        playerBody     = GetComponent <Rigidbody2D> ();
        spriteRenderer = GetComponent <SpriteRenderer> ();
        animator       = GetComponent <Animator> ();
        //orientationSystem = GetComponent<OrientationSystem> ();
        DirectionHandler  = new FourDirectionSystem();
        chargeAttackState = ChargeAttackState.Setup;

        colliderUp    = GameObject.Find("cAttack Collider Up").GetComponent <SwordCollider> ();
        colliderDown  = GameObject.Find("cAttack Collider Down").GetComponent <SwordCollider> ();
        colliderLeft  = GameObject.Find("cAttack Collider Left").GetComponent <SwordCollider> ();
        colliderRight = GameObject.Find("cAttack Collider Right").GetComponent <SwordCollider> ();

        colliderUp.DisableCollider();
        colliderDown.DisableCollider();
        colliderRight.DisableCollider();
        colliderLeft.DisableCollider();
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        //Only check collisions when in attacking state
        if (other.tag == "Player" && hitPlayer == false)
        {
            //Get attack info
            attackInfo = GetComponentInParent <AttackInfoContainer> ();

            Debug.Log("Dash hit player");
            playerController.HurtPlayer(attackInfo);
            hitPlayer = true;
            return;
        }

        //If the player's shield was hit, stop attack
        if (other.tag == "Player Shield")
        {
            //controllerScript.AttackBlocked ();

            //Instantiate some particles
        }
    }
    //pass in AttackType and an AttackInfoContainer
    public void HurtPlayer(AttackInfoContainer enemyAttack)
    {
        //Update info on hurt script
        hurtInfo.UpdateHurtInfo(enemyAttack);

        //Deal Damage
        playerHealthComponent.TakeDamage(enemyAttack.damage);

        //If state was cancelled, make player flinch
        if (CancelCurrentState())
        {
            switch (enemyAttack.attackType)
            {
            case AttackType.MeleeWeakAttack:
                playerState = PlayerState.Flinch;
                break;

            case AttackType.MeleeStrongAttack:
                //playerState = PlayerState.KnockBackAir;
                break;
            }
        }
    }
    //Reference to animator

    // Use this for initialization
    protected virtual void Start()
    {
        //Get player's script and controller
        //Get animator component
        //anim = GetComponent<Animator>();
        Debug.Log("Base Start");

        //Initialize to default values
        attackInfo            = GetComponent <AttackInfoContainer> ();
        attackInfo.attackType = AttackType.MeleeWeakAttack;
        attackInfo.direction  = Vector2.zero;
        attackInfo.force      = baseAttackForce;

        //playerObject = GameObject.Find ("Player");
        playerController = GameObject.Find("Player").GetComponent <PlayerController>();
        playerTransform  = GameObject.Find("Player").GetComponent <Transform> ();
        rb           = GetComponent <Rigidbody2D> ();
        enemyState   = EnemyBaseState.Roaming;
        pursuitState = PursuitState.Chasing;
        attackState  = AttackState.Attacking;
        timer        = 0f;
        attackTimer  = 0f;
        flinchTimer  = 0f;
    }
Example #22
0
 //TODO: Get Animations lined up with damage taken by player
 void BasicAttack(AttackInfoContainer theContainer)
 {
     anim.speed = 6 / basicAttackSpeed;
     anim.SetTrigger("Attack");
     movementScript.thePlayer.GetComponent <MeleeCombat>().queueHit(theContainer);
 }
Example #23
0
 // Use this for initialization
 void Start()
 {
     playerController = GameObject.Find("Player").GetComponent <PlayerController> ();
     attackInfo       = GetComponent <AttackInfoContainer> ();
 }
Example #24
0
 //TODO: create an "AttackInfoContainer" to store attack damage, status effect etc. and replace the float
 //param with it
 /// <summary>
 /// queues a hit to the enemy, pass true if hit and AttackInfo in the second param TODO:(float for now)
 /// </summary>
 /// <returns><c>true</c>, if hit was caused, <c>false</c> otherwise.</returns>
 /// <param name="wasHit">If set to <c>true</c> was hit.</param>
 /// <param name="damageNum">Damage number.</param>
 public void queueHit(AttackInfoContainer theAttackInfo)
 {
     hitsToMe.Enqueue ((object)theAttackInfo);
 }
Example #25
0
 //TODO: create an "AttackInfoContainer" to store attack damage, status effect etc. and replace the float
 //param with it
 /// <summary>
 /// queues a hit to the enemy, pass true if hit and AttackInfo in the second param TODO:(float for now)
 /// </summary>
 /// <returns><c>true</c>, if hit was caused, <c>false</c> otherwise.</returns>
 /// <param name="wasHit">If set to <c>true</c> was hit.</param>
 /// <param name="damageNum">Damage number.</param>
 public void queueHit(AttackInfoContainer theAttackInfo)
 {
     hitsToMe.Enqueue((object)theAttackInfo);
 }
Example #26
0
 //TODO: Get Animations lined up with damage taken by player
 void BasicAttack(AttackInfoContainer theContainer)
 {
     anim.speed = 6/ basicAttackSpeed;
     anim.SetTrigger ("Attack");
     movementScript.thePlayer.GetComponent<MeleeCombat>().queueHit(theContainer);
 }