예제 #1
0
    private void Update()
    {
        Ray        ray = FPSCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (Physics.Raycast(ray, out hitInfo, weaponRange))
            {
                switch (hitInfo.collider.tag)
                {
                case "Tree":
                    treeHealth = hitInfo.collider.GetComponentInParent <TreeHealth>();
                    AttackTree();
                    break;

                case "Enemy":
                    advancedAI = hitInfo.collider.GetComponent <AdvancedEnemyAI>();
                    AttackEnemy();
                    break;

                default:
                    break;
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        Ray        ray = FPSCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        Debug.DrawRay(ray.origin, ray.direction * weaponRange, Color.blue);
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (Physics.Raycast(ray, out hitInfo, weaponRange))
            {
                if (hitInfo.collider.tag == "Enemy")
                {
                    enemy = hitInfo.collider.GetComponent <AdvancedEnemyAI>();
                    enemy.TakeDamage(Damage());
                }
            }
        }
    }
예제 #3
0
    private void Update()
    {
        Ray        ray = FPSCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        Debug.DrawRay(ray.origin, ray.direction * weaponRange, Color.green);

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (Physics.Raycast(ray, out hitInfo, weaponRange))
            {
                if (hitInfo.collider.tag == "Tree")
                {
                    treeHealth = hitInfo.collider.GetComponentInParent <TreeHealth>();
                    AttackTree();
                }
                else if (hitInfo.collider.tag == "Enemy")
                {
                    enemyAI = hitInfo.collider.GetComponent <AdvancedEnemyAI>();
                    AttackEnemy();
                }
            }
        }
    }
예제 #4
0
 private void Start()
 {
     advancedEnemyAI = GetComponentInParent <AdvancedEnemyAI>();
 }