Beispiel #1
0
    /// <summary>
    /// Shoots the projectile like an arrow or something.
    /// Shoots the projectile and then starts the coroutine until it gets there
    /// Once our projectile has hit, we can have the hero take damage and
    /// then we can tell the game our turn has finished
    /// </summary>
    /// <returns>The projectile.</returns>
    public IEnumerator shootProjectile()
    {
        Debug.Log("we have shot our projectile. go into animation cooldown round");
        anim.SetTrigger("ShotProjectile");

        // then we have to start a new coroutine for shooting the arrow
        ProjectileAnimator sa = GameObject.Find("Arrow").GetComponent <ProjectileAnimator>();

        yield return(StartCoroutine(sa.FireProjectile()));

        // okay let's kill it
        ShakeCamera();
        screenFlash();


        enemyUnit.enemyHealth.TakeDamage(15);



        // for now we'll relinquish our turn here
        // tell our battle manager that we are done
        BattleManager batMan = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <BattleManager> ();

        batMan.attackDone = " Fired an arrow at " + enemyUnit.playerName;

        Toolbox.Instance.isLocked = false;
    }
Beispiel #2
0
    /// <summary>
    /// Shoots the projectile like an arrow or something.
    /// Shoots the projectile and then starts the coroutine until it gets there
    /// Once our projectile has hit, we can have the hero take damage and
    /// then we can tell the game our turn has finished
    /// </summary>
    /// <returns>The projectile.</returns>
    public IEnumerator shootProjectile()
    {
        Debug.Log("we have shot our projectile. go into animation cooldown round");
        anim.SetTrigger("ShotProjectile");

        // then we have to start a new coroutine for shooting the arrow
        ProjectileAnimator sa = GameObject.Find("Arrow").GetComponent <ProjectileAnimator>();

        yield return(StartCoroutine(sa.FireProjectile()));

        // okay let's kill it
        ShakeCamera();
        screenFlash();

        EnemyUnit    attackingPlayer    = gameObject.GetComponent <EnemyUnit> ();
        TargetPicker playerTargetPicker = gameObject.AddComponent <TargetPicker>();

        playerTargetPicker.currentPlayer = attackingPlayer;
        playerTargetPicker.battleList    = gameObject.GetComponent <BattleMenu> ().allCombatants;
        playerTargetPicker.loadBattle();
        targetUnit = playerTargetPicker.RandomTarget().gameObject.GetComponent <PlayerUnit> ();


        int damageDealt = Mathf.RoundToInt(Random.Range(attackDamage * 0.8f, attackDamage * 1.2f));

        targetUnit.playerHealth.TakeDamage(damageDealt);

        Destroy(playerTargetPicker);

        // for now we'll relinquish our turn here
        // tell our battle manager that we are done
        BattleManager batMan = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <BattleManager> ();

        batMan.turnFinished       = true;
        batMan.attackDone         = " Fired an arrow at " + targetUnit.playerName;
        Toolbox.Instance.isLocked = false;
    }
Beispiel #3
0
 protected virtual void Start()
 {
     _animator       = new ProjectileAnimator(GetComponent <Animator>());
     _rigidBody      = GetComponent <Rigidbody2D>();
     _motionProvider = GetMotionProvider();
 }