コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();
            int startingRoll = random.Next(1, 7) + random.Next(1, 7) + random.Next(1, 7);

            swordDamage = new SwordDamage(startingRoll);
            DisplayDamage();
        }
コード例 #2
0
    void Attack()
    {
        isAttacking = true;
        anim.SetBool("isAttacking", true);

        moving = false;
        anim.SetBool("isMoving", false);
        SwordDamage sword = GetComponentInChildren <SwordDamage>();

        sword.SetCanDealDamage(true);
    }
コード例 #3
0
    private void PrepareForAbility()
    {
        transform.rotation = abilityCanvas.transform.rotation;
        abilityActive      = true;
        moving             = false;
        anim.SetBool("isMoving", false);
        playerAgent.isStopped = true;
        abilityCanvas.GetComponent <RotateIndicator>().SetActiveAbility(false);
        anim.SetBool("isAttacking", false);
        isAttacking = false;
        SwordDamage sword = GetComponentInChildren <SwordDamage>();

        sword.SetCanDealDamage(false);
        enemyTargeted = false;
    }
コード例 #4
0
    void SetPosition()
    {
        //Cast a ray from screen to game world.
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 100))
        {
            enemyTargeted  = false;
            targetPosition = hit.point;
            lookAtTarget   = new Vector3(targetPosition.x - transform.position.x, transform.position.y, targetPosition.z - transform.position.z);


            if (hit.collider.tag == "Enemy")
            {
                enemyTargeted = true;
                target        = hit.collider.gameObject.transform;
                //if ray hits an enemy, and the distance is less than player basic attack range then instead of moving
                //attack the enemy.

                if (Vector3.Distance(target.position, transform.position) <= basicAttackRange)
                {
                    if (!isAttacking)
                    {
                        playerRot          = Quaternion.LookRotation(lookAtTarget);
                        transform.rotation = playerRot;
                        Attack();
                    }
                    return;
                }
            }
            //Using navigation agent from unity, set the destination of the agent to the ray hit point
            playerAgent.isStopped = false;
            playerAgent.SetDestination(targetPosition);

            moving = true;
            anim.SetBool("isMoving", true);

            if (!enemyTargeted)
            {
                AttackFinished();
                SwordDamage sword = GetComponentInChildren <SwordDamage>();
                sword.SetCanDealDamage(false);
            }
        }
    }
コード例 #5
0
    public void OnTriggerEnter(Collider collider)
    {
        if (collider.gameObject.tag == "Weapon" && timer <= 0f)
        {
            timer = maxTimer;

            SwordDamage sword = collider.GetComponent <SwordDamage>();
            if (sword.shouldDamage)
            {
                Vector3 dir = collider.transform.parent.parent.parent.position - transform.position;
                dir = -dir.normalized;

                TakeDamage(sword.damage, dir * sword.force);

                Camera.main.GetComponent <CameraShake>().CamShake(0.08f, 0.35f);
            }
        }
    }